Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/pypa/setuptools into ruff-i…
Browse files Browse the repository at this point in the history
…sort
  • Loading branch information
Avasam committed Jul 1, 2024
2 parents a1f979c + 449021c commit 582d32e
Show file tree
Hide file tree
Showing 80 changed files with 402 additions and 382 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 70.1.0
current_version = 70.1.1
commit = True
tag = True

Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,6 @@ jobs:
if: hashFiles('coverage.xml') != '' # Rudimentary `file.exists()`
uses: codecov/codecov-action@v4
with:
files: >-
${{ github.workspace }}\coverage.xml
flags: >- # Mark which lines are covered by which envs
CI-GHA,
${{ github.job }},
Expand Down
9 changes: 9 additions & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
v70.1.1
=======

Misc
----

- #4429


v70.1.0
=======

Expand Down
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@
github_repo_url = f'{github_url}/{github_repo_slug}'
github_sponsors_url = f'{github_url}/sponsors'
extlinks = {
'user': (f'{github_sponsors_url}/%s', '@%s'), # noqa: WPS323
'pypi': ('https://pypi.org/project/%s', '%s'), # noqa: WPS323
'wiki': ('https://wikipedia.org/wiki/%s', '%s'), # noqa: WPS323
'user': (f'{github_sponsors_url}/%s', '@%s'),
'pypi': ('https://pypi.org/project/%s', '%s'),
'wiki': ('https://wikipedia.org/wiki/%s', '%s'),
}
extensions += ['sphinx.ext.extlinks']

Expand Down
24 changes: 20 additions & 4 deletions docs/userguide/declarative_config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ Configuring setuptools using ``setup.cfg`` files
call is still required even if your configuration resides in ``setup.cfg``.

``Setuptools`` allows using configuration files (for example, :file:`setup.cfg`)
to define a package’s metadata and other options that are normally supplied
to the ``setup()`` function (declarative config).
to define a package’s metadata and other options (declarative config).

This approach not only allows automation scenarios but also reduces
boilerplate code in some cases.
This approach allows automation scenarios and can reduce boilerplate code.

.. _example-setup-config:

Expand Down Expand Up @@ -135,6 +133,24 @@ value associated with ``""`` in the ``package_dir`` dictionary.
Please see :doc:`package discovery </userguide/package_discovery>` for more
details.

Interpolation
=============

Config files are parsed using :mod:`configparser` with
`interpolation <https://docs.python.org/3/library/configparser.html#interpolation-of-values>`_
enabled. As a result, one config value may reference another. This
feature may be used, for example, in defining extras:

.. code-block:: ini
[options.extras_require]
tester =
pytest==3.3.2
pytest-sugar
dev =
pytest-xdist
%(tester)s
Specifying values
=================

Expand Down
2 changes: 2 additions & 0 deletions newsfragments/4434.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix distribution name normalisation (:pep:`625`) for valid versions that are
not canonical (e.g. ``1.0-2``).
4 changes: 2 additions & 2 deletions pkg_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2041,7 +2041,7 @@ def _extract_resource(self, manager: ResourceManager, zip_path) -> str: # noqa:

if not WRITE_SUPPORT:
raise OSError(
'"os.rename" and "os.unlink" are not supported ' 'on this platform'
'"os.rename" and "os.unlink" are not supported on this platform'
)
try:
if not self.egg_name:
Expand Down Expand Up @@ -2808,7 +2808,7 @@ def _parse_extras(cls, extras_spec):
return ()
req = Requirement.parse('x' + extras_spec)
if req.specs:
raise ValueError()
raise ValueError
return req.extras

@classmethod
Expand Down
10 changes: 5 additions & 5 deletions pkg_resources/extern/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ def load_module(self, fullname: str):
"""
root, base, target = fullname.partition(self.root_name + '.')
for prefix in self.search_path:
extant = prefix + target
try:
extant = prefix + target
__import__(extant)
mod = sys.modules[extant]
sys.modules[fullname] = mod
return mod
except ImportError:
pass
continue
mod = sys.modules[extant]
sys.modules[fullname] = mod
return mod
else:
raise ImportError(
"The '{target}' package is required; "
Expand Down
4 changes: 2 additions & 2 deletions pkg_resources/tests/test_pkg_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def test_setuptools_not_imported(self):
lines = (
'import pkg_resources',
'import sys',
('assert "setuptools" not in sys.modules, ' '"setuptools was imported"'),
('assert "setuptools" not in sys.modules, "setuptools was imported"'),
)
cmd = [sys.executable, '-c', '; '.join(lines)]
subprocess.check_call(cmd)
Expand Down Expand Up @@ -293,7 +293,7 @@ def test_distribution_version_missing_undetected_path():

msg, dist = excinfo.value.args
expected = (
"Missing 'Version:' header and/or PKG-INFO file at path: " '[could not detect]'
"Missing 'Version:' header and/or PKG-INFO file at path: [could not detect]"
)
assert msg == expected

Expand Down
2 changes: 1 addition & 1 deletion pkg_resources/tests/test_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def test_marker_evaluation_with_extras(self):
"/foo_dir/Foo-1.2.dist-info",
metadata=Metadata((
"METADATA",
"Provides-Extra: baz\n" "Requires-Dist: quux; extra=='baz'",
"Provides-Extra: baz\nRequires-Dist: quux; extra=='baz'",
)),
)
ad.add(Foo)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ backend-path = ["."]

[project]
name = "setuptools"
version = "70.1.0"
version = "70.1.1"
authors = [
{ name = "Python Packaging Authority", email = "[email protected]" },
]
Expand Down
2 changes: 2 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ extend-select = [
"I", # isort
"PYI", # flake8-pyi
"UP", # pyupgrade
"TRY",
"YTT", # flake8-2020
]
ignore = [
"TRY301", # raise-within-try, it's handy
"UP015", # redundant-open-modes, explicit is preferred
"UP030", # temporarily disabled
"UP031", # temporarily disabled
Expand Down
2 changes: 1 addition & 1 deletion setuptools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ def _get_project_config_files(self, filenames=None):
"""Ignore ``pyproject.toml``, they are not related to setup_requires"""
try:
cfg, toml = super()._split_standard_project_metadata(filenames)
return cfg, ()
except Exception:
return filenames, ()
return cfg, ()

def finalize_options(self):
"""
Expand Down
22 changes: 19 additions & 3 deletions setuptools/_core_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from . import _normalization, _reqs
from .extern.packaging.markers import Marker
from .extern.packaging.requirements import Requirement
from .extern.packaging.utils import canonicalize_name
from .extern.packaging.utils import canonicalize_name, canonicalize_version
from .extern.packaging.version import Version
from .warnings import SetuptoolsDeprecationWarning

Expand Down Expand Up @@ -263,7 +263,23 @@ def _write_provides_extra(file, processed_extras, safe, unsafe):

# from pypa/distutils#244; needed only until that logic is always available
def get_fullname(self):
return _distribution_fullname(self.get_name(), self.get_version())


def _distribution_fullname(name: str, version: str) -> str:
"""
>>> _distribution_fullname('setup.tools', '1.0-2')
'setup_tools-1.0.post2'
>>> _distribution_fullname('setup-tools', '1.2post2')
'setup_tools-1.2.post2'
>>> _distribution_fullname('setup-tools', '1.0-r2')
'setup_tools-1.0.post2'
>>> _distribution_fullname('setup.tools', '1.0.post')
'setup_tools-1.0.post0'
>>> _distribution_fullname('setup.tools', '1.0+ubuntu-1')
'setup_tools-1.0+ubuntu.1'
"""
return "{}-{}".format(
canonicalize_name(self.get_name()).replace('-', '_'),
self.get_version(),
canonicalize_name(name).replace('-', '_'),
canonicalize_version(version, strip_trailing_zero=False),
)
2 changes: 1 addition & 1 deletion setuptools/_importlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def disable_importlib_metadata_finder(metadata):

disable_importlib_metadata_finder(metadata)
else:
import importlib.metadata as metadata # noqa: F401
import importlib.metadata as metadata


if sys.version_info < (3, 9):
Expand Down
10 changes: 6 additions & 4 deletions setuptools/command/bdist_egg.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class bdist_egg(Command):
'keep-temp',
'k',
"keep the pseudo-installation tree around after "
+ "creating the distribution archive",
"creating the distribution archive",
),
('dist-dir=', 'd', "directory to put final built distributions in"),
('skip-build', None, "skip rebuilding everything (for testing/debugging)"),
Expand Down Expand Up @@ -291,9 +291,11 @@ def get_ext_outputs(self):

paths = {self.bdist_dir: ''}
for base, dirs, files in sorted_walk(self.bdist_dir):
for filename in files:
if os.path.splitext(filename)[1].lower() in NATIVE_EXTENSIONS:
all_outputs.append(paths[base] + filename)
all_outputs.extend(
paths[base] + filename
for filename in files
if os.path.splitext(filename)[1].lower() in NATIVE_EXTENSIONS
)
for filename in dirs:
paths[os.path.join(base, filename)] = paths[base] + filename + '/'

Expand Down
12 changes: 6 additions & 6 deletions setuptools/command/bdist_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class bdist_wheel(Command):
"plat-name=",
"p",
"platform name to embed in generated filenames "
f"(default: {get_platform(None)})",
f"[default: {get_platform(None)}]",
),
(
"keep-temp",
Expand All @@ -189,7 +189,7 @@ class bdist_wheel(Command):
(
"relative",
None,
"build the archive using relative paths (default: false)",
"build the archive using relative paths [default: false]",
),
(
"owner=",
Expand All @@ -201,18 +201,18 @@ class bdist_wheel(Command):
"g",
"Group name used when creating a tar file [default: current group]",
),
("universal", None, "make a universal wheel (default: false)"),
("universal", None, "make a universal wheel [default: false]"),
(
"compression=",
None,
"zipfile compression (one of: {}) (default: 'deflated')".format(
"zipfile compression (one of: {}) [default: 'deflated']".format(
", ".join(supported_compressions)
),
),
(
"python-tag=",
None,
f"Python implementation compatibility tag (default: '{python_tag()}')",
f"Python implementation compatibility tag [default: '{python_tag()}']",
),
(
"build-number=",
Expand All @@ -224,7 +224,7 @@ class bdist_wheel(Command):
(
"py-limited-api=",
None,
"Python tag (cp32|cp33|cpNN) for abi3 wheel tag (default: false)",
"Python tag (cp32|cp33|cpNN) for abi3 wheel tag [default: false]",
),
]

Expand Down
2 changes: 1 addition & 1 deletion setuptools/command/dist_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class dist_info(Command):
'output-dir=',
'o',
"directory inside of which the .dist-info will be"
"created (default: top of the source tree)",
"created [default: top of the source tree]",
),
('tag-date', 'd', "Add date stamp (e.g. 20050528) to version number"),
('tag-build=', 'b', "Specify explicit tag to add to version number"),
Expand Down
Loading

0 comments on commit 582d32e

Please sign in to comment.