mirror of
https://github.com/pyenv/pyenv.git
synced 2026-09-10 07:36:16 -04:00
python-build: add build prerequisite installer (#3532)
Some checks failed
pyenv_tests / pyenv_tests (ubuntu-22.04) (push) Failing after 1s
pyenv_tests / pyenv_tests (ubuntu-24.04-arm) (push) Has been cancelled
pyenv_tests / pyenv_tests_docker (push) Has been cancelled
pyenv_tests / pyenv_tests (ubuntu-22.04-arm) (push) Has been cancelled
pyenv_tests / pyenv_tests (ubuntu-24.04) (push) Has been cancelled
pyenv_tests / pyenv_tests (macos-15-intel) (push) Has been cancelled
pyenv_tests / pyenv_tests (macos-26) (push) Has been cancelled
pyenv_tests / pyenv_tests (macos-14) (push) Has been cancelled
pyenv_tests / pyenv_tests (macos-15) (push) Has been cancelled
build / discover_build_logic_change (push) Has been cancelled
build / build (push) Has been cancelled
Some checks failed
pyenv_tests / pyenv_tests (ubuntu-22.04) (push) Failing after 1s
pyenv_tests / pyenv_tests (ubuntu-24.04-arm) (push) Has been cancelled
pyenv_tests / pyenv_tests_docker (push) Has been cancelled
pyenv_tests / pyenv_tests (ubuntu-22.04-arm) (push) Has been cancelled
pyenv_tests / pyenv_tests (ubuntu-24.04) (push) Has been cancelled
pyenv_tests / pyenv_tests (macos-15-intel) (push) Has been cancelled
pyenv_tests / pyenv_tests (macos-26) (push) Has been cancelled
pyenv_tests / pyenv_tests (macos-14) (push) Has been cancelled
pyenv_tests / pyenv_tests (macos-15) (push) Has been cancelled
build / discover_build_logic_change (push) Has been cancelled
build / build (push) Has been cancelled
This commit is contained in:
parent
2548d53706
commit
265b0dcefa
16
.github/actions/build-python/action.yml
vendored
16
.github/actions/build-python/action.yml
vendored
|
|
@ -9,6 +9,12 @@ inputs:
|
||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
steps:
|
steps:
|
||||||
|
- shell: bash
|
||||||
|
run: |
|
||||||
|
#envvars
|
||||||
|
export PYENV_ROOT="$GITHUB_WORKSPACE"
|
||||||
|
echo "PYENV_ROOT=$PYENV_ROOT" >> $GITHUB_ENV
|
||||||
|
echo "$PYENV_ROOT/shims:$PYENV_ROOT/bin" >> $GITHUB_PATH
|
||||||
# The two OSes differ only in this step.
|
# The two OSes differ only in this step.
|
||||||
- if: runner.os == 'macOS'
|
- if: runner.os == 'macOS'
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
@ -19,15 +25,7 @@ runs:
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
#prerequisites
|
#prerequisites
|
||||||
sudo apt-get update -q; sudo apt install -yq make build-essential libssl-dev zlib1g-dev \
|
pyenv install-prerequisites
|
||||||
libbz2-dev libreadline-dev libsqlite3-dev curl \
|
|
||||||
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
|
|
||||||
- shell: bash
|
|
||||||
run: |
|
|
||||||
#envvars
|
|
||||||
export PYENV_ROOT="$GITHUB_WORKSPACE"
|
|
||||||
echo "PYENV_ROOT=$PYENV_ROOT" >> $GITHUB_ENV
|
|
||||||
echo "$PYENV_ROOT/shims:$PYENV_ROOT/bin" >> $GITHUB_PATH
|
|
||||||
- shell: bash
|
- shell: bash
|
||||||
run: |
|
run: |
|
||||||
#build
|
#build
|
||||||
|
|
|
||||||
10
.github/workflows/modified_scripts_build.yml
vendored
10
.github/workflows/modified_scripts_build.yml
vendored
|
|
@ -220,10 +220,7 @@ jobs:
|
||||||
echo "$PYENV_ROOT/shims:$PYENV_ROOT/bin" >> $GITHUB_PATH
|
echo "$PYENV_ROOT/shims:$PYENV_ROOT/bin" >> $GITHUB_PATH
|
||||||
- run: |
|
- run: |
|
||||||
#prerequisites
|
#prerequisites
|
||||||
sudo apt-get update -q; sudo apt-get install -yq make build-essential \
|
pyenv install-prerequisites
|
||||||
libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev \
|
|
||||||
curl llvm libncurses5-dev libncursesw5-dev \
|
|
||||||
xz-utils tk-dev libffi-dev liblzma-dev
|
|
||||||
if [[ "${{ matrix.python-version }}" =~ pypy.*-(src|dev) ]]; then
|
if [[ "${{ matrix.python-version }}" =~ pypy.*-(src|dev) ]]; then
|
||||||
export PYENV_BOOTSTRAP_VERSION=pypy2.7-7
|
export PYENV_BOOTSTRAP_VERSION=pypy2.7-7
|
||||||
echo "PYENV_BOOTSTRAP_VERSION=$PYENV_BOOTSTRAP_VERSION" >> $GITHUB_ENV
|
echo "PYENV_BOOTSTRAP_VERSION=$PYENV_BOOTSTRAP_VERSION" >> $GITHUB_ENV
|
||||||
|
|
@ -283,10 +280,7 @@ jobs:
|
||||||
echo "_PYTHON_BUILD_FORCE_SKIP_XZ=1" >> $GITHUB_ENV
|
echo "_PYTHON_BUILD_FORCE_SKIP_XZ=1" >> $GITHUB_ENV
|
||||||
- run: |
|
- run: |
|
||||||
#prerequisites
|
#prerequisites
|
||||||
sudo apt-get update -q; sudo apt-get install -yq make build-essential \
|
pyenv install-prerequisites
|
||||||
libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev \
|
|
||||||
curl libncursesw5-dev \
|
|
||||||
xz-utils tk-dev libffi-dev liblzma-dev
|
|
||||||
- run: |
|
- run: |
|
||||||
#build
|
#build
|
||||||
pyenv --debug install ${{ matrix.python-version }} && rc=$? || rc=$?
|
pyenv --debug install ${{ matrix.python-version }} && rc=$? || rc=$?
|
||||||
|
|
|
||||||
|
|
@ -54,8 +54,11 @@ Or, if you would like to install the latest development release:
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Before you begin, you should ensure that your build environment has the proper
|
On Ubuntu, Debian, and Mint, install the recommended build dependencies with:
|
||||||
system dependencies for compiling the wanted Python Version (see our [recommendations](https://github.com/pyenv/pyenv/wiki#suggested-build-environment)).
|
|
||||||
|
pyenv install-prerequisites
|
||||||
|
|
||||||
|
For other environments, see our [build environment recommendations](https://github.com/pyenv/pyenv/wiki#suggested-build-environment).
|
||||||
|
|
||||||
### Using `pyenv install` with pyenv
|
### Using `pyenv install` with pyenv
|
||||||
|
|
||||||
|
|
@ -361,4 +364,3 @@ git diff --name-only master \
|
||||||
- Filter out any which don't live where python-build keeps its build scripts
|
- Filter out any which don't live where python-build keeps its build scripts
|
||||||
- Look only at the file name (i.e. the python version name)
|
- Look only at the file name (i.e. the python version name)
|
||||||
- Run a new docker container for each, building that version
|
- Run a new docker container for each, building that version
|
||||||
|
|
||||||
|
|
|
||||||
47
plugins/python-build/bin/pyenv-install-prerequisites
Executable file
47
plugins/python-build/bin/pyenv-install-prerequisites
Executable file
|
|
@ -0,0 +1,47 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Summary: Install Python build prerequisites on Debian-based systems
|
||||||
|
#
|
||||||
|
# Usage: pyenv install-prerequisites
|
||||||
|
#
|
||||||
|
set -e
|
||||||
|
[ -n "$PYENV_DEBUG" ] && set -x
|
||||||
|
|
||||||
|
# Provide pyenv completions
|
||||||
|
if [ "$1" = "--complete" ]; then
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
pyenv-help install-prerequisites 2>/dev/null
|
||||||
|
[ -z "$1" ] || exit "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
|
||||||
|
usage 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ "$#" -eq 0 ] || usage 1 >&2
|
||||||
|
|
||||||
|
if ! command -v apt-get >/dev/null; then
|
||||||
|
echo "pyenv: installing build prerequisites is not supported on this system" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
prerequisites=(
|
||||||
|
make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev
|
||||||
|
libsqlite3-dev curl git llvm libncurses5-dev libncursesw5-dev xz-utils
|
||||||
|
tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev libzstd-dev
|
||||||
|
)
|
||||||
|
|
||||||
|
if [ "$(id -u)" -eq 0 ]; then
|
||||||
|
apt_get=(apt-get)
|
||||||
|
elif command -v sudo >/dev/null; then
|
||||||
|
apt_get=(sudo apt-get)
|
||||||
|
else
|
||||||
|
echo "pyenv: sudo is required to install build prerequisites" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
"${apt_get[@]}" update -q
|
||||||
|
"${apt_get[@]}" install -yq "${prerequisites[@]}"
|
||||||
83
plugins/python-build/test/install-prerequisites.bats
Normal file
83
plugins/python-build/test/install-prerequisites.bats
Normal file
|
|
@ -0,0 +1,83 @@
|
||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
_setup() {
|
||||||
|
prerequisites="make build-essential libssl-dev zlib1g-dev libbz2-dev \
|
||||||
|
libreadline-dev libsqlite3-dev curl git llvm libncurses5-dev \
|
||||||
|
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev \
|
||||||
|
liblzma-dev libzstd-dev"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "completion does not install packages" {
|
||||||
|
stub apt-get
|
||||||
|
|
||||||
|
PATH="${BATS_TEST_DIRNAME}/../../../libexec:$PATH" \
|
||||||
|
run pyenv completions install-prerequisites
|
||||||
|
|
||||||
|
assert_success "--help"
|
||||||
|
unstub apt-get
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "supports help" {
|
||||||
|
stub pyenv-help 'install-prerequisites : echo "Usage: pyenv install-prerequisites"'
|
||||||
|
|
||||||
|
run pyenv-install-prerequisites --help
|
||||||
|
|
||||||
|
assert_success "Usage: pyenv install-prerequisites"
|
||||||
|
unstub pyenv-help
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "rejects arguments" {
|
||||||
|
stub pyenv-help 'install-prerequisites : echo "Usage: pyenv install-prerequisites"'
|
||||||
|
|
||||||
|
run pyenv-install-prerequisites unexpected
|
||||||
|
|
||||||
|
assert_failure "Usage: pyenv install-prerequisites"
|
||||||
|
unstub pyenv-help
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "installs build prerequisites with apt-get as root" {
|
||||||
|
stub id '-u : echo 0'
|
||||||
|
stub apt-get \
|
||||||
|
'update -q : true' \
|
||||||
|
"install -yq ${prerequisites} : true"
|
||||||
|
|
||||||
|
run pyenv-install-prerequisites
|
||||||
|
|
||||||
|
assert_success
|
||||||
|
unstub apt-get
|
||||||
|
unstub id
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "uses sudo when not running as root" {
|
||||||
|
stub id '-u : echo 1000'
|
||||||
|
stub apt-get
|
||||||
|
stub sudo \
|
||||||
|
'apt-get update -q : true' \
|
||||||
|
"apt-get install -yq ${prerequisites} : true"
|
||||||
|
|
||||||
|
run pyenv-install-prerequisites
|
||||||
|
|
||||||
|
assert_success
|
||||||
|
unstub sudo
|
||||||
|
unstub apt-get
|
||||||
|
unstub id
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "fails when apt-get is unavailable" {
|
||||||
|
PATH="$(path_without apt-get)" run pyenv-install-prerequisites
|
||||||
|
|
||||||
|
assert_failure "pyenv: installing build prerequisites is not supported on this system"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "fails when sudo is unavailable for an unprivileged user" {
|
||||||
|
stub id '-u : echo 1000'
|
||||||
|
stub apt-get
|
||||||
|
|
||||||
|
PATH="$(path_without sudo)" run pyenv-install-prerequisites
|
||||||
|
|
||||||
|
assert_failure "pyenv: sudo is required to install build prerequisites"
|
||||||
|
unstub apt-get
|
||||||
|
unstub id
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,7 @@ setup() {
|
||||||
export PYTHON_BUILD_CURL_OPTS=
|
export PYTHON_BUILD_CURL_OPTS=
|
||||||
export PYTHON_BUILD_HTTP_CLIENT="curl"
|
export PYTHON_BUILD_HTTP_CLIENT="curl"
|
||||||
|
|
||||||
|
export PYENV_TEST_DIR="${BATS_TEST_TMPDIR}/pyenv"
|
||||||
export FIXTURE_ROOT="${BATS_TEST_DIRNAME}/fixtures"
|
export FIXTURE_ROOT="${BATS_TEST_DIRNAME}/fixtures"
|
||||||
export INSTALL_ROOT="${BATS_TEST_TMPDIR}/install"
|
export INSTALL_ROOT="${BATS_TEST_TMPDIR}/install"
|
||||||
PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
|
PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
|
||||||
|
|
@ -148,7 +149,7 @@ path_without() {
|
||||||
if [ "$found" != "${PYENV_ROOT}/shims" ]; then
|
if [ "$found" != "${PYENV_ROOT}/shims" ]; then
|
||||||
alt="${PYENV_TEST_DIR}/$(echo "${found#/}" | tr '/' '-')"
|
alt="${PYENV_TEST_DIR}/$(echo "${found#/}" | tr '/' '-')"
|
||||||
mkdir -p "$alt"
|
mkdir -p "$alt"
|
||||||
for util in bash head cut readlink greadlink; do
|
for util in bash head cut readlink greadlink tr; do
|
||||||
if [ -x "${found}/$util" ]; then
|
if [ -x "${found}/$util" ]; then
|
||||||
ln -s "${found}/$util" "${alt}/$util"
|
ln -s "${found}/$util" "${alt}/$util"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue