diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2021-11-07 04:48:16 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-07 04:48:16 -0500 |
| commit | dec4d0b3edd20614dced9c5c9203e755a4f9addd (patch) | |
| tree | 4325d0bc6d2814160920c893bb39c83e8633b1be | |
| parent | 7a1411ffc1cce75cc5251071154ff53f3fd0444d (diff) | |
| parent | 4a979b6f38415d8841f650234dff301ed63658e7 (diff) | |
| download | python-setuptools-git-dec4d0b3edd20614dced9c5c9203e755a4f9addd.tar.gz | |
Merge pull request #2857 from abravalheri/deprecated-distutils-command
Deprecate support for commands inheriting from distutils
| -rw-r--r-- | changelog.d/2856.deprecation.rst | 2 | ||||
| -rw-r--r-- | setuptools/command/egg_info.py | 5 | ||||
| -rw-r--r-- | setuptools/tests/test_sdist.py | 20 |
3 files changed, 9 insertions, 18 deletions
diff --git a/changelog.d/2856.deprecation.rst b/changelog.d/2856.deprecation.rst new file mode 100644 index 00000000..fe4144b4 --- /dev/null +++ b/changelog.d/2856.deprecation.rst @@ -0,0 +1,2 @@ +Support for custom commands that inherit directly from ``distutils`` is +**deprecated**. Users should extend classes provided by setuptools instead. diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 8ae27d87..f2210292 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -621,10 +621,11 @@ class manifest_maker(sdist): if hasattr(build_py, 'get_data_files_without_manifest'): return build_py.get_data_files_without_manifest() - log.warn( + warnings.warn( "Custom 'build_py' does not implement " "'get_data_files_without_manifest'.\nPlease extend command classes" - " from setuptools instead of distutils." + " from setuptools instead of distutils.", + SetuptoolsDeprecationWarning ) return build_py.get_data_files() diff --git a/setuptools/tests/test_sdist.py b/setuptools/tests/test_sdist.py index e6d8e908..66f46ad0 100644 --- a/setuptools/tests/test_sdist.py +++ b/setuptools/tests/test_sdist.py @@ -11,6 +11,7 @@ from unittest import mock import pytest import pkg_resources +from setuptools import SetuptoolsDeprecationWarning from setuptools.command.sdist import sdist from setuptools.command.egg_info import manifest_maker from setuptools.dist import Distribution @@ -148,8 +149,7 @@ class TestSdistTest: self.assert_package_data_in_manifest(cmd) - @mock.patch('setuptools.command.egg_info.log') - def test_custom_build_py(self, log_stub): + def test_custom_build_py(self): """ Ensure projects defining custom build_py don't break when creating sdists (issue #2849) @@ -180,25 +180,13 @@ class TestSdistTest: cmd.distribution.cmdclass = {'build_py': CustomBuildPy} assert cmd.distribution.get_command_class('build_py') == CustomBuildPy - with quiet(): + msg = "setuptools instead of distutils" + with quiet(), pytest.warns(SetuptoolsDeprecationWarning, match=msg): cmd.run() using_custom_command_guard.assert_called() self.assert_package_data_in_manifest(cmd) - warn_stub = log_stub.warn - warn_stub.assert_called() - for call in warn_stub.call_args_list: - args, _kw = call - if "setuptools instead of distutils" in args[0]: - return - else: - raise AssertionError( - "The user should have been warned to extend setuptools command" - " classes instead of distutils", - warn_stub.call_args_list - ) - def test_setup_py_exists(self): dist = Distribution(SETUP_ATTRS) dist.script_name = 'foo.py' |
