Skip to content

Commit

Permalink
Merge pull request #1647 from msarahan/fix_skip_existing_url
Browse files Browse the repository at this point in the history
create and index noarch folder for skip_existing_url test
  • Loading branch information
msarahan authored Jan 11, 2017
2 parents 1cc8627 + 737c3ca commit 99111e2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
20 changes: 16 additions & 4 deletions conda_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,10 +813,6 @@ def bundle_conda(output, metadata, config, env, **kw):
if f not in files:
files.append(f)
files = filter_files(files, prefix=config.build_prefix)
output_folder = None
if config.output_folder:
output_folder = os.path.join(config.output_folder, config.subdir)
final_output = os.path.join(output_folder or config.bldpkgs_dir, output_filename)

# lock the output directory while we build this file
# create the tarball in a temporary directory to minimize lock time
Expand Down Expand Up @@ -848,10 +844,26 @@ def order(f):
config.run_package_verify_scripts else None
verifier.verify_package(ignore_scripts=ignore_scripts, run_scripts=run_scripts,
path_to_package=tmp_path)
if config.output_folder:
output_folder = os.path.join(config.output_folder, config.subdir)
else:
output_folder = config.bldpkgs_dir
final_output = os.path.join(output_folder, output_filename)
if os.path.isfile(final_output):
os.remove(final_output)
print(final_output)
utils.copy_into(tmp_path, final_output, config.timeout, locking=config.locking)

update_index(os.path.dirname(output_folder), config=config)

# HACK: conda really wants a noarch folder to be around. Create it as necessary.
if os.path.basename(output_folder) != 'noarch':
try:
os.makedirs(os.path.join(os.path.dirname(output_folder), 'noarch'))
except OSError:
pass
update_index(os.path.join(os.path.dirname(output_folder), 'noarch'), config=config)

# remove files from build prefix. This is so that they can be included in other packages. If
# we were to leave them in place, then later scripts meant to also include them may not.
for f in files:
Expand Down
8 changes: 5 additions & 3 deletions conda_build/cli/main_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,14 +304,16 @@ def execute(args):
if action:
for recipe in args.recipe:
action(recipe, config)
outputs = []

else:
api.build(args.recipe, post=args.post, build_only=args.build_only,
notest=args.notest, already_built=None, config=config,
noverify=args.no_verify)
outputs = api.build(args.recipe, post=args.post, build_only=args.build_only,
notest=args.notest, already_built=None, config=config,
noverify=args.no_verify)

if not args.output and len(utils.get_build_folders(config.croot)) > 0:
build.print_build_intermediate_warning(config)
return outputs


def main():
Expand Down
5 changes: 5 additions & 0 deletions tests/test_api_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,11 @@ def test_skip_existing_url(test_metadata, testing_workdir, capfd):
# create the index so conda can find the file
api.update_index(platform, config=test_metadata.config)

# HACK: manually create noarch location there, so that conda 4.3.2+ considers this a valid channel
noarch = os.path.join(output_dir, 'noarch')
os.makedirs(noarch)
api.update_index(noarch, config=test_metadata.config)

test_metadata.config.skip_existing = True
test_metadata.config.channel_urls = [url_path(output_dir)]
api.build(test_metadata)
Expand Down
6 changes: 2 additions & 4 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,8 @@ def test_build_output_folder(testing_workdir, test_metadata, capfd):
args = [testing_workdir, '--no-build-id',
'--croot', tmp, '--no-activate', '--no-anaconda-upload',
'--output-folder', out]
main_build.execute(args)
test_metadata.config.output_folder = out
output, error = capfd.readouterr()
assert "anaconda upload {}".format(out) in output
output = main_build.execute(args)[0]
assert os.path.isfile(os.path.join(out, test_metadata.config.subdir, os.path.basename(output)))


def test_render_output_build_path_set_python(testing_workdir, test_metadata, capfd):
Expand Down

0 comments on commit 99111e2

Please sign in to comment.