Skip to content

Commit 18d961a

Browse files
authored
Merge branch 'main' into pytest-mypy-log-filename
2 parents 6c16a39 + 3595113 commit 18d961a

20 files changed

+145
-462
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 71.1.0
2+
current_version = 72.1.0
33
commit = True
44
tag = True
55

NEWS.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
v72.1.0
2+
=======
3+
4+
Features
5+
--------
6+
7+
- Restore the tests command and deprecate access to the module. (#4519) (#4520)
8+
9+
10+
v72.0.0
11+
=======
12+
13+
Deprecations and Removals
14+
-------------------------
15+
16+
- The test command has been removed. Users relying on 'setup.py test' will need to migrate to another test runner or pin setuptools before this version. (#931)
17+
18+
119
v71.1.0
220
=======
321

docs/userguide/dependency_management.rst

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,56 @@ Build system requirement
1818
========================
1919

2020
After organizing all the scripts and files and getting ready for packaging,
21-
there needs to be a way to specify what programs and libraries are actually needed
22-
to do the packaging (in our case, ``setuptools`` of course).
23-
This needs to be specified in your ``pyproject.toml`` file
24-
(if you have forgot what this is, go to :doc:`/userguide/quickstart` or :doc:`/build_meta`):
21+
there needs to be a way to specify what programs and libraries (build backend)
22+
are actually needed to build the package for distribution. For Setuptools, the
23+
requisite library is ``setuptools``. Specify the build backend in a
24+
``pyproject.toml`` file (see also :doc:`/userguide/quickstart` or
25+
:doc:`/build_meta`):
2526

2627
.. code-block:: toml
2728
2829
[build-system]
2930
requires = ["setuptools"]
3031
#...
3132
32-
Please note that you should also include here any other ``setuptools`` plugin
33-
(e.g., :pypi:`setuptools-scm`, :pypi:`setuptools-golang`, :pypi:`setuptools-rust`)
33+
Also include any other ``setuptools`` plugins
34+
(e.g., :pypi:`setuptools_scm`, :pypi:`setuptools-golang`, :pypi:`setuptools-rust`)
3435
or build-time dependency (e.g., :pypi:`Cython`, :pypi:`cppy`, :pypi:`pybind11`).
3536

37+
.. code-block:: toml
38+
39+
[build-system]
40+
requires = ["setuptools", "cython", "setuptools_scm"]
41+
42+
43+
If the project depends on a feature introduced in a specific version of Setuptools,
44+
it is good practice to specify it as a lower bound:
45+
46+
.. code-block:: toml
47+
48+
[build-system]
49+
requires = ["setuptools >= 61.2"]
50+
51+
Some may be tempted to also include an upper-bound for yet unreleased major
52+
versions (e.g. ``setuptools <= 70``) or pin to a specific version (e.g.
53+
``setuptools == 70.0.4``) in order to avoid the project being uninstallable
54+
should those backward-incompatible changes affect this release of the project.
55+
Setuptools maintainers recommend strongly against this precautionary approach.
56+
The team primarily maintains one release, the latest monotonically-increasing
57+
release, and encourages users to use that latest release (work at HEAD). As a
58+
result, the team is cognizant of and takes responsibility for making
59+
backward-incompatible changes and aims to mitigate the impact of any breaking
60+
changes prior to releasing that change. By pinning against an unreleased
61+
version, it causes toil (maintenance burden) for each and every project that
62+
does the pinning (and the consumers that use it) and increases the risk of
63+
erosion if maintenance is unsustained. This tradeoff between reproducibility
64+
and compatibility is especially stark because Setuptools frequently releases
65+
backward-incompatible releases for a variety of reasons, many of which won't
66+
affect a given project.
67+
3668
.. note::
3769
In previous versions of ``setuptools``,
38-
this used to be accomplished with the ``setup_requires`` keyword but is
70+
the ``setup_requires`` keyword performed a similar function but is
3971
now considered deprecated in favor of the :pep:`517` style described above.
4072
To peek into how this legacy keyword is used, consult our :doc:`guide on
4173
deprecated practice (WIP) </deprecated/index>`.

docs/userguide/quickstart.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Installation
77

88
You can install the latest version of ``setuptools`` using :pypi:`pip`::
99

10-
pip install --upgrade setuptools
10+
pip install --upgrade setuptools[core]
1111

1212
Most of the times, however, you don't have to...
1313

@@ -56,6 +56,16 @@ containing a ``build-system`` section similar to the example below:
5656
This section declares what are your build system dependencies, and which
5757
library will be used to actually do the packaging.
5858

59+
.. note::
60+
61+
Package maintainers might be tempted to use ``setuptools[core]`` as the
62+
requirement, given the guidance above. Avoid doing so, as the extra
63+
is currently considered an internal implementation detail and is likely
64+
to go away in the future and the Setuptools team will not support
65+
compatibility for problems arising from packages published with this
66+
extra declared. Vendored packages will satisfy the dependencies in
67+
the most common isolated build scenarios.
68+
5969
.. note::
6070

6171
Historically this documentation has unnecessarily listed ``wheel``

pyproject.toml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ backend-path = ["."]
55

66
[project]
77
name = "setuptools"
8-
version = "71.1.0"
8+
version = "72.1.0"
99
authors = [
1010
{ name = "Python Packaging Authority", email = "distutils-sig@python.org" },
1111
]
@@ -141,7 +141,6 @@ rotate = "setuptools.command.rotate:rotate"
141141
saveopts = "setuptools.command.saveopts:saveopts"
142142
sdist = "setuptools.command.sdist:sdist"
143143
setopt = "setuptools.command.setopt:setopt"
144-
test = "setuptools.command.test:test"
145144
upload_docs = "setuptools.command.upload_docs:upload_docs"
146145

147146
[project.entry-points."setuptools.finalize_distribution_options"]
@@ -153,19 +152,15 @@ eager_resources = "setuptools.dist:assert_string_list"
153152
namespace_packages = "setuptools.dist:check_nsp"
154153
extras_require = "setuptools.dist:check_extras"
155154
install_requires = "setuptools.dist:check_requirements"
156-
tests_require = "setuptools.dist:check_requirements"
157155
setup_requires = "setuptools.dist:check_requirements"
158156
python_requires = "setuptools.dist:check_specifier"
159157
entry_points = "setuptools.dist:check_entry_points"
160-
test_suite = "setuptools.dist:check_test_suite"
161158
zip_safe = "setuptools.dist:assert_bool"
162159
package_data = "setuptools.dist:check_package_data"
163160
exclude_package_data = "setuptools.dist:check_package_data"
164161
include_package_data = "setuptools.dist:assert_bool"
165162
packages = "setuptools.dist:check_packages"
166163
dependency_links = "setuptools.dist:assert_string_list"
167-
test_loader = "setuptools.dist:check_importable"
168-
test_runner = "setuptools.dist:check_importable"
169164
use_2to3 = "setuptools.dist:invalid_unless_false"
170165

171166
[project.entry-points."egg_info.writers"]

setuptools/_path.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
import contextlib
12
import os
23
import sys
34
from typing import Union
45

6+
from more_itertools import unique_everseen
7+
8+
59
if sys.version_info >= (3, 9):
610
StrPath = Union[str, os.PathLike[str]] # Same as _typeshed.StrPath
711
else:
@@ -38,3 +42,41 @@ def normpath(filename: StrPath) -> str:
3842
# See pkg_resources.normalize_path for notes about cygwin
3943
file = os.path.abspath(filename) if sys.platform == 'cygwin' else filename
4044
return os.path.normcase(os.path.realpath(os.path.normpath(file)))
45+
46+
47+
@contextlib.contextmanager
48+
def paths_on_pythonpath(paths):
49+
"""
50+
Add the indicated paths to the head of the PYTHONPATH environment
51+
variable so that subprocesses will also see the packages at
52+
these paths.
53+
54+
Do this in a context that restores the value on exit.
55+
56+
>>> getfixture('monkeypatch').setenv('PYTHONPATH', 'anything')
57+
>>> with paths_on_pythonpath(['foo', 'bar']):
58+
... assert 'foo' in os.environ['PYTHONPATH']
59+
... assert 'anything' in os.environ['PYTHONPATH']
60+
>>> os.environ['PYTHONPATH']
61+
'anything'
62+
63+
>>> getfixture('monkeypatch').delenv('PYTHONPATH')
64+
>>> with paths_on_pythonpath(['foo', 'bar']):
65+
... assert 'foo' in os.environ['PYTHONPATH']
66+
>>> os.environ.get('PYTHONPATH')
67+
"""
68+
nothing = object()
69+
orig_pythonpath = os.environ.get('PYTHONPATH', nothing)
70+
current_pythonpath = os.environ.get('PYTHONPATH', '')
71+
try:
72+
prefix = os.pathsep.join(unique_everseen(paths))
73+
to_join = filter(None, [prefix, current_pythonpath])
74+
new_path = os.pathsep.join(to_join)
75+
if new_path:
76+
os.environ['PYTHONPATH'] = new_path
77+
yield
78+
finally:
79+
if orig_pythonpath is nothing:
80+
os.environ.pop('PYTHONPATH', None)
81+
else:
82+
os.environ['PYTHONPATH'] = orig_pythonpath

0 commit comments

Comments
 (0)