Skip to content

Commit 7430dcd

Browse files
committed
Use dependency-groups in pyproject.toml for dev dependencies
1 parent ce45656 commit 7430dcd

File tree

10 files changed

+116
-43
lines changed

10 files changed

+116
-43
lines changed

CONTRIBUTING.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,28 @@ updating the code if necessary.
5959

6060
Setting up the development environment:
6161
* Install Python 3.10+
62-
* Install the requirements
62+
* Install the requirements (needs pip 25.1+)
6363
```bash
64-
$ python3 -m pip install -U pip
65-
$ python3 -m pip install -Ur requirements-dev.txt
64+
# recommended to use a virtual environment
65+
$ python3 -m venv .venv
66+
$ source .venv/bin/activate
67+
# make sure pip is up to date
68+
$ pip install -U pip
69+
# install all development dependencies and driver
70+
$ pip install -U --group dev -e .
6671
```
6772
* Install the pre-commit hook, that will do some code-format-checking everytime
6873
you commit.
6974
```bash
7075
$ pre-commit install
7176
```
77+
* If you need to commit, skipping the pre-commit hook, you can use the `--no-verify`
78+
option with `git commit`:
79+
```bash
80+
$ git commit --no-verify
81+
```
82+
However, the checks will still be run in CI on every pull request. So this can only be
83+
used for quick local commits. Make sure all check pass before opening a pull request.
7284

7385

7486
## Got an idea for a new project?

benchkit/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
FROM python:3.12
1+
FROM python:3.13
22

33
WORKDIR /driver
44

55
COPY . /driver
66

77
# Install dependencies
88
RUN pip install -U pip && \
9-
pip install -Ur requirements-dev.txt
9+
pip install --group benchkit && \
10+
pip install .
1011

1112
ENTRYPOINT ["python", "-m", "benchkit"]

pyproject.toml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,87 @@ requires = [
6565
]
6666
build-backend = "setuptools.build_meta"
6767

68+
[dependency-groups]
69+
# To install all development dependencies as well as the driver with all optional dependencies,
70+
# run `pip install --group dev`
71+
dev = [
72+
# dev tools
73+
{include-group = "dep-project-dependencies"},
74+
{include-group = "tox"},
75+
{include-group = "precommit"},
76+
{include-group = "unasync"},
77+
{include-group = "test"},
78+
{include-group = "typing"},
79+
{include-group = "docs"},
80+
{include-group = "testkit"},
81+
{include-group = "benchkit"},
82+
{include-group = "packaging"},
83+
{include-group = "release"},
84+
]
85+
# tool for runnig test matrix
86+
tox = ["tox >= 4.25.0"]
87+
# run pre-commit hooks (includes linting, formatting, type checking, ...)
88+
precommit = [
89+
"pre-commit >= 4.2.0",
90+
# runs unasync and type checker outside pre-commit's isolation
91+
{include-group = "unasync"},
92+
{include-group = "typing"},
93+
]
94+
# auto-generate sync driver from async code
95+
unasync = [
96+
"unasync == 0.5.0",
97+
"isort >= 6.0.1",
98+
]
99+
# dependencies for running tests
100+
test = [
101+
"coverage[toml] >= 7.8.0",
102+
{include-group = "dep-freezegun"},
103+
"mock >= 5.2.0",
104+
"pytest >= 8.3.5",
105+
"pytest-asyncio >= 0.26.0",
106+
"pytest-benchmark >= 5.1.0",
107+
"pytest-cov >= 6.1.1",
108+
"pytest-mock >= 3.14.0",
109+
]
110+
# type checker and type stubs for static type checking
111+
typing = [
112+
"mypy >= 1.15.0",
113+
"typing-extensions >= 4.13.2",
114+
"types-pytz >= 2025.2.0.20250326",
115+
{include-group = "dep-project-dependencies"},
116+
# tests are also type-checked
117+
{include-group = "test"},
118+
# testkit backend is also type-checked
119+
{include-group = "testkit"},
120+
# benchkit backend is also type-checked
121+
{include-group = "benchkit"},
122+
]
123+
# generate documentation
124+
docs = ["Sphinx >= 8.1.3"]
125+
# running the testkit backend
126+
testkit = [
127+
{include-group = "dep-freezegun"},
128+
]
129+
# running the benchkit backend for benchmarking
130+
benchkit = ["sanic >= 25.3.0"]
131+
# building and packaging the driver
132+
packaging = [
133+
"build >= 1.2.2",
134+
]
135+
# releasing the packaged driver to PyPI
136+
release = [
137+
"twine >= 6.1.0",
138+
]
139+
140+
# single dependencies and other include-groups (not really meant to be installed as a group, but to avoid duplication)
141+
dep-freezegun = ["freezegun >= 1.5.1"]
142+
dep-project-dependencies = [
143+
"pytz",
144+
"numpy >= 1.7.0, < 3.0.0",
145+
"pandas >= 1.1.0, < 3.0.0",
146+
"pyarrow >= 1.0.0",
147+
]
148+
68149
[tool.setuptools.dynamic]
69150
version = {attr = "neo4j._meta.version"}
70151

requirements-dev.txt

Lines changed: 0 additions & 32 deletions
This file was deleted.

requirements.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

testkit/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,5 @@ RUN pyenv global $(pyenv versions --bare --skip-aliases | sort --version-sort --
5454
# + tox and tools for starting the tests
5555
# https://pip.pypa.io/en/stable/news/
5656
RUN for version in $PYTHON_VERSIONS; do \
57-
python$version -m pip install -U pip && \
58-
python$version -m pip install -U coverage tox; \
57+
python$version -m pip install -U pip; \
5958
done

testkit/build.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121

2222
if __name__ == "__main__":
2323
run_python(
24-
["-m", "pip", "install", "-U", "pip", "build"],
24+
["-m", "pip", "install", "--group", "packaging"],
2525
warning_as_error=False,
2626
)
2727
run_python(["-m", "build", "."], warning_as_error=True)
2828
run_python(
29-
["-m", "pip", "install", "-Ur", "requirements-dev.txt"],
29+
["-m", "pip", "install", "--group", "testkit", "-e", "."],
3030
warning_as_error=False,
3131
)

testkit/integration.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@
1818

1919

2020
if __name__ == "__main__":
21+
run_python(
22+
["-m", "pip", "install", "--group", "tox"],
23+
warning_as_error=False,
24+
)
2125
run_python(["-m", "tox", "-vv", "-f", "integration"])

testkit/unittests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818

1919

2020
if __name__ == "__main__":
21+
run_python(
22+
["-m", "pip", "install", "--group", "tox"],
23+
warning_as_error=False,
24+
)
2125
run_python(
2226
[
2327
"-m",

tox.ini

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ envlist = py{310,311,312,313}-{unit,integration,performance}
33

44
[testenv]
55
passenv = TEST_*
6-
deps = -r requirements-dev.txt
6+
dependency_groups =
7+
test
8+
extras =
9+
numpy
10+
pandas
11+
pyarrow
712
setenv =
813
COVERAGE_FILE={envdir}/.coverage
914
TEST_SUITE_NAME={envname}

0 commit comments

Comments
 (0)