41
41
else :
42
42
shell_path = '/bin/bash'
43
43
44
+ channel_urls = ()
45
+ override_channels = False
46
+ verbose = True
44
47
45
48
def prefix_files ():
46
49
'''
@@ -129,6 +132,14 @@ def rewrite_file_with_new_prefix(path, data, old_prefix, new_prefix):
129
132
os .chmod (path , stat .S_IMODE (st .st_mode ) | stat .S_IWUSR ) # chmod u+w
130
133
return data
131
134
135
+
136
+ def get_run_dists (m ):
137
+ prefix = join (cc .envs_dirs [0 ], '_run' )
138
+ rm_rf (prefix )
139
+ create_env (prefix , [ms .spec for ms in m .ms_depends ('run' )])
140
+ return sorted (linked (prefix ))
141
+
142
+
132
143
def create_info_files (m , files , include_recipe = True ):
133
144
'''
134
145
Creates the metadata files that will be stored in the built package.
@@ -173,10 +184,29 @@ def create_info_files(m, files, include_recipe=True):
173
184
print ("WARNING: anaconda.org only recognizes about/readme as README.md and README.rst" ,
174
185
file = sys .stderr )
175
186
187
+ info_index = m .info_index ()
188
+ pin_depends = m .get_value ('build/pin_depends' )
189
+ if pin_depends :
190
+ dists = get_run_dists (m )
191
+ with open (join (config .info_dir , 'requires' ), 'w' ) as fo :
192
+ fo .write ("""\
193
+ # This file as created when building:
194
+ #
195
+ # %s.tar.bz2 (on '%s')
196
+ #
197
+ # It can be used to create the runtime environment of this package using:
198
+ # $ conda create --name <env> --file <this file>
199
+ """ % (m .dist (), cc .subdir ))
200
+ for dist in sorted (dists + [m .dist ()]):
201
+ fo .write ('%s\n ' % '=' .join (dist .rsplit ('-' , 2 )))
202
+ if pin_depends == 'strict' :
203
+ info_index ['depends' ] = [' ' .join (dist .rsplit ('-' , 2 ))
204
+ for dist in dists ]
205
+
176
206
# Deal with Python 2 and 3's different json module type reqs
177
207
mode_dict = {'mode' : 'w' , 'encoding' : 'utf-8' } if PY3 else {'mode' : 'wb' }
178
208
with open (join (config .info_dir , 'index.json' ), ** mode_dict ) as fo :
179
- json .dump (m . info_index () , fo , indent = 2 , sort_keys = True )
209
+ json .dump (info_index , fo , indent = 2 , sort_keys = True )
180
210
181
211
if include_recipe :
182
212
with open (join (config .info_dir , 'recipe.json' ), ** mode_dict ) as fo :
@@ -250,25 +280,23 @@ def create_info_files(m, files, include_recipe=True):
250
280
shutil .copyfile (join (m .path , m .get_value ('app/icon' )),
251
281
join (config .info_dir , 'icon.png' ))
252
282
253
- def get_build_index (clear_cache = True , channel_urls = (), override_channels = False ):
283
+ def get_build_index (clear_cache = True ):
254
284
if clear_cache :
255
285
# remove the cache such that a refetch is made,
256
286
# this is necessary because we add the local build repo URL
257
287
fetch_index .cache = {}
258
288
return get_index (channel_urls = [url_path (config .croot )] + list (channel_urls ),
259
- prepend = not override_channels )
289
+ prepend = not override_channels )
260
290
261
- def create_env (prefix , specs , clear_cache = True , verbose = True , channel_urls = (),
262
- override_channels = False ):
291
+ def create_env (prefix , specs , clear_cache = True ):
263
292
'''
264
293
Create a conda envrionment for the given prefix and specs.
265
294
'''
266
295
if not isdir (config .bldpkgs_dir ):
267
296
os .makedirs (config .bldpkgs_dir )
268
297
update_index (config .bldpkgs_dir )
269
298
if specs : # Don't waste time if there is nothing to do
270
- index = get_build_index (clear_cache = True , channel_urls = channel_urls ,
271
- override_channels = override_channels )
299
+ index = get_build_index (clear_cache = True )
272
300
273
301
warn_on_old_conda_build (index )
274
302
@@ -304,7 +332,6 @@ def warn_on_old_conda_build(index):
304
332
""" % (vers_inst [0 ], pkgs [- 1 ].version ), file = sys .stderr )
305
333
306
334
307
-
308
335
def rm_pkgs_cache (dist ):
309
336
'''
310
337
Removes dist from the package cache.
@@ -320,8 +347,7 @@ def bldpkg_path(m):
320
347
'''
321
348
return join (config .bldpkgs_dir , '%s.tar.bz2' % m .dist ())
322
349
323
- def build (m , get_src = True , verbose = True , post = None , channel_urls = (),
324
- override_channels = False , include_recipe = True ):
350
+ def build (m , get_src = True , post = None , include_recipe = True ):
325
351
'''
326
352
Build the package with the specified metadata.
327
353
@@ -368,14 +394,12 @@ def build(m, get_src=True, verbose=True, post=None, channel_urls=(),
368
394
# Version number could be missing due to dependency on source info.
369
395
print ("BUILD START:" , m .dist ())
370
396
create_env (config .build_prefix ,
371
- [ms .spec for ms in m .ms_depends ('build' )],
372
- verbose = verbose , channel_urls = channel_urls ,
373
- override_channels = override_channels )
397
+ [ms .spec for ms in m .ms_depends ('build' )])
374
398
375
399
if m .name () in [i .rsplit ('-' , 2 )[0 ] for i in linked (config .build_prefix )]:
376
400
print ("%s is installed as a build dependency. Removing." %
377
401
m .name ())
378
- index = get_build_index (clear_cache = False , channel_urls = channel_urls , override_channels = override_channels )
402
+ index = get_build_index (clear_cache = False )
379
403
actions = plan .remove_actions (config .build_prefix , [m .name ()], index = index )
380
404
assert not plan .nothing_to_do (actions ), actions
381
405
plan .display_actions (actions , index )
@@ -483,7 +507,7 @@ def build(m, get_src=True, verbose=True, post=None, channel_urls=(),
483
507
print ("STOPPING BUILD BEFORE POST:" , m .dist ())
484
508
485
509
486
- def test (m , verbose = True , channel_urls = (), override_channels = False , move_broken = True ):
510
+ def test (m , move_broken = True ):
487
511
'''
488
512
Execute any test scripts for the given package.
489
513
@@ -533,8 +557,7 @@ def test(m, verbose=True, channel_urls=(), override_channels=False, move_broken=
533
557
# as the tests are run by perl, we need to specify it
534
558
specs += ['perl %s*' % environ .get_perl_ver ()]
535
559
536
- create_env (config .test_prefix , specs , verbose = verbose ,
537
- channel_urls = channel_urls , override_channels = override_channels )
560
+ create_env (config .test_prefix , specs )
538
561
539
562
env = dict (os .environ )
540
563
env .update (environ .get_dict (m , prefix = config .test_prefix ))
@@ -595,6 +618,6 @@ def tests_failed(m, move_broken):
595
618
if not isdir (config .broken_dir ):
596
619
os .makedirs (config .broken_dir )
597
620
598
- if move_broken :
621
+ if move_broken :
599
622
shutil .move (bldpkg_path (m ), join (config .broken_dir , "%s.tar.bz2" % m .dist ()))
600
623
sys .exit ("TESTS FAILED: " + m .dist ())
0 commit comments