mirror of
https://github.com/pyenv/pyenv.git
synced 2026-09-10 07:36:16 -04:00
Compare commits
No commits in common. "master" and "v2.8.5" have entirely different histories.
16
.github/actions/build-python/action.yml
vendored
16
.github/actions/build-python/action.yml
vendored
|
|
@ -9,12 +9,6 @@ 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
|
||||||
|
|
@ -25,7 +19,15 @@ runs:
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
#prerequisites
|
#prerequisites
|
||||||
pyenv install-prerequisites
|
sudo apt-get update -q; sudo apt install -yq make build-essential libssl-dev zlib1g-dev \
|
||||||
|
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,7 +220,10 @@ jobs:
|
||||||
echo "$PYENV_ROOT/shims:$PYENV_ROOT/bin" >> $GITHUB_PATH
|
echo "$PYENV_ROOT/shims:$PYENV_ROOT/bin" >> $GITHUB_PATH
|
||||||
- run: |
|
- run: |
|
||||||
#prerequisites
|
#prerequisites
|
||||||
pyenv install-prerequisites
|
sudo apt-get update -q; sudo apt-get install -yq make build-essential \
|
||||||
|
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
|
||||||
|
|
@ -280,7 +283,10 @@ jobs:
|
||||||
echo "_PYTHON_BUILD_FORCE_SKIP_XZ=1" >> $GITHUB_ENV
|
echo "_PYTHON_BUILD_FORCE_SKIP_XZ=1" >> $GITHUB_ENV
|
||||||
- run: |
|
- run: |
|
||||||
#prerequisites
|
#prerequisites
|
||||||
pyenv install-prerequisites
|
sudo apt-get update -q; sudo apt-get install -yq make build-essential \
|
||||||
|
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=$?
|
||||||
|
|
|
||||||
36
Makefile
36
Makefile
|
|
@ -10,14 +10,11 @@ TEST_PYTHON_BUILD_DOCKER_TARGETS = $(foreach bash,$(TEST_BASH_VERSIONS),$(addsuf
|
||||||
TEST_BINARY_DOCKER_PREFIX = test-binary-docker
|
TEST_BINARY_DOCKER_PREFIX = test-binary-docker
|
||||||
TEST_BINARY_DOCKER_TARGETS = $(foreach bash,$(TEST_BASH_VERSIONS),$(addsuffix -$(bash),$(TEST_BINARY_DOCKER_PREFIX)) $(addsuffix -gnu-$(bash),$(TEST_BINARY_DOCKER_PREFIX)))
|
TEST_BINARY_DOCKER_TARGETS = $(foreach bash,$(TEST_BASH_VERSIONS),$(addsuffix -$(bash),$(TEST_BINARY_DOCKER_PREFIX)) $(addsuffix -gnu-$(bash),$(TEST_BINARY_DOCKER_PREFIX)))
|
||||||
|
|
||||||
TEST_LINK_DOCKER_PREFIX = test-link-docker
|
|
||||||
TEST_LINK_DOCKER_TARGETS = $(foreach bash,$(TEST_BASH_VERSIONS),$(addsuffix -$(bash),$(TEST_LINK_DOCKER_PREFIX)) $(addsuffix -gnu-$(bash),$(TEST_LINK_DOCKER_PREFIX)))
|
|
||||||
|
|
||||||
TEST_BATS_IMAGE_PREFIX = test-pyenv-docker-image
|
TEST_BATS_IMAGE_PREFIX = test-pyenv-docker-image
|
||||||
TEST_BATS_IMAGE_TARGETS = $(foreach bash,$(TEST_BASH_VERSIONS),$(addsuffix -$(bash),$(TEST_BATS_IMAGE_PREFIX)) $(addsuffix -gnu-$(bash),$(TEST_BATS_IMAGE_PREFIX)))
|
TEST_BATS_IMAGE_TARGETS = $(foreach bash,$(TEST_BASH_VERSIONS),$(addsuffix -$(bash),$(TEST_BATS_IMAGE_PREFIX)) $(addsuffix -gnu-$(bash),$(TEST_BATS_IMAGE_PREFIX)))
|
||||||
|
|
||||||
.PHONY: test-docker
|
.PHONY: test-docker
|
||||||
test-docker: $(TEST_UNIT_DOCKER_PREFIX) $(TEST_PYTHON_BUILD_DOCKER_PREFIX) $(TEST_BINARY_DOCKER_PREFIX) $(TEST_LINK_DOCKER_PREFIX)
|
test-docker: $(TEST_UNIT_DOCKER_PREFIX) $(TEST_PYTHON_BUILD_DOCKER_PREFIX) $(TEST_BINARY_DOCKER_PREFIX)
|
||||||
|
|
||||||
.PHONY: $(TEST_UNIT_DOCKER_PREFIX)
|
.PHONY: $(TEST_UNIT_DOCKER_PREFIX)
|
||||||
$(TEST_UNIT_DOCKER_PREFIX): $(TEST_UNIT_DOCKER_TARGETS)
|
$(TEST_UNIT_DOCKER_PREFIX): $(TEST_UNIT_DOCKER_TARGETS)
|
||||||
|
|
@ -91,29 +88,6 @@ $(TEST_BINARY_DOCKER_TARGETS): $(TEST_BINARY_DOCKER_PREFIX)-% : $(TEST_BATS_IMAG
|
||||||
bats $${CI:+-F "/code/test/libexec/bats-format-tap-suite"} \
|
bats $${CI:+-F "/code/test/libexec/bats-format-tap-suite"} \
|
||||||
$${BATS_TEST_FILTER:+--filter "$${BATS_TEST_FILTER}"} plugins/pyenv-binary/test/$${BATS_FILE_FILTER}
|
$${BATS_TEST_FILTER:+--filter "$${BATS_TEST_FILTER}"} plugins/pyenv-binary/test/$${BATS_FILE_FILTER}
|
||||||
|
|
||||||
.PHONY: $(TEST_LINK_DOCKER_PREFIX)
|
|
||||||
$(TEST_LINK_DOCKER_PREFIX): $(TEST_LINK_DOCKER_TARGETS)
|
|
||||||
|
|
||||||
.PHONY: $(TEST_LINK_DOCKER_TARGETS)
|
|
||||||
$(TEST_LINK_DOCKER_TARGETS): DOCKER_IMAGE = $(TEST_BATS_IMAGE_PREFIX)
|
|
||||||
$(TEST_LINK_DOCKER_TARGETS): GNU = $(if $(findstring -gnu-,$@),True,False)
|
|
||||||
$(TEST_LINK_DOCKER_TARGETS): BASH = $(filter $(TEST_BASH_VERSIONS),$(subst -, ,$@))
|
|
||||||
$(TEST_LINK_DOCKER_TARGETS): DOCKER_TAG = bash-$(BASH)-gnu-$(GNU)
|
|
||||||
$(TEST_LINK_DOCKER_TARGETS): INTERACTIVE = $(if $(findstring true,$(CI)),,-ti)
|
|
||||||
$(TEST_LINK_DOCKER_TARGETS): $(TEST_LINK_DOCKER_PREFIX)-% : $(TEST_BATS_IMAGE_PREFIX)-%
|
|
||||||
$(info Running test with docker image '$(DOCKER_IMAGE):$(DOCKER_TAG)')
|
|
||||||
docker run \
|
|
||||||
--init \
|
|
||||||
-v $(PWD):/code:ro \
|
|
||||||
-v /etc/passwd:/etc/passwd:ro \
|
|
||||||
-v /etc/group:/etc/group:ro \
|
|
||||||
-u "$$(id -u $$(whoami)):$$(id -g $$(whoami))" \
|
|
||||||
$${CI+-e CI="$${CI}"} \
|
|
||||||
$(INTERACTIVE) \
|
|
||||||
$(DOCKER_IMAGE):$(DOCKER_TAG) \
|
|
||||||
bats $${CI:+-F "/code/test/libexec/bats-format-tap-suite"} \
|
|
||||||
$${BATS_TEST_FILTER:+--filter "$${BATS_TEST_FILTER}"} plugins/pyenv-link/test/$${BATS_FILE_FILTER}
|
|
||||||
|
|
||||||
# Build all images needed for bats under docker
|
# Build all images needed for bats under docker
|
||||||
.PHONY: $(TEST_BATS_IMAGE_PREFIX)
|
.PHONY: $(TEST_BATS_IMAGE_PREFIX)
|
||||||
$(TEST_BATS_IMAGE_PREFIX): $(TEST_BATS_IMAGE_TARGETS)
|
$(TEST_BATS_IMAGE_PREFIX): $(TEST_BATS_IMAGE_TARGETS)
|
||||||
|
|
@ -136,13 +110,13 @@ $(TEST_BATS_IMAGE_TARGETS):
|
||||||
./ ; \
|
./ ; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
.PHONY: test test-unit test-python-build test-binary test-link
|
.PHONY: test test-unit test-python-build test-binary
|
||||||
|
|
||||||
# Do not pass in user flags to build tests.
|
# Do not pass in user flags to build tests.
|
||||||
unexport PYTHON_CFLAGS
|
unexport PYTHON_CFLAGS
|
||||||
unexport PYTHON_CONFIGURE_OPTS
|
unexport PYTHON_CONFIGURE_OPTS
|
||||||
|
|
||||||
test: test-unit test-python-build test-binary test-link
|
test: test-unit test-python-build test-binary
|
||||||
|
|
||||||
test-unit: bats
|
test-unit: bats
|
||||||
PATH="./bats/bin:$$PATH" test/run
|
PATH="./bats/bin:$$PATH" test/run
|
||||||
|
|
@ -155,10 +129,6 @@ test-binary: bats
|
||||||
cd plugins/pyenv-binary && $(PWD)/bats/bin/bats $${CI:+-F "$(PWD)/test/libexec/bats-format-tap-suite"} \
|
cd plugins/pyenv-binary && $(PWD)/bats/bin/bats $${CI:+-F "$(PWD)/test/libexec/bats-format-tap-suite"} \
|
||||||
$${BATS_TEST_FILTER:+--filter "$${BATS_TEST_FILTER}"} test/$${BATS_FILE_FILTER}
|
$${BATS_TEST_FILTER:+--filter "$${BATS_TEST_FILTER}"} test/$${BATS_FILE_FILTER}
|
||||||
|
|
||||||
test-link: bats
|
|
||||||
cd plugins/pyenv-link && $(PWD)/bats/bin/bats $${CI:+-F "$(PWD)/test/libexec/bats-format-tap-suite"} \
|
|
||||||
$${BATS_TEST_FILTER:+--filter "$${BATS_TEST_FILTER}"} test/$${BATS_FILE_FILTER}
|
|
||||||
|
|
||||||
.SECONDARY: bats-$(TEST_BATS_VERSION)
|
.SECONDARY: bats-$(TEST_BATS_VERSION)
|
||||||
bats-$(TEST_BATS_VERSION):
|
bats-$(TEST_BATS_VERSION):
|
||||||
git clone --depth 1 --branch $(TEST_BATS_VERSION) https://github.com/bats-core/bats-core.git bats-$(TEST_BATS_VERSION)
|
git clone --depth 1 --branch $(TEST_BATS_VERSION) https://github.com/bats-core/bats-core.git bats-$(TEST_BATS_VERSION)
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,6 @@ This project was forked from [rbenv](https://github.com/rbenv/rbenv) and
|
||||||
|
|
||||||
* Lets you **change the global Python version** on a per-user basis.
|
* Lets you **change the global Python version** on a per-user basis.
|
||||||
* Provides support for **per-project Python versions**.
|
* Provides support for **per-project Python versions**.
|
||||||
* Supports **multiple Python distributions**: CPython, PyPy, Stackless Python, Jython, and more.
|
|
||||||
See the [full list of available versions](https://github.com/pyenv/pyenv/tree/master/plugins/python-build/share/python-build).
|
|
||||||
* Allows you to **override the Python version** with an environment
|
* Allows you to **override the Python version** with an environment
|
||||||
variable.
|
variable.
|
||||||
* Searches for commands from **multiple versions of Python at a time**.
|
* Searches for commands from **multiple versions of Python at a time**.
|
||||||
|
|
|
||||||
|
|
@ -473,12 +473,12 @@ function pyenv {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ("${commands[*]}" -split ' ') -contains \$command ) {
|
if ( ("${commands[*]}" -split ' ') -contains \$command ) {
|
||||||
\$shell_cmds = (& (get-command -commandtype application pyenv -totalcount 1) sh-\$command \$args)
|
\$shell_cmds = (& (get-command -commandtype application pyenv) sh-\$command \$args)
|
||||||
if ( \$shell_cmds.Count -gt 0 ) {
|
if ( \$shell_cmds.Count -gt 0 ) {
|
||||||
iex (\$shell_cmds -join "\`n")
|
iex (\$shell_cmds -join "\`n")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
& (get-command -commandtype application pyenv -totalcount 1) \$command \$args
|
& (get-command -commandtype application pyenv) \$command \$args
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EOS
|
EOS
|
||||||
|
|
|
||||||
1
plugins/.gitignore
vendored
1
plugins/.gitignore
vendored
|
|
@ -3,5 +3,4 @@
|
||||||
!/version-ext-compat
|
!/version-ext-compat
|
||||||
!/python-build
|
!/python-build
|
||||||
!/pyenv-binary
|
!/pyenv-binary
|
||||||
!/pyenv-link
|
|
||||||
/python-build/test/build
|
/python-build/test/build
|
||||||
|
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2023 yfprojects
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
# pyenv-link
|
|
||||||
A [pyenv](https://github.com/pyenv/pyenv) plugin for linking Python installations and virtual environments into your pyenv root.
|
|
||||||
|
|
||||||
This plugin recommends the [pyenv-virtualenv](https://github.com/pyenv/pyenv-virtualenv/) plugin.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
Make an arbitrary virtualenv available through pyenv. This automatically guesses a fitting name from the prompt, the directory name or the location of the venv.
|
|
||||||
|
|
||||||
```console
|
|
||||||
$ pyenv link version .venv
|
|
||||||
Linked new version named myproject
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also specify a name to use for the venv.
|
|
||||||
|
|
||||||
```console
|
|
||||||
$ pyenv link version .venv myname
|
|
||||||
Linked new version named myname
|
|
||||||
```
|
|
||||||
|
|
||||||
The same command can give a platform-specific binary installation a shorter name:
|
|
||||||
|
|
||||||
```console
|
|
||||||
$ pyenv link version "$(pyenv root)/versions/3.13.14-linux-x86_64" 3.13.14
|
|
||||||
Linked new version named 3.13.14
|
|
||||||
```
|
|
||||||
|
|
||||||
Now you can make pyenv activate/use the venv automatically:
|
|
||||||
|
|
||||||
```console
|
|
||||||
$ pyenv local myproject
|
|
||||||
```
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
#
|
|
||||||
# Summary: Link a Python environment as a pyenv version
|
|
||||||
#
|
|
||||||
# Usage: pyenv link version [--dry] [--quiet] <path> [<name>]
|
|
||||||
#
|
|
||||||
# Link a virtual python environment to pyenvs version directory
|
|
||||||
# so that the venv can be used like one created with *pyenv-virtualenv*.
|
|
||||||
#
|
|
||||||
# <path> should be a path to a Python installation or virtual environment.
|
|
||||||
|
|
||||||
set -e
|
|
||||||
[ -n "$PYENV_DEBUG" ] && set -x
|
|
||||||
|
|
||||||
# Provide pyenv completions
|
|
||||||
case "$1" in
|
|
||||||
--complete)
|
|
||||||
if [ -z "$2" ]; then
|
|
||||||
echo version
|
|
||||||
else
|
|
||||||
shift 2
|
|
||||||
pyenv-link-version --complete "$@"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
version)
|
|
||||||
shift
|
|
||||||
pyenv-link-version "$@"
|
|
||||||
exit $?
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
pyenv-help --usage link >&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
@ -1,150 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
#
|
|
||||||
# Summary: Link a Python environment as a pyenv version
|
|
||||||
#
|
|
||||||
# Usage: pyenv link version [--dry] [--quiet] <path> [<name>]
|
|
||||||
#
|
|
||||||
# Link a virtual python environment to pyenvs version directory
|
|
||||||
# so that the venv can be used like one created with *pyenv-virtualenv*.
|
|
||||||
#
|
|
||||||
# <path> should be a path to a Python installation or virtual environment.
|
|
||||||
# <name> should be string used as a version name it may not be present
|
|
||||||
# in the pyenv version directory yet.
|
|
||||||
# If not specified a matching name is guessed from pyvenv.cfg
|
|
||||||
# or directory name of the venv.
|
|
||||||
set -e
|
|
||||||
[ -n "$PYENV_DEBUG" ] && set -x
|
|
||||||
|
|
||||||
# functions
|
|
||||||
|
|
||||||
if ! {
|
|
||||||
enable -f "${BASH_SOURCE%/*}"/../../../libexec/pyenv-realpath.dylib realpath ||
|
|
||||||
type realpath # realpath available?
|
|
||||||
} >/dev/null 2>&1; then
|
|
||||||
# realpath requires GNU coreutils to be installed. That's why its bundled with pyenv
|
|
||||||
echo realpath not available >&2
|
|
||||||
|
|
||||||
# work-around when realpath is unavailable
|
|
||||||
realpath() {
|
|
||||||
(cd "$1" && pwd)
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
|
|
||||||
guess_name() {
|
|
||||||
local venv_dir=$1
|
|
||||||
local name
|
|
||||||
|
|
||||||
# guess venv name from pyvenv.cfg
|
|
||||||
local pyvenv_cfg_path=$venv_dir/pyvenv.cfg
|
|
||||||
if [ -f "$pyvenv_cfg_path" ]; then
|
|
||||||
# if `prompt` key wasn't found the var remains empty
|
|
||||||
name=$(cut -b 1-1024 "$pyvenv_cfg_path" | sed -n '/^ *prompt *= */s///p')
|
|
||||||
case "$name" in
|
|
||||||
\"*\" | \'*\')
|
|
||||||
name=${name:1:${#name}-2}
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
# guess venv name from name of venv directory
|
|
||||||
local venv_dir_name=${venv_dir##*/}
|
|
||||||
if [ -z "$name" ]; then
|
|
||||||
case "$venv_dir_name" in
|
|
||||||
venv | env | .venv | .env | ENV | VENV) ;;
|
|
||||||
*) name=$venv_dir_name ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
# guess venv name from name of the parent directory of the venv directory
|
|
||||||
local venv_dir_parent=${venv_dir%/*}
|
|
||||||
local venv_dir_parent_name=${venv_dir_parent##*/}
|
|
||||||
if [ -z "$name" ]; then
|
|
||||||
name=$venv_dir_parent_name
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "$name"
|
|
||||||
}
|
|
||||||
|
|
||||||
# process args
|
|
||||||
POSARGS=()
|
|
||||||
# Provide pyenv completions
|
|
||||||
if [ "$1" = "--complete" ]; then
|
|
||||||
echo --dry
|
|
||||||
echo --quiet
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
for arg in "$@"; do
|
|
||||||
case $arg in
|
|
||||||
--dry)
|
|
||||||
dry=true # any value
|
|
||||||
;;
|
|
||||||
--quiet)
|
|
||||||
quiet=true # any value
|
|
||||||
;;
|
|
||||||
-*)
|
|
||||||
pyenv-help --usage link-version >&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
POSARGS+=("$arg")
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! ${#POSARGS[@]} -le 2 ] || [ ! ${#POSARGS[@]} -ge 1 ]; then
|
|
||||||
pyenv-help --usage link-version >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
venv_dir=${POSARGS[0]%/}
|
|
||||||
venv_name=${POSARGS[1]}
|
|
||||||
|
|
||||||
# Check venv exists
|
|
||||||
if [ ! -d "$venv_dir" ]; then
|
|
||||||
echo "The virtual env you specified doesn't exist"
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
# make venv dir absolute
|
|
||||||
venv_dir=$(realpath "$venv_dir")
|
|
||||||
|
|
||||||
# determine venv name
|
|
||||||
if [ -z "$venv_name" ]; then
|
|
||||||
venv_name=$(guess_name "$venv_dir")
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$venv_name" in
|
|
||||||
"" | */* | . | .. | *:* | system | *[[:cntrl:]]* )
|
|
||||||
echo "pyenv-link: invalid version name \`${venv_name}'" >&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
versions_dir="$PYENV_ROOT/versions"
|
|
||||||
pyenv_prefix_path="$versions_dir/$venv_name"
|
|
||||||
|
|
||||||
if [ -e "$pyenv_prefix_path" ] || [ -L "$pyenv_prefix_path" ]; then
|
|
||||||
echo Version "$venv_name" already exists >&2
|
|
||||||
exit 3
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$venv_dir" in
|
|
||||||
"$versions_dir"/*)
|
|
||||||
link_target=${venv_dir#"$versions_dir"/}
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
link_target=$venv_dir
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# link to pyenv version directory
|
|
||||||
if [ -z "$dry" ]; then
|
|
||||||
mkdir -p "$versions_dir"
|
|
||||||
ln -s "$link_target" "$pyenv_prefix_path"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# output
|
|
||||||
if [ -z "$quiet" ]; then
|
|
||||||
echo "Linked new version named $venv_name"
|
|
||||||
fi
|
|
||||||
|
|
@ -1,61 +0,0 @@
|
||||||
#!/usr/bin/env bats
|
|
||||||
|
|
||||||
load test_helper
|
|
||||||
|
|
||||||
@test "link completions use the dispatcher" {
|
|
||||||
run pyenv completions link
|
|
||||||
assert_success
|
|
||||||
assert_output <<OUT
|
|
||||||
--help
|
|
||||||
version
|
|
||||||
OUT
|
|
||||||
run pyenv completions link version
|
|
||||||
assert_success
|
|
||||||
assert_output <<OUT
|
|
||||||
--help
|
|
||||||
--dry
|
|
||||||
--quiet
|
|
||||||
OUT
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "link requires a version path" {
|
|
||||||
run pyenv-link version
|
|
||||||
assert_failure "Usage: pyenv link version [--dry] [--quiet] <path> [<name>]"
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "links an installed binary under its plain version name" {
|
|
||||||
create_alt_executable_in_version "3.13.14-linux-x86_64" python 'echo linked-python'
|
|
||||||
run pyenv-link version "$PYENV_ROOT/versions/3.13.14-linux-x86_64" 3.13.14
|
|
||||||
assert_success "Linked new version named 3.13.14"
|
|
||||||
assert_equal "3.13.14-linux-x86_64" "$(readlink "$PYENV_ROOT/versions/3.13.14")"
|
|
||||||
PYENV_VERSION=3.13.14 run pyenv exec python
|
|
||||||
assert_success "linked-python"
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "links external paths containing spaces into a fresh root" {
|
|
||||||
mkdir -p "$PYENV_TEST_DIR/external env/bin"
|
|
||||||
run pyenv-link version "$PYENV_TEST_DIR/external env" custom
|
|
||||||
assert_success "Linked new version named custom"
|
|
||||||
assert_equal "$PYENV_TEST_DIR/external env" "$(readlink "$PYENV_ROOT/versions/custom")"
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "refuses a dangling destination link" {
|
|
||||||
mkdir -p "$PYENV_ROOT/versions" "$PYENV_TEST_DIR/source"
|
|
||||||
ln -s missing "$PYENV_ROOT/versions/dangling"
|
|
||||||
run pyenv-link version "$PYENV_TEST_DIR/source" dangling
|
|
||||||
assert_failure "Version dangling already exists"
|
|
||||||
assert_equal missing "$(readlink "$PYENV_ROOT/versions/dangling")"
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "rejects invalid version names" {
|
|
||||||
mkdir -p "$PYENV_TEST_DIR/source"
|
|
||||||
for name in ../outside . .. 'foo/bar' 'foo:bar' system; do
|
|
||||||
run pyenv-link version "$PYENV_TEST_DIR/source" "$name"
|
|
||||||
assert_failure "pyenv-link: invalid version name \`$name'"
|
|
||||||
assert [ ! -e "$PYENV_ROOT/outside" ]
|
|
||||||
done
|
|
||||||
echo "prompt = '../outside'" > "$PYENV_TEST_DIR/source/pyvenv.cfg"
|
|
||||||
run pyenv-link version "$PYENV_TEST_DIR/source"
|
|
||||||
assert_failure "pyenv-link: invalid version name \`../outside'"
|
|
||||||
assert [ ! -e "$PYENV_ROOT/outside" ]
|
|
||||||
}
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
../../../test/test_helper.bash
|
|
||||||
|
|
@ -54,11 +54,8 @@ Or, if you would like to install the latest development release:
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
On Ubuntu, Debian, and Mint, install the recommended build dependencies with:
|
Before you begin, you should ensure that your build environment has the proper
|
||||||
|
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
|
||||||
|
|
||||||
|
|
@ -364,3 +361,4 @@ 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
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
#!/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[@]}"
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
# SOFTWARE.
|
# SOFTWARE.
|
||||||
VERSION='25.3.4.1'
|
VERSION='25.3.4.1'
|
||||||
RELEASE_TAG='graal-25.3.4'
|
|
||||||
|
|
||||||
colorize 1 "GraalPy 23.1 and later installed by python-build use the faster Oracle GraalVM distribution" && echo
|
colorize 1 "GraalPy 23.1 and later installed by python-build use the faster Oracle GraalVM distribution" && echo
|
||||||
colorize 1 "Oracle GraalVM uses the GFTC license, which is free for development and production use, see https://medium.com/graalvm/161527df3d76" && echo
|
colorize 1 "Oracle GraalVM uses the GFTC license, which is free for development and production use, see https://medium.com/graalvm/161527df3d76" && echo
|
||||||
|
|
@ -47,4 +46,4 @@ case "$graalpy_arch" in
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
install_package "graalpy3.13-${VERSION}" "https://github.com/oracle/graalpython/releases/download/${RELEASE_TAG}/graalpy3.13-${VERSION}-${graalpy_arch}.tar.gz#${checksum}" "copy" ensurepip
|
install_package "graalpy3.13-${VERSION}" "https://github.com/oracle/graalpython/releases/download/graal-${VERSION}/graalpy3.13-${VERSION}-${graalpy_arch}.tar.gz#${checksum}" "copy" ensurepip
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
# SOFTWARE.
|
# SOFTWARE.
|
||||||
VERSION='25.3.4.1'
|
VERSION='25.3.4.1'
|
||||||
RELEASE_TAG='graal-25.3.4'
|
|
||||||
|
|
||||||
graalpy_arch="$(graalpy_architecture 2>/dev/null || true)"
|
graalpy_arch="$(graalpy_architecture 2>/dev/null || true)"
|
||||||
|
|
||||||
|
|
@ -42,4 +41,4 @@ case "$graalpy_arch" in
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
install_package "graalpy3.13-community-${VERSION}" "https://github.com/oracle/graalpython/releases/download/${RELEASE_TAG}/graalpy3.13-community-${VERSION}-${graalpy_arch}.tar.gz#${checksum}" "copy" ensurepip
|
install_package "graalpy3.13-community-${VERSION}" "https://github.com/oracle/graalpython/releases/download/graal-${VERSION}/graalpy3.13-community-${VERSION}-${graalpy_arch}.tar.gz#${checksum}" "copy" ensurepip
|
||||||
|
|
|
||||||
|
|
@ -1,83 +0,0 @@
|
||||||
#!/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,7 +2,6 @@ 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"
|
||||||
|
|
@ -149,7 +148,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 tr; do
|
for util in bash head cut readlink greadlink; 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
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,8 @@ unset PYENV_VERSION
|
||||||
unset PYENV_DIR
|
unset PYENV_DIR
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
|
|
||||||
|
|
||||||
export _PYENV_INSTALL_PREFIX="${BATS_TEST_DIRNAME%/*}"
|
export _PYENV_INSTALL_PREFIX="${BATS_TEST_DIRNAME%/*}"
|
||||||
local PLUGIN_PREFIX
|
export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
|
||||||
if [[ $_PYENV_INSTALL_PREFIX =~ /plugins/[^/]+$ ]]; then
|
|
||||||
PLUGIN_PREFIX="$_PYENV_INSTALL_PREFIX"
|
|
||||||
_PYENV_INSTALL_PREFIX="${_PYENV_INSTALL_PREFIX::${#_PYENV_INSTALL_PREFIX}-${#BASH_REMATCH[0]}}"
|
|
||||||
fi
|
|
||||||
if ! enable -f "${_PYENV_INSTALL_PREFIX}"/libexec/pyenv-realpath.dylib realpath 2>/dev/null; then
|
if ! enable -f "${_PYENV_INSTALL_PREFIX}"/libexec/pyenv-realpath.dylib realpath 2>/dev/null; then
|
||||||
if [ -n "$PYENV_NATIVE_EXT" ]; then
|
if [ -n "$PYENV_NATIVE_EXT" ]; then
|
||||||
echo "pyenv: failed to load \`realpath' builtin" >&2
|
echo "pyenv: failed to load \`realpath' builtin" >&2
|
||||||
|
|
@ -33,9 +27,6 @@ setup() {
|
||||||
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
|
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
|
||||||
PATH="${PYENV_TEST_DIR}/bin:$PATH"
|
PATH="${PYENV_TEST_DIR}/bin:$PATH"
|
||||||
PATH="${_PYENV_INSTALL_PREFIX}/libexec:$PATH"
|
PATH="${_PYENV_INSTALL_PREFIX}/libexec:$PATH"
|
||||||
if [[ -n $PLUGIN_PREFIX ]]; then
|
|
||||||
PATH="${PLUGIN_PREFIX}/libexec:${PLUGIN_PREFIX}/bin:$PATH"
|
|
||||||
fi
|
|
||||||
PATH="${BATS_TEST_DIRNAME}/libexec:$PATH"
|
PATH="${BATS_TEST_DIRNAME}/libexec:$PATH"
|
||||||
PATH="${PYENV_ROOT}/shims:$PATH"
|
PATH="${PYENV_ROOT}/shims:$PATH"
|
||||||
PATH="${BATS_TEST_TMPDIR}/stubs:$PATH"
|
PATH="${BATS_TEST_TMPDIR}/stubs:$PATH"
|
||||||
|
|
@ -49,7 +40,6 @@ setup() {
|
||||||
# even if its output is redirected, breaking the comparison logic
|
# even if its output is redirected, breaking the comparison logic
|
||||||
export NO_COLOR=1
|
export NO_COLOR=1
|
||||||
|
|
||||||
|
|
||||||
# If test specific setup exist, run it
|
# If test specific setup exist, run it
|
||||||
if [[ $(type -t _setup) == function ]];then
|
if [[ $(type -t _setup) == function ]];then
|
||||||
_setup
|
_setup
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue