Skip to content

Commit 271678a

Browse files
Fix tox.ini to read dependencies from pyproject.toml
1 parent 74ce71a commit 271678a

File tree

2 files changed

+40
-11
lines changed

2 files changed

+40
-11
lines changed

pyproject.toml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ docs = [
5353
"myst-nb>=1.0.0,<1.2",
5454
]
5555
notebooks = [
56-
"scikit-learn>=1.3.2,<1.6",
56+
"scikit-learn>=1.5.1,<1.6",
5757
"torch>=2.1.2,<2.6",
5858
"torchvision>=0.16.2,<0.21",
5959
"ipywidgets>=8.1.1,<8.2",
@@ -73,11 +73,9 @@ dev-mypy = [
7373
"types-toml>=0.10.0,<0.11",
7474
"types-tqdm>=4.66,<4.68",
7575
]
76-
dev-linters = [
77-
"frouros[dev-ruff, dev-mypy]",
78-
]
7976
dev = [
80-
"frouros[dev-tests, dev-linters]",
77+
"frouros[docs,notebooks,dev-tests,dev-ruff,dev-mypy]",
78+
"tox>=4.23.2,<4.24",
8179
]
8280

8381
[project.urls]

tox.ini

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
minversion = 4.16.0
2+
minversion = 4.23.2
33
envlist =
44
py3{9, 10, 11, 12}
55
linters
@@ -9,6 +9,12 @@ python = python3
99
skip_install = true
1010
package = frouros
1111
venv = {toxinidir}/.venv
12+
deps =
13+
# Package used as a workaround to install the dependencies read from pyproject.toml dev section.
14+
toml>=0.10.2,<0.11
15+
pyproject_reader =
16+
# Workaround to install the dependencies read from pyproject.toml dev section. Use toml to read the file and install the dependencies.
17+
python -c "import toml, subprocess; deps = toml.load('pyproject.toml')['project']['optional-dependencies']['{env:DEPS_SECTION}']; subprocess.run(['pip', 'install'] + deps)"
1218

1319
[gh-actions]
1420
python =
@@ -20,8 +26,13 @@ python =
2026
[testenv]
2127
# Force to upgrade pip/wheel/setuptools to the latest version
2228
download = True
23-
extras = dev-tests
24-
commands = pytest --cov={[base]package} \
29+
deps = {[base]deps}
30+
setenv =
31+
DEPS_SECTION = dev-tests
32+
commands_pre =
33+
{[base]pyproject_reader}
34+
commands =
35+
pytest --cov={[base]package} \
2536
--cov-report term \
2637
--cov-report=xml \
2738
--cov-fail-under=90
@@ -31,16 +42,36 @@ addopts = -ra -q
3142
norecursedirs = docs
3243

3344
[testenv:ruff]
34-
extras = dev-ruff
45+
basepython = {[base]python}
46+
skip_install = {[base]skip_install}
47+
deps = {[base]deps}
48+
setenv =
49+
DEPS_SECTION = dev-ruff
50+
commands_pre =
51+
{[base]pyproject_reader}
3552
commands = ruff check --config pyproject.toml .
3653
ruff format --config pyproject.toml .
3754

3855
[testenv:mypy]
39-
extras = dev-mypy
56+
basepython = {[base]python}
57+
skip_install = {[base]skip_install}
58+
deps = {[base]deps}
59+
setenv =
60+
DEPS_SECTION = dev-mypy
61+
commands_pre =
62+
{[base]pyproject_reader}
4063
commands = mypy --config-file pyproject.toml .
4164

4265
[testenv:linters]
43-
extras = dev-linters
66+
basepython = {[base]python}
67+
skip_install = {[base]skip_install}
68+
setenv =
69+
PYTHONPATH = $PYTHONPATH:{toxinidir}:{[base]venv}/lib/{[base]python}/site-packages
70+
deps =
71+
{[base]deps}
72+
commands_pre =
73+
{[testenv:ruff]commands_pre}
74+
{[testenv:mypy]commands_pre}
4475
commands =
4576
{[testenv:ruff]commands}
4677
{[testenv:mypy]commands}

0 commit comments

Comments
 (0)