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

allow case insensitive matches of prefix path in binaries #1171

Merged
merged 5 commits into from
Aug 6, 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
8 changes: 6 additions & 2 deletions conda_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import json
import logging
import os
import re
import shutil
import stat
import subprocess
Expand Down Expand Up @@ -107,6 +108,8 @@ def have_prefix_files(files):
forward_slash_prefix_bytes = forward_slash_prefix.encode('utf-8')
double_backslash_prefix = prefix.replace('\\', '\\\\')
double_backslash_prefix_bytes = double_backslash_prefix.encode('utf-8')
# moar escapes for regex
prefix_bytes = prefix_bytes.replace(b'\\', b'\\\\')

for f in files:
if f.endswith(('.pyc', '.pyo', '.a')):
Expand Down Expand Up @@ -136,8 +139,9 @@ def have_prefix_files(files):
mm.close() and fi.close()
fi = open(path, 'rb+')
mm = mmap.mmap(fi.fileno(), 0)
if mm.find(prefix_bytes) != -1:
yield (prefix, mode, f)
prefix_matches = re.findall(prefix_bytes, mm, re.IGNORECASE)
for match in prefix_matches:
yield (match.decode('utf-8'), mode, f)
if on_win and mm.find(forward_slash_prefix_bytes) != -1:
# some windows libraries use unix-style path separators
yield (forward_slash_prefix, mode, f)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ def main():
with open(fn, 'rb') as f:
data = f.read()

print("Prefix: ")
print(prefix)
print("Binary data (prefix should be in this): ")
print(data)
assert prefix.encode('utf-8') in data

Expand Down
3 changes: 1 addition & 2 deletions tests/test_build_recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ def test_build_with_no_activate_does_not_activate():
subprocess.check_call(cmd.split(), cwd=metadata_dir)


@pytest.mark.skipif(sys.platform == "win32",
reason="no binary prefix manipulation done on windows.")
@pytest.mark.xfail(sys.platform == 'win32', reason="Binary replacement not supported in conda yet.")
def test_binary_has_prefix_files():
cmd = 'conda build --no-anaconda-upload {}/_binary_has_prefix_files'.format(metadata_dir)
subprocess.check_call(cmd.split())
Expand Down