Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add missing support for include_recipe in meta.yaml #1085

Merged
merged 1 commit into from
Jul 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion conda_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def create_info_files(m, files, include_recipe=True):
if not isdir(config.info_dir):
os.makedirs(config.info_dir)

if include_recipe:
if include_recipe and m.include_recipe():
recipe_dir = join(config.info_dir, 'recipe')
os.makedirs(recipe_dir)

Expand Down
5 changes: 4 additions & 1 deletion conda_build/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def _git_clean(source_meta):
'has_prefix_files', 'binary_has_prefix_files', 'ignore_prefix_files',
'detect_binary_files_with_prefix', 'rpaths', 'script_env',
'always_include_files', 'skip', 'msvc_compiler',
'pin_depends' # pin_depends is experimental still
'pin_depends', 'include-recipe' # pin_depends is experimental still
],
'requirements': ['build', 'run', 'conflicts'],
'app': ['entry', 'icon', 'summary', 'type', 'cli_opts',
Expand Down Expand Up @@ -605,6 +605,9 @@ def ignore_prefix_files(self):
def always_include_files(self):
return self.get_value('build/always_include_files', [])

def include_recipe(self):
return self.get_value('build/include-recipe', True)

def binary_has_prefix_files(self):
ret = self.get_value('build/binary_has_prefix_files', [])
if not isinstance(ret, list):
Expand Down
6 changes: 6 additions & 0 deletions tests/test-recipes/metadata/_no_include_recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package:
name: no_include_recipe
version: 0.0

build:
include-recipe: False
54 changes: 54 additions & 0 deletions tests/test_build_recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import subprocess
import shutil
import sys
import tarfile
import tempfile

import pytest
Expand All @@ -23,6 +24,21 @@ def is_valid_dir(parent_dir, dirname):
return valid


def package_has_file(package_path, file_path):
try:
with tarfile.open(package_path) as t:
try:
t.getmember(file_path)
return True
except KeyError:
return False
except OSError as e:
raise RuntimeError("Could not extract %s (%s)" % (package_path, e))
except tarfile.ReadError:
raise RuntimeError("Could not extract metadata from %s. "
"File probably corrupt." % package_path)


# def test_CONDA_BLD_PATH():
# env = dict(os.environ)
# cmd = 'conda build --no-anaconda-upload {}/source_git_jinja2'.format(metadata_dir)
Expand Down Expand Up @@ -377,3 +393,41 @@ def test_patch():
lines = modified.readlines()
assert lines[0] == '43770\n'
os.chdir(basedir)


def test_no_include_recipe_cmd_line_arg():
"""Two ways to not include recipe: build/include_recipe: False in meta.yaml; or this.
Former is tested with specific recipe."""
output_file = os.path.join(sys.prefix, "conda-bld", subdir,
"empty_sections-0.0-0.tar.bz2")

# first, make sure that the recipe is there by default
cmd = ('conda build --no-anaconda-upload '
'{}/empty_sections').format(metadata_dir)
subprocess.check_call(cmd.split(), cwd=metadata_dir)
assert package_has_file(output_file, "info/recipe/meta.yaml")

# make sure that it is not there when the command line flag is passed
cmd = ('conda build --no-anaconda-upload --no-include-recipe '
'{}/empty_sections').format(metadata_dir)
subprocess.check_call(cmd.split(), cwd=metadata_dir)
assert not package_has_file(output_file, "info/recipe/meta.yaml")


def test_no_include_recipe_meta_yaml():
# first, make sure that the recipe is there by default. This test copied from above, but copied
# as a sanity check here.
output_file = os.path.join(sys.prefix, "conda-bld", subdir,
"empty_sections-0.0-0.tar.bz2")

cmd = ('conda build --no-anaconda-upload '
'{}/empty_sections').format(metadata_dir)
subprocess.check_call(cmd.split(), cwd=metadata_dir)
assert package_has_file(output_file, "info/recipe/meta.yaml")

output_file = os.path.join(sys.prefix, "conda-bld", subdir,
"no_include_recipe-0.0-0.tar.bz2")
cmd = ('conda build --no-anaconda-upload '
'{}/_no_include_recipe').format(metadata_dir)
subprocess.check_call(cmd.split(), cwd=metadata_dir)
assert not package_has_file(output_file, "info/recipe/meta.yaml")