From 2d607a9e59aa854b387f22d79301acb8739b133a Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 10 May 2020 13:19:52 -0400 Subject: Emit deprecation warning when 2to3 is used. Ref #2086. --- setuptools/lib2to3_ex.py | 7 +++++++ setuptools/tests/test_test.py | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/setuptools/lib2to3_ex.py b/setuptools/lib2to3_ex.py index 4b1a73fe..817dce40 100644 --- a/setuptools/lib2to3_ex.py +++ b/setuptools/lib2to3_ex.py @@ -7,6 +7,7 @@ Customized Mixin2to3 support: This module raises an ImportError on Python 2. """ +import warnings from distutils.util import Mixin2to3 as _Mixin2to3 from distutils import log from lib2to3.refactor import RefactoringTool, get_fixers_from_package @@ -33,6 +34,12 @@ class Mixin2to3(_Mixin2to3): return if not files: return + + warnings.warn( + "2to3 support is deprecated. Please migrate to " + "a single-codebase solution or roll your own " + "conversion process.", + DeprecationWarning) log.info("Fixing " + " ".join(files)) self.__build_fixer_names() self.__exclude_fixers() diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 8ee70a7e..0f77d8ff 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -73,7 +73,11 @@ def quiet_log(): log.set_verbosity(0) +ack_2to3 = pytest.mark.filterwarnings('ignore:2to3 support is deprecated') + + @pytest.mark.usefixtures('sample_test', 'quiet_log') +@ack_2to3 def test_test(capfd): params = dict( name='foo', @@ -124,6 +128,7 @@ def test_tests_are_run_once(capfd): @pytest.mark.usefixtures('sample_test') +@ack_2to3 def test_warns_deprecation(capfd): params = dict( name='foo', @@ -149,6 +154,7 @@ def test_warns_deprecation(capfd): @pytest.mark.usefixtures('sample_test') +@ack_2to3 def test_deprecation_stderr(capfd): params = dict( name='foo', -- cgit v1.2.3 From b286525862fa0a4839f37b5836a20178293d7335 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 10 May 2020 13:27:50 -0400 Subject: Update changelog. --- changelog.d/2086.change.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/2086.change.rst diff --git a/changelog.d/2086.change.rst b/changelog.d/2086.change.rst new file mode 100644 index 00000000..9fa54e5a --- /dev/null +++ b/changelog.d/2086.change.rst @@ -0,0 +1 @@ +Deprecate 'use_2to3' functionality. Packagers are encouraged to use single-source solutions or build tool chains to manage conversions outside of setuptools. -- cgit v1.2.3 From 0fffb84a1bc7925fbf862365787ab20e9ab89a0c Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 10 May 2020 14:03:30 -0400 Subject: In the deprecation warning, acknowledge that it's only for projects that still require Python 2 support. --- setuptools/lib2to3_ex.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/setuptools/lib2to3_ex.py b/setuptools/lib2to3_ex.py index 817dce40..6d9b147c 100644 --- a/setuptools/lib2to3_ex.py +++ b/setuptools/lib2to3_ex.py @@ -36,9 +36,10 @@ class Mixin2to3(_Mixin2to3): return warnings.warn( - "2to3 support is deprecated. Please migrate to " - "a single-codebase solution or roll your own " - "conversion process.", + "2to3 support is deprecated. If the project still " + "requires Python 2 support, please migrate to " + "a single-codebase solution or employ an " + "independent conversion process.", DeprecationWarning) log.info("Fixing " + " ".join(files)) self.__build_fixer_names() -- cgit v1.2.3 From a354d7bc1b7737fc1b4a9d238a247364035ab3d8 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 10 May 2020 14:23:10 -0400 Subject: Use the SetuptoolsDeprecationWarning to make the warning more visible outside test runners. --- setuptools/lib2to3_ex.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setuptools/lib2to3_ex.py b/setuptools/lib2to3_ex.py index 6d9b147c..017f7285 100644 --- a/setuptools/lib2to3_ex.py +++ b/setuptools/lib2to3_ex.py @@ -13,6 +13,7 @@ from distutils import log from lib2to3.refactor import RefactoringTool, get_fixers_from_package import setuptools +from ._deprecation_warning import SetuptoolsDeprecationWarning class DistutilsRefactoringTool(RefactoringTool): @@ -40,7 +41,7 @@ class Mixin2to3(_Mixin2to3): "requires Python 2 support, please migrate to " "a single-codebase solution or employ an " "independent conversion process.", - DeprecationWarning) + SetuptoolsDeprecationWarning) log.info("Fixing " + " ".join(files)) self.__build_fixer_names() self.__exclude_fixers() -- cgit v1.2.3