-
-
Notifications
You must be signed in to change notification settings - Fork 289
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
open with utf-8 support #231
Conversation
@@ -32,12 +32,12 @@ def function_wrapper(self, *args, **kw): | |||
|
|||
|
|||
class InstallerBase(object): | |||
SETUP_BOOTSTRAP_HEADER = "import sys" | |||
SETUP_BOOTSTRAP_HEADER = "import sys; from codecs import open" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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')...
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
@kwlzn cheers for the feedback - Updated. |
@acaire merged - thanks for the PR! |
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)