Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove eggsecutable #2545

Merged
merged 2 commits into from Jan 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/2545.breaking.rst
@@ -0,0 +1 @@
Removed support for eggsecutables.
2 changes: 0 additions & 2 deletions setup.py
Expand Up @@ -171,8 +171,6 @@ def _restore_install_lib(self):
"dependency_links.txt = setuptools.command.egg_info:overwrite_arg",
],
"console_scripts": list(_gen_console_scripts()),
"setuptools.installation":
['eggsecutable = setuptools.command.easy_install:bootstrap'],
},
dependency_links=[
pypi_link(
Expand Down
49 changes: 2 additions & 47 deletions setuptools/command/bdist_egg.py
Expand Up @@ -2,7 +2,6 @@

Build .egg distributions"""

from distutils.errors import DistutilsSetupError
from distutils.dir_util import remove_tree, mkpath
from distutils import log
from types import CodeType
Expand All @@ -11,12 +10,10 @@
import re
import textwrap
import marshal
import warnings

from pkg_resources import get_build_platform, Distribution, ensure_directory
from pkg_resources import EntryPoint
from setuptools.extension import Library
from setuptools import Command, SetuptoolsDeprecationWarning
from setuptools import Command

from sysconfig import get_path, get_python_version

Expand Down Expand Up @@ -268,49 +265,7 @@ def zip_safe(self):
return analyze_egg(self.bdist_dir, self.stubs)

def gen_header(self):
epm = EntryPoint.parse_map(self.distribution.entry_points or '')
ep = epm.get('setuptools.installation', {}).get('eggsecutable')
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' "
"or refer to a module" % (ep,)
)

pyver = '{}.{}'.format(*sys.version_info)
pkg = ep.module_name
full = '.'.join(ep.attrs)
base = ep.attrs[0]
basename = os.path.basename(self.egg_output)

header = (
"#!/bin/sh\n"
'if [ `basename $0` = "%(basename)s" ]\n'
'then exec python%(pyver)s -c "'
"import sys, os; sys.path.insert(0, os.path.abspath('$0')); "
"from %(pkg)s import %(base)s; sys.exit(%(full)s())"
'" "$@"\n'
'else\n'
' echo $0 is not the correct name for this egg file.\n'
' echo Please rename it back to %(basename)s and try again.\n'
' exec false\n'
'fi\n'
) % locals()

if not self.dry_run:
mkpath(os.path.dirname(self.egg_output), dry_run=self.dry_run)
f = open(self.egg_output, 'w')
f.write(header)
f.close()
return 'a'
return 'w'

def copy_metadata_to(self, target_dir):
"Copy metadata (egg info) to the target_dir"
Expand Down
10 changes: 0 additions & 10 deletions setuptools/command/easy_install.py
Expand Up @@ -2284,16 +2284,6 @@ def current_umask():
return tmp


def bootstrap():
# This function is called when setuptools*.egg is run using /bin/sh
import setuptools

argv0 = os.path.dirname(setuptools.__path__[0])
sys.argv[0] = argv0
sys.argv.append(argv0)
main()


def main(argv=None, **kw):
from setuptools import setup
from setuptools.dist import Distribution
Expand Down
15 changes: 0 additions & 15 deletions setuptools/tests/test_bdist_egg.py
Expand Up @@ -7,7 +7,6 @@
import pytest

from setuptools.dist import Distribution
from setuptools import SetuptoolsDeprecationWarning

from . import contexts

Expand Down Expand Up @@ -65,17 +64,3 @@ 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()