Skip to content

Support multiple abi and platform values for pip download. #8820

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

Merged
merged 7 commits into from
Oct 28, 2020

Conversation

katzdm
Copy link
Contributor

@katzdm katzdm commented Aug 28, 2020

As proposed in #6121.

This is useful when fetching wheels for a well-defined interpreter, whose supported ABIs and platforms are known and fixed, different than the one pip is running under.

@uranusjr
Copy link
Member

Would it be better to make the options action="append", instead of inventing a new comma-separated format? IMO it fits pip’s current argument design to do something like this instead:

pip download ...
    --abi cp36m --abi cp36 --abi abi3 --abi none
    ...

@McSinyx
Copy link
Contributor

McSinyx commented Aug 29, 2020

+1 on making it an append option, as it won't break backward compatibility.

@uranusjr
Copy link
Member

I don’t think backward compatibility would be an issue either way, since comma is not a valid character in wheel tags anyway 🙂

@McSinyx
Copy link
Contributor

McSinyx commented Aug 29, 2020

I was thinking about the name change (e.g. platform -> platforms) but I guess we can keep an alias if we're to go with the comma-separated list.

@katzdm
Copy link
Contributor Author

katzdm commented Aug 29, 2020

Thanks for the guidance! This is my first would-be contribution to pip, so I'm a bit unfamiliar with internal stylistic conventions - Will look at action="append" shortly!

@katzdm
Copy link
Contributor Author

katzdm commented Sep 3, 2020

@uranusjr I pushed the action="append" change a few days ago - Would you mind taking another look, when you have a chance?

Copy link
Member

@uranusjr uranusjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay. Just one nitpick on the help message, otherwise this looks good to me. Thanks for the effort!

@katzdm katzdm force-pushed the multi-abis-platforms branch 2 times, most recently from 02cf555 to d091260 Compare September 9, 2020 14:57
@katzdm
Copy link
Contributor Author

katzdm commented Sep 9, 2020

@uranusjr No problem, and thanks for taking a look! I've addressed your feedback, and have added a couple of elementary functional test-cases. Let me know if you have any other points of concern, whether you'd like to see broader test coverage, or whether things look good to you as-is.

Thanks again for your time!

@katzdm
Copy link
Contributor Author

katzdm commented Sep 10, 2020

@uranusjr Thanks for the review and approval! As this is my first time contributing to pip, I'm not familiar with how the review proceeds from here. Are multiple approving reviews typically awaited before merging?

@katzdm
Copy link
Contributor Author

katzdm commented Sep 17, 2020

Friendly ping 🙂

@katzdm katzdm force-pushed the multi-abis-platforms branch 2 times, most recently from 91a0cc5 to c12157d Compare September 28, 2020 15:02
@katzdm
Copy link
Contributor Author

katzdm commented Sep 29, 2020

@uranusjr @pradyunsg Wanted to ping this again - I had to rebase and resolve some conflicts yesterday, following other changes that were merged. Would be nice to get this in, to avoid doing so repeatedly.

Still a bit unclear as to whether we're waiting on other steps (e.g. additional reviews) before merging. Some clarification on the usual process would be appreciated.

Thanks in advance!

@pradyunsg
Copy link
Member

Usually, we wait on a couple of reviews or have the primary reviewer be fairly certain that things will work. I'm personally not super comfortable around ABI tags and if/how we should expose them to the end user, so I'm not comfortable reviewing this (and considering the implications of this change) myself. :)

@uranusjr if you reckon this is good to go, I'm happy to merge.

@uranusjr
Copy link
Member

Wheel tags are difficult, but these flags are designed as explicit overrides and the user has always been responsible for keeping the values straight, so I don’t think this PR has much chance to go wrong, actually. I think it’d be fine including this in 20.3.

if platforms and len(platforms) == 1:
# Only expand list of platforms if a single platform was provided.
# Otherwise, assume that the list provided is comprehensive.
platforms = _get_custom_platforms(platforms[0])
Copy link
Member

@xavfernandez xavfernandez Sep 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not call _get_custom_platforms on all provided platforms ?

I'd find it strange that pip download --platform manylinux2010 foobar would successfully find a manylinux1_x86_64 wheel but pip download --platform manylinux2010 --platform manylinux2014 foobar wouldn't.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xavfernandez I think this is a bit tricky.

I think it's reasonable to assume that anybody providing multiple --platform invocations is a fairly expert user, who is targeting a particular python interpreter different than the one through which pip is running. Therefore, the user should be the authority on what is and is not supported.

There may be edge-cases in which manylinux2014 wheels are acceptable, but manylinux1 wheels are not. For instance, the manylinux2014 and manylinux2010 specifications don't allow for binaries to link against the ncurses library, whereas manylinux1 does allow this library. If a user knows that their target environment does not provide ncurses, then they might write

pip download \
    --platform manylinux2014  --platform manylinux2010 --platform any \
    --abi cp39m --abi abi3 --abi none \
    --python-version 39 \
    --no-deps \
    hiredis==0.3.1

To avoid downloading wheels built for manylinux1.

This won't be an issue for most users, but it could come up in more complex deployments (e.g. large monorepos), which (I think) is the setting in which this feature is most likely to be useful.

What do you think? We could always add platform-expansion here later - It's probably more difficult to take it back, afterwards.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another question is one of precedence. Given the following two commands:

1. pip download --platform manylinux2014_x86_64 --platform linux_x86_64 foobar==0.1.0

2. pip download --platform manylinux_2014_x86_64 --platform any foobar==0.1.0

where the available wheels are built for [linux_x86_64, manylinux2010_x86_64, any], what should each command download?

If we perform manylinux-expansion, I would expect for 1 to download linux_86_64 (since I explicitly declared that platform to be acceptable), whereas I would expect for 2 to download manylinux2010_x86_64 (since any should probably be lowest precedence).

On the other hand, one might argue that manylinux2014_x86_64 should expand "in-place" in the precedence-list, to include all three manylinux-platforms. In that case, 1 should download manylinux2010_x86_64.

My intention isn't to argue which approach is more "correct" - Instead, it's to point out that the outcome is non-obvious. If we instead tell pip to just trust what the user provided, then this question melts away.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expects the --platform values be simply union-ed, and all expansions done in-place. The wheels downloaded would typically be installed by pip install on a specific platform, which would again filter the wheels. Incompatible wheels downloaded previously wouldn’t really make any practical differences (except some additional local disk space).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, I suppose I don't feel strongly in either direction.

@uranusjr @xavfernandez I've pushed a change to implement this - Let me know what you think.

@katzdm katzdm force-pushed the multi-abis-platforms branch 3 times, most recently from 12a2530 to 880fe55 Compare October 16, 2020 14:26
@katzdm katzdm force-pushed the multi-abis-platforms branch 2 times, most recently from 4fb0344 to 0fa1a08 Compare October 27, 2020 01:27
@katzdm
Copy link
Contributor Author

katzdm commented Oct 27, 2020

Looks like the MacOS test failures are happening at HEAD, and are likely unrelated.

@pradyunsg
Copy link
Member

Yup -- #9030.

@xavfernandez
Copy link
Member

Since #9030 should now be solved, rebasing again (sorry) should make the tests pass.

@katzdm katzdm force-pushed the multi-abis-platforms branch from 0fa1a08 to 7632c7a Compare October 27, 2020 23:00
@katzdm
Copy link
Contributor Author

katzdm commented Oct 27, 2020

Since #9030 should now be solved, rebasing again (sorry) should make the tests pass.

@xavfernandez Thanks for the heads up - Done and pushed.

@uranusjr uranusjr added this to the 20.3 milestone Oct 28, 2020
@pradyunsg
Copy link
Member

Merging given multiple approvals and that @uranusjr wants this in 20.3. :P

@pradyunsg pradyunsg merged commit c4dbc7d into pypa:master Oct 28, 2020
@katzdm katzdm deleted the multi-abis-platforms branch October 28, 2020 11:20
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: feature request Request for a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants