Skip to content

Commit

Permalink
refactor: Update for PDM 1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed May 6, 2021
1 parent 00d193a commit 100d7ac
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 22 deletions.
20 changes: 8 additions & 12 deletions docs/work.md
Expand Up @@ -29,8 +29,8 @@ The generated project has this structure:
├── 📄 pyproject.toml ------------- # project metadata and dependencies
├── 📄 README.md ------------------ #
├── 📁 scripts -------------------- # helper scripts
│   ├── 📄 multirun.sh ------------ # to run a command in multiple virtualenvs
│   └── 📄 setup.sh --------------- # to install dependencies in multiple virtualenvs
│   ├── 📄 multirun.sh ------------ # to run a command against multiple Python versions
│   └── 📄 setup.sh --------------- # to install dependencies for multiple Python versions
├── 📁 src ------------------------ # the source code directory
│   └── 📁 your_package ----------- # your package
│   ├── 📄 cli.py ------------- # the command line entry point
Expand All @@ -44,13 +44,9 @@ The generated project has this structure:

## Dependencies and virtual environments

Dependencies and virtual environments are managed by [PDM](https://github.com/pdm-project/pdm).
Dependencies are managed by [PDM](https://github.com/pdm-project/pdm).

You don't have to -and you should not- create the virtualenvs yourself,
or activate/deactivate them.

Use `pdm install -d` to create the virtualenv the first time and install the dependencies.
Re-run `pdm install` to re-install the dependencies into the virtualenv.
Use `pdm install` to install the dependencies.

Dependencies are written in `pyproject.toml`,
under the `[project]`, `[project.optional-dependencies]`
Expand Down Expand Up @@ -82,7 +78,7 @@ pdm remove -ds stats numpy

- Use `pdm update` the re-lock the dependencies
(write the complete dependency resolution in `pdm.lock`)
and install their updated version in the virtualenv.
and install their updated version.
- Use `pdm lock` to just re-lock the dependencies.
- Use `pdm run CMD [ARGS...]` to run a command installed in `__pypackages__`
- Use `pdm list` to show the list of dependencies.
Expand Down Expand Up @@ -172,8 +168,8 @@ The first thing you should run when entering your repository is:
make setup
```

This will install the project's dependencies in new Python virtualenvs:
one virtualenv per chosen Python version.
This will install the project's dependencies in `__pypackages__`:
one folder per chosen Python version.
The chosen Python versions are defined
in both scripts `setup.sh` and `multirun.sh`
in the `scripts/` folder.
Expand All @@ -182,7 +178,7 @@ or temporarily with the `PYTHON_VERSIONS` environment variable.

If you don't have the `make` command,
you can use `bash scripts/setup.sh` instead,
or even just `pdm install -d`
or even just `pdm install`
if you don't plan on using multiple Python versions.

Now you can start writing and editing code in `src/your_package`.
Expand Down
10 changes: 5 additions & 5 deletions project/.github/workflows/ci.yml
Expand Up @@ -51,23 +51,23 @@ jobs:

- name: Check if the documentation builds correctly
run: |
pdm install -ds duty -s docs
pdm install -s duty -s docs
pdm run duty check-docs
- name: Check the code quality
run: |
pdm install -ds duty -s quality --no-default
pdm install -s duty -s quality --no-default
pdm run duty check-code-quality
- name: Check if the code is correctly typed
run: |
pdm install -ds duty -s typing --no-default
pdm install -s duty -s typing --no-default
pdm run duty check-types
- name: Check for vulnerabilities in dependencies
run: |
pip install safety
pdm install -ds duty --no-default
pdm install -s duty --no-default
pdm run duty check-dependencies
tests:
Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:
- name: Install dependencies
run: |
pdm use -f ${{ matrix.python-version }}
pdm install -ds duty -s tests
pdm install -s duty -s tests
- name: Run the test suite
run: pdm run duty test
2 changes: 1 addition & 1 deletion project/.gitlab-ci.yml
Expand Up @@ -15,7 +15,7 @@ stages:
before_script:
- pip install pdm
- pdm --version
- pdm install -d
- pdm install

# Quality jobs

Expand Down
2 changes: 1 addition & 1 deletion project/CONTRIBUTING.md.jinja
Expand Up @@ -28,7 +28,7 @@ make setup
```

Now you can try running `make setup` again,
or simply `pdm install -d`.
or simply `pdm install`.

You now have the dependencies installed.

Expand Down
6 changes: 3 additions & 3 deletions project/scripts/setup.sh
Expand Up @@ -12,17 +12,17 @@ install_with_pipx() {
fi
}

install_with_pipx pdm==1.5.0b1
install_with_pipx pdm

if [ -n "${PYTHON_VERSIONS}" ]; then
for python_version in ${PYTHON_VERSIONS}; do
if pdm use -f "${python_version}" &>/dev/null; then
echo "> Using Python ${python_version} environment"
pdm install -d
pdm install
else
echo "> pdm use -f ${python_version}: Python version not available?" >&2
fi
done
else
pdm install -d
pdm install
fi

0 comments on commit 100d7ac

Please sign in to comment.