diff --git a/docs/work.md b/docs/work.md index 7e45f9c..38fdbda 100644 --- a/docs/work.md +++ b/docs/work.md @@ -229,14 +229,25 @@ The first thing you should run when entering your repository is: make setup ``` +If you don't have the `make` command, +you can use `bash scripts/setup.sh` directly, +or even just `pdm install` +if you don't plan on using multiple Python versions. + This will install the project's dependencies in `__pypackages__`: one folder per chosen Python version. The chosen Python versions are defined in the Makefile. +If you would like to use *virtual environments (venvs)* instead, +set the PDM configuration item `python.use_venv` to true: -If you don't have the `make` command, -you can use `bash scripts/setup.sh` instead, -or even just `pdm install` -if you don't plan on using multiple Python versions. +```bash +pdm config --local python.use_venv +``` + +Remove the `--local` flag to enable using venvs for all your local projects. + +When venvs are enabled, the setup script will create named venvs (`name=3.xx`) +in your `venv.location` directory (PDM configuration). Now you can start writing and editing code in `src/your_package`. diff --git a/project/Makefile.jinja b/project/Makefile.jinja index b6ff2a0..caa02ef 100644 --- a/project/Makefile.jinja +++ b/project/Makefile.jinja @@ -2,6 +2,7 @@ SHELL := bash DUTY := $(if $(VIRTUAL_ENV),,pdm run) duty export PDM_MULTIRUN_VERSIONS ?= 3.8 3.9 3.10 3.11 3.12 +export PDM_MULTIRUN_USE_VENVS ?= $(if $(shell pdm config python.use_venv | grep True),1,0) args = $(foreach a,$($(subst -,_,$1)_args),$(if $(value $a),$a="$($a)")) check_quality_args = files diff --git a/project/scripts/setup.sh b/project/scripts/setup.sh index bbf0d11..eef3843 100755 --- a/project/scripts/setup.sh +++ b/project/scripts/setup.sh @@ -12,6 +12,13 @@ if ! pdm self list 2>/dev/null | grep -q pdm-multirun; then fi if [ -n "${PDM_MULTIRUN_VERSIONS}" ]; then + if [ "${PDM_MULTIRUN_USE_VENVS}" -eq "1" ]; then + for version in ${PDM_MULTIRUN_VERSIONS}; do + if ! pdm venv --path "${version}" &>/dev/null; then + pdm venv create --name "${version}" "${version}" + fi + done + fi pdm multirun -v pdm install -G:all else pdm install -G:all