mirror of
https://github.com/apisnetworks/pyenv.git
synced 2026-11-30 19:59:01 +00:00
python-build: Add rustpython-dev (#3642)
This commit is contained in:
1 parent
f5bc93950b
commit
8eb39f5070
4 files changed
+65
-2
No files matched your search
@@ -113,6 +113,9 @@ jobs:
|
||||
echo "PYENV_BOOTSTRAP_VERSION=$PYENV_BOOTSTRAP_VERSION" >> $GITHUB_ENV
|
||||
pyenv install $PYENV_BOOTSTRAP_VERSION
|
||||
fi
|
||||
if [[ "${{ matrix.python-version }}" == rustpython-* ]]; then
|
||||
rustup update stable
|
||||
fi
|
||||
- run: |
|
||||
#build
|
||||
pyenv --debug install ${{ matrix.python-version }} && rc=$? || rc=$?
|
||||
@@ -228,6 +231,9 @@ jobs:
|
||||
echo "PYENV_BOOTSTRAP_VERSION=$PYENV_BOOTSTRAP_VERSION" >> $GITHUB_ENV
|
||||
pyenv install $PYENV_BOOTSTRAP_VERSION
|
||||
fi
|
||||
if [[ "${{ matrix.python-version }}" == rustpython-* ]]; then
|
||||
rustup update stable
|
||||
fi
|
||||
- run: |
|
||||
#build
|
||||
pyenv --debug install ${{ matrix.python-version }} && rc=$? || rc=$?
|
||||
|
||||
@@ -1150,6 +1150,12 @@ build_package_pyston() {
|
||||
make_python_symlinks pyston
|
||||
}
|
||||
|
||||
# Print the `X.Y' version of the given interpreter.
|
||||
interpreter_version_suffix() {
|
||||
# Use syntax accepted in both Py2 and Py3. Even though current Py2 holdouts (e.g. PyPy) support e.g. print()
|
||||
"${1:?}" -c 'import sys; sys.stdout.write("%d.%d\n" % sys.version_info[:2])'
|
||||
}
|
||||
|
||||
# Add missing `python', `pythonX' and `pythonX.Y' symlinks as per PEP 394.
|
||||
make_python_symlinks() {
|
||||
local seeder_basename version_suffix real_interpreter
|
||||
@@ -1159,8 +1165,7 @@ make_python_symlinks() {
|
||||
|
||||
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()
|
||||
version_suffix=$("${PREFIX_PATH}/bin/$seeder_basename" -c 'import sys; sys.stdout.write("%d.%d\n" % sys.version_info[:2])')
|
||||
version_suffix=$(interpreter_version_suffix "${PREFIX_PATH}/bin/$seeder_basename")
|
||||
for interpreter_name in "${interpreter_names[@]}"; do
|
||||
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"
|
||||
@@ -1203,6 +1208,21 @@ build_package_micropython() {
|
||||
}>&4 2>&1
|
||||
}
|
||||
|
||||
build_package_rustpython() {
|
||||
local version_suffix
|
||||
# `--target-dir target` keeps the binary at a known path even if CARGO_TARGET_DIR is set
|
||||
{ cargo build --release --locked --target-dir target
|
||||
mkdir -p "${PREFIX_PATH}/bin"
|
||||
cp target/release/rustpython "${PREFIX_PATH}/bin/rustpython"
|
||||
# RustPython finds its stdlib through a CPython-style landmark search
|
||||
# for `lib/pythonX.Y/os.py` under the prefix
|
||||
version_suffix=$(interpreter_version_suffix target/release/rustpython)
|
||||
mkdir -p "${PREFIX_PATH}/lib/python${version_suffix}"
|
||||
cp -R Lib/. "${PREFIX_PATH}/lib/python${version_suffix}"
|
||||
} >&4 2>&1
|
||||
make_python_symlinks rustpython
|
||||
}
|
||||
|
||||
pypy_architecture() {
|
||||
case "${_PYTHON_BUILD_CACHE_UNAME_S:=$(uname -s)}" in
|
||||
"Darwin" )
|
||||
@@ -1598,6 +1618,19 @@ require_java() {
|
||||
export JAVA="$java"
|
||||
}
|
||||
|
||||
require_cargo() {
|
||||
if ! command -v cargo 1>/dev/null 2>&1; then
|
||||
{ echo
|
||||
colorize 1 "ERROR"
|
||||
echo ": This package must be built with Cargo, but python-build couldn't"
|
||||
echo "find a \`cargo\` executable on your system. Please install Rust"
|
||||
echo "(e.g. via https://rustup.rs) and try again."
|
||||
echo
|
||||
} >&3
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Let Jython installer to generate shell script instead of python script even if there's `python2.7` available in `$PATH` (#800)
|
||||
# FIXME: better function naming
|
||||
unrequire_python27() {
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
require_cargo
|
||||
install_git "rustpython-dev" "https://github.com/RustPython/RustPython" "main" rustpython ensurepip
|
||||
@@ -283,6 +283,28 @@ OUT
|
||||
done
|
||||
}
|
||||
|
||||
@test "rustpython: install stdlib and create python* symlinks" {
|
||||
mkdir -p "${BATS_TEST_TMPDIR}/rustpython/target/release" "${BATS_TEST_TMPDIR}/rustpython/Lib"
|
||||
cd "${BATS_TEST_TMPDIR}/rustpython"
|
||||
executable target/release/rustpython <<OUT
|
||||
#!$BASH
|
||||
echo 3.15
|
||||
OUT
|
||||
touch Lib/os.py
|
||||
stub cargo "build --release --locked --target-dir target : true"
|
||||
|
||||
TMPDIR="$BATS_TEST_TMPDIR" run_inline_definition <<OUT
|
||||
build_package_rustpython
|
||||
OUT
|
||||
assert_success
|
||||
unstub cargo
|
||||
|
||||
[ -f "${INSTALL_ROOT}/lib/python3.15/os.py" ]
|
||||
for name in python python3 python3.15; do
|
||||
assert_equal "$(resolve_link "${INSTALL_ROOT}/bin/$name")" "rustpython"
|
||||
done
|
||||
}
|
||||
|
||||
@test "enable framework" {
|
||||
framework_path="${INSTALL_ROOT}/Library/Frameworks/Python.framework/Versions/Current/bin"
|
||||
mkdir -p "$framework_path"
|
||||
|
||||
Reference in new issue
Block a user