Skip to content

Commit

Permalink
Use open with utf-8 support (#231)
Browse files Browse the repository at this point in the history
Without this fix, pex will raise pex.resolver.Untranslateable due to non utf-8 characters in setup.py or \__init\__.py.

$ pex -r requirements.txt -c foobar -o foobar.pex
**** Failed to install pygments-markdown-lexer-0.1.0.dev39. stdout:

**** Failed to install pygments-markdown-lexer-0.1.0.dev39. stderr:
Traceback (most recent call last):
  File "<stdin>", line 7, in <module>
  File "/tmp/virtualenv/lib/python3.4/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 158: ordinal not in range(128)

Traceback (most recent call last):
  File "/tmp/virtualenv/bin/pex", line 11, in <module>
    sys.exit(main())
  File "/tmp/virtualenv/lib/python3.4/site-packages/pex/bin/pex.py", line 509, in main
    pex_builder = build_pex(reqs, options, resolver_options_builder)
  File "/tmp/virtualenv/lib/python3.4/site-packages/pex/bin/pex.py", line 471, in build_pex
    resolveds = resolver.resolve(resolvables)
  File "/tmp/virtualenv/lib/python3.4/site-packages/pex/resolver.py", line 200, in resolve
    dist = self.build(package, resolvable.options)
  File "/tmp/virtualenv/lib/python3.4/site-packages/pex/resolver.py", line 257, in build
    dist = super(CachingResolver, self).build(package, options)
  File "/tmp/virtualenv/lib/python3.4/site-packages/pex/resolver.py", line 168, in build
    raise Untranslateable('Package %s is not translateable by %s' % (package, translator))
pex.resolver.Untranslateable: Package SourcePackage('file:///root/.pex/build/pygments-markdown-lexer-0.1.0.dev39.zip') is not translateable by ChainedTranslator(WheelTranslator, EggTranslator, SourceTranslator)
  • Loading branch information
acaire authored and kwlzn committed Apr 28, 2016
1 parent 2cfcb7a commit 5aea7d0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pex/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ def function_wrapper(self, *args, **kw):


class InstallerBase(object):
SETUP_BOOTSTRAP_HEADER = "import sys"
SETUP_BOOTSTRAP_HEADER = "import io, sys"
SETUP_BOOTSTRAP_MODULE = "sys.path.insert(0, %(path)r); import %(module)s"
SETUP_BOOTSTRAP_FOOTER = """
__file__ = 'setup.py'
sys.argv[0] = 'setup.py'
exec(compile(open(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec'))
exec(compile(io.open(__file__, encoding='utf-8').read().replace('\\r\\n', '\\n'), __file__, 'exec'))
"""

class Error(Exception): pass
Expand Down

0 comments on commit 5aea7d0

Please sign in to comment.