diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b1bd10d3..db6a7766 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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? diff --git a/benchkit/Dockerfile b/benchkit/Dockerfile index e425b66e..87eed099 100644 --- a/benchkit/Dockerfile +++ b/benchkit/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.12 +FROM python:3.13 WORKDIR /driver @@ -6,6 +6,7 @@ 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"] diff --git a/pyproject.toml b/pyproject.toml index fd287b48..491b0c5b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"} diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index 03cf6c4f..00000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,32 +0,0 @@ -# the driver itself --e .[pandas,numpy,pyarrow] - -# needed for packaging -build>=1.2.2 - -# auto-generate sync driver from async code -unasync==0.5.0 -# pre-commit hooks and tools -pre-commit>=4.2.0 -isort>=6.0.1 -mypy>=1.15.0 -typing-extensions>=4.13.2 -types-pytz>=2025.2.0.20250326 -ruff>=0.11.6 - -# needed for running tests -coverage[toml]>=7.8.0 -freezegun>=1.5.1 -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 -tox>=4.25.0 - -# needed for building docs -Sphinx>=8.1.3 - -# needed for BenchKit -sanic>=25.3.0 diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index af44f198..00000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -pytz diff --git a/testkit/Dockerfile b/testkit/Dockerfile index 56fc59be..44aba2ed 100644 --- a/testkit/Dockerfile +++ b/testkit/Dockerfile @@ -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 diff --git a/testkit/build.py b/testkit/build.py index e56edaa7..07c20137 100644 --- a/testkit/build.py +++ b/testkit/build.py @@ -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, ) diff --git a/testkit/integration.py b/testkit/integration.py index 2e1977d1..22c6136a 100644 --- a/testkit/integration.py +++ b/testkit/integration.py @@ -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"]) diff --git a/testkit/unittests.py b/testkit/unittests.py index 12f12a7a..67578280 100644 --- a/testkit/unittests.py +++ b/testkit/unittests.py @@ -18,6 +18,10 @@ if __name__ == "__main__": + run_python( + ["-m", "pip", "install", "--group", "tox"], + warning_as_error=False, + ) run_python( [ "-m", diff --git a/tox.ini b/tox.ini index f00edc9a..f31fae52 100644 --- a/tox.ini +++ b/tox.ini @@ -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}