浏览代码

Merge pull request #613 from minrk/refuse-setup-install-egg

disable bdist_egg unless explicitly requested
Steven Silvester 8 年之前
父节点
当前提交
b39a131e1f
共有 1 个文件被更改,包括 13 次插入0 次删除
  1. 13 0
      setup.py

+ 13 - 0
setup.py

@@ -8,6 +8,7 @@ from setuptools import setup, find_packages, Command
 from setuptools.command.sdist import sdist
 from setuptools.command.build_py import build_py
 from setuptools.command.egg_info import egg_info
+from setuptools.command.bdist_egg import bdist_egg
 from subprocess import check_call
 import os
 import sys
@@ -58,12 +59,23 @@ def js_prerelease(command, strict=False):
             command.run(self)
     return DecoratedCommand
 
+
 def update_package_data(distribution):
     """update build_py options to get package_data changes"""
     build_py = distribution.get_command_obj('build_py')
     build_py.finalize_options()
 
 
+class bdist_egg_disabled(bdist_egg):
+    """Disabled version of bdist_egg
+
+    Prevents setup.py install performing setuptools' default easy_install,
+    which it should never ever do.
+    """
+    def run(self):
+        sys.exit("Aborting implicit building of eggs. Use `pip install .` to install from source.")
+
+
 class NPM(Command):
     description = 'install package.json dependencies using npm'
 
@@ -134,6 +146,7 @@ setup_args = {
         'egg_info': js_prerelease(egg_info),
         'sdist': js_prerelease(sdist, strict=True),
         'jsdeps': NPM,
+        'bdist_egg': bdist_egg if 'bdist_egg' in sys.argv else bdist_egg_disabled,
     },
     'entry_points': {
         'console_scripts': [