-
-
Notifications
You must be signed in to change notification settings - Fork 292
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
Regression of artifact URL due to change since pip 23.3 #2414
Comments
@tachikoma-li most useful would be log text (instead of screen shots) and an example of the lock file generated with both versions of Pip. Even better, just the full pex command line (and input requirements files, if any). I'm not exactly sure what problem you are encountering. The #2156 issue was moot, since the querystring that user needed was dynamic and changed over time (an auth token with an expiry). Pex currently absolutely does not support dynamic URLs. Whatever artifact URL is written down in the lockfile when it is created must be good forever after or the lockfile must be regenerated. If your lockfile artifact URLs are missing static querystring data they need, that's different and we can use this issue to track a fix. I look forward to hearing more details about your case. |
Hi @jsirois, we have some internal Python packages (in both wheel and sdist format) host in the private PyPI. When we try to generate the lockfile with pex, we have some issues with the URLs for those internal packages. In particular, Pex uses the impermanent URLs for those packages which causes the installation to fail later, and the issue only happens with pip >= 23.3.1. With pip 23.2 (or any lower version), the lockfile can pick up the URL pointing to the private PyPI (instead of the impermanent URLs that have the token for authentication), which allows us to use pex3 lock create --use-pip-config <internal_pkg> --pip-version 23.2 but the following fails pex3 lock create --use-pip-config <internal_pkg> --pip-version 23.3.1 From what I understand, pants needs static URLs for downloading packages in parallel when resolving dependencies. But the behavior seems to be inconsistent with different configurations:
pex3 lock create --use-pip-config <internal_pkg> --pip-version 24.0 --only-build <internal_pkg> we can also get the expected lock. It seems Pex relies on log from pip to get the information of the artifacts. One thing we notice is this change from pip can affect the log. For example, all logs related to build tracker are only available for sdist (which is part of the release of pip 23.3), but not for wheel, which seems to explain the inconsistence mentioned above. Just wondering, is this the intended behavior, is there any plan to fix the issue for wheel (or the make the behavior for sdist similar to wheel? |
@tachikoma-li the Pip change you identify may or may not have to do with the issue you see. That said, it should only affect sdists (and VCS URLs and local project paths) and not wheels - exactly the opposite of the problem you're having if I understand correctly.
The Pex integration tests are extensive and include locks of wheels, sdists, VCS URLs and even local projects across the full range of supported Pip versions. As such, you're hitting a corner here that almost certainly involves the specifics of the private PyPI setup you use. Note that Pex CI itself uses a "private" devpi mirror instead of PyPI directly - although there is no auth used. More to the point, I really need to be able to reproduce your issue to solve it. Can you please provide all of the details from either the "Indirect" or "Direct" lists below? Indirect:
Direct:
|
@jsirois Unfortunately, we can't provide the full pip log for now. Our internal server will redirect to AWS to fetch the packages when recieving download requests, which seems to have the same behavior as
[global]
index-url=https://m.devpi.net/root/pypi/+simple/
{"allow_builds": true, "allow_prereleases": false, "allow_wheels": true, "build_isolation": true, "constraints": [], "locked_resolves": [{"locked_requirements": [{"artifacts": [{"algorithm": "sha256", "hash": "55c570405f142630c6b9f72fe09d9b67cf1477fcf543ae5b8dcb1f5b7377da81", "url": "https://files.pythonhosted.org/packages/7d/cd/d7460c9a869b16c3dd4e1e403cce337df165368c71d6af229a74699622ce/wheel-0.43.0-py3-none-any.whl"}], "project_name": "wheel", "requires_dists": ["pytest>=6.0.0; extra == \"test\"", "setuptools>=65; extra == \"test\""], "requires_python": ">=3.8", "version": "0.43.0"}], "platform_tag": ["cp310", "cp310", "macosx_14_0_arm64"]}], "only_builds": [], "only_wheels": [], "path_mappings": {}, "pex_version": "2.3.1", "pip_version": "23.3.1", "prefer_older_binary": false, "requirements": ["wheel"], "requires_python": [], "resolver_version": "pip-2020-resolver", "style": "strict", "target_systems": [], "transitive": true, "use_pep517": null} Note that the URL is the redirected one.
{"allow_builds": true, "allow_prereleases": false, "allow_wheels": true, "build_isolation": true, "constraints": [], "locked_resolves": [{"locked_requirements": [{"artifacts": [{"algorithm": "sha256", "hash": "465ef92c69fa5c5da2d1cf8ac40559a8c940886afcef87dcf14b9470862f1d85", "url": "https://m.devpi.net/root/pypi/%2Bf/465/ef92c69fa5c5d/wheel-0.43.0.tar.gz"}], "project_name": "wheel", "requires_dists": ["pytest>=6.0.0; extra == \"test\"", "setuptools>=65; extra == \"test\""], "requires_python": ">=3.8", "version": "0.43.0"}], "platform_tag": ["cp310", "cp310", "macosx_14_0_arm64"]}], "only_builds": ["wheel"], "only_wheels": [], "path_mappings": {}, "pex_version": "2.3.1", "pip_version": "23.3.1", "prefer_older_binary": false, "requirements": ["wheel"], "requires_python": [], "resolver_version": "pip-2020-resolver", "style": "strict", "target_systems": [], "transitive": true, "use_pep517": null} Now note the URL is not the redirected one.
{"allow_builds": true, "allow_prereleases": false, "allow_wheels": true, "build_isolation": true, "constraints": [], "locked_resolves": [{"locked_requirements": [{"artifacts": [{"algorithm": "sha256", "hash": "55c570405f142630c6b9f72fe09d9b67cf1477fcf543ae5b8dcb1f5b7377da81", "url": "https://m.devpi.net/root/pypi/%2Bf/55c/570405f142630/wheel-0.43.0-py3-none-any.whl"}], "project_name": "wheel", "requires_dists": ["pytest>=6.0.0; extra == \"test\"", "setuptools>=65; extra == \"test\""], "requires_python": ">=3.8", "version": "0.43.0"}], "platform_tag": ["cp310", "cp310", "macosx_14_0_arm64"]}], "only_builds": [], "only_wheels": [], "path_mappings": {}, "pex_version": "2.3.1", "pip_version": "23.2", "prefer_older_binary": false, "requirements": ["wheel"], "requires_python": [], "resolver_version": "pip-2020-resolver", "style": "strict", "target_systems": [], "transitive": true, "use_pep517": null}` Note that the URL is not the redirected one. This is very close to our issue where the redirected URL is impermanent with auth tokens and causing trouble, while the original URL would work. And this would only affect pip version >= 23.3.1 (excluding the sdist case). |
@tachikoma-liI thanks, I think your last post starts to help reveal the issue here - its use of
This is a bug, but a long standing one (you can also specify extra indexes in a requirements.txt file and Pip will use those but Pex will not known about them - same bug). The idea of introducing --use-pip-config (which was introduce in September 2023 in v2.1.147) was to enable things like Pip keyring support. @tachikoma-li now that you know you must tell Pex directly about the indexes to use, does doing so fix your problem? |
To explain what I think the issue really is here: You're using Pants to run pex and Pants does this:
As such Pants ends up launching Pex like so:
Which mean Pex ends up launching Pip like so:
So now Pip is configured with 2 |
Hi @jsirois, thanks for the quick reply!
with a redirected URL.
with the original URL.
with the original URL. That is, it seems the issue remains for a single index. |
@tachikoma-li Perhaps this is not clear from the
To see what is passed to Pip you can run Pex with
N.B. that pip subprocess is run with |
@jsirois, thanks. Just tried with |
@tachikoma-li Ok, great - thanks. I repro that at the 23.2 / 23.3.1 boundary. This is enough to work with now. |
Ok. It turns out the issue was in fact related to the build tracker logging change, but that just masked the real issue. Logging for re-directs has always looked like so (this is a Pip 23.2 example):
The lines tracked by the Pex Locker are - in order from the log snip above:
Lines 3 and 4 exist for Pip 23.2 and older but do not for Pip 23.3 and newer. Line 3 in particular is the log line that masked a bug introduced in #2276 in the handling of lines 1 and 2. Lines 1, 2 and 3 all funnel to here: Lines 287 to 301 in 27c2db2
On line 295 the So it seems the fix is to only record the 1st |
When support for Pip 23.3.1 was added in #2276 a latent bug in artifact URL recording was exposed in cases where the index being used issued re-directs. Fix up artifact URL recording to grab the primary index URL and not subsequent re-directs. Implementing the fix above led to a test failure that revealed another bug whereby lock file artifact downloads were not respecting the locked resolve target when it was a foreign platform, which is now fixed. Finally, fixing the un-patched foreign platform target issue in lock file artifact downloads revealed that artifact URLs with hashes were not being taken advantage of in all cases. Now, when there is a version of an artifact URL seen that contains hashes - the best of those is always used to prevent needless post-processing to download and hash the artifact at lock creation time. Fixes #2414
The fix is released in 2.3.3: https://github.com/pex-tool/pex/releases/tag/v2.3.3 |
Looks like there is a "breaking" change from pip in this commit, which applies the build_tracker conditionally. The result is that there will be no log info from the build tracker module, including the item like this that is used in pex. It seems as a result of this change, the URL for artifacts from private python package index hit the same issue as raised in #2156.
It affects pip >= 23.3. Lower versions seem fine with pex generating proper URLs for those artifacts.
As an example, this is the log from pip
23.2.1
for installingrequests
:and this is from pip
23.3
:The text was updated successfully, but these errors were encountered: