pyenv-binary: use xz compression for archives (#3543)
Some checks failed
build / discover_build_logic_change (push) Waiting to run
build / build (push) Blocked by required conditions
pyenv_tests / pyenv_tests (macos-14) (push) Waiting to run
pyenv_tests / pyenv_tests (macos-15) (push) Waiting to run
pyenv_tests / pyenv_tests (macos-15-intel) (push) Waiting to run
pyenv_tests / pyenv_tests (macos-26) (push) Waiting to run
pyenv_tests / pyenv_tests (ubuntu-22.04-arm) (push) Waiting to run
pyenv_tests / pyenv_tests (ubuntu-24.04) (push) Waiting to run
pyenv_tests / pyenv_tests (ubuntu-24.04-arm) (push) Waiting to run
pyenv_tests / pyenv_tests_docker (push) Waiting to run
pyenv_tests / pyenv_tests (ubuntu-22.04) (push) Failing after 1s

This commit is contained in:
Ayush 2026-09-15 04:54:23 +05:30 committed by GitHub
parent 5d43b9a39d
commit 676b71e7b5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 27 additions and 24 deletions

View file

@ -52,7 +52,7 @@ jobs:
- name: Update downloads
run: |
mkdir -p site/pythons/binaries
cp "dist/$entry.tar.gz" "dist/$entry.meta" "dist/$entry" \
cp "dist/$entry.tar.xz" "dist/$entry.meta" "dist/$entry" \
site/pythons/binaries/
cd site/pythons
./update.sh

View file

@ -14,6 +14,9 @@ architecture and a compatible libc) and have the recorded system libraries. It
is not portable across, say, glibc and musl, or to an older glibc; the platform
and dependency metadata exist to catch that.
Installing a binary package requires `tar` with xz support (typically provided
by the `xz` package).
## Commands
### `pyenv binary package [-v|--verbose] <version>[:<entry>] --archive-base-url <url>`
@ -29,7 +32,7 @@ Pass `-v` to show build progress from `pyenv install`.
```sh
pyenv binary package 3.12.7 \
--archive-base-url https://example.com/binaries
# On Debian 12 x86_64, writes 3.12.7-debian-12-x86_64.tar.gz,
# On Debian 12 x86_64, writes 3.12.7-debian-12-x86_64.tar.xz,
# its .meta file and a `3.12.7-debian-12-x86_64' definition.
pyenv binary package 3.12.7:company-python \
@ -54,7 +57,7 @@ pyenv binary package-name 3.12.7
### `pyenv binary save <version> [<output-dir>] [--name <name>]`
Packs an installed version into `<version>-<platform>.tar.gz` (relative paths)
Packs an installed version into `<version>-<platform>.tar.xz` (relative paths)
and writes `<version>-<platform>.meta` describing the build platform (OS, arch,
distro and libc version) and the system libraries the build links against. Use
`--name` to set a different base name for both files.
@ -78,7 +81,7 @@ needs are present.
```sh
pyenv binary generate-installer ./dist/3.12.7-linux-x86_64.meta \
--archive-url https://example.com/3.12.7-linux-x86_64.tar.gz \
--archive-url https://example.com/3.12.7-linux-x86_64.tar.xz \
-o "$(pyenv root)/plugins/python-build/share/python-build/3.12.7-linux-x86_64"
pyenv install 3.12.7-linux-x86_64

View file

@ -7,7 +7,7 @@
# Installs <version> from source under a separate entry name, saves it as a
# binary package, then emits a python-build definition for that package.
# The archive, metadata and definition are written to the current directory
# as <entry>.tar.gz, <entry>.meta and <entry>.
# as <entry>.tar.xz, <entry>.meta and <entry>.
#
# <version> A version `pyenv install' knows how to build.
# <entry> The optional name to build under and install the
@ -16,7 +16,7 @@
# -v,--verbose Show build progress from `pyenv install'.
# --archive-base-url <url>
# Where the archive will be hosted; the definition
# downloads it from <url>/<entry>.tar.gz.
# downloads it from <url>/<entry>.tar.xz.
#
set -e
[ -n "$PYENV_DEBUG" ] && set -x
@ -80,4 +80,4 @@ pyenv-install ${verbose:+--verbose} "$spec"
pyenv-binary-save "$entry" "$PWD" --name "$entry"
pyenv-binary-generate-installer "${entry}.meta" \
--archive-url "${archive_base_url%/}/${entry}.tar.gz" -o "$entry"
--archive-url "${archive_base_url%/}/${entry}.tar.xz" -o "$entry"

View file

@ -4,7 +4,7 @@
#
# Usage: pyenv binary save <version> [<output-dir>] [--name <name>]
#
# Packs an installed version into a relocatable .tar.gz (relative paths) and
# Packs an installed version into a relocatable .tar.xz (relative paths) and
# writes a metadata file listing the build platform and the system libraries
# it links against, so an installer can check compatibility before unpacking.
#
@ -134,10 +134,10 @@ system_deps() {
mkdir -p "$output_dir"
package_name="${package_name:-${version}-${platform}}"
archive="${package_name}.tar.gz"
archive="${package_name}.tar.xz"
metadata="${package_name}.meta"
tar -C "$(dirname "$prefix")" -czf "${output_dir}/${archive}" "$(basename "$prefix")"
tar -C "$(dirname "$prefix")" -cJf "${output_dir}/${archive}" "$(basename "$prefix")"
{
echo "# pyenv-binary metadata"

View file

@ -66,10 +66,10 @@ pyenv-install --list --bare
run pyenv-binary-package 3.12.7 --archive-base-url http://example.com/binaries
assert_success
assert [ -d "${PYENV_ROOT}/versions/3.12.7-debian-12-x86_64" ]
assert [ -f "${BATS_TEST_TMPDIR}/3.12.7-debian-12-x86_64.tar.gz" ]
assert [ -f "${BATS_TEST_TMPDIR}/3.12.7-debian-12-x86_64.tar.xz" ]
assert [ -f "${BATS_TEST_TMPDIR}/3.12.7-debian-12-x86_64.meta" ]
run grep '^ARCHIVE_URL=' "${BATS_TEST_TMPDIR}/3.12.7-debian-12-x86_64"
assert_success "ARCHIVE_URL=http://example.com/binaries/3.12.7-debian-12-x86_64.tar.gz"
assert_success "ARCHIVE_URL=http://example.com/binaries/3.12.7-debian-12-x86_64.tar.xz"
}
@test "rejects an entry name containing a slash" {
@ -102,10 +102,10 @@ generate-installer"
--archive-base-url http://example.com/binaries
assert_success
assert [ -d "${PYENV_ROOT}/versions/3.12.7-test" ]
assert [ -f "${BATS_TEST_TMPDIR}/3.12.7-test.tar.gz" ]
assert [ -f "${BATS_TEST_TMPDIR}/3.12.7-test.tar.xz" ]
assert [ -f "${BATS_TEST_TMPDIR}/3.12.7-test.meta" ]
run grep '^ARCHIVE_URL=' "${BATS_TEST_TMPDIR}/3.12.7-test"
assert_success "ARCHIVE_URL=http://example.com/binaries/3.12.7-test.tar.gz"
assert_success "ARCHIVE_URL=http://example.com/binaries/3.12.7-test.tar.xz"
}
@test "correctly joins archive base url with a trailing slash" {
@ -127,5 +127,5 @@ done
run pyenv-binary-package 3.12.7:3.12.7-test \
--archive-base-url http://example.com/binaries/
assert_success
assert_line "pyenv-binary-generate-installer --archive-url http://example.com/binaries/3.12.7-test.tar.gz"
assert_line "pyenv-binary-generate-installer --archive-url http://example.com/binaries/3.12.7-test.tar.xz"
}

View file

@ -33,13 +33,13 @@ platform() {
@test "packages an installed version" {
create_version "3.12.7"
local out="${BATS_TEST_TMPDIR}/dist"
local archive="${out}/3.12.7-$(platform).tar.gz"
local archive="${out}/3.12.7-$(platform).tar.xz"
run pyenv-binary-save "3.12.7" "$out"
assert_success "Saved 3.12.7-$(platform).tar.gz and 3.12.7-$(platform).meta to $out"
assert_success "Saved 3.12.7-$(platform).tar.xz and 3.12.7-$(platform).meta to $out"
assert [ -f "$archive" ]
assert [ -f "${out}/3.12.7-$(platform).meta" ]
run tar -tzf "$archive"
run tar -tJf "$archive"
assert_success
assert_line 0 "3.12.7/"
}
@ -49,10 +49,10 @@ platform() {
local out="${BATS_TEST_TMPDIR}/dist"
run pyenv-binary-save "3.12.7" "$out" --name "custom"
assert_success "Saved custom.tar.gz and custom.meta to $out"
assert [ -f "${out}/custom.tar.gz" ]
assert_success "Saved custom.tar.xz and custom.meta to $out"
assert [ -f "${out}/custom.tar.xz" ]
run grep '^archive=' "${out}/custom.meta"
assert_success "archive=custom.tar.gz"
assert_success "archive=custom.tar.xz"
}
@test "fails when --name has no value" {
@ -76,7 +76,7 @@ platform() {
assert_success
assert_line "version=3.12.7"
assert_line "platform=$(platform)"
assert_line "archive=3.12.7-$(platform).tar.gz"
assert_line "archive=3.12.7-$(platform).tar.xz"
}
@test "records the original installation prefix" {
@ -94,7 +94,7 @@ platform() {
PATH="$(path_without readelf)" run pyenv-binary-save "3.12.7" "${BATS_TEST_TMPDIR}/dist"
assert_failure "pyenv-binary: need readelf to inspect shared libraries"
assert [ ! -e "${BATS_TEST_TMPDIR}/dist/3.12.7-$(platform).tar.gz" ]
assert [ ! -e "${BATS_TEST_TMPDIR}/dist/3.12.7-$(platform).tar.xz" ]
}
@test "records only direct libraries resolved outside the prefix" {

View file

@ -12,7 +12,7 @@ FROM bash:$BASH
apk add sed coreutils findutils \
;fi
# Bats
RUN apk add --update parallel ncurses git binutils \
RUN apk add --update parallel ncurses git binutils xz \
&& mkdir -p ~/.parallel \
&& touch ~/.parallel/will-cite
COPY --from=bats /root/bats-core /root/bats-core