Skip to content

Commit 86f7424

Browse files
committed
Track latest setupbase
1 parent be2892e commit 86f7424

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

{{cookiecutter.github_project_name}}/setupbase.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@
2525
if os.path.exists('MANIFEST'): os.remove('MANIFEST')
2626

2727

28-
from distutils.core import setup
2928
from distutils.cmd import Command
3029
from distutils.command.build_py import build_py
3130
from distutils.command.sdist import sdist
32-
from distutils.dist import Distribution
3331
from distutils import log
3432

33+
from setuptools.command.develop import develop
34+
from setuptools.command.bdist_egg import bdist_egg
35+
3536
try:
3637
from wheel.bdist_wheel import bdist_wheel
3738
except ImportError:
@@ -69,11 +70,6 @@ def list2cmdline(cmd_list):
6970
skip_npm = False
7071

7172

72-
# For some commands, use setuptools. Note that we do NOT list install here!
73-
if 'develop' in sys.argv or any(a.startswith('bdist') for a in sys.argv):
74-
import setuptools
75-
76-
7773
# ---------------------------------------------------------------------------
7874
# Public Functions
7975
# ---------------------------------------------------------------------------
@@ -127,6 +123,17 @@ def update_package_data(distribution):
127123
build_py.finalize_options()
128124

129125

126+
class bdist_egg_disabled(bdist_egg):
127+
"""Disabled version of bdist_egg
128+
129+
Prevents setup.py install performing setuptools' default easy_install,
130+
which it should never ever do.
131+
"""
132+
def run(self):
133+
sys.exit("Aborting implicit building of eggs. Use `pip install .` "
134+
" to install from source.")
135+
136+
130137
def create_cmdclass(prerelease_cmd=None, package_data_spec=None,
131138
data_files_spec=None):
132139
"""Create a command class with the given optional prerelease class.
@@ -162,18 +169,22 @@ def create_cmdclass(prerelease_cmd=None, package_data_spec=None,
162169
wrapper = functools.partial(_wrap_command, wrapped)
163170
handle_files = _get_file_handler(package_data_spec, data_files_spec)
164171

172+
if 'bdist_egg' in sys.argv:
173+
egg = wrapper(bdist_egg, strict=True)
174+
else:
175+
egg = bdist_egg_disabled
176+
165177
cmdclass = dict(
166178
build_py=wrapper(build_py, strict=is_repo),
179+
bdist_egg=egg,
167180
sdist=wrapper(sdist, strict=True),
168-
handle_files=handle_files
181+
handle_files=handle_files,
169182
)
170183

171184
if bdist_wheel:
172185
cmdclass['bdist_wheel'] = wrapper(bdist_wheel, strict=True)
173186

174-
if 'develop' in sys.argv:
175-
from setuptools.command.develop import develop
176-
cmdclass['develop'] = wrapper(develop, strict=True)
187+
cmdclass['develop'] = wrapper(develop, strict=True)
177188
return cmdclass
178189

179190

@@ -231,6 +242,7 @@ def combine_commands(*commands):
231242
"""Return a Command that combines several commands."""
232243

233244
class CombinedCommand(Command):
245+
user_options = []
234246

235247
def initialize_options(self):
236248
self.commands = []

0 commit comments

Comments
 (0)