mirror of
https://github.com/pyenv/pyenv.git
synced 2026-10-02 23:41:06 +09:00
python-build: create pypy* symlinks for PyPy (#3562)
Source and some older versions builds do not create them
This commit is contained in:
parent
a3c666e177
commit
df5372511c
@ -1002,18 +1002,24 @@ build_package_pyston() {
|
|||||||
build_package_copy
|
build_package_copy
|
||||||
# Pyston tarballs provide an executable with a version-specific naming scheme
|
# Pyston tarballs provide an executable with a version-specific naming scheme
|
||||||
# and `pyston` and `pyston3` symlinks to it.
|
# and `pyston` and `pyston3` symlinks to it.
|
||||||
build_package_make_python_symlinks pyston
|
make_python_symlinks pyston
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add missing `python', `pythonX' and `pythonX.Y' symlinks as per PEP 394.
|
# Add missing `python', `pythonX' and `pythonX.Y' symlinks as per PEP 394.
|
||||||
build_package_make_python_symlinks() {
|
make_python_symlinks() {
|
||||||
seeder="${1:?}"
|
local seeder_basename version_suffix real_interpreter
|
||||||
local real_interpreter version_suffix
|
local -a interpreter_names
|
||||||
real_interpreter=$(resolve_link "${PREFIX_PATH}/bin/$seeder" || echo $seeder)
|
seeder_basename="${1:?}"; shift
|
||||||
|
(($#)) && interpreter_names=("$@") || interpreter_names=(python)
|
||||||
|
|
||||||
|
local real_interpreter
|
||||||
|
real_interpreter=$(resolve_link "${PREFIX_PATH}/bin/$seeder_basename" || echo $seeder_basename)
|
||||||
# Use syntax accepted in both Py2 and Py3. Even though current Py2 holdouts (e.g. PyPy) support e.g. print()
|
# Use syntax accepted in both Py2 and Py3. Even though current Py2 holdouts (e.g. PyPy) support e.g. print()
|
||||||
version_suffix=$("${PREFIX_PATH}/bin/$seeder" -c 'import sys; sys.stdout.write("%d.%d\n" % sys.version_info[:2])' 2>&4)
|
version_suffix=$("${PREFIX_PATH}/bin/$seeder_basename" -c 'import sys; sys.stdout.write("%d.%d\n" % sys.version_info[:2])')
|
||||||
for name in python "python${version_suffix%.*}" "python${version_suffix}"; do
|
for interpreter_name in "${interpreter_names[@]}"; do
|
||||||
[[ -e "${PREFIX_PATH}/bin/$name" ]] || ln -fs "${real_interpreter}" "${PREFIX_PATH}/bin/$name"
|
for name in "$interpreter_name" "$interpreter_name${version_suffix%.*}" "$interpreter_name${version_suffix}"; do
|
||||||
|
[[ -e "${PREFIX_PATH}/bin/$name" ]] || ln -fs "${real_interpreter}" "${PREFIX_PATH}/bin/$name"
|
||||||
|
done
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1122,8 +1128,21 @@ build_package_pypy() {
|
|||||||
ln -fs "../bin/${bin##*/}" "${PREFIX_PATH}/lib/${bin##*/}"
|
ln -fs "../bin/${bin##*/}" "${PREFIX_PATH}/lib/${bin##*/}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# PyPy source builds may create only a pypy* executable with a version-sepecific name
|
||||||
|
local seeder= seeder_candidate
|
||||||
|
for seeder_candidate in "${PREFIX_PATH}/bin/"pypy*; do
|
||||||
|
if [[ -f $seeder_candidate && -x $seeder_candidate ]]; then
|
||||||
|
seeder="${seeder_candidate##*/}"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
shopt -u nullglob
|
shopt -u nullglob
|
||||||
build_package_make_python_symlinks "pypy"
|
[[ -n $seeder ]] || {
|
||||||
|
echo "python-build: Cannot find a valid PyPy executable in \`${PREFIX_PATH}/bin'" >&4
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
make_python_symlinks "$seeder" pypy python
|
||||||
}
|
}
|
||||||
|
|
||||||
build_package_pypy_builder() {
|
build_package_pypy_builder() {
|
||||||
|
|||||||
@ -264,14 +264,13 @@ OUT
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "pypy: create python* symlinks" {
|
@test "pypy: create pypy* and python* symlinks" {
|
||||||
mkdir -p "${BATS_TEST_TMPDIR}/pypy/bin"
|
mkdir -p "${BATS_TEST_TMPDIR}/pypy/bin"
|
||||||
cd "${BATS_TEST_TMPDIR}/pypy"
|
cd "${BATS_TEST_TMPDIR}/pypy"
|
||||||
executable bin/real_interpreter_name <<OUT
|
executable bin/pypywhatever <<OUT
|
||||||
#!$BASH
|
#!$BASH
|
||||||
echo 3.11
|
echo 3.11
|
||||||
OUT
|
OUT
|
||||||
ln -s real_interpreter_name bin/pypy
|
|
||||||
|
|
||||||
TMPDIR="$BATS_TEST_TMPDIR" run_inline_definition <<OUT
|
TMPDIR="$BATS_TEST_TMPDIR" run_inline_definition <<OUT
|
||||||
build_package_pypy
|
build_package_pypy
|
||||||
@ -279,8 +278,8 @@ build_package_verify_py311
|
|||||||
OUT
|
OUT
|
||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
for name in python python3 python3.11; do
|
for name in pypy pypy3 pypy3.11 python python3 python3.11; do
|
||||||
assert_equal "$(resolve_link "${INSTALL_ROOT}/bin/$name")" "real_interpreter_name"
|
assert_equal "$(resolve_link "${INSTALL_ROOT}/bin/$name")" "pypywhatever"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user