From 577ec2b95a6b3a5ca65695163891ea7a459305ae Mon Sep 17 00:00:00 2001 From: Grant Herman Date: Mon, 18 May 2026 15:32:01 -0400 Subject: [PATCH] Move from requirements-*.txt to dependency groups Dependency groups are the latest and greatest way to manage the dependencies of a project needed only by contributors. Signed-off-by: Grant Herman Co-authored-by: Matt Wozniski --- .github/workflows/build.yml | 5 +++-- .github/workflows/docs.yml | 3 ++- .github/workflows/test_uv_python.yml | 2 +- CONTRIBUTING.md | 3 ++- Dockerfile | 20 ++++++++++---------- README.md | 2 +- pyproject.toml | 5 +++++ requirements-docs.txt | 5 ----- requirements-extra.txt | 5 ----- requirements-test.txt | 11 ----------- 10 files changed, 24 insertions(+), 37 deletions(-) delete mode 100644 requirements-docs.txt delete mode 100644 requirements-extra.txt delete mode 100644 requirements-test.txt diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 856a5e05a2..dd192331a7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -100,7 +100,8 @@ jobs: sudo apt-get install -qy clang-format npm libdebuginfod-dev libunwind-dev liblz4-dev pkg-config - name: Install Python dependencies run: | - python3 -m pip install -r requirements-extra.txt + python3 -m pip install --upgrade pip + python3 -m pip install --group extra - name: Install Package run: | python3 -m pip install -e . @@ -130,7 +131,7 @@ jobs: - name: Install Python dependencies and package run: | python3 -m pip install --upgrade pip - python3 -m pip install -r requirements-test.txt + python3 -m pip install --group test python3 -m pip install -e . env: MEMRAY_MINIMIZE_INLINING: 1 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 97d0bfcdc3..9903e96fad 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -28,7 +28,8 @@ jobs: sudo apt-get install --no-install-recommends -qy libdebuginfod-dev libunwind-dev liblz4-dev pkg-config - name: Install Python dependencies run: | - python3 -m pip install -r requirements-extra.txt + python3 -m pip install --upgrade pip + python3 -m pip install --group extra - name: Install Package run: | python3 -m pip install -e . diff --git a/.github/workflows/test_uv_python.yml b/.github/workflows/test_uv_python.yml index 356ba35d31..3849abf7b5 100644 --- a/.github/workflows/test_uv_python.yml +++ b/.github/workflows/test_uv_python.yml @@ -46,7 +46,7 @@ jobs: - name: Install Python dependencies run: | uv pip install --upgrade pip cython pkgconfig - uv pip install -r requirements-test.txt + uv pip install --group test - name: Build package run: | diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 62c669cb5b..a763084714 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -68,7 +68,8 @@ easier to validate it. Before commiting anything, install the prek (pre-commit) hooks: ```shell -python3 -m pip install -r requirements-extra.txt +python3 -m pip install --upgrade pip +python3 -m pip install --group extra prek install ``` diff --git a/Dockerfile b/Dockerfile index 2f054b697f..0ec6386814 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,16 +39,16 @@ ENV PATH="${VIRTUAL_ENV}/bin:/usr/lib/ccache:${PATH}" \ PYTHON="${VIRTUAL_ENV}/bin/python" \ MEMRAY_MINIMIZE_INLINING="1" -COPY requirements-test.txt requirements-extra.txt requirements-docs.txt /tmp/ - -RUN $PYTHON -m pip install -U \ - -r /tmp/requirements-extra.txt \ - -r /tmp/requirements-test.txt \ - -r /tmp/requirements-docs.txt \ - cython \ - pkgconfig \ - setuptools \ - wheel +COPY pyproject.toml /tmp/pyproject.toml + +RUN $PYTHON -m pip install --upgrade pip \ + && $PYTHON -m pip install \ + --group /tmp/pyproject.toml:test \ + --group /tmp/pyproject.toml:extra \ + cython \ + pkgconfig \ + setuptools \ + wheel RUN npm install -g prettier diff --git a/README.md b/README.md index 90e975b435..7af3c81180 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ cd memray python3 -m venv ../memray-env/ # just an example, put this wherever you want source ../memray-env/bin/activate python3 -m pip install --upgrade pip -python3 -m pip install -e . -r requirements-test.txt -r requirements-extra.txt +python3 -m pip install -e . --group test --group extra ``` This will install Memray in the virtual environment in development mode (the `-e` of the last `pip install` command). diff --git a/pyproject.toml b/pyproject.toml index 5078f5d77d..000d10ac1a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,6 +9,11 @@ requires = [ build-backend = 'setuptools.build_meta' +[dependency-groups] +test=['Cython', 'coverage[toml]', "greenlet; python_version < '3.14'", 'pytest', 'pytest-cov', 'ipython', 'setuptools', 'pkgconfig', 'pytest-textual-snapshot', 'textual >= 0.43, != 0.65.2, != 0.66', 'packaging'] +docs=['IPython', 'sphinx','sphinx-autobuild', 'sphinx-argparse', 'furo'] +extra=['mypy', 'bump2version','towncrier', 'prek', {include-group = "docs"}] + [tool.ruff] line-length = 95 select = ["C4", "E", "F", "I001", "PERF", "W"] diff --git a/requirements-docs.txt b/requirements-docs.txt deleted file mode 100644 index a646cf83b7..0000000000 --- a/requirements-docs.txt +++ /dev/null @@ -1,5 +0,0 @@ -IPython -sphinx -sphinx-autobuild -sphinx-argparse -furo diff --git a/requirements-extra.txt b/requirements-extra.txt deleted file mode 100644 index aedb06c0df..0000000000 --- a/requirements-extra.txt +++ /dev/null @@ -1,5 +0,0 @@ -mypy -bump2version -towncrier -prek --r requirements-docs.txt diff --git a/requirements-test.txt b/requirements-test.txt deleted file mode 100644 index 3ff4f2fd8e..0000000000 --- a/requirements-test.txt +++ /dev/null @@ -1,11 +0,0 @@ -Cython -coverage[toml] -greenlet; python_version < '3.14' -pytest -pytest-cov -ipython -setuptools -pkgconfig -pytest-textual-snapshot -textual >= 0.43, != 0.65.2, != 0.66 -packaging