diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c29fc1b..7b843e5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,10 +55,15 @@ Remember that many community members have become regular contributors and some a ### 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 pre-commit hooks to notice mistakes before the CI does it for you ;) ```bash diff --git a/bin/target_driver.sh b/bin/target_driver.sh index 191fd93..5c9b720 100755 --- a/bin/target_driver.sh +++ b/bin/target_driver.sh @@ -3,7 +3,7 @@ set -e version="$1"; shift -sed -i "s/\"\(neo4j *== *\).*\"/\"\1$version\"/" pyproject.toml +sed -i "s/\"\(neo4j *\([\[0-9a-zA-Z, \]\+]\)\? *== *\).*\"/\"\1$version\"/" pyproject.toml sed -i "s/\(version *= *\)\"[0-9]\+\.[0-9]\+\.[0-9]\+\(.*\)\"/\1\"$version.0\"/" pyproject.toml cd driver diff --git a/changelog.d/44.dev.md b/changelog.d/44.dev.md new file mode 100644 index 0000000..58e98f4 --- /dev/null +++ b/changelog.d/44.dev.md @@ -0,0 +1 @@ +Use dependency groups in `pyproject.toml` for development dependencies. diff --git a/pyproject.toml b/pyproject.toml index 5f7ad5a..902780a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -61,6 +61,40 @@ pyarrow = ["neo4j[pyarrow]"] requires = ["maturin ~= 1.9.1"] build-backend = "maturin" +[dependency-groups] +# To install all development dependencies as well as the driver with all optional dependencies, +# run `pip install --group dev -e .` inside repository root folder. +dev = [ + # dev tools + {include-group = "dep-project-dependencies"}, + {include-group = "tox"}, + {include-group = "precommit"}, + {include-group = "test"}, + {include-group = "packaging"}, +] +tox = [ + "tox >= 4.25.0", +] +precommit = [ + "pre-commit >= 4.2.0", + "isort >= 6.0.1", +] +test = [ + "pytest >= 8.3.5", + "pytest-benchmark >= 5.1.0", + "pytest-mock >= 3.14.1", +] +packaging = [ + "build", + "maturin ~= 1.9.1", + "towncrier >= 24.8.0", +] + +# single dependencies and other include-groups (not really meant to be installed as a group, but to avoid duplication) +dep-project-dependencies = [ + "neo4j[numpy,pandas,pyarrow] == 5.28.1", +] + [tool.maturin] features = ["pyo3/extension-module", "pyo3/generate-import-lib"] module-name = "neo4j._rust" diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index f6717b4..0000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,18 +0,0 @@ -.[numpy,pandas,pyarrow] - -# for local development -pre-commit>=4.2.0 -isort>=6.0.1 - -# for unit tests -tox>=4.25.0 -pytest>=8.3.5 -pytest-benchmark>=5.1.0 -pytest-mock>=3.14.1 - -# for Python driver's TestKit backend -freezegun>=1.5.1 - -# for packaging -maturin~=1.9.1 -towncrier>=24.8.0 diff --git a/testkit/build.py b/testkit/build.py index 05c3ea3..1393c49 100644 --- a/testkit/build.py +++ b/testkit/build.py @@ -19,4 +19,17 @@ if __name__ == "__main__": run_python(["-m", "pip", "install", "-U", "pip"]) - run_python(["-m", "pip", "install", "-Ur", "requirements-dev.txt"]) + run_python(["-m", "pip", "install", "-U", "--group", "packaging"]) + run_python(["-m", "build", "."]) + run_python( + [ + "-m", + "pip", + "install", + "-U", + "--group", + "driver/pyproject.toml:testkit", + "-e", + ".", + ] + ) diff --git a/tox.ini b/tox.ini index 579f325..2dea77e 100644 --- a/tox.ini +++ b/tox.ini @@ -2,6 +2,11 @@ envlist = py{310,311,312,313}-{test} [testenv] -deps = -r requirements-dev.txt +dependency_groups = + test +extras = + numpy + pandas + pyarrow commands = test: python -m pytest -v --benchmark-skip {posargs} tests