120 lines
1.7 KiB
Bash
Executable file
120 lines
1.7 KiB
Bash
Executable file
#! /usr/bin/env sh
|
|
|
|
root="/prj/venv"
|
|
url="http://localhost:8000"
|
|
url_pypi="${url}/pypi/simple"
|
|
|
|
activate() {
|
|
echo
|
|
export VIRTUAL_ENV="${1}"
|
|
echo "→ ${VIRTUAL_ENV}"
|
|
export OLD_PATH="${PATH}"
|
|
export PATH="${VIRTUAL_ENV}/bin:${PATH}"
|
|
echo "→ ${PATH}"
|
|
python3 --version
|
|
pip --version
|
|
}
|
|
deactivate() {
|
|
echo
|
|
echo "← ${VIRTUAL_ENV}"
|
|
export PATH="${OLD_PATH}"
|
|
echo "← ${PATH}"
|
|
unset OLD_PATH VIRTUAL_ENV
|
|
}
|
|
list() {
|
|
echo
|
|
ls -a -l "${1}/bin"
|
|
}
|
|
pip_install() {
|
|
echo
|
|
pip install \
|
|
--index-url "${url_pypi}" \
|
|
--no-cache-dir \
|
|
"${@}"
|
|
}
|
|
remove() {
|
|
rm --force --recursive "${@}"
|
|
}
|
|
uv_install() {
|
|
set \
|
|
"pelican" \
|
|
\
|
|
"hatch" \
|
|
\
|
|
"Sphinx" \
|
|
"sphinx-rtd-theme" \
|
|
\
|
|
"gitlint" \
|
|
\
|
|
"pydoclint" \
|
|
"pylint" \
|
|
"ruff" \
|
|
\
|
|
"pytest" \
|
|
\
|
|
"toml" \
|
|
\
|
|
"twine" \
|
|
\
|
|
"mypy" \
|
|
"pyright" \
|
|
\
|
|
"ruamel.yaml" \
|
|
"PyYAML" \
|
|
"types-PyYAML"
|
|
echo
|
|
uv pip install --index-url "${url_pypi}" "${@}"
|
|
}
|
|
uv_python() {
|
|
echo
|
|
export UV_PYTHON_INSTALL_DIR="${1}/cpypy"
|
|
export UV_PYTHON_INSTALL_MIRROR="${url}/cpypy"
|
|
uv python install "${2}"
|
|
unset \
|
|
UV_PYTHON_INSTALL_DIR \
|
|
UV_PYTHON_INSTALL_MIRROR
|
|
}
|
|
uv_venv() {
|
|
echo
|
|
uv venv \
|
|
--allow-existing \
|
|
--index-url "${url_pypi}" \
|
|
--relocatable \
|
|
--seed \
|
|
"${1}"
|
|
}
|
|
|
|
os="${root}/os"
|
|
remove "${os}"
|
|
python3 -m "venv" "${os}"
|
|
activate "${os}"
|
|
list "${os}"
|
|
pip_install --upgrade "pip"
|
|
pip_install "uv"
|
|
list "${os}"
|
|
|
|
set \
|
|
"3.12"
|
|
|
|
for version in "${@}"; do
|
|
py="${root}/${version}"
|
|
remove "${py}"
|
|
uv_python "${py}" "${version}"
|
|
uv_venv "${py}"
|
|
done
|
|
|
|
deactivate
|
|
|
|
for version in "${@}"; do
|
|
activate "${py}"
|
|
list "${py}"
|
|
pip_install "uv"
|
|
list "${py}"
|
|
uv_install
|
|
for module in "rwx"; do
|
|
ln --symbolic \
|
|
"/rwx/rwx/${module}" \
|
|
"${py}/lib/python${version}/site-packages/${module}"
|
|
done
|
|
list "${py}"
|
|
done
|