From f3757ed5492a7012405126d47ca660b834587d54 Mon Sep 17 00:00:00 2001 From: Pravin Kamble Date: Sun, 7 Dec 2025 19:01:16 +0530 Subject: [PATCH 1/8] removed requirements txt files --- pyproject.toml | 41 +++++++++++++++++++++ requirements.txt | 13 ------- requirements/requirements-documentation.txt | 5 --- requirements/requirements-optionals.txt | 11 ------ requirements/requirements-packaging.txt | 8 ---- requirements/requirements-testing.txt | 9 ----- tox.ini | 14 +++---- 7 files changed, 46 insertions(+), 55 deletions(-) delete mode 100644 requirements.txt delete mode 100644 requirements/requirements-documentation.txt delete mode 100644 requirements/requirements-optionals.txt delete mode 100644 requirements/requirements-packaging.txt delete mode 100644 requirements/requirements-testing.txt diff --git a/pyproject.toml b/pyproject.toml index da608a26c4..aa4722f331 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,6 +33,47 @@ classifiers = [ dynamic = [ "version" ] dependencies = [ "django>=4.2" ] + +optional-dependencies.documentation = [ + # MkDocs to build our documentation. + "mkdocs==1.6", + # pylinkvalidator to check for broken links in documentation. + "pylinkvalidator==0.3", +] +optional-dependencies.optional = [ + # Optional packages which may be used with REST framework. + "coreapi==2.3.1", + "coreschema==0.0.4", + "django-filter", + "django-guardian>=2.4,<2.5", + "inflection==0.5.1", + "legacy-cgi; python_version>='3.13'", + "markdown>=3.3.7", + "psycopg[binary]>=3.1.8", + "pygments~=2.17.0", + "pyyaml>=5.3.1,<5.4", +] +optional-dependencies.packaging = [ + # Transifex client for managing translation resources. + "transifex-client", + # Twine for secured PyPI uploads. + "twine>=3.4.2,<4.0.2", + + # Wheel for PyPI installs. + "wheel>=0.36.2,<0.40", + +] +optional-dependencies.testing = [ + # temporary pin of attrs + "attrs==22.1", + "importlib-metadata<5", + + # Pytest for running the tests. + "pytest>=7.0.1,<8", + "pytest-cov>=4,<5", + "pytest-django>=4.5.2,<5", + "pytz", +] urls.Changelog = "https://www.django-rest-framework.org/community/release-notes/" urls.Funding = "https://fund.django-rest-framework.org/topics/funding/" urls.Homepage = "https://www.django-rest-framework.org" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index c3a1f1187c..0000000000 --- a/requirements.txt +++ /dev/null @@ -1,13 +0,0 @@ -# The base set of requirements for REST framework is actually -# just Django and pytz, but for the purposes of development -# and testing there are a number of packages that are useful -# to install. - -# Laying these out as separate requirements files, allows us to -# only included the relevant sets when running tox, and ensures -# we are only ever declaring our dependencies in one place. - --r requirements/requirements-optionals.txt --r requirements/requirements-testing.txt --r requirements/requirements-documentation.txt --r requirements/requirements-packaging.txt diff --git a/requirements/requirements-documentation.txt b/requirements/requirements-documentation.txt deleted file mode 100644 index 2cf936ef38..0000000000 --- a/requirements/requirements-documentation.txt +++ /dev/null @@ -1,5 +0,0 @@ -# MkDocs to build our documentation. -mkdocs==1.6.0 - -# pylinkvalidator to check for broken links in documentation. -pylinkvalidator==0.3 diff --git a/requirements/requirements-optionals.txt b/requirements/requirements-optionals.txt deleted file mode 100644 index a19e4d1929..0000000000 --- a/requirements/requirements-optionals.txt +++ /dev/null @@ -1,11 +0,0 @@ -# Optional packages which may be used with REST framework. -coreapi==2.3.1 -coreschema==0.0.4 -django-filter -django-guardian>=2.4.0,<2.5 -inflection==0.5.1 -legacy-cgi; python_version>="3.13" -markdown>=3.3.7 -psycopg[binary]>=3.1.8 -pygments~=2.17.0 -pyyaml>=5.3.1,<5.4 diff --git a/requirements/requirements-packaging.txt b/requirements/requirements-packaging.txt deleted file mode 100644 index 81f22a35a1..0000000000 --- a/requirements/requirements-packaging.txt +++ /dev/null @@ -1,8 +0,0 @@ -# Wheel for PyPI installs. -wheel>=0.36.2,<0.40.0 - -# Twine for secured PyPI uploads. -twine>=3.4.2,<4.0.2 - -# Transifex client for managing translation resources. -transifex-client diff --git a/requirements/requirements-testing.txt b/requirements/requirements-testing.txt deleted file mode 100644 index a3821a5089..0000000000 --- a/requirements/requirements-testing.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Pytest for running the tests. -pytest>=7.0.1,<8.0 -pytest-cov>=4.0.0,<5.0 -pytest-django>=4.5.2,<5.0 -importlib-metadata<5.0 -# temporary pin of attrs -attrs==22.1.0 -pytz # Remove when dropping support for Django<5.0 -setuptools>=77.0.3 diff --git a/tox.ini b/tox.ini index 6980d0bfa3..936527f16b 100644 --- a/tox.ini +++ b/tox.ini @@ -22,28 +22,24 @@ deps = django52: Django>=5.2,<6.0 django60: Django>=6.0,<6.1 djangomain: https://github.com/django/django/archive/main.tar.gz - -rrequirements/requirements-testing.txt - -rrequirements/requirements-optionals.txt + .[testing, optional] [testenv:base] ; Ensure optional dependencies are not required deps = - django<6.1 - -rrequirements/requirements-testing.txt + .[testing] [testenv:dist] commands = python -W error::DeprecationWarning -W error::PendingDeprecationWarning runtests.py --no-pkgroot --staticfiles {posargs} deps = - django<6.1 - -rrequirements/requirements-testing.txt - -rrequirements/requirements-optionals.txt + .[testing, optional] [testenv:docs] skip_install = true commands = mkdocs build deps = - -rrequirements/requirements-testing.txt - -rrequirements/requirements-documentation.txt + .[testing, optional] + [testenv:py312-djangomain] ignore_outcome = true From 58d82d6268c52068997d1eedaa9b962419d004dd Mon Sep 17 00:00:00 2001 From: Pravin Kamble Date: Sun, 7 Dec 2025 19:19:47 +0530 Subject: [PATCH 2/8] Updated Testing section from Contributing.md --- docs/community/contributing.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/community/contributing.md b/docs/community/contributing.md index 797bf72e38..511e547278 100644 --- a/docs/community/contributing.md +++ b/docs/community/contributing.md @@ -75,8 +75,7 @@ To run the tests, clone the repository, and then: # Setup the virtual environment python3 -m venv env source env/bin/activate - pip install -e . - pip install -r requirements.txt + pip install -e .[testing,optional,packaging] # Run the tests ./runtests.py From fff5e241795c2e0d5c35e0d36e7dd2f994c744fa Mon Sep 17 00:00:00 2001 From: Pravin Kamble Date: Sun, 7 Dec 2025 19:30:16 +0530 Subject: [PATCH 3/8] updated command to install dependencies for documentation in CI --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8ae01735c7..9262c38d46 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -60,7 +60,7 @@ jobs: python-version: '3.13' - name: Install dependencies - run: pip install -r requirements/requirements-documentation.txt + run: pip install -e .[testing] # Start mkdocs server and wait for it to be ready - run: mkdocs serve & From b883295d3796aa64ddb76c7cb19bf5bb14a21655 Mon Sep 17 00:00:00 2001 From: Pravin Kamble Date: Sun, 7 Dec 2025 19:36:53 +0530 Subject: [PATCH 4/8] updated tox.ini --- .github/workflows/main.yml | 2 +- pyproject.toml | 2 ++ tox.ini | 21 ++++++++++----------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9262c38d46..9844fb7615 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -60,7 +60,7 @@ jobs: python-version: '3.13' - name: Install dependencies - run: pip install -e .[testing] + run: pip install -e .[documentation] # Start mkdocs server and wait for it to be ready - run: mkdocs serve & diff --git a/pyproject.toml b/pyproject.toml index aa4722f331..58802944b7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,6 +72,8 @@ optional-dependencies.testing = [ "pytest>=7.0.1,<8", "pytest-cov>=4,<5", "pytest-django>=4.5.2,<5", + + # Remove when dropping support for Django<5.0 "pytz", ] urls.Changelog = "https://www.django-rest-framework.org/community/release-notes/" diff --git a/tox.ini b/tox.ini index 936527f16b..f194b3f9bc 100644 --- a/tox.ini +++ b/tox.ini @@ -16,30 +16,29 @@ setenv = PYTHONDONTWRITEBYTECODE=1 PYTHONWARNINGS=once deps = - django42: Django>=4.2,<5.0 - django50: Django>=5.0,<5.1 - django51: Django>=5.1,<5.2 - django52: Django>=5.2,<6.0 - django60: Django>=6.0,<6.1 - djangomain: https://github.com/django/django/archive/main.tar.gz - .[testing, optional] + django42: Django>=4.2,<5.0 + django50: Django>=5.0,<5.1 + django51: Django>=5.1,<5.2 + django52: Django>=5.2,<6.0 + django60: Django>=6.0,<6.1 + djangomain: https://github.com/django/django/archive/main.tar.gz + .[testing,optional] [testenv:base] ; Ensure optional dependencies are not required deps = - .[testing] + .[testing] [testenv:dist] commands = python -W error::DeprecationWarning -W error::PendingDeprecationWarning runtests.py --no-pkgroot --staticfiles {posargs} deps = - .[testing, optional] + .[testing,optional] [testenv:docs] skip_install = true commands = mkdocs build deps = - .[testing, optional] - + .[testing,documentation] [testenv:py312-djangomain] ignore_outcome = true From 1c989dfbca7d5418f991d881b46d48c4db94ae5c Mon Sep 17 00:00:00 2001 From: Pravin Kamble Date: Mon, 8 Dec 2025 10:42:58 +0530 Subject: [PATCH 5/8] build: Adopt PEP 735 for development dependency management --- pyproject.toml | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 58802944b7..5120a3a577 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,13 +34,33 @@ dynamic = [ "version" ] dependencies = [ "django>=4.2" ] -optional-dependencies.documentation = [ +[dependency-groups] +dev = [ + { include-group = "docs" }, + { include-group = "optional" }, + { include-group = "test" }, +] + +test = [ + # temporary pin of attrs + "attrs==22.1", + "importlib-metadata<5", + + # Pytest for running the tests. + "pytest>=7.0.1,<8", + "pytest-cov>=4,<5", + "pytest-django>=4.5.2,<5", + + # Remove when dropping support for Django<5.0 + "pytz", +] +docs = [ # MkDocs to build our documentation. "mkdocs==1.6", # pylinkvalidator to check for broken links in documentation. "pylinkvalidator==0.3", ] -optional-dependencies.optional = [ +optional = [ # Optional packages which may be used with REST framework. "coreapi==2.3.1", "coreschema==0.0.4", @@ -53,29 +73,6 @@ optional-dependencies.optional = [ "pygments~=2.17.0", "pyyaml>=5.3.1,<5.4", ] -optional-dependencies.packaging = [ - # Transifex client for managing translation resources. - "transifex-client", - # Twine for secured PyPI uploads. - "twine>=3.4.2,<4.0.2", - - # Wheel for PyPI installs. - "wheel>=0.36.2,<0.40", - -] -optional-dependencies.testing = [ - # temporary pin of attrs - "attrs==22.1", - "importlib-metadata<5", - - # Pytest for running the tests. - "pytest>=7.0.1,<8", - "pytest-cov>=4,<5", - "pytest-django>=4.5.2,<5", - - # Remove when dropping support for Django<5.0 - "pytz", -] urls.Changelog = "https://www.django-rest-framework.org/community/release-notes/" urls.Funding = "https://fund.django-rest-framework.org/topics/funding/" urls.Homepage = "https://www.django-rest-framework.org" From b05db8b8ba7d3f0057f968927d3e8edaace82e4c Mon Sep 17 00:00:00 2001 From: Pravin Kamble Date: Mon, 8 Dec 2025 10:49:09 +0530 Subject: [PATCH 6/8] Update installation commands for dependency groups in tox.ini and main.yml --- .github/workflows/main.yml | 2 +- tox.ini | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9844fb7615..0ecdf0a7a7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -60,7 +60,7 @@ jobs: python-version: '3.13' - name: Install dependencies - run: pip install -e .[documentation] + run: pip install . --group docs # Start mkdocs server and wait for it to be ready - run: mkdocs serve & diff --git a/tox.ini b/tox.ini index f194b3f9bc..8c7d861caa 100644 --- a/tox.ini +++ b/tox.ini @@ -15,6 +15,9 @@ envdir = {toxworkdir}/venvs/{envname} setenv = PYTHONDONTWRITEBYTECODE=1 PYTHONWARNINGS=once +dependency_groups = + test + optional deps = django42: Django>=4.2,<5.0 django50: Django>=5.0,<5.1 @@ -22,23 +25,28 @@ deps = django52: Django>=5.2,<6.0 django60: Django>=6.0,<6.1 djangomain: https://github.com/django/django/archive/main.tar.gz - .[testing,optional] [testenv:base] ; Ensure optional dependencies are not required +dependency_groups = + test deps = - .[testing] [testenv:dist] commands = python -W error::DeprecationWarning -W error::PendingDeprecationWarning runtests.py --no-pkgroot --staticfiles {posargs} +dependency_groups = + test + optional deps = - .[testing,optional] [testenv:docs] skip_install = true -commands = mkdocs build +commands = + mkdocs build +dependency_groups = + test + docs deps = - .[testing,documentation] [testenv:py312-djangomain] ignore_outcome = true From c847be5b847661d00476514fea3c49342aec8630 Mon Sep 17 00:00:00 2001 From: Pravin Kamble Date: Mon, 8 Dec 2025 10:50:46 +0530 Subject: [PATCH 7/8] update installation command in testing section of contributing docs --- docs/community/contributing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/community/contributing.md b/docs/community/contributing.md index 511e547278..00e4ec4d89 100644 --- a/docs/community/contributing.md +++ b/docs/community/contributing.md @@ -75,7 +75,7 @@ To run the tests, clone the repository, and then: # Setup the virtual environment python3 -m venv env source env/bin/activate - pip install -e .[testing,optional,packaging] + pip install -e . --group dev # Run the tests ./runtests.py From 54f479df246d4f7454dd4f7b04e577cd3d49feee Mon Sep 17 00:00:00 2001 From: Pravin Kamble Date: Tue, 9 Dec 2025 09:10:44 +0530 Subject: [PATCH 8/8] Clean up old `requirements text files` references in workflows and docs * Removed references to `requirements.txt` in GitHub Actions workflows. * Updated `mkdocs-deploy.yml` and `main.yml` to install dependencies using `pyproject.toml`. * Cleaned up documentation to remove mentions of the `requirements` folder. --- .github/workflows/main.yml | 3 +-- .github/workflows/mkdocs-deploy.yml | 4 ++-- docs/community/project-management.md | 8 -------- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0ecdf0a7a7..00457a53d3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,7 +28,6 @@ jobs: python-version: ${{ matrix.python-version }} allow-prereleases: true cache: 'pip' - cache-dependency-path: 'requirements/*.txt' - name: Upgrade packaging tools run: python -m pip install --upgrade pip setuptools virtualenv wheel @@ -60,7 +59,7 @@ jobs: python-version: '3.13' - name: Install dependencies - run: pip install . --group docs + run: pip install --group docs # Start mkdocs server and wait for it to be ready - run: mkdocs serve & diff --git a/.github/workflows/mkdocs-deploy.yml b/.github/workflows/mkdocs-deploy.yml index ef58e9b779..778c7f1275 100644 --- a/.github/workflows/mkdocs-deploy.yml +++ b/.github/workflows/mkdocs-deploy.yml @@ -7,7 +7,7 @@ on: paths: - docs/** - docs_theme/** - - requirements/requirements-documentation.txt + - pyproject.toml - mkdocs.yml - .github/workflows/mkdocs-deploy.yml @@ -25,5 +25,5 @@ jobs: - uses: actions/setup-python@v6 with: python-version: 3.x - - run: pip install -r requirements/requirements-documentation.txt + - run: pip install --group docs - run: mkdocs gh-deploy diff --git a/docs/community/project-management.md b/docs/community/project-management.md index 5c7577ec81..7856fedd5d 100644 --- a/docs/community/project-management.md +++ b/docs/community/project-management.md @@ -81,14 +81,6 @@ When pushing the release to PyPI ensure that your environment has been installed --- -## Project requirements - -All our test requirements are pinned to exact versions, in order to ensure that our test runs are reproducible. We maintain the requirements in the `requirements` directory. The requirements files are referenced from the `tox.ini` configuration file, ensuring we have a single source of truth for package versions used in testing. - -Package upgrades should generally be treated as isolated pull requests. You can check if there are any packages available at a newer version, by using the `pip list --outdated`. - ---- - ## Project ownership The PyPI package is owned by `@tomchristie`. As a backup `@j4mie` also has ownership of the package.