diff --git a/readme.md b/readme.md index 30b7aa9..1c9ea47 100644 --- a/readme.md +++ b/readme.md @@ -56,6 +56,7 @@ from various contexts of CA, CI and OCI / OS. | SPCD_URL_DEBIAN | Debian repository URL | https://deb.debian.org | | SPCD_URL_EPEL | EPEL repository URL | https://dl.fedoraproject.org | | SPCD_URL_FEDORA | Fedora repository URL | https://rpmfind.net | +| SPCD_URL_PYTHON | Python repository URL | https://pypi.org/project | | SPCD_URL_ROCKY | Rocky repository URL | https://dl.rockylinux.org | | SPCD_URL_UBUNTU | Ubuntu repository URL | https://ubuntu.mirrors.ovh.net | @@ -83,11 +84,6 @@ from various contexts of CA, CI and OCI / OS. * define templates * actions * includes -* handle python virtual environment - * install venv if necessary - * upgrade pip - * install packages - * ruff * relay environment module name * write tests diff --git a/spcd.sh b/spcd.sh index 6af63bf..bb9007f 100644 --- a/spcd.sh +++ b/spcd.sh @@ -7,6 +7,7 @@ [ -n "${SPCD_DNS_1}" ] || SPCD_DNS_1="9.9.9.9" [ -n "${SPCD_GIT_MAIN}" ] || SPCD_GIT_MAIN="spcd" [ -n "${SPCD_GIT_ROOT}" ] || SPCD_GIT_ROOT="rwx" +[ -n "${SPCD_URL_PYTHON}" ] || SPCD_URL_PYTHON="https://pypi.org/project" # main spcd_main() { @@ -690,6 +691,31 @@ spcd_install_packages() { "${SPCD_PM_PACMAN}") spcd_install_package "openssh" ;; *) ;; esac + # venv + spcd_step "Install Python virtual environment" + case "${SPCD_OS_ID}" in + "${SPCD_OS_DEBIAN}" | "${SPCD_OS_UBUNTU}") + spcd_install_package "python3-venv" + ;; + # FIXME arch + *) ;; + esac + spcd_split + spcd_write "/etc/pip.conf" "\ +[global] +index-url = ${SPCD_URL_PYTHON} +" + spcd_split + spcd_ip__venv="/opt/venv" + "${SPCD_PYTHON_ALIAS}" -m "venv" "${spcd_ip__venv}" + . "${spcd_ip__venv}/bin/activate" + spcd_split + pip install --upgrade "pip" + spcd_split + pip install \ + "pelican" \ + "ruff" \ + "sphinx" } spcd_install_python_modules() {