Skip to content
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

Switch from get-pip.py to ensurepip #955

Merged
merged 1 commit into from
Sep 11, 2024

Conversation

edmorley
Copy link
Contributor

@edmorley edmorley commented Aug 30, 2024

Since:

  • All versions of Python that are actively built by this repo now include the ensurepip module.
  • The policy of these images is now to use the same pip version as the one bundled with ensurepip (rather than always upgrading as pip releases occur) to avoid breaking changes, and for parity with the venv module.
  • As such, we might as well actually use ensurepip to install pip (since it installs the exact pip version we want) rather than manually doing the same using get-pip.py.
  • Doing so simplifies the build scripts and removes an external dependency, tightening the supply chain.

Now that the pip/setuptools versions track (or mostly track, in the case of setuptools) the ensurepip versions, the concerns over frequent invalidation of the Python layer no longer apply, and so the pip/setuptools install can now be part of the Python layer, reducing layer count by one.

This change is a no-op in terms of pip/setuptools/wheel versions, since the pip versions being used already exactly matched the ensurepip version of pip.

Closes #951.

@edmorley edmorley marked this pull request as ready for review August 30, 2024 10:09
Copy link
Member

@tianon tianon left a comment

Choose a reason for hiding this comment

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

Excellent, thank you! Just a few really minor stylistic notes, but overall this looks really good. ❤️

Dockerfile-linux.template Outdated Show resolved Hide resolved
Dockerfile-windows.template Outdated Show resolved Hide resolved
Dockerfile-linux.template Outdated Show resolved Hide resolved
Dockerfile-windows.template Outdated Show resolved Hide resolved
versions.sh Outdated Show resolved Hide resolved
@edmorley
Copy link
Contributor Author

edmorley commented Aug 30, 2024

Thank you for the feedback! I've made the those changes - I wouldn't normally force push for review changes, but since this repo uses merge commits rather than squash and merge I wanted to avoid the additional commits ending up on master. However, the diff from before can still be seen here:
https://github.com/docker-library/python/compare/7eab18fc115a913534bb0bc5c40bf45c26b61b05..0a4fcf7342f030937b1aad2848d07c0c995bf713

Happy to make further changes if you spot anything else :-)

(And also no rush to merge this; we can wait until the other changes are released first etc)

Copy link
Member

@tianon tianon left a comment

Choose a reason for hiding this comment

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

Last thing I see -- my mental model here is that the closing ; on a long multi-line is similar to the closing ) or } so I outdent it to make it clear this is the end of the extra long command+args. 👍

Thanks for your work on this! ❤️

Dockerfile-windows.template Outdated Show resolved Hide resolved
Dockerfile-linux.template Outdated Show resolved Hide resolved
@edmorley
Copy link
Contributor Author

edmorley commented Sep 7, 2024

I was going to rebase this on master after last night's Python version releases (which have caused conflicts with this PR), however, for some reason the Python 3.12.6 update hasn't been pushed yet by the automation? Did that job fail? (I don't know where those jobs run)
https://github.com/docker-library/python/commits/master/

Since:
* All versions of Python that are actively built by this repo now
  include the `ensurepip` module.
* The policy of these images is now to use the same pip version as the
  one bundled with `ensurepip` (rather than always upgrading as pip
  releases occur) to avoid breaking changes, and for parity with the
  `venv` module.
* As such, we might as well actually use `ensurepip` to install pip
  (since it installs the exact pip version we want) rather than manually
  doing the same using `get-pip.py`.

Now that the pip/setuptools versions track (or mostly track, in the case
of setuptools) the ensurepip versions, the concerns over frequent
invalidation of the Python layer no longer apply, and so the
pip/setuptools install can now be part of the Python layer, reducing
layer count by one.

This change is a no-op in terms of pip/setuptools/wheel versions,
since the pip versions being used already exactly matched the
`ensurepip` version of pip.

Closes docker-library#951.
@edmorley
Copy link
Contributor Author

edmorley commented Sep 9, 2024

I've rebased on master now that the bump for #960 has landed.

@tianon
Copy link
Member

tianon commented Sep 9, 2024

Also, to be really explicit, thank you so much for bringing up the original thread, being so thoughtful and thorough, seeing it all the way through including the extra cleanup of get-pip vs ensurepip here, and generally helping respond to the folks that were broken by the whole transition -- it's really appreciated. ❤️

@edmorley
Copy link
Contributor Author

That's very kind of you to say, it's been no trouble! :-)

@yosifkit yosifkit merged commit 31bbb37 into docker-library:master Sep 11, 2024
42 checks passed
docker-library-bot added a commit to docker-library-bot/official-images that referenced this pull request Sep 11, 2024
Changes:

- docker-library/python@31bbb37: Merge pull request docker-library/python#955 from edmorley/rm-get-pip
- docker-library/python@9cd3243: Switch from get-pip.py to ensurepip
@edmorley edmorley deleted the rm-get-pip branch September 11, 2024 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch from get-pip to ensurepip
3 participants