Adjust the setup.py install deprecation notice when building RPM packages

Before:

    /usr/lib/python3.12/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
    !!

            ********************************************************************************
            Please avoid running ``setup.py`` directly.
            Instead, use pypa/build, pypa/installer, pypa/build or
            other standards-based tools.

            See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
            ********************************************************************************

    !!

After:

    /usr/lib/python3.12/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
    !!

            ********************************************************************************
            Please avoid running ``setup.py`` directly.
            Instead, use pypa/build, pypa/installer, pypa/build or
            other standards-based tools.

            Follow the current Python packaging guidelines when building
            Python RPM packages.

            See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html
            and https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/ for details.
            ********************************************************************************

    !!
This commit is contained in:
Miro Hrončok 2023-05-05 17:55:25 +02:00
parent 67b4ba944f
commit d01f5faf1f
2 changed files with 49 additions and 1 deletions

View File

@ -0,0 +1,41 @@
From 797316bb195387962758faaf85d6c453832ae61d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
Date: Fri, 5 May 2023 17:53:11 +0200
Subject: [PATCH] Adjust the setup.py install deprecation message and URL
But only when building RPM packages.
---
setuptools/command/install.py | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/setuptools/command/install.py b/setuptools/command/install.py
index dec4e32..704a317 100644
--- a/setuptools/command/install.py
+++ b/setuptools/command/install.py
@@ -1,6 +1,7 @@
from distutils.errors import DistutilsArgError
import inspect
import glob
+import os
import platform
import distutils.command.install as orig
@@ -36,8 +37,13 @@ class install(orig.install):
Please avoid running ``setup.py`` directly.
Instead, use pypa/build, pypa/installer, pypa/build or
other standards-based tools.
- """,
- see_url="https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html",
+ """
+ + ("""
+ Follow the current Python packaging guidelines when building
+ Python RPM packages.
+ """ if "RPM_BUILD_ROOT" in os.environ else ""),
+ see_url=("https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html" +
+ ("\nand https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/" if "RPM_BUILD_ROOT" in os.environ else "")),
# TODO: Document how to bootstrap setuptools without install
# (e.g. by unziping the wheel file)
# and then add a due_date to this warning.
--
2.40.0

View File

@ -19,7 +19,7 @@
Name: python-setuptools Name: python-setuptools
# When updating, update the bundled libraries versions bellow! # When updating, update the bundled libraries versions bellow!
Version: 67.7.2 Version: 67.7.2
Release: 1%{?dist} Release: 2%{?dist}
Summary: Easily build and distribute Python packages Summary: Easily build and distribute Python packages
# setuptools is MIT # setuptools is MIT
# platformdirs is MIT # platformdirs is MIT
@ -41,6 +41,10 @@ Source0: %{pypi_source %{srcname} %{version}}
# Some test deps are optional and either not desired or not available in Fedora, thus this patch removes them. # Some test deps are optional and either not desired or not available in Fedora, thus this patch removes them.
Patch: Remove-optional-or-unpackaged-test-deps.patch Patch: Remove-optional-or-unpackaged-test-deps.patch
# The `setup.py install` deprecation notice might be confusing for RPM packagers
# adjust it, but only when $RPM_BUILD_ROOT is set
Patch: Adjust-the-setup.py-install-deprecation-message.patch
BuildArch: noarch BuildArch: noarch
BuildRequires: python%{python3_pkgversion}-devel BuildRequires: python%{python3_pkgversion}-devel
@ -226,6 +230,9 @@ PYTHONPATH=$(pwd) %pytest \
%changelog %changelog
* Fri May 05 2023 Miro Hrončok <mhroncok@redhat.com> - 67.7.2-2
- Adjust the `setup.py install` deprecation notice when building RPM packages
* Fri Apr 21 2023 Charalampos Stratakis <cstratak@redhat.com> - 67.7.2-1 * Fri Apr 21 2023 Charalampos Stratakis <cstratak@redhat.com> - 67.7.2-1
- Update to 67.7.2 - Update to 67.7.2
- Fixes: rhbz#2144132 - Fixes: rhbz#2144132