Support setuptools v69.0.3+

This commit is contained in:
jxy_git 2024-04-08 15:58:21 +08:00
parent 71f5cee278
commit e44adfe60c
2 changed files with 119 additions and 23 deletions

View File

@ -0,0 +1,101 @@
From b3fc602f10ef40a3543d6d47a93ae0cda234fdad Mon Sep 17 00:00:00 2001
From: Henry Schreiner <HenrySchreinerIII@gmail.com>
Date: Tue, 23 Jan 2024 12:58:30 +0100
Subject: [PATCH] tests: support setuptools v69.0.3+ (#722)
* tests: support setuptools v69.0.3+
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* tests: missed one more normalization fix
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* fix: add MANIFEST.in for old setuptools in tests
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* tests: used the wrong name
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
---------
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
---
tests/packages/test-setuptools/MANIFEST.in | 1 +
tests/test_projectbuilder.py | 6 ++++--
tests/test_self_packaging.py | 1 +
tests/test_util.py | 6 ++++--
4 files changed, 10 insertions(+), 4 deletions(-)
create mode 100644 tests/packages/test-setuptools/MANIFEST.in
diff --git a/tests/packages/test-setuptools/MANIFEST.in b/tests/packages/test-setuptools/MANIFEST.in
new file mode 100644
index 0000000..e69e3cf
--- /dev/null
+++ b/tests/packages/test-setuptools/MANIFEST.in
@@ -0,0 +1 @@
+include pyproject.toml setup.cfg
diff --git a/tests/test_projectbuilder.py b/tests/test_projectbuilder.py
index d424680..c55cd09 100644
--- a/tests/test_projectbuilder.py
+++ b/tests/test_projectbuilder.py
@@ -502,7 +502,8 @@ def test_metadata_path_no_prepare(tmp_dir, package_test_no_prepare):
pathlib.Path(builder.metadata_path(tmp_dir)),
).metadata
- assert metadata['name'] == 'test-no-prepare'
+ # Setuptools < v69.0.3 (https://github.com/pypa/setuptools/pull/4159) normalized this to dashes
+ assert metadata['name'].replace('-', '_') == 'test_no_prepare'
assert metadata['Version'] == '1.0.0'
@@ -513,7 +514,8 @@ def test_metadata_path_with_prepare(tmp_dir, package_test_setuptools):
pathlib.Path(builder.metadata_path(tmp_dir)),
).metadata
- assert metadata['name'] == 'test-setuptools'
+ # Setuptools < v69.0.3 (https://github.com/pypa/setuptools/pull/4159) normalized this to dashes
+ assert metadata['name'].replace('-', '_') == 'test_setuptools'
assert metadata['Version'] == '1.0.0'
diff --git a/tests/test_self_packaging.py b/tests/test_self_packaging.py
index fb1d124..3a436ef 100644
--- a/tests/test_self_packaging.py
+++ b/tests/test_self_packaging.py
@@ -27,6 +27,7 @@ sdist_files = {
'tests/constraints.txt',
'tests/packages/test-cant-build-via-sdist/some-file-that-is-needed-for-build.txt',
'tests/packages/test-no-project/empty.txt',
+ 'tests/packages/test-setuptools/MANIFEST.in',
'tox.ini',
}
diff --git a/tests/test_util.py b/tests/test_util.py
index 74f2cf1..b6252e8 100644
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -12,7 +12,8 @@ import build.util
def test_wheel_metadata(package_test_setuptools, isolated):
metadata = build.util.project_wheel_metadata(package_test_setuptools, isolated)
- assert metadata['name'] == 'test-setuptools'
+ # Setuptools < v69.0.3 (https://github.com/pypa/setuptools/pull/4159) normalized this to dashes
+ assert metadata['name'].replace('-', '_') == 'test_setuptools'
assert metadata['version'] == '1.0.0'
@@ -39,6 +40,7 @@ def test_wheel_metadata_isolation(package_test_flit):
def test_with_get_requires(package_test_metadata):
metadata = build.util.project_wheel_metadata(package_test_metadata)
- assert metadata['name'] == 'test-metadata'
+ # Setuptools < v69.0.3 (https://github.com/pypa/setuptools/pull/4159) normalized this to dashes
+ assert metadata['name'].replace('-', '_') == 'test_metadata'
assert str(metadata['version']) == '1.0.0'
assert metadata['summary'] == 'hello!'
--
2.43.0

View File

@ -2,12 +2,13 @@
Name: python-%{pypi_name}
Version: 1.0.3
Release: 1
Release: 2
Summary: A simple, correct PEP517 package builder
License: MIT
URL: https://github.com/pypa/build
Source0: %{url}/archive/%{version}/%{pypi_name}-%{version}.tar.gz
# https://github.com/pypa/build/pull/722
Patch0: Support-setuptools-v69.0.3+.patch
BuildArch: noarch
BuildRequires: python3-devel
@ -29,19 +30,18 @@ BuildRequires: python3-tox-current-env
%description
A simple, correct PEP517 package builder.
%package -n python3-%{pypi_name}
Summary: %{summary}
Provides: python-%{pypi_name} = %{version}-%{release}
%description -n python3-%{pypi_name}
A simple, correct PEP517 package builder.
%pyproject_extras_subpkg -n python3-%{pypi_name} virtualenv
%prep
%autosetup -p1 -n %{pypi_name}-%{version}
sed -i '/sys\.platform\.startswith('\''win'\''):/,/build\.ProjectBuilder(test_no_permission)/ s/^/# /' tests/test_projectbuilder.py
%build
%pyproject_build
@ -51,15 +51,7 @@ A simple, correct PEP517 package builder.
%check
# The skipped tests require internet
TOX_TESTENV_PASSENV="${TOX_TESTENV_PASSENV:-*}" \
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}" \
PATH="%{buildroot}%{_bindir}:$PATH" \
PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}}" \
PYTHONDONTWRITEBYTECODE=1 \
%{?__pytest_addopts:PYTEST_ADDOPTS="${PYTEST_ADDOPTS:-} %{__pytest_addopts}"} \
PYTEST_XDIST_AUTO_NUM_WORKERS=%{_smp_build_ncpus} \
%{__python3} -m tox -e py%{python3_version_nodots} --current-env \
-- -k "not (test_build_package or \
%pytest -- -k "not (test_build_package or \
test_build_package_via_sdist or \
test_output[via-sdist-isolation] or \
test_output[wheel-direct-isolation] or \
@ -78,6 +70,9 @@ PYTEST_XDIST_AUTO_NUM_WORKERS=%{_smp_build_ncpus} \
%{python3_sitelib}/%{pypi_name}*.dist-info/
%changelog
* Mon Apr 08 2024 jiangxinyu <jiangxinyu@kylinos.cn> - 1.0.3-2
- Support setuptools v69.0.3+
* Mon Nov 20 2023 jiangxinyu <jiangxinyu@kylinos.cn> - 1.0.3-1
- Update package to version 1.0.3