Commit 78e2272d authored by PJ Eby's avatar PJ Eby

Added support for old-style RPMs (i.e. non-egg RPMs)

--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041238
parent 66e82581
# This is just a kludge so that bdist_rpm doesn't guess wrong about the
# distribution name and version, if the egg_info command is going to alter them
# distribution name and version, if the egg_info command is going to alter
# them, and another kludge to allow you to build old-style non-egg RPMs
from distutils.command.bdist_rpm import bdist_rpm as _bdist_rpm
class bdist_rpm(_bdist_rpm):
user_options = _bdist_rpm.user_options + [
('no-egg', None, "Don't install as an egg (may break the package!)")
]
boolean_options = _bdist_rpm.boolean_options + ['no-egg']
def initialize_options(self):
_bdist_rpm.initialize_options(self)
self.no_egg = None
def run(self):
self.run_command('egg_info') # ensure distro name is up-to-date
_bdist_rpm.run(self)
def _make_spec_file(self):
spec = _bdist_rpm._make_spec_file(self)
if not self.no_egg:
return spec
# Hack the spec file so that we install old-style
return [
line.replace(
"setup.py install ","setup.py install --old-and-unmanageable "
) for line in spec
]
......@@ -4,6 +4,16 @@ from distutils.command.install import install as _install
class install(_install):
"""Use easy_install to install the package, w/dependencies"""
user_options = _install.user_options + [
('old-and-unmanageable', None, "Try not to use this!"),
]
boolean_options = _install.boolean_options + ['old-and-unmanageable']
def initialize_options(self):
_install.initialize_options(self)
self.old_and_unmanageable = None
def handle_extra_path(self):
# We always ignore extra_path, because we always install eggs
# (you can always use install_* commands directly if needed)
......@@ -11,23 +21,24 @@ class install(_install):
self.extra_dirs = ''
def run(self):
calling_module = sys._getframe(1).f_globals.get('__name__','')
if calling_module != 'distutils.dist':
# We're not being run from the command line, so use old-style
# behavior. This is a bit kludgy, because a command might use
# dist.run_command() to run 'install', but bdist_dumb and
# bdist_wininst both call run directly at the moment.
# When this is part of the distutils, the old install behavior
# should probably be requested with a flag, or a different method.
if (self.old_and_unmanageable or
sys._getframe(1).f_globals.get('__name__','') != 'distutils.dist'
):
# Either we were asked for the old behavior, or we're not being
# run from the command line. This is a bit kludgy, because a
# command might use dist.run_command() to run 'install', but
# bdist_dumb and bdist_wininst both call run() directly right now.
return _install.run(self)
from setuptools.command.easy_install import easy_install
cmd = easy_install(
self.distribution, args="x", ignore_conflicts_at_my_risk=1,
root=self.root
)
cmd.ensure_finalized() # finalize before bdist_egg munges install cmd
self.run_command('bdist_egg')
args = [self.distribution.get_command_obj('bdist_egg').egg_output]
......@@ -39,3 +50,33 @@ class install(_install):
cmd.run()
setuptools.bootstrap_install_from = None
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment