open with utf-8 support#231
Merged
Merged
Conversation
|
|
||
| class InstallerBase(object): | ||
| SETUP_BOOTSTRAP_HEADER = "import sys" | ||
| SETUP_BOOTSTRAP_HEADER = "import sys; from codecs import open" |
Contributor
There was a problem hiding this comment.
any reason to not just use io.open here instead? it should be in python 2.6 and up and also supports an encoding= kwarg - and is the default open in python3.
I think you could also avoid the semicolon by using the multiple import syntax at the module level:
...
SETUP_BOOTSTRAP_HEADER = "import io, sys"
...
exec(compile(io.open(..., encoding='utf-8')...
...
Contributor
Author
There was a problem hiding this comment.
I just took this SO question as gospel in terms of speed improvements but admittedly didn't do any benchmarks - I'll push again with io.open
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)
Contributor
Author
|
@kwlzn cheers for the feedback - Updated. |
Contributor
|
@acaire merged - thanks for the PR! |
This was referenced May 24, 2016
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 "", line 7, in
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
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)