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

Use the bundled pip wheel to perform pip bootstrap #1442

Merged
merged 1 commit into from
Apr 27, 2023
Merged

Conversation

edmorley
Copy link
Member

@edmorley edmorley commented Apr 27, 2023

Previously the buildpack downloaded a pip wheel from S3 in order to bootstrap the pip/setuptools/wheel installation.

Newer Python versions (Python 3.4+) bundle a pip wheel as part of the ensurepip module, which we can use instead of having to perform this download now that we've dropped support for Python 2.

This approach:

  • improves performance/reliability of repeat builds, since it saves having to download the pip wheel each time
  • reduces the toil of performing pip updates, since we no longer need to upload new pip versions to the S3 bucket each time (for example in Update pip to 23.1.2 and setuptools to 67.7.2 #1441)
  • matches the approach already used in the new Python CNB.

GUS-W-13111316.

@edmorley edmorley self-assigned this Apr 27, 2023
Previously the buildpack downloaded a pip wheel from S3 in order
to bootstrap the pip/setuptools/wheel installation.

Newer Python versions (Python 3.4+) bundle a pip wheel as part of
the `ensurepip` module, which we can use instead of having to
perform this download now that we've dropped support for Python 2.

This approach:
- improves performance/reliability of repeat builds, since it saves
  having to download the pip wheel each time
- reduces the toil of performing pip updates, since we no longer need
  to upload new pip versions to the S3 bucket each time
- matches the approach already used in the new Python CNB.

GUS-W-13111316.
@edmorley edmorley marked this pull request as ready for review April 27, 2023 10:52
@edmorley edmorley requested a review from a team as a code owner April 27, 2023 10:52
@edmorley edmorley enabled auto-merge (squash) April 27, 2023 10:54
@edmorley edmorley merged commit 69a2603 into main Apr 27, 2023
@edmorley edmorley deleted the use-bundled-pip branch April 27, 2023 11:21
edmorley added a commit that referenced this pull request Apr 27, 2023
In some older versions of Python multiple pip wheels have been accidentally
bundled with the Python stdlib upstream. For example in Python 3.9.0 (which
has been superseded by newer patch versions of Python 3.9.x):
https://github.com/python/cpython/tree/v3.9.0/Lib/ensurepip/_bundled

After #1442, this results in eg:

```
-----> Installing pip 23.1.2, setuptools 67.7.2 and wheel 0.40.0
/app/.heroku/python/bin/python: can't open file '/build/.heroku/python/lib/python3.9/ensurepip/_bundled/pip-20.2.1-py2.py3-none-any.whl
.heroku/python/lib/python3.9/ensurepip/_bundled/pip-20.2.3-py2.py3-none-any.whl/pip': [Errno 2] No such file or directory
```

Whilst these affected Python versions are old/insecure and not available on
newer stacks, we should still make sure they work as expected.

As such, the lookup of the bundled pip wheel needs to handle this case,
which it now does by just picking the first found pip wheel.

This was spotted via https://heroku.support/1245122, which was from an
app using the `main` branch of this buildpack (since #1442 hasn't yet
been released to the buildpack registry).

GUS-W-13111316.
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.

2 participants