-
-
Notifications
You must be signed in to change notification settings - Fork 258
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
import path leak for six
with OSX default python
#302
Comments
related: pypa/pip#2468 |
how do you intend to address this? the first thing that comes to my mind is just scrubbing 'Extras' from sys.path, though that could get messy... |
haven't dug into it but on the surface it seems like it could be as simple as just scrubbing let me know if you have a better idea. |
I think that's pretty reasonable, considering the scrubbing that pex already does. |
Is there any interim solution to this for affected users? |
this is limited to the OSX default interpreter, so one possible solution would be to use an alternate python interpreter (e.g. one from python.org, homebrew or built from sources). |
I'm running into this issue even when using a virtualenv with either a python.org interpreter or homebrew interpreter. Is there by chance any way to tell Pants which interpreter to use with PEX? I can't find anything in the documentation, but I'm new to working with this so I might be missing something. Or is there some way maybe to specify additional paths to scrub? I could see that being fairly useful if it exists. We have a couple devs running into this issue and it'd be great if we didn't have to wipe and revert back to El Capitan to get our local builds working. |
can you demonstrate the issue with a python.org or homebrew interpreter? I don't seem to reproduce that on my end and afaict this is very specific to modern OSX /usr/bin/python. for posterity, here's a quick code-based workaround that was discussed with another user:
|
I was able to repro as you see above - this was triggered when setting up Pants on a new MacBookPro. It was using the homebrew python and had a reboot mixed in, on a fresh clone of Pants at today's HEAD. The TLDR is that, on a new MacBookPro at least, your set of scrubbed sites is perhaps incomplete.
But I don't see why Pex is constructing the path the way it does? It seems like the
This passes for me - unless I uninstall the six module from pip - then it falls back to the System 1.4.1. Workaround for the afflicted is to install homebrew python, install
Now - if you do that and then uninstall the global six...
Perhaps this is all expected. I had a couple false starts to this report where I thought I was seeing non-determinism in the sys.path patching - it seemed to do surprising things to the order, and perhaps reverse the ordering at times? It is completely possible that I was just getting fooled by the cache hits. But I can provide more of the verbose output or sys.paths as needed. |
Any updates on this? I'm hitting it too now. I have a brew python installed, but Pants selects the system one for whatever reason, and the ancient version of six there is leaking into the chroot. |
It was probably buried in the breadth of my reply but you can hardcode the
PYTHONPATH to point to just the homebrew one and at least proceed.
…On Sun, Jan 29, 2017, 3:11 AM Benjy Weinberger ***@***.***> wrote:
Any updates on this? I'm hitting it too now. I have a brew python
installed, but Pants selects the system one for whatever reason, and the
ancient version of six there is leaking into the chroot.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#302 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABqcAadjDjPg7MalJ4lszwoXbo9uctJFks5rXEm0gaJpZM4KJWTZ>
.
|
grabbing this one due to user impact. |
reviewable here: #370 |
Fixes #302 before: [omerta pex (kwlzn/osxtras)]$ pex --version pex 1.2.3 [omerta pex (kwlzn/osxtras)]$ pex six -o /tmp/six_broke.pex [omerta pex (kwlzn/osxtras)]$ PEX_VERBOSE=9 PEX_PYTHON=/usr/bin/python /tmp/six_broke.pex pex: Detected PEX_PYTHON, re-exec to /usr/bin/python ... Python 2.7.10 (default, Jul 30 2016, 19:40:32) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> from six import wraps Traceback (most recent call last): File "<console>", line 1, in <module> ImportError: cannot import name wraps >>> import six; six.__file__ '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.pyc' >>> after: [omerta pex (kwlzn/osxtras)]$ tox -e py27-package ... [omerta pex (kwlzn/osxtras)]$ ./dist/pex27 six -o /tmp/six.pex ... [omerta pex (kwlzn/osxtras)]$ PEX_VERBOSE=9 PEX_PYTHON=/usr/bin/python /tmp/six.pex pex: Detected PEX_PYTHON, re-exec to /usr/bin/python ... pex: Found .pth file: /Library/Python/2.7/site-packages/Extras.pth pex: Found site extra: /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python pex: Found site extra: /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC ... pex: Tainted path element: /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python pex: Tainted path element: /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC ... pex: Scrubbing from site-packages: /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python pex: Scrubbing from site-packages: /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC ... Python 2.7.10 (default, Jul 30 2016, 19:40:32) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> from six import wraps >>> import six; six.__file__ '/Users/kwilson/.pex/install/six-1.10.0-py2.py3-none-any.whl.a99dfb27e60da3957f6667853b91ea52e173da0a/six-1.10.0-py2.py3-none-any.whl/six.pyc' >>>
Fixes pex-tool#302 before: [omerta pex (kwlzn/osxtras)]$ pex --version pex 1.2.3 [omerta pex (kwlzn/osxtras)]$ pex six -o /tmp/six_broke.pex [omerta pex (kwlzn/osxtras)]$ PEX_VERBOSE=9 PEX_PYTHON=/usr/bin/python /tmp/six_broke.pex pex: Detected PEX_PYTHON, re-exec to /usr/bin/python ... Python 2.7.10 (default, Jul 30 2016, 19:40:32) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> from six import wraps Traceback (most recent call last): File "<console>", line 1, in <module> ImportError: cannot import name wraps >>> import six; six.__file__ '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.pyc' >>> after: [omerta pex (kwlzn/osxtras)]$ tox -e py27-package ... [omerta pex (kwlzn/osxtras)]$ ./dist/pex27 six -o /tmp/six.pex ... [omerta pex (kwlzn/osxtras)]$ PEX_VERBOSE=9 PEX_PYTHON=/usr/bin/python /tmp/six.pex pex: Detected PEX_PYTHON, re-exec to /usr/bin/python ... pex: Found .pth file: /Library/Python/2.7/site-packages/Extras.pth pex: Found site extra: /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python pex: Found site extra: /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC ... pex: Tainted path element: /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python pex: Tainted path element: /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC ... pex: Scrubbing from site-packages: /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python pex: Scrubbing from site-packages: /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC ... Python 2.7.10 (default, Jul 30 2016, 19:40:32) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> from six import wraps >>> import six; six.__file__ '/Users/kwilson/.pex/install/six-1.10.0-py2.py3-none-any.whl.a99dfb27e60da3957f6667853b91ea52e173da0a/six-1.10.0-py2.py3-none-any.whl/six.pyc' >>>
when running a pex that bundles
six
with the OSX system python (/usr/bin/python
), the import ofsix
references the system path (an ancient version ofsix
) rather than the one provided with the pex. this seems to relate to OSX's bespoke usage of the "Extras" path in their installation, which pex does not classify as user-site or site-packages during the sys.path scrubbing.repro:
The text was updated successfully, but these errors were encountered: