Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: pypa/setuptools
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v75.3.0
Choose a base ref
...
head repository: pypa/setuptools
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v75.3.1
Choose a head ref
  • 6 commits
  • 10 files changed
  • 1 contributor

Commits on Mar 11, 2025

  1. Merge pull request #4766 from di/fix/3777

    Fix "Wheel naming is not following PEP 491 convention"
    jaraco committed Mar 11, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    jaraco Jason R. Coombs
    Copy the full SHA
    9559193 View commit details
  2. Repoint the news fragment.

    jaraco committed Mar 11, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    jaraco Jason R. Coombs
    Copy the full SHA
    1740976 View commit details
  3. Bump version: 75.3.0 → 75.3.1

    jaraco committed Mar 11, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    jaraco Jason R. Coombs
    Copy the full SHA
    23b7b52 View commit details
  4. Verified

    This commit was signed with the committer’s verified signature.
    jaraco Jason R. Coombs
    Copy the full SHA
    5cac330 View commit details
  5. Verified

    This commit was signed with the committer’s verified signature.
    jaraco Jason R. Coombs
    Copy the full SHA
    be96588 View commit details
  6. Mark failing test as xfail.

    Ref #4745
    jaraco committed Mar 11, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    jaraco Jason R. Coombs
    Copy the full SHA
    51a09c9 View commit details
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 = 75.3.0
current_version = 75.3.1
commit = True
tag = True

9 changes: 9 additions & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
v76.0.1
=======

Bugfixes
--------

- Fix wheel file naming to follow binary distribution specification -- by :user:`di` (#4877)


v75.3.0
=======

5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ backend-path = ["."]

[project]
name = "setuptools"
version = "75.3.0"
version = "75.3.1"
authors = [
{ name = "Python Packaging Authority", email = "distutils-sig@python.org" },
]
@@ -60,6 +60,9 @@ test = [
"pyproject-hooks!=1.1",

"jaraco.test>=5.5", # py.typed

# temporarily pin ruff for backport bugfix (#4879)
"ruff <= 0.7.1",
]

doc = [
8 changes: 7 additions & 1 deletion setuptools/_normalization.py
Original file line number Diff line number Diff line change
@@ -134,7 +134,13 @@ def filename_component_broken(value: str) -> str:
def safer_name(value: str) -> str:
"""Like ``safe_name`` but can be used as filename component for wheel"""
# See bdist_wheel.safer_name
return filename_component(safe_name(value))
return (
# Per https://packaging.python.org/en/latest/specifications/name-normalization/#name-normalization
re.sub(r"[-_.]+", "-", safe_name(value))
.lower()
# Per https://packaging.python.org/en/latest/specifications/binary-distribution-format/#escaping-and-unicode
.replace("-", "_")
)


def safer_best_effort_version(value: str) -> str:
12 changes: 1 addition & 11 deletions setuptools/command/bdist_wheel.py
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@
from wheel.wheelfile import WheelFile

from .. import Command, __version__
from .._normalization import safer_name
from ..warnings import SetuptoolsDeprecationWarning
from .egg_info import egg_info as egg_info_cls

@@ -35,13 +36,6 @@
from _typeshed import ExcInfo


def safe_name(name: str) -> str:
"""Convert an arbitrary string to a standard distribution name
Any runs of non-alphanumeric/. characters are replaced with a single '-'.
"""
return re.sub("[^A-Za-z0-9.]+", "-", name)


def safe_version(version: str) -> str:
"""
Convert an arbitrary string to a standard version string
@@ -147,10 +141,6 @@ def get_abi_tag() -> str | None:
return abi


def safer_name(name: str) -> str:
return safe_name(name).replace("-", "_")


def safer_version(version: str) -> str:
return safe_version(version).replace("-", "_")

2 changes: 2 additions & 0 deletions setuptools/tests/config/test_setupcfg.py
Original file line number Diff line number Diff line change
@@ -422,6 +422,7 @@ def test_not_utf8(self, tmpdir):
with get_dist(tmpdir):
pass

@pytest.mark.xfail(reason="#4864")
def test_warn_dash_deprecation(self, tmpdir):
# warn_dash_deprecation() is a method in setuptools.dist
# remove this test and the method when no longer needed
@@ -439,6 +440,7 @@ def test_warn_dash_deprecation(self, tmpdir):
assert metadata.author_email == 'test@test.com'
assert metadata.maintainer_email == 'foo@foo.com'

@pytest.mark.xfail(reason="#4864")
def test_make_option_lowercase(self, tmpdir):
# remove this test and the method make_option_lowercase() in setuptools.dist
# when no longer needed
4 changes: 2 additions & 2 deletions setuptools/tests/test_bdist_wheel.py
Original file line number Diff line number Diff line change
@@ -252,9 +252,9 @@ def test_no_scripts(wheel_paths):


def test_unicode_record(wheel_paths):
path = next(path for path in wheel_paths if "unicode.dist" in path)
path = next(path for path in wheel_paths if "unicode_dist" in path)
with ZipFile(path) as zf:
record = zf.read("unicode.dist-0.1.dist-info/RECORD")
record = zf.read("unicode_dist-0.1.dist-info/RECORD")

assert "åäö_日本語.py".encode() in record

5 changes: 3 additions & 2 deletions setuptools/tests/test_dist.py
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
from setuptools import Distribution
from setuptools.dist import check_package_data, check_specifier

from .test_easy_install import make_nspkg_sdist
from .test_easy_install import make_trivial_sdist
from .test_find_packages import ensure_files
from .textwrap import DALS

@@ -25,7 +25,7 @@ def test_dist_fetch_build_egg(tmpdir):
def sdist_with_index(distname, version):
dist_dir = index.mkdir(distname)
dist_sdist = '%s-%s.tar.gz' % (distname, version)
make_nspkg_sdist(str(dist_dir.join(dist_sdist)), distname, version)
make_trivial_sdist(str(dist_dir.join(dist_sdist)), distname, version)
with dist_dir.join('index.html').open('w') as fp:
fp.write(
DALS(
@@ -138,6 +138,7 @@ def test_check_package_data(package_data, expected_message):
check_package_data(None, 'package_data', package_data)


@pytest.mark.xfail(reason="#4745")
def test_check_specifier():
# valid specifier value
attrs = {'name': 'foo', 'python_requires': '>=3.0, !=3.1'}
2 changes: 1 addition & 1 deletion setuptools/tests/test_dist_info.py
Original file line number Diff line number Diff line change
@@ -188,7 +188,7 @@ def test_dist_info_is_the_same_as_in_wheel(
dist_info = next(tmp_path.glob("dir_dist/*.dist-info"))

assert dist_info.name == wheel_dist_info.name
assert dist_info.name.startswith(f"{name.replace('-', '_')}-{version}{suffix}")
assert dist_info.name.startswith(f"my_proj-{version}{suffix}")
for file in "METADATA", "entry_points.txt":
assert read(dist_info / file) == read(wheel_dist_info / file)

18 changes: 11 additions & 7 deletions setuptools/tests/test_easy_install.py
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@
import setuptools.command.easy_install as ei
from pkg_resources import Distribution as PRDistribution, normalize_path, working_set
from setuptools import sandbox
from setuptools._normalization import safer_name
from setuptools.command.easy_install import PthDistributions
from setuptools.dist import Distribution
from setuptools.sandbox import run_setup
@@ -669,11 +670,11 @@ def test_setup_requires_override_nspkg(self, use_setup_cfg):

with contexts.save_pkg_resources_state():
with contexts.tempdir() as temp_dir:
foobar_1_archive = os.path.join(temp_dir, 'foo.bar-0.1.tar.gz')
foobar_1_archive = os.path.join(temp_dir, 'foo_bar-0.1.tar.gz')
make_nspkg_sdist(foobar_1_archive, 'foo.bar', '0.1')
# Now actually go ahead an extract to the temp dir and add the
# extracted path to sys.path so foo.bar v0.1 is importable
foobar_1_dir = os.path.join(temp_dir, 'foo.bar-0.1')
foobar_1_dir = os.path.join(temp_dir, 'foo_bar-0.1')
os.mkdir(foobar_1_dir)
with tarfile.open(foobar_1_archive) as tf:
tf.extraction_filter = lambda member, path: member
@@ -696,7 +697,7 @@ def test_setup_requires_override_nspkg(self, use_setup_cfg):
len(foo.__path__) == 2):
print('FAIL')
if 'foo.bar-0.2' not in foo.__path__[0]:
if 'foo_bar-0.2' not in foo.__path__[0]:
print('FAIL')
"""
)
@@ -717,8 +718,8 @@ def test_setup_requires_override_nspkg(self, use_setup_cfg):
# Don't even need to install the package, just
# running the setup.py at all is sufficient
run_setup(test_setup_py, ['--name'])
except pkg_resources.VersionConflict:
self.fail(
except pkg_resources.VersionConflict: # pragma: nocover
pytest.fail(
'Installing setup.py requirements caused a VersionConflict'
)

@@ -1118,6 +1119,8 @@ def make_nspkg_sdist(dist_path, distname, version):
package with the same name as distname. The top-level package is
designated a namespace package).
"""
# Assert that the distname contains at least one period
assert '.' in distname

parts = distname.split('.')
nspackage = parts[0]
@@ -1206,10 +1209,11 @@ def create_setup_requires_package(
package itself is just 'test_pkg'.
"""

normalized_distname = safer_name(distname)
test_setup_attrs = {
'name': 'test_pkg',
'version': '0.0',
'setup_requires': ['%s==%s' % (distname, version)],
'setup_requires': [f'{normalized_distname}=={version}'],
'dependency_links': [os.path.abspath(path)],
}
if setup_attrs:
@@ -1258,7 +1262,7 @@ def create_setup_requires_package(
with open(os.path.join(test_pkg, 'setup.py'), 'w', encoding="utf-8") as f:
f.write(setup_py_template % test_setup_attrs)

foobar_path = os.path.join(path, '%s-%s.tar.gz' % (distname, version))
foobar_path = os.path.join(path, f'{normalized_distname}-{version}.tar.gz')
make_package(foobar_path, distname, version)

return test_pkg