Skip to content

Commit

Permalink
unicode fixes for entry points on py3
Browse files Browse the repository at this point in the history
  • Loading branch information
msarahan committed Feb 4, 2017
1 parent 09cb6d6 commit 40acb03
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
3 changes: 1 addition & 2 deletions conda_build/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,7 @@ def convert(package_file, output_dir=".", show_imports=False, platforms=None, fo
"""Convert changes a package from one platform to another. It applies only to things that are
portable, such as pure python, or header-only C/C++ libraries."""
from .convert import conda_convert
if not platforms:
platforms = []
platforms = _ensure_list(platforms)
if package_file.endswith('tar.bz2'):
return conda_convert(package_file, output_dir=output_dir, show_imports=show_imports,
platforms=platforms, force=force, verbose=verbose, quiet=quiet,
Expand Down
11 changes: 8 additions & 3 deletions conda_build/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,9 @@ def get_pure_py_file_map(t, platform):
pathmember = None

# is None when info/has_prefix does not exist
has_prefix_files = t.extractfile("info/has_prefix").read()
has_prefix_files = None
if 'info/has_prefix' in t.getnames():
has_prefix_files = t.extractfile("info/has_prefix").read().decode()
if has_prefix_files:
fieldnames = ['prefix', 'type', 'path']
csv_dialect = csv.Sniffer().sniff(has_prefix_files)
Expand Down Expand Up @@ -369,8 +371,11 @@ def get_pure_py_file_map(t, platform):
writer = csv.DictWriter(output, fieldnames=fieldnames, dialect=csv_dialect)
writer.writerows(has_prefix_files.values())
member = t.getmember('info/has_prefix')
member.size = len(output.getvalue())
file_map['info/has_prefix'] = member, bytes_io(output.getvalue())
output_val = output.getvalue()
if hasattr(output_val, 'encode'):
output_val = output_val.encode()
member.size = len(output_val)
file_map['info/has_prefix'] = member, bytes_io(output_val)

return file_map

Expand Down
2 changes: 1 addition & 1 deletion tests/test_api_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def test_convert_from_unix_to_win_creates_entry_points(test_config, testing_work
assert_package_consistency(converted_fn)
paths_content = json.loads(package_has_file(converted_fn, 'info/paths.json').decode())
paths_list = {f['_path'] for f in paths_content['paths']}
files = set(package_has_file(converted_fn, 'info/files').splitlines())
files = {p.decode() for p in package_has_file(converted_fn, 'info/files').splitlines()}
assert files == paths_list

index = json.loads(package_has_file(converted_fn, 'info/index.json').decode())
Expand Down

0 comments on commit 40acb03

Please sign in to comment.