From 28c1ba1e2a6d08edc03c73e29293a571888981f9 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Fri, 25 Oct 2024 11:13:55 +0100 Subject: [PATCH] Improved compatibility with future versions of `setuptools` (#638) --- docs/news.rst | 9 +++++++++ src/wheel/bdist_wheel.py | 19 +++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/docs/news.rst b/docs/news.rst index eda608a2..bfd2921b 100644 --- a/docs/news.rst +++ b/docs/news.rst @@ -1,6 +1,15 @@ Release Notes ============= +**UNRELEASED** + +- Added a redirection from ``wheel.bdist_wheel.bdist_wheel`` to + ``setuptools.command.bdist_wheel.bdist_wheel`` to improve compatibility with + ``setuptools``' latest fixes. + + Projects are still advised to migrate away from the deprecated module and import + the ``setuptools``' implementation explicitly. (PR by @abravalheri) + **0.44.0 (2024-08-04)** - Canonicalized requirements in METADATA file (PR by Wim Jeantine-Glenn) diff --git a/src/wheel/bdist_wheel.py b/src/wheel/bdist_wheel.py index 05d93eee..dd7b8629 100644 --- a/src/wheel/bdist_wheel.py +++ b/src/wheel/bdist_wheel.py @@ -1,7 +1,6 @@ +from typing import TYPE_CHECKING from warnings import warn -from ._bdist_wheel import bdist_wheel as bdist_wheel - warn( "The 'wheel' package is no longer the canonical location of the 'bdist_wheel' " "command, and will be removed in a future release. Please update to setuptools " @@ -9,3 +8,19 @@ DeprecationWarning, stacklevel=1, ) + +if TYPE_CHECKING: + from ._bdist_wheel import bdist_wheel as bdist_wheel +else: + try: + # Better integration/compatibility with setuptools: + # in the case new fixes or PEPs are implemented in setuptools + # there is no need to backport them to the deprecated code base. + # This is useful in the case of old packages in the ecosystem + # that are still used but have low maintenance. + from setuptools.command.bdist_wheel import bdist_wheel + except ImportError: + # Only used in the case of old setuptools versions. + # If the user wants to get the latest fixes/PEPs, + # they are encouraged to address the deprecation warning. + from ._bdist_wheel import bdist_wheel as bdist_wheel