mirror of
https://github.com/pyenv/pyenv.git
synced 2026-10-02 23:41:06 +09:00
python-build: create PEP 394 symlinks for PyPy (#3559)
This commit is contained in:
parent
beb4f2ffd2
commit
26370b7f24
@ -1000,15 +1000,20 @@ build_package_jython_builder() {
|
||||
|
||||
build_package_pyston() {
|
||||
build_package_copy
|
||||
|
||||
# Pyston tarballs provide an executable with a version-specific naming scheme
|
||||
# and `pyston` and `pyston3` symlinks to it.
|
||||
# Add the `python', `pythonX' and `pythonX.Y' symlinks as per PEP 394.
|
||||
build_package_make_python_symlinks pyston
|
||||
}
|
||||
|
||||
# Add missing `python', `pythonX' and `pythonX.Y' symlinks as per PEP 394.
|
||||
build_package_make_python_symlinks() {
|
||||
seeder="${1:?}"
|
||||
local real_interpreter version_suffix
|
||||
real_interpreter=$(resolve_link "${PREFIX_PATH}/bin/pyston" || echo pyston)
|
||||
version_suffix=$("${PREFIX_PATH}/bin/pyston" -c 'import sys; print("%d.%d" % sys.version_info[:2])' 2>&4)
|
||||
real_interpreter=$(resolve_link "${PREFIX_PATH}/bin/$seeder" || echo $seeder)
|
||||
# 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)
|
||||
for name in python "python${version_suffix%.*}" "python${version_suffix}"; do
|
||||
ln -fs "${real_interpreter}" "${PREFIX_PATH}/bin/$name"
|
||||
[[ -e "${PREFIX_PATH}/bin/$name" ]] || ln -fs "${real_interpreter}" "${PREFIX_PATH}/bin/$name"
|
||||
done
|
||||
}
|
||||
|
||||
@ -1110,22 +1115,15 @@ build_package_graalpython() {
|
||||
|
||||
build_package_pypy() {
|
||||
build_package_copy
|
||||
mkdir -p "${PREFIX_PATH}/bin" "${PREFIX_PATH}/lib"
|
||||
local bin
|
||||
shopt -s nullglob
|
||||
for bin in "bin/"*; do
|
||||
if [ -f "${bin}" ] && [ -x "${bin}" ] && [ ! -L "${bin}" ]; then
|
||||
case "${bin##*/}" in
|
||||
"libpypy"* )
|
||||
( cd "${PREFIX_PATH}/lib" && ln -fs "../bin/${bin##*/}" "${bin##*/}" )
|
||||
;;
|
||||
"pypy"* )
|
||||
( cd "${PREFIX_PATH}/bin" && ln -fs "${bin##*/}" "python" )
|
||||
;;
|
||||
esac
|
||||
for bin in "bin/libpypy"*; do
|
||||
if [[ -f "${bin}" && -x "${bin}" && ! -L "${bin}" ]]; then
|
||||
ln -fs "../bin/${bin##*/}" "${PREFIX_PATH}/lib/${bin##*/}"
|
||||
fi
|
||||
done
|
||||
shopt -u nullglob
|
||||
build_package_make_python_symlinks "pypy"
|
||||
}
|
||||
|
||||
build_package_pypy_builder() {
|
||||
|
||||
@ -264,6 +264,26 @@ OUT
|
||||
done
|
||||
}
|
||||
|
||||
@test "pypy: create python* symlinks" {
|
||||
mkdir -p "${BATS_TEST_TMPDIR}/pypy/bin"
|
||||
cd "${BATS_TEST_TMPDIR}/pypy"
|
||||
executable bin/real_interpreter_name <<OUT
|
||||
#!$BASH
|
||||
echo 3.11
|
||||
OUT
|
||||
ln -s real_interpreter_name bin/pypy
|
||||
|
||||
TMPDIR="$BATS_TEST_TMPDIR" run_inline_definition <<OUT
|
||||
build_package_pypy
|
||||
build_package_verify_py311
|
||||
OUT
|
||||
assert_success
|
||||
|
||||
for name in python python3 python3.11; do
|
||||
assert_equal "$(resolve_link "${INSTALL_ROOT}/bin/$name")" "real_interpreter_name"
|
||||
done
|
||||
}
|
||||
|
||||
@test "enable framework" {
|
||||
framework_path="${INSTALL_ROOT}/Library/Frameworks/Python.framework/Versions/Current/bin"
|
||||
mkdir -p "$framework_path"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user