You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 8, 2024. It is now read-only.
Repository navigation
This repository was archived by the owner on Jan 8, 2024. It is now read-only.
PAR picks up system-installed version instead of bundled version #38
pip 1.5.4 from most likely from the python-pip package, which is indeed ancient. I'd recommend doing pip install --upgrade --user pip virtualenv setuptools to put a newer version in ~/.local, and then apt-get remove python-pip python-virtualenv python3-pip for general sanity. But meanwhile, I'm able to repro this, fix might be complicated though.
pkg_resources doesn't recognize the packages inside the .par file, so it finds the old pip package. It's actually using the correct, newer version of pip, but I should fix this anyway.
tl;dr I just linked an issue from rules_python, which winds back to this same problem.
Near as I can tell, this same problem is the root of why we cannot build .whl files for pip packages (that don't have them on pypi) unless the host has the wheel package installed.
This is because the metadata extracted from packages on the path is used to determine the "commands" that have been registered by a particular installed package.
My conclusion is that we need our own pkg_resources.register_finder(...) defined in a custom entrypoint. When we pip_import stuff, the whl_library includes the package metadata as data, so all of the information is present in the PAR, we just need to access it.
The final gotcha (because nothing is easy) is that because wheel compilation happens in a separate process, we need whatever we do to work by just setting PYTHONPATH before invoking that process. I see two possible options:
The more straightforward would be to expand deps and put their directories onto PYTHONPATH, but for reasons stated elsewhere unpacking PAR files is undesirable; or
Create dummy metadata outside of the PAR that aggregates the metadata of stuff bundled into the PAR and (somehow) direct their invocations through the PAR (and have the PAR entrypoint be smart enough to handle this).
More investigation: Simply doing import pip changes sys.path in hard to predict ways, that are also hard to prevent, and hard to fixup after the fact. Also, pip can be the regular pip, or the heavily patched Debian-specific version, and it's hard to tell at runtime which one you're getting.
Activity
mattmoor commentedon Sep 14, 2017
@duggelz Sorry I forgot to do this until just now, lmk if I can provide any more info.
duggelz commentedon Sep 15, 2017
pip 1.5.4 from most likely from the
python-pippackage, which is indeed ancient. I'd recommend doingpip install --upgrade --user pip virtualenv setuptoolsto put a newer version in~/.local, and thenapt-get remove python-pip python-virtualenv python3-pipfor general sanity. But meanwhile, I'm able to repro this, fix might be complicated though.duggelz commentedon Sep 15, 2017
pkg_resources doesn't recognize the packages inside the .par file, so it finds the old pip package. It's actually using the correct, newer version of pip, but I should fix this anyway.
https://github.com/pypa/pip/blob/a9d56c7734fd465d01437d61f632749a293e7805/src/pip/_internal/utils/misc.py#L835
https://github.com/pypa/pip/blob/a9d56c7734fd465d01437d61f632749a293e7805/src/pip/_internal/utils/outdated.py#L101
duggelz commentedon Sep 16, 2017
We'd have to do some surgery to tell pkg_resources about .par files, which are similar to, but different than .egg files. https://github.com/pypa/setuptools/blob/9f295a706590b1e3618978d6f2d83af0b893ec4d/pkg_resources/__init__.py#L1985
and
https://github.com/pypa/setuptools/blob/9f295a706590b1e3618978d6f2d83af0b893ec4d/pkg_resources/__init__.py#L692
which gets into some tricky distinctions about eggs, wheels, sdists, .par files, and zip applications.
mattmoor commentedon Oct 12, 2017
tl;dr I just linked an issue from
rules_python, which winds back to this same problem.Near as I can tell, this same problem is the root of why we cannot build
.whlfiles forpippackages (that don't have them onpypi) unless the host has thewheelpackage installed.This is because the metadata extracted from packages on the path is used to determine the "commands" that have been registered by a particular installed package.
My conclusion is that we need our own
pkg_resources.register_finder(...)defined in a custom entrypoint. When wepip_importstuff, thewhl_libraryincludes the package metadata as data, so all of the information is present in thePAR, we just need to access it.The final gotcha (because nothing is easy) is that because wheel compilation happens in a separate process, we need whatever we do to work by just setting
PYTHONPATHbefore invoking that process. I see two possible options:The more straightforward would be to expand deps and put their directories onto
PYTHONPATH, but for reasons stated elsewhere unpackingPARfiles is undesirable; orCreate dummy metadata outside of the
PARthat aggregates the metadata of stuff bundled into thePARand (somehow) direct their invocations through thePAR(and have thePARentrypoint be smart enough to handle this).Either way, I'm way outside of my depth. :)
mattmoor commentedon Oct 12, 2017
Hi there.
I missed that the first time I peeked at
__main__.pyin the unzippedPAR. This is probably where we hook intopkg_resources.mattmoor commentedon Oct 13, 2017
Searching for examples of other finders, I happened across this, which seems close.
mattmoor commentedon Oct 13, 2017
Alright, hacking the hell out of that sample, I have something that seems to work for my tiny example... Basically, I added this to
support.py:With this call in
setup:Who knows what breaks, but with this,
list_resources.parprints:I'm going to declare my day of Python spelunking a success and pray @duggelz finds this useful :)
This disables OSX validation on the Bazel CI setup.
duggelz commentedon Nov 4, 2017
After much head-scratching, it turns out pip has it's own private, independent, vendored version of
pkg_resources, so my fix doesn't fix it.Silence a warning erroneously emitted by pip.
duggelz commentedon Nov 7, 2017
Ok, I don't think I can fix the 'bdist_wheel' issue without a ridiculous amount of hackery. The expedient solutions are:
Based on this and other considerations, I don't think I can avoid doing 2 any longer.
duggelz commentedon Nov 7, 2017
More investigation: Simply doing
import pipchangessys.pathin hard to predict ways, that are also hard to prevent, and hard to fixup after the fact. Also,pipcan be the regularpip, or the heavily patched Debian-specific version, and it's hard to tell at runtime which one you're getting.https://github.com/pypa/pip/blob/master/src/pip/_vendor/__init__.py
duggelz commentedon Nov 10, 2017
I don't think I appreciated that Github automatically closes issues if you have the right wording in your PR.