forked from python/cpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'webknjaz/docs/ensurepip-download-artifa…
…cts' into main
- Loading branch information
Showing
10 changed files
with
638 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* | ||
!.gitignore | ||
!README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Upstream packaging | ||
|
||
To populate this directory, the initial build packagers are supposed | ||
to invoke the following command: | ||
|
||
```console | ||
$ python -m ensurepip.bundle | ||
``` | ||
|
||
It will download a pre-defined version of the Pip wheel. Its SHA-256 | ||
hash is guaranteed to match the one on PyPI. | ||
|
||
# Downstream packaging | ||
|
||
Packagers of the downstream distributions are welcome to put an | ||
alternative wheel version in the directory defined by the | ||
`WHEEL_PKG_DIR` configuration setting. If this is done, | ||
|
||
```console | ||
$ python -m ensurepip | ||
``` | ||
|
||
will prefer the replacement distribution package over the bundled one. |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"""Build time dist downloading and bundling logic.""" | ||
|
||
from __future__ import annotations | ||
|
||
import sys | ||
from contextlib import suppress | ||
from importlib.resources import as_file as _traversable_to_pathlib_ctx | ||
|
||
from ._structs import BUNDLED_WHEELS_PATH, REMOTE_DIST_PKGS | ||
|
||
|
||
def ensure_wheels_are_downloaded(*, verbosity: bool = False) -> None: | ||
"""Download wheels into bundle if they are not there yet.""" | ||
for pkg in REMOTE_DIST_PKGS: | ||
existing_whl_file_path = BUNDLED_WHEELS_PATH / pkg.wheel_file_name | ||
with suppress(FileNotFoundError): | ||
if pkg.matches(existing_whl_file_path.read_bytes()): | ||
if verbosity: | ||
print( | ||
f'A valid `{pkg.wheel_file_name}` is already ' | ||
'present in cache. Skipping download.', | ||
file=sys.stderr, | ||
) | ||
continue | ||
|
||
if verbosity: | ||
print( | ||
f'Downloading `{pkg.wheel_file_name}`...', | ||
file=sys.stderr, | ||
) | ||
downloaded_whl_contents = pkg.download_verified_wheel_contents() | ||
|
||
if verbosity: | ||
print( | ||
f'Saving `{pkg.wheel_file_name}` to disk...', | ||
file=sys.stderr, | ||
) | ||
with _traversable_to_pathlib_ctx(BUNDLED_WHEELS_PATH) as bundled_dir: | ||
whl_file_path = bundled_dir / pkg.wheel_file_name | ||
whl_file_path.write_bytes(downloaded_whl_contents) |
Oops, something went wrong.