Skip to content

Use dependency-groups in pyproject.toml for dev dependencies #1201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,28 @@ updating the code if necessary.

Setting up the development environment:
* Install Python 3.10+
* Install the requirements
* Install the requirements (needs pip 25.1+)
```bash
$ python3 -m pip install -U pip
$ python3 -m pip install -Ur requirements-dev.txt
# recommended to use a virtual environment
$ python3 -m venv .venv
$ source .venv/bin/activate
# make sure pip is up to date
$ pip install -U pip
# install all development dependencies and driver
$ pip install -U --group dev -e .
```
* Install the pre-commit hook, that will do some code-format-checking everytime
you commit.
```bash
$ pre-commit install
```
* If you need to commit, skipping the pre-commit hook, you can use the `--no-verify`
option with `git commit`:
```bash
$ git commit --no-verify
```
However, the checks will still be run in CI on every pull request. So this can only be
used for quick local commits. Make sure all check pass before opening a pull request.


## Got an idea for a new project?
Expand Down
5 changes: 3 additions & 2 deletions benchkit/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
FROM python:3.12
FROM python:3.13

WORKDIR /driver

COPY . /driver

# Install dependencies
RUN pip install -U pip && \
pip install -Ur requirements-dev.txt
pip install --group benchkit && \
pip install .

ENTRYPOINT ["python", "-m", "benchkit"]
81 changes: 81 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,87 @@ requires = [
]
build-backend = "setuptools.build_meta"

[dependency-groups]
# To install all development dependencies as well as the driver with all optional dependencies,
# run `pip install --group dev`
dev = [
# dev tools
{include-group = "dep-project-dependencies"},
{include-group = "tox"},
{include-group = "precommit"},
{include-group = "unasync"},
{include-group = "test"},
{include-group = "typing"},
{include-group = "docs"},
{include-group = "testkit"},
{include-group = "benchkit"},
{include-group = "packaging"},
{include-group = "release"},
]
# tool for runnig test matrix
tox = ["tox >= 4.25.0"]
# run pre-commit hooks (includes linting, formatting, type checking, ...)
precommit = [
"pre-commit >= 4.2.0",
# runs unasync and type checker outside pre-commit's isolation
{include-group = "unasync"},
{include-group = "typing"},
]
# auto-generate sync driver from async code
unasync = [
"unasync == 0.5.0",
"isort >= 6.0.1",
]
# dependencies for running tests
test = [
"coverage[toml] >= 7.8.0",
{include-group = "dep-freezegun"},
"mock >= 5.2.0",
"pytest >= 8.3.5",
"pytest-asyncio >= 0.26.0",
"pytest-benchmark >= 5.1.0",
"pytest-cov >= 6.1.1",
"pytest-mock >= 3.14.0",
]
# type checker and type stubs for static type checking
typing = [
"mypy >= 1.15.0",
"typing-extensions >= 4.13.2",
"types-pytz >= 2025.2.0.20250326",
{include-group = "dep-project-dependencies"},
# tests are also type-checked
{include-group = "test"},
# testkit backend is also type-checked
{include-group = "testkit"},
# benchkit backend is also type-checked
{include-group = "benchkit"},
]
# generate documentation
docs = ["Sphinx >= 8.1.3"]
# running the testkit backend
testkit = [
{include-group = "dep-freezegun"},
]
# running the benchkit backend for benchmarking
benchkit = ["sanic >= 25.3.0"]
# building and packaging the driver
packaging = [
"build >= 1.2.2",
]
# releasing the packaged driver to PyPI
release = [
"twine >= 6.1.0",
]

# single dependencies and other include-groups (not really meant to be installed as a group, but to avoid duplication)
dep-freezegun = ["freezegun >= 1.5.1"]
dep-project-dependencies = [
"pytz",
"numpy >= 1.7.0, < 3.0.0",
"pandas >= 1.1.0, < 3.0.0",
"pyarrow >= 1.0.0",
]

[tool.setuptools.dynamic]
version = {attr = "neo4j._meta.version"}

Expand Down
32 changes: 0 additions & 32 deletions requirements-dev.txt

This file was deleted.

1 change: 0 additions & 1 deletion requirements.txt

This file was deleted.

3 changes: 1 addition & 2 deletions testkit/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,5 @@ RUN pyenv global $(pyenv versions --bare --skip-aliases | sort --version-sort --
# + tox and tools for starting the tests
# https://pip.pypa.io/en/stable/news/
RUN for version in $PYTHON_VERSIONS; do \
python$version -m pip install -U pip && \
python$version -m pip install -U coverage tox; \
python$version -m pip install -U pip; \
done
4 changes: 2 additions & 2 deletions testkit/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@

if __name__ == "__main__":
run_python(
["-m", "pip", "install", "-U", "pip", "build"],
["-m", "pip", "install", "--group", "packaging"],
warning_as_error=False,
)
run_python(["-m", "build", "."], warning_as_error=True)
run_python(
["-m", "pip", "install", "-Ur", "requirements-dev.txt"],
["-m", "pip", "install", "--group", "testkit", "-e", "."],
warning_as_error=False,
)
4 changes: 4 additions & 0 deletions testkit/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@


if __name__ == "__main__":
run_python(
["-m", "pip", "install", "--group", "tox"],
warning_as_error=False,
)
run_python(["-m", "tox", "-vv", "-f", "integration"])
4 changes: 4 additions & 0 deletions testkit/unittests.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@


if __name__ == "__main__":
run_python(
["-m", "pip", "install", "--group", "tox"],
warning_as_error=False,
)
run_python(
[
"-m",
Expand Down
7 changes: 6 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ envlist = py{310,311,312,313}-{unit,integration,performance}

[testenv]
passenv = TEST_*
deps = -r requirements-dev.txt
dependency_groups =
test
extras =
numpy
pandas
pyarrow
setenv =
COVERAGE_FILE={envdir}/.coverage
TEST_SUITE_NAME={envname}
Expand Down