Skip to content

Commit e0bce48

Browse files
authored
Merge pull request #705 from NLeSC/688-dev-as-group
2 parents d668871 + 737504a commit e0bce48

File tree

7 files changed

+19
-18
lines changed

7 files changed

+19
-18
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
### Added
66

7-
- Typing support. [#698](https://github.com/NLeSC/python-template/pull/698)
7+
* Typing support. [#698](https://github.com/NLeSC/python-template/pull/698)
88

99
### Changed
1010

1111
* Recommend `ruff format` instead of `yapf` for fixing code style readability [#695](https://github.com/NLeSC/python-template/pull/695)
12+
* Replace optional dependencies with dependency groups in template [#705](https://github.com/NLeSC/python-template/pull/705)
1213

1314
### Removed
1415

template/pyproject.toml.jinja

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ readme = {file = "README.md", content-type = "text/markdown"}
4141
requires-python = ">=3.10"
4242
version = "{{ version }}"
4343

44-
[project.optional-dependencies]
44+
[dependency-groups]
4545
dev = [
4646
"build", # build is not only used in publishing (below), but also in the template's test suite
4747
"bump-my-version",
@@ -104,16 +104,16 @@ command_line = "-m pytest"
104104
{%- endif %}
105105

106106
[tool.tox]
107-
legacy_tox_ini = """
108-
[tox]
109-
envlist = py310,py311,py312
107+
requires = ["tox>=4.22"]
108+
env_list = [ "py310", "py311", "py312" ]
110109
skip_missing_interpreters = true
111110
{% if AddLocalTests -%}
112-
[testenv]
113-
commands = pytest
114-
extras = dev
111+
[tool.box.testenv]
112+
description = "Run test under {base_python}"
113+
commands = [["pytest"]]
114+
[tool.tox.env_run_base]
115+
dependency_groups = [ "dev" ]
115116
{%- endif %}
116-
"""
117117

118118
[tool.ruff]
119119
line-length = 79

template/{% if AddDevDoc %}README.dev.md{% endif %}.jinja

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ python -m pip install --upgrade pip setuptools
1818
# install {{ package_name }} as an editable package
1919
python -m pip install --no-cache-dir --editable .
2020
# install development dependencies
21-
python -m pip install --no-cache-dir --editable .[dev]
21+
python -m pip install --no-cache-dir --editable . --group dev
2222
# install documentation dependencies only
23-
python -m pip install --no-cache-dir --editable .[docs]
23+
python -m pip install --no-cache-dir --editable . --group docs
2424
```
2525

2626
Afterwards check that the install directory is present in the `PATH` environment variable.

template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddGitHubActionBuild %}build.yml{% endif %}.jinja

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Upgrade pip and install dependencies
3333
run: |
3434
python -m pip install --upgrade pip setuptools
35-
python -m pip install .[dev,publishing]
35+
python -m pip install . --group dev --group publishing
3636
- name: Run unit tests
3737
run: python -m pytest -v
3838
- name: Verify that we can build the package
@@ -58,7 +58,7 @@ jobs:
5858
- name: Upgrade pip and install dependencies
5959
run: |
6060
python -m pip install --upgrade pip setuptools
61-
python -m pip install .[dev,publishing]
61+
python -m pip install . --group dev
6262
- name: Check style against standards using ruff
6363
run: |
6464
ruff check .
@@ -78,7 +78,7 @@ jobs:
7878
- name: Upgrade pip and install dependencies
7979
run: |
8080
python -m pip install --upgrade pip setuptools
81-
python -m pip install .[dev]
81+
python -m pip install . --group dev
8282
- name: Run {{ SelectTypeChecker }}
8383
run: |
8484
{{ SelectTypeChecker }}

template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddGitHubActionDocumentation %}documentation.yml{% endif %}

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- name: Upgrade pip and install dependencies
2929
run: |
3030
python -m pip install --upgrade pip setuptools
31-
python -m pip install .[dev,publishing]
31+
python -m pip install . --group dev --group docs
3232
- name: Install pandoc using apt
3333
run: sudo apt install pandoc
3434
- name: Build documentation

template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddSonarCloud %}sonarcloud.yml{% endif %}

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
which python
2929
python --version
3030
- name: Install dependencies
31-
run: python -m pip install .[dev]
31+
run: python -m pip install . --group dev
3232
- name: Run unit tests with coverage
3333
run: python -m pytest --cov --cov-report term --cov-report xml --junitxml=xunit-result.xml tests/
3434
- name: Correct coverage paths

tests/test_project.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def baked_with_development_dependencies(copie_session, project_env_bin_dir, copi
6464
bin_dir = project_env_bin_dir
6565
latest_pip_output = run([f'{bin_dir}python', '-m', 'pip', 'install', '--upgrade', 'pip', 'setuptools'], project_dir)
6666
assert latest_pip_output.returncode == 0
67-
pip_output = run([f'{bin_dir}python', '-m', 'pip', 'install', '--editable', '.[dev]'], project_dir)
67+
pip_output = run([f'{bin_dir}python', '-m', 'pip', 'install', '--editable', '.', '--group', 'dev'], project_dir)
6868
assert pip_output.returncode == 0
6969
return project_dir
7070

@@ -91,7 +91,7 @@ def test_tox(baked_with_development_dependencies, project_env_bin_dir):
9191
bin_dir = project_env_bin_dir
9292
result = run([f'{bin_dir}tox'], project_dir)
9393
assert result.returncode == 0
94-
assert '== 3 passed in' in result.stdout
94+
assert 'congratulations :)' in result.stdout
9595
# assert (project_dir / '.tox' / 'dist' / 'my_python_package-0.1.0.zip').exists()
9696
assert (project_dir / '.tox' / '.pkg' / 'dist'/ 'my_python_package-0.1.0.tar.gz').exists()
9797

0 commit comments

Comments
 (0)