From ae72d635578417b8c606feef85d153a393bed24d Mon Sep 17 00:00:00 2001 From: Miro Hrončok Date: Jun 11 2020 22:55:19 +0000 Subject: [PATCH 1/4] Proof of concept: Validate bundled provides in %check We repeatadly forget to update the list of bndled provides. This is a proof of concept of validating the provides in %check. It is not very elegant, but if we like the idea, I can macronize most of this, so the usage would only be: %global bundled_file pkg_resources/_vendor/vendored.txt %{lua: bundled = { packaging="16.8", pyparsing="2.2.1", six="1.10.0", appdirs="1.4.3", } } %package -n python3-setuptools ... %bundled_provides -f python3dist({name}) %check ... %validate_bundles And we could reuse it in setuptools, pip, pipenv... --- diff --git a/python-setuptools.spec b/python-setuptools.spec index a714c7a..7e06986 100644 --- a/python-setuptools.spec +++ b/python-setuptools.spec @@ -45,6 +45,30 @@ BuildRequires: python3-wheel BuildRequires: python3-rpm-generators %endif # without bootstrap +# Virtual provides for the packages bundled by setuptools. +# You can find the versions in setuptools/setuptools/_vendor/vendored.txt +# We cannot read them at this point, but we can assert their validity in %%check +%global bundled_count 4 +%{lua: + bundled = { + packaging="16.8", + pyparsing="2.2.1", + six="1.10.0", + appdirs="1.4.3", + } +} +%global bundled_file pkg_resources/_vendor/vendored.txt +%global bundled %{lua: + for name in pairs(bundled) do + print("Provides: bundled(python3dist(" .. name .. ")) = " .. bundled[name] .. "\\n") + end +} +%global bundled_file_expected %{lua: + for name in pairs(bundled) do + print(name .. "==" .. bundled[name] .. "\\\\n") + end +} + %description Setuptools is a collection of enhancements to the Python distutils that allow you to more easily build and distribute Python packages, especially ones that @@ -53,15 +77,6 @@ have dependencies on other packages. This package also contains the runtime components of setuptools, necessary to execute the software that requires pkg_resources. -# Virtual provides for the packages bundled by setuptools. -# You can find the versions in setuptools/setuptools/_vendor/vendored.txt -%global bundled %{expand: -Provides: bundled(python3dist(packaging)) = 16.8 -Provides: bundled(python3dist(pyparsing)) = 2.2.1 -Provides: bundled(python3dist(six)) = 1.10.0 -Provides: bundled(python3dist(appdirs)) = 1.4.3 -} - %package -n python3-setuptools Summary: Easily build and distribute Python 3 packages Conflicts: python-setuptools < %{version}-%{release} @@ -150,6 +165,13 @@ PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=$(pwd) pytest-%{python3_version} \ --ignore=pavement.py %endif # with tests +# Assert our bundling info is correct +test %{bundled_count} -eq $(wc -l < %{bundled_file}) +# NB: this is not bash, so <(sort ...) doesn't work +sort %{bundled_file} > upstream_info +echo -ne '%{bundled_file_expected}' | sort > downstream_info +diff upstream_info downstream_info + %files -n python3-setuptools %license LICENSE From 73d056de7bef85a7fcdb2a70b6aae14b61812bb9 Mon Sep 17 00:00:00 2001 From: Miro Hrončok Date: Jun 15 2020 10:57:32 +0000 Subject: [PATCH 2/4] Fixup: Drop no longer useful bundled_count --- diff --git a/python-setuptools.spec b/python-setuptools.spec index 7e06986..f99edcf 100644 --- a/python-setuptools.spec +++ b/python-setuptools.spec @@ -48,7 +48,6 @@ BuildRequires: python3-rpm-generators # Virtual provides for the packages bundled by setuptools. # You can find the versions in setuptools/setuptools/_vendor/vendored.txt # We cannot read them at this point, but we can assert their validity in %%check -%global bundled_count 4 %{lua: bundled = { packaging="16.8", @@ -166,7 +165,6 @@ PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=$(pwd) pytest-%{python3_version} \ %endif # with tests # Assert our bundling info is correct -test %{bundled_count} -eq $(wc -l < %{bundled_file}) # NB: this is not bash, so <(sort ...) doesn't work sort %{bundled_file} > upstream_info echo -ne '%{bundled_file_expected}' | sort > downstream_info From 87a0971296d03c48b4d08c4c770937788d76f143 Mon Sep 17 00:00:00 2001 From: Miro Hrončok Date: Jun 15 2020 10:58:05 +0000 Subject: [PATCH 3/4] Fixup: Use nicer diff and ignore all whitespace changes (newlines and amount) --- diff --git a/python-setuptools.spec b/python-setuptools.spec index f99edcf..3be98a2 100644 --- a/python-setuptools.spec +++ b/python-setuptools.spec @@ -168,7 +168,7 @@ PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=$(pwd) pytest-%{python3_version} \ # NB: this is not bash, so <(sort ...) doesn't work sort %{bundled_file} > upstream_info echo -ne '%{bundled_file_expected}' | sort > downstream_info -diff upstream_info downstream_info +diff -Bbu upstream_info downstream_info %files -n python3-setuptools From 8194da148446b80cbed0dbea53004d7339e0e3b3 Mon Sep 17 00:00:00 2001 From: Miro Hrončok Date: Jun 15 2020 11:00:04 +0000 Subject: [PATCH 4/4] Fixup: Make the bunled check part of %check even --without tests Also, run it first, it is orders of magnitude faster. --- diff --git a/python-setuptools.spec b/python-setuptools.spec index 3be98a2..c74024f 100644 --- a/python-setuptools.spec +++ b/python-setuptools.spec @@ -156,20 +156,20 @@ install -p dist/%{python_wheelname} -t %{buildroot}%{python_wheeldir} %endif -%if %{with tests} %check -# --ignore=pavement.py: -# pavement.py is only used by upstream to do releases and vendoring, we don't ship it -PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=$(pwd) pytest-%{python3_version} \ - --ignore=pavement.py -%endif # with tests - # Assert our bundling info is correct # NB: this is not bash, so <(sort ...) doesn't work sort %{bundled_file} > upstream_info echo -ne '%{bundled_file_expected}' | sort > downstream_info diff -Bbu upstream_info downstream_info +%if %{with tests} +# --ignore=pavement.py: +# pavement.py is only used by upstream to do releases and vendoring, we don't ship it +PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=$(pwd) pytest-%{python3_version} \ + --ignore=pavement.py +%endif # with tests + %files -n python3-setuptools %license LICENSE