venv/re.sh

112 lines
1.5 KiB
Bash
Raw Normal View History

2024-09-26 19:27:56 +00:00
#! /usr/bin/env sh
root="/prj"
url="http://localhost:8000"
url_pypi="${url}/pypi/simple"
activate() {
2024-09-28 20:49:09 +00:00
echo
export VIRTUAL_ENV="${1}"
echo "${VIRTUAL_ENV}"
export OLD_PATH="${PATH}"
export PATH="${VIRTUAL_ENV}/bin:${PATH}"
echo "${PATH}"
python3 --version
pip --version
2024-09-26 19:27:56 +00:00
}
deactivate() {
2024-09-28 20:49:09 +00:00
echo
echo "${VIRTUAL_ENV}"
export PATH="${OLD_PATH}"
echo "${PATH}"
unset OLD_PATH VIRTUAL_ENV
2024-09-26 19:27:56 +00:00
}
list() {
2024-09-28 20:49:09 +00:00
echo
ls -a -l "${1}/bin"
2024-09-26 19:27:56 +00:00
}
pip_install() {
2024-09-28 20:49:09 +00:00
echo
pip install --index-url "${url_pypi}" "${@}"
2024-09-26 19:27:56 +00:00
}
remove() {
2024-09-28 20:49:09 +00:00
rm --force --recursive "${@}"
2024-09-26 19:27:56 +00:00
}
uv_install() {
2024-09-28 20:49:09 +00:00
echo
uv pip install --index-url "${url_pypi}" "${@}"
2024-09-26 19:27:56 +00:00
}
uv_python() {
2024-09-28 20:49:09 +00:00
echo
export UV_PYTHON_INSTALL_MIRROR="${url}/cpypy"
uv python install
#--cache-dir "${1}/cpypy"
unset UV_PYTHON_INSTALL_MIRROR
2024-09-26 19:27:56 +00:00
}
uv_venv() {
2024-09-28 20:49:09 +00:00
echo
uv venv --index-url "${url_pypi}" --seed "${1}"
#--cache-dir "${1}/cpypy"
2024-09-26 19:27:56 +00:00
}
remove ~/.cache/pip ~/.local/share/uv
2024-09-28 21:47:31 +00:00
os="${root}/venv.os"
2024-09-28 21:52:50 +00:00
py="${root}/venv"
2024-09-26 19:27:56 +00:00
2024-09-28 21:52:50 +00:00
remove "${os}" "${py}"
2024-09-26 19:27:56 +00:00
2024-09-28 21:47:31 +00:00
python3 -m "venv" "${os}"
activate "${os}"
list "${os}"
2024-09-26 19:27:56 +00:00
pip_install --upgrade "pip"
pip_install "uv"
2024-09-28 21:47:31 +00:00
list "${os}"
2024-09-26 19:27:56 +00:00
2024-09-28 21:52:50 +00:00
uv_python "${py}"
uv_venv "${py}"
2024-09-26 19:27:56 +00:00
deactivate
2024-09-28 21:47:31 +00:00
# remove "${os}"
2024-09-28 21:52:50 +00:00
activate "${py}"
2024-09-26 19:27:56 +00:00
2024-09-28 21:52:50 +00:00
list "${py}"
2024-09-26 19:27:56 +00:00
pip_install "uv"
2024-09-28 21:52:50 +00:00
list "${py}"
2024-09-26 19:27:56 +00:00
set \
2024-09-28 20:47:29 +00:00
\
"pelican" \
\
"hatch" \
\
"Sphinx" \
"sphinx-rtd-theme" \
\
"gitlint" \
2024-09-28 21:01:05 +00:00
\
2024-09-28 20:47:29 +00:00
"pydoclint" \
"pylint" \
"ruff" \
\
"pytest" \
\
"toml" \
\
"twine" \
\
"mypy" \
"pyright" \
\
"ruamel.yaml" \
"PyYAML" \
"types-PyYAML"
2024-09-26 19:27:56 +00:00
uv_install "${@}"
2024-09-28 21:52:50 +00:00
ln --symbolic "/rwx/rwx/rwx" "${py}/lib/python"*"/site-packages/rwx"
2024-09-28 21:40:14 +00:00
2024-09-28 21:52:50 +00:00
list "${py}"