Skip to content

Commit 96776d3

Browse files
authored
Merge pull request #1201 from robsdedude/dependency-groups
Use dependency-groups in pyproject.toml for dev dependencies
2 parents bd3afc6 + 58d76ca commit 96776d3

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
@@ -68,6 +68,87 @@ requires = [
6868
]
6969
build-backend = "setuptools.build_meta"
7070

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

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)