Skip to content

Commit

Permalink
feature/mx-1573 switch to pdm (#11)
Browse files Browse the repository at this point in the history
# Changes
- switch to pdm
  • Loading branch information
cutoffthetop authored Mar 19, 2024
1 parent 373c139 commit eb32887
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 48 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changes

- improve prompt for project name
- prepare switch from poetry to pdm
- switch from poetry to pdm

### Deprecated

Expand Down
3 changes: 1 addition & 2 deletions mex-{{ cookiecutter.project_name }}/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ dmypy.json
.pydocstyle
Makefile
mex.bat
pdm.lock
poetry.lock
*.lock
poetry.toml
pytest.ini
requirements.txt
10 changes: 5 additions & 5 deletions mex-{{ cookiecutter.project_name }}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ repos:
name: whitespaces
- id: fix-byte-order-marker
name: byte-order
- repo: https://github.com/python-poetry/poetry
rev: 1.8.2
- repo: https://github.com/pdm-project/pdm
rev: 2.12.4
hooks:
- id: poetry-check
name: poetry
- id: pdm-lock-check
name: pdm
- repo: local
hooks:
- id: mypy
name: mypy
entry: poetry run dmypy run --timeout 7200 -- mex
entry: pdm run dmypy run --timeout 7200 -- mex
files: ^mex/
language: system
pass_filenames: false
Expand Down
10 changes: 5 additions & 5 deletions mex-{{ cookiecutter.project_name }}/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ hooks:
install: setup hooks
# install packages from lock file in local virtual environment
@ echo installing package; \
poetry install --no-interaction --sync; \
pdm sync --clean --group dev; \

linter:
# run the linter hooks from pre-commit on all files
Expand All @@ -28,12 +28,12 @@ linter:
pytest:
# run the pytest test suite with all unit tests
@ echo running unit tests; \
poetry run pytest -m "not integration"; \
pdm run pytest -m "not integration"; \

wheel:
# build the python package
@ echo building wheel; \
poetry build --no-interaction --format wheel; \
pdm build --no-sdist; \

container:
# build the docker image
Expand Down Expand Up @@ -61,5 +61,5 @@ start: container
docs:
# use sphinx to auto-generate html docs from code
@ echo generating api docs; \
poetry run sphinx-apidoc -f -o docs/source mex; \
poetry run sphinx-build -aE -b dirhtml docs docs/dist; \
pdm run sphinx-apidoc -f -o docs/source mex; \
pdm run sphinx-build -aE -b dirhtml docs docs/dist; \
11 changes: 5 additions & 6 deletions mex-{{ cookiecutter.project_name }}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,15 @@ components of the MEx project are open-sourced under the same license as well.
- on windows run `.\mex.bat test`
- or run manually
- linter checks via `pre-commit run --all-files`
- all tests via `poetry run pytest`
- just unit tests via `poetry run pytest -m "not integration"`
- all tests via `pdm run pytest`
- just unit tests via `pdm run pytest -m "not integration"`

### updating dependencies

- update boilerplate files with `cruft update`
- update global requirements in `requirements.txt` manually
- update git hooks with `pre-commit autoupdate`
- show outdated dependencies with `poetry show --outdated`
- update dependencies in poetry using `poetry update --lock`
- update package dependencies using `pdm autoupdate`
- update github actions in `.github/workflows/*.yml` manually

### creating release
Expand All @@ -91,8 +90,8 @@ components of the MEx project are open-sourced under the same license as well.

## commands

- run `poetry run {command} --help` to print instructions
- run `poetry run {command} --debug` for interactive debugging
- run `pdm run {command} --help` to print instructions
- run `pdm run {command} --debug` for interactive debugging

### {{ cookiecutter.project_name }}

Expand Down
8 changes: 4 additions & 4 deletions mex-{{ cookiecutter.project_name }}/mex.bat
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if "%CI%"=="" (

@REM install packages from lock file in local virtual environment
echo installing package
poetry install --no-interaction --sync
pdm sync --clean --group dev
exit /b %errorlevel%


Expand All @@ -34,14 +34,14 @@ if %errorlevel% neq 0 exit /b %errorlevel%

@REM run the pytest test suite with unit and integration tests
echo running all tests
poetry run pytest
pdm run pytest
exit /b %errorlevel%


:docs
@REM use sphinx to auto-generate html docs from code
echo generating api docs
poetry run sphinx-apidoc -f -o docs\source mex
pdm run sphinx-apidoc -f -o docs\source mex
if %errorlevel% neq 0 exit /b %errorlevel%
poetry run sphinx-build -aE -b dirhtml docs docs\dist
pdm run sphinx-build -aE -b dirhtml docs docs\dist
exit /b %errorlevel%
2 changes: 0 additions & 2 deletions mex-{{ cookiecutter.project_name }}/poetry.toml

This file was deleted.

50 changes: 28 additions & 22 deletions mex-{{ cookiecutter.project_name }}/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
[tool.poetry]
[project]
name = "mex-{{ cookiecutter.project_name }}"
version = "0.1.0"
description = "{{ cookiecutter.short_summary }}"
authors = ["RKI MEx Team <[email protected]>"]
readme = "README.md"
license = "MIT"
repository = "https://github.com/robert-koch-institut/mex-{{ cookiecutter.project_name }}"
packages = [{ include = "mex" }]

[tool.poetry.dependencies]
python = "^3.11"

[tool.poetry.group.dev.dependencies]
black = "^24.2.0"
ipdb = "^0.13.13"
mypy = "^1.9.0"
pytest = "^8.1.1"
pytest-cov = "^4.1.0"
pytest-random-order = "^1.1.1"
ruff = "^0.3.2"
sphinx = "^7.2.6"
authors = [{ name = "MEx Team", email = "[email protected]" }]
readme = { file = "README.md", content-type = "text/markdown" }
license = { file = "LICENSE" }
urls = { Repository = "https://github.com/robert-koch-institut/mex-{{ cookiecutter.project_name }}" }
requires-python = ">=3.11"
dependencies = []
optional-dependencies.dev = [
"black>=24.2.0",
"ipdb>=0.13.13",
"mypy>=1.9.0",
"pytest>=8.1.1",
"pytest-cov>=4.1.0",
"pytest-random-order>=1.1.1",
"ruff>=0.3.2",
"sphinx>=7.2.6",
]

[tool.poetry.scripts]
[project.scripts]
{{ cookiecutter.project_name }} = "mex.{{ cookiecutter.project_name }}.main:main"

[tool.cruft]
Expand All @@ -37,6 +35,14 @@ show_error_codes = true
strict = true
plugins = ["pydantic.mypy"]

[tool.pdm]
distribution = true

[tool.pdm.scripts]
autoupdate = { cmd = "pdm update --group :all --update-eager --save-minimum" }
lint = { cmd = "pre-commit run --all-files" }
test = { cmd = "pdm run pytest --numprocesses=auto --dist=worksteal" }

[tool.pydantic-mypy]
warn_untyped_fields = true

Expand Down Expand Up @@ -109,5 +115,5 @@ known-first-party = ["mex", "tests"]
convention = "google"

[build-system]
requires = ["poetry-core>=1.9.0"]
build-backend = "poetry.core.masonry.api"
requires = ["pdm-backend>=2.1.8"]
build-backend = "pdm.backend"
2 changes: 1 addition & 1 deletion mex-{{ cookiecutter.project_name }}/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cruft==2.15.0
poetry==1.8.2
pdm==2.12.4
pre-commit==3.6.2
wheel==0.43.0

0 comments on commit eb32887

Please sign in to comment.