Skip to content

Commit

Permalink
Merge branch 'ignore_prefix_files' into 1.21.x
Browse files Browse the repository at this point in the history
  • Loading branch information
msarahan committed Jun 7, 2016
2 parents bb54adc + 67fba8b commit fe279ea
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 2 deletions.
1 change: 1 addition & 0 deletions conda.recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ requirements:
- python
run:
- python
- psutil
- conda
- jinja2
- patchelf [linux]
Expand Down
File renamed without changes.
11 changes: 11 additions & 0 deletions conda_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
14 changes: 12 additions & 2 deletions conda_build/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
],
Expand Down Expand Up @@ -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', [])

Expand Down
14 changes: 14 additions & 0 deletions tests/test-recipes/metadata/ignore_prefix_files/meta.yaml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions tests/test-recipes/metadata/ignore_prefix_files/run_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import os
import sys

# assumes that sys.prefix is <root>/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"))
19 changes: 19 additions & 0 deletions tests/test-recipes/metadata/ignore_some_prefix_files/meta.yaml
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions tests/test-recipes/metadata/ignore_some_prefix_files/run_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import os
import sys

# assumes that sys.prefix is <root>/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()

0 comments on commit fe279ea

Please sign in to comment.