diff --git a/changelog.d/1557.change.rst b/changelog.d/1557.change.rst new file mode 100644 index 0000000000..9f8af4a6cc --- /dev/null +++ b/changelog.d/1557.change.rst @@ -0,0 +1 @@ +Deprecated eggsecutable scripts and updated docs. diff --git a/docs/setuptools.txt b/docs/setuptools.txt index f84837ff48..efcd0a8671 100644 --- a/docs/setuptools.txt +++ b/docs/setuptools.txt @@ -560,6 +560,8 @@ Services and Plugins`_. "Eggsecutable" Scripts ---------------------- +.. deprecated:: 45.3.0 + Occasionally, there are situations where it's desirable to make an ``.egg`` file directly executable. You can do this by including an entry point such as the following:: diff --git a/setuptools/command/bdist_egg.py b/setuptools/command/bdist_egg.py index 98470f1715..1b28d4c938 100644 --- a/setuptools/command/bdist_egg.py +++ b/setuptools/command/bdist_egg.py @@ -11,13 +11,14 @@ import re import textwrap import marshal +import warnings from setuptools.extern import six from pkg_resources import get_build_platform, Distribution, ensure_directory from pkg_resources import EntryPoint from setuptools.extension import Library -from setuptools import Command +from setuptools import Command, SetuptoolsDeprecationWarning try: # Python 2.7 or >=3.2 @@ -278,6 +279,12 @@ def gen_header(self): if ep is None: return 'w' # not an eggsecutable, do it the usual way. + warnings.warn( + "Eggsecutables are deprecated and will be removed in a future " + "version.", + SetuptoolsDeprecationWarning + ) + if not ep.attrs or ep.extras: raise DistutilsSetupError( "eggsecutable entry point (%r) cannot have 'extras' " diff --git a/setuptools/tests/test_bdist_egg.py b/setuptools/tests/test_bdist_egg.py index fb5b90b1a3..8760ea304c 100644 --- a/setuptools/tests/test_bdist_egg.py +++ b/setuptools/tests/test_bdist_egg.py @@ -7,6 +7,7 @@ import pytest from setuptools.dist import Distribution +from setuptools import SetuptoolsDeprecationWarning from . import contexts @@ -64,3 +65,17 @@ def test_exclude_source_files(self, setup_context, user_override): names = list(zi.filename for zi in zip.filelist) assert 'hi.pyc' in names assert 'hi.py' not in names + + def test_eggsecutable_warning(self, setup_context, user_override): + dist = Distribution(dict( + script_name='setup.py', + script_args=['bdist_egg'], + name='foo', + py_modules=['hi'], + entry_points={ + 'setuptools.installation': + ['eggsecutable = my_package.some_module:main_func']}, + )) + dist.parse_command_line() + with pytest.warns(SetuptoolsDeprecationWarning): + dist.run_commands()