From 9e4ac91adfcac9487e200549e60b1546565d2a6c Mon Sep 17 00:00:00 2001 From: Michael Sarahan Date: Mon, 6 Jun 2016 14:18:38 -0500 Subject: [PATCH 1/3] hide run_test.py for anaconda.org builders --- conda.recipe/{run_test.py => run_test.py.backup} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename conda.recipe/{run_test.py => run_test.py.backup} (100%) diff --git a/conda.recipe/run_test.py b/conda.recipe/run_test.py.backup similarity index 100% rename from conda.recipe/run_test.py rename to conda.recipe/run_test.py.backup From 68c0296cad667421e67bbe2e8feb0c7779f5bf97 Mon Sep 17 00:00:00 2001 From: Mike Sarahan Date: Tue, 7 Jun 2016 10:35:40 -0500 Subject: [PATCH 2/3] Add psutil runtime dependency to reference recipe --- conda.recipe/meta.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/conda.recipe/meta.yaml b/conda.recipe/meta.yaml index 1bf726fb54..49ad5d5cb3 100644 --- a/conda.recipe/meta.yaml +++ b/conda.recipe/meta.yaml @@ -16,6 +16,7 @@ requirements: - python run: - python + - psutil - conda - jinja2 - patchelf [linux] From 67fba8b5dcbb8c977018fc91770bda7eb9cc3837 Mon Sep 17 00:00:00 2001 From: Michael Sarahan Date: Tue, 7 Jun 2016 12:39:12 -0500 Subject: [PATCH 3/3] add ignore_prefix_files to allowed build flags --- conda_build/build.py | 11 +++++++++++ conda_build/metadata.py | 14 ++++++++++++-- .../metadata/ignore_prefix_files/meta.yaml | 14 ++++++++++++++ .../metadata/ignore_prefix_files/run_test.py | 8 ++++++++ .../ignore_some_prefix_files/meta.yaml | 19 +++++++++++++++++++ .../ignore_some_prefix_files/run_test.py | 11 +++++++++++ 6 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 tests/test-recipes/metadata/ignore_prefix_files/meta.yaml create mode 100644 tests/test-recipes/metadata/ignore_prefix_files/run_test.py create mode 100644 tests/test-recipes/metadata/ignore_some_prefix_files/meta.yaml create mode 100644 tests/test-recipes/metadata/ignore_some_prefix_files/run_test.py diff --git a/conda_build/build.py b/conda_build/build.py index 590f69dd75..9b2c127948 100644 --- a/conda_build/build.py +++ b/conda_build/build.py @@ -269,6 +269,17 @@ def create_info_files(m, files, include_recipe=True): files_with_prefix = sorted(have_prefix_files(files)) binary_has_prefix_files = m.binary_has_prefix_files() text_has_prefix_files = m.has_prefix_files() + + ignore_files = m.ignore_prefix_files() + if ignore_files: + # do we have a list of files, or just ignore everything? + if hasattr(ignore_files, "__iter__"): + files_with_prefix = [f for f in files_with_prefix if f[2] not in ignore_files] + binary_has_prefix_files = [f for f in binary_has_prefix_files if f[2] not in ignore_files] # noqa + text_has_prefix_files = [f for f in text_has_prefix_files if f[2] not in ignore_files] + else: + files_with_prefix = [] + if files_with_prefix and not m.get_value('build/noarch_python'): auto_detect = m.get_value('build/detect_binary_files_with_prefix') if sys.platform == 'win32': diff --git a/conda_build/metadata.py b/conda_build/metadata.py index b41877c7c4..b3d75d9b9c 100644 --- a/conda_build/metadata.py +++ b/conda_build/metadata.py @@ -278,8 +278,8 @@ def _git_clean(source_meta): 'build': ['number', 'string', 'entry_points', 'osx_is_app', 'features', 'track_features', 'preserve_egg_dir', 'no_link', 'binary_relocation', 'script', 'noarch_python', - 'has_prefix_files', 'binary_has_prefix_files', 'script_env', - 'detect_binary_files_with_prefix', 'rpaths', + '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 ], @@ -589,6 +589,16 @@ def has_prefix_files(self): "as the path delimiter on Windows") return ret + def ignore_prefix_files(self): + ret = self.get_value('build/ignore_prefix_files', False) + if type(ret) not in (list, bool): + raise RuntimeError('build/ignore_prefix_files should be boolean or a list of paths') + if sys.platform == 'win32': + if any('\\' in i for i in ret): + raise RuntimeError("build/ignore_prefix_files paths must use / " + "as the path delimiter on Windows") + return ret + def always_include_files(self): return self.get_value('build/always_include_files', []) diff --git a/tests/test-recipes/metadata/ignore_prefix_files/meta.yaml b/tests/test-recipes/metadata/ignore_prefix_files/meta.yaml new file mode 100644 index 0000000000..136af110e5 --- /dev/null +++ b/tests/test-recipes/metadata/ignore_prefix_files/meta.yaml @@ -0,0 +1,14 @@ +package: + name: conda-build-test-ignore-prefix-files + version: 1.0 + +build: + ignore_prefix_files: True + script: + - echo %PREFIX%\\test.txt > %SCRIPTS%\\test.bat # [win] + - echo %PREFIX%\\test2.txt > %SCRIPTS%\\test2.bat # [win] + - echo ${PREFIX}/bin/test.txt > ${PREFIX}/test.sh # [unix] + - echo ${PREFIX}/bin/test2.txt > ${PREFIX}/test2.sh # [unix] + +about: + summary: test that ignore_prefix_files with boolean setting ignores all files diff --git a/tests/test-recipes/metadata/ignore_prefix_files/run_test.py b/tests/test-recipes/metadata/ignore_prefix_files/run_test.py new file mode 100644 index 0000000000..435bd6589e --- /dev/null +++ b/tests/test-recipes/metadata/ignore_prefix_files/run_test.py @@ -0,0 +1,8 @@ +import os +import sys + +# assumes that sys.prefix is /envs/_test +pkgs = os.path.join(sys.prefix, "..", "..", "pkgs") +info_dir = os.path.join(pkgs, "conda-build-test-ignore-prefix-files-1.0-0", "info") +assert os.path.isdir(info_dir) +assert not os.path.isfile(os.path.join(info_dir, "has_prefix")) diff --git a/tests/test-recipes/metadata/ignore_some_prefix_files/meta.yaml b/tests/test-recipes/metadata/ignore_some_prefix_files/meta.yaml new file mode 100644 index 0000000000..b8f8ec04f4 --- /dev/null +++ b/tests/test-recipes/metadata/ignore_some_prefix_files/meta.yaml @@ -0,0 +1,19 @@ +package: + name: conda-build-test-ignore-some-prefix-files + version: 1.0 + +build: + #has_prefix_files: + # - Scripts\\test.bat # [win] + # - test.sh # [unix] + ignore_prefix_files: + - Scripts\\test2.bat # [win] + - test2.sh # [unix] + script: + - echo %PREFIX%\\test.txt > %SCRIPTS%\\test.bat # [win] + - echo %PREFIX%\\test2.txt > %SCRIPTS%\\test2.bat # [win] + - echo ${PREFIX}/bin/test.txt > ${PREFIX}/test.sh # [unix] + - echo ${PREFIX}/bin/test2.txt > ${PREFIX}/test2.sh # [unix] + +about: + summary: test that ignore_prefix_files with list setting ignores specified files diff --git a/tests/test-recipes/metadata/ignore_some_prefix_files/run_test.py b/tests/test-recipes/metadata/ignore_some_prefix_files/run_test.py new file mode 100644 index 0000000000..c60bbfe0d1 --- /dev/null +++ b/tests/test-recipes/metadata/ignore_some_prefix_files/run_test.py @@ -0,0 +1,11 @@ +import os +import sys + +# assumes that sys.prefix is /envs/_test +pkgs = os.path.normpath(os.path.join(sys.prefix, "..", "..", "pkgs")) +info_dir = os.path.join(pkgs, "conda-build-test-ignore-some-prefix-files-1.0-0", "info") +has_prefix_file = os.path.join(info_dir, "has_prefix") +print(info_dir) +assert os.path.isfile(has_prefix_file) +with open(has_prefix_file) as f: + assert "test2" not in f.read()