1
0
mirror of https://github.com/django/django.git synced 2025-07-05 18:29:11 +00:00

[4.2.x] Migrated setuptools configuration to pyproject.toml.

This branch migrates setuptools configuration from setup.py/setup.cfg to
pyproject.toml. In order to ensure that the generated binary files have
consistent casing (both the tarball and the wheel), setuptools version
is limited to ">=61.0.0,<69.3.0".

Configuration for flake8 was moved to a dedicated .flake8 file since
it cannot be configured via pyproject.toml.

Also, __pycache__ exclusion was removed from MANIFEST and the
extras/Makefile was replaced with a simpler build command.

Co-authored-by: Nick Pope <nick@nickpope.me.uk>

Backport of 4686541691dbe986f58ac87630c3b7a04db4ff93 from main.
This commit is contained in:
Claude Paroz 2024-06-24 20:34:43 +02:00 committed by nessita
parent 35c34ed2d0
commit afe52d89c4
9 changed files with 92 additions and 147 deletions

9
.flake8 Normal file
View File

@ -0,0 +1,9 @@
[flake8]
exclude = build,.git,.tox,./tests/.env
extend-ignore = E203
max-line-length = 88
per-file-ignores =
django/core/cache/backends/filebased.py:W601
django/core/cache/backends/base.py:W601
django/core/cache/backends/redis.py:W601
tests/cache/tests.py:W601

View File

@ -12,5 +12,4 @@ graft extras
graft js_tests graft js_tests
graft scripts graft scripts
graft tests graft tests
global-exclude __pycache__
global-exclude *.py[co] global-exclude *.py[co]

View File

@ -46,7 +46,7 @@ Python style
* Unless otherwise specified, follow :pep:`8`. * Unless otherwise specified, follow :pep:`8`.
Use :pypi:`flake8` to check for problems in this area. Note that our Use :pypi:`flake8` to check for problems in this area. Note that our
``setup.cfg`` file contains some excluded files (deprecated modules we don't ``.flake8`` file contains some excluded files (deprecated modules we don't
care about cleaning up and some third-party code that Django vendors) as well care about cleaning up and some third-party code that Django vendors) as well
as some excluded errors that we don't consider as gross violations. Remember as some excluded errors that we don't consider as gross violations. Remember
that :pep:`8` is only a guide, so respect the style of the surrounding code that :pep:`8` is only a guide, so respect the style of the surrounding code

View File

@ -58,7 +58,7 @@ You'll need a few things before getting started:
.. code-block:: shell .. code-block:: shell
$ python -m pip install wheel twine $ python -m pip install build twine
* Access to Django's record on PyPI. Create a file with your credentials: * Access to Django's record on PyPI. Create a file with your credentials:
@ -222,9 +222,15 @@ OK, this is the fun part, where we actually push out a release!
Please see `notes on setting the VERSION tuple`_ below for details Please see `notes on setting the VERSION tuple`_ below for details
on ``VERSION``. on ``VERSION``.
#. If this is a pre-release package, update the "Development Status" trove #. If this is a pre-release package also update the "Development Status"
classifier in ``setup.cfg`` to reflect this. Otherwise, make sure the trove classifier in ``pyproject.toml`` to reflect this. An ``rc``
classifier is set to ``Development Status :: 5 - Production/Stable``. pre-release should not change the trove classifier (:commit:`example
commit for alpha release <eeeacc52a967234e920c001b7908c4acdfd7a848>`,
:commit:`example commit for beta release
<25fec8940b24107e21314ab6616e18ce8dec1c1c>`).
#. Otherwise, make sure the classifier is set to
``Development Status :: 5 - Production/Stable``.
#. Tag the release using ``git tag``. For example: #. Tag the release using ``git tag``. For example:
@ -238,8 +244,8 @@ OK, this is the fun part, where we actually push out a release!
#. Make sure you have an absolutely clean tree by running ``git clean -dfx``. #. Make sure you have an absolutely clean tree by running ``git clean -dfx``.
#. Run ``make -f extras/Makefile`` to generate the release packages. This will #. Run ``python -m build`` to generate the release packages. This will create
create the release packages in a ``dist/`` directory. the release packages in a ``dist/`` directory.
#. Generate the hashes of the release packages: #. Generate the hashes of the release packages:

View File

@ -97,7 +97,7 @@ To use Argon2id as your default storage algorithm, do the following:
#. Install the :pypi:`argon2-cffi` package. This can be done by running #. Install the :pypi:`argon2-cffi` package. This can be done by running
``python -m pip install django[argon2]``, which is equivalent to ``python -m pip install django[argon2]``, which is equivalent to
``python -m pip install argon2-cffi`` (along with any version requirement ``python -m pip install argon2-cffi`` (along with any version requirement
from Django's ``setup.cfg``). from Django's ``pyproject.toml``).
#. Modify :setting:`PASSWORD_HASHERS` to list ``Argon2PasswordHasher`` first. #. Modify :setting:`PASSWORD_HASHERS` to list ``Argon2PasswordHasher`` first.
That is, in your settings file, you'd put:: That is, in your settings file, you'd put::
@ -128,7 +128,7 @@ To use Bcrypt as your default storage algorithm, do the following:
#. Install the :pypi:`bcrypt` package. This can be done by running #. Install the :pypi:`bcrypt` package. This can be done by running
``python -m pip install django[bcrypt]``, which is equivalent to ``python -m pip install django[bcrypt]``, which is equivalent to
``python -m pip install bcrypt`` (along with any version requirement from ``python -m pip install bcrypt`` (along with any version requirement from
Django's ``setup.cfg``). Django's ``pyproject.toml``).
#. Modify :setting:`PASSWORD_HASHERS` to list ``BCryptSHA256PasswordHasher`` #. Modify :setting:`PASSWORD_HASHERS` to list ``BCryptSHA256PasswordHasher``
first. That is, in your settings file, you'd put:: first. That is, in your settings file, you'd put::

View File

@ -1,9 +0,0 @@
all: sdist bdist_wheel
sdist:
python setup.py sdist
bdist_wheel:
python setup.py bdist_wheel
.PHONY : sdist bdist_wheel

View File

@ -1,7 +1,71 @@
[build-system] [build-system]
requires = ['setuptools>=40.8.0'] requires = ["setuptools>=61.0.0,<69.3.0"]
build-backend = 'setuptools.build_meta' build-backend = "setuptools.build_meta"
[project]
name = "Django"
dynamic = ["version"]
requires-python = ">= 3.8"
dependencies = [
"asgiref >= 3.6.0, < 4",
"backports.zoneinfo; python_version<'3.9'",
"sqlparse>=0.3.1",
"tzdata; sys_platform == 'win32'",
]
authors = [
{name = "Django Software Foundation", email = "foundation@djangoproject.com"},
]
description = "A high-level Python web framework that encourages rapid development and clean, pragmatic design."
readme = "README.rst"
license = {text = "BSD-3-Clause"}
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Framework :: Django",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
"Topic :: Internet :: WWW/HTTP :: WSGI",
"Topic :: Software Development :: Libraries :: Application Frameworks",
"Topic :: Software Development :: Libraries :: Python Modules",
]
[project.optional-dependencies]
argon2 = ["argon2-cffi>=19.1.0"]
bcrypt = ["bcrypt"]
[project.scripts]
django-admin = "django.core.management:execute_from_command_line"
[project.urls]
Homepage = "https://www.djangoproject.com/"
Documentation = "https://docs.djangoproject.com/"
"Release notes" = "https://docs.djangoproject.com/en/stable/releases/"
Funding = "https://www.djangoproject.com/fundraising/"
Source = "https://github.com/django/django"
Tracker = "https://code.djangoproject.com/"
[tool.black] [tool.black]
target-version = ['py38'] target-version = ["py38"]
force-exclude = 'tests/test_runner_apps/tagged/tests_syntax_error.py' force-exclude = "tests/test_runner_apps/tagged/tests_syntax_error.py"
[tool.isort]
profile = "black"
default_section = "THIRDPARTY"
known_first_party = "django"
[tool.setuptools.dynamic]
version = {attr = "django.__version__"}
[tool.setuptools.packages.find]
include = ["django*"]

View File

@ -1,69 +0,0 @@
[metadata]
name = Django
version = attr: django.__version__
url = https://www.djangoproject.com/
author = Django Software Foundation
author_email = foundation@djangoproject.com
description = A high-level Python web framework that encourages rapid development and clean, pragmatic design.
long_description = file: README.rst
license = BSD-3-Clause
classifiers =
Development Status :: 5 - Production/Stable
Environment :: Web Environment
Framework :: Django
Intended Audience :: Developers
License :: OSI Approved :: BSD License
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Topic :: Internet :: WWW/HTTP
Topic :: Internet :: WWW/HTTP :: Dynamic Content
Topic :: Internet :: WWW/HTTP :: WSGI
Topic :: Software Development :: Libraries :: Application Frameworks
Topic :: Software Development :: Libraries :: Python Modules
project_urls =
Documentation = https://docs.djangoproject.com/
Release notes = https://docs.djangoproject.com/en/stable/releases/
Funding = https://www.djangoproject.com/fundraising/
Source = https://github.com/django/django
Tracker = https://code.djangoproject.com/
[options]
python_requires = >=3.8
packages = find:
include_package_data = true
zip_safe = false
install_requires =
asgiref >= 3.6.0, < 4
backports.zoneinfo; python_version<"3.9"
sqlparse >= 0.3.1
tzdata; sys_platform == 'win32'
[options.entry_points]
console_scripts =
django-admin = django.core.management:execute_from_command_line
[options.extras_require]
argon2 = argon2-cffi >= 19.1.0
bcrypt = bcrypt
[flake8]
exclude = build,.git,.tox,./tests/.env
extend-ignore = E203
max-line-length = 88
per-file-ignores =
django/core/cache/backends/filebased.py:W601
django/core/cache/backends/base.py:W601
django/core/cache/backends/redis.py:W601
tests/cache/tests.py:W601
[isort]
profile = black
default_section = THIRDPARTY
known_first_party = django

View File

@ -1,55 +0,0 @@
import os
import site
import sys
from distutils.sysconfig import get_python_lib
from setuptools import setup
# Allow editable install into user site directory.
# See https://github.com/pypa/pip/issues/7953.
site.ENABLE_USER_SITE = "--user" in sys.argv[1:]
# Warn if we are installing over top of an existing installation. This can
# cause issues where files that were deleted from a more recent Django are
# still present in site-packages. See #18115.
overlay_warning = False
if "install" in sys.argv:
lib_paths = [get_python_lib()]
if lib_paths[0].startswith("/usr/lib/"):
# We have to try also with an explicit prefix of /usr/local in order to
# catch Debian's custom user site-packages directory.
lib_paths.append(get_python_lib(prefix="/usr/local"))
for lib_path in lib_paths:
existing_path = os.path.abspath(os.path.join(lib_path, "django"))
if os.path.exists(existing_path):
# We note the need for the warning here, but present it after the
# command is run, so it's more likely to be seen.
overlay_warning = True
break
setup()
if overlay_warning:
sys.stderr.write(
"""
========
WARNING!
========
You have just installed Django over top of an existing
installation, without removing it first. Because of this,
your install may now include extraneous files from a
previous version that have since been removed from
Django. This is known to cause a variety of problems. You
should manually remove the
%(existing_path)s
directory and re-install Django.
"""
% {"existing_path": existing_path}
)