Commit 29108200 authored by PJ Eby's avatar PJ Eby

EasyInstall now builds eggs in a temporary directory alongside the setup

script it's running.  This avoids it getting confused by projects with
non-standard distribution locations, and projects that may have various
eggs already sitting in their distribution directory.  It should probably
also do something like this for the build directory to ensure a clean,
fresh build, but it seems like overkill, since it only affects local
projects, not stuff that EasyInstall downloaded in the first place.

--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041111
parent ebe75f51
......@@ -1079,6 +1079,8 @@ Release Notes/Change History
This is used by the ``easy_install`` command to find possibly-conflicting
"unmanaged" packages when installing the distribution.
* Fixed the swapped ``-d`` and ``-b`` options of ``bdist_egg``.
0.5a8
* The "egg_info" command now always sets the distribution metadata to "safe"
forms of the distribution name and version, so that distribution files will
......
......@@ -12,7 +12,7 @@ __ http://peak.telecommunity.com/DevCenter/EasyInstall
"""
import sys, os.path, zipimport, shutil, tempfile, zipfile
from glob import glob
from setuptools import Command
from setuptools.sandbox import run_setup
from distutils import log, dir_util
......@@ -412,21 +412,21 @@ class easy_install(Command):
# .egg dirs or files are already built, so just return them
if dist_filename.lower().endswith('.egg'):
return [self.install_egg(dist_filename, True, tmpdir)]
if dist_filename.lower().endswith('.exe'):
elif dist_filename.lower().endswith('.exe'):
return [self.install_exe(dist_filename, tmpdir)]
# Anything else, try to extract and build
setup_base = tmpdir
if os.path.isfile(dist_filename):
unpack_archive(dist_filename, tmpdir, self.unpack_progress)
elif os.path.isdir(dist_filename):
tmpdir = dist_filename # ugh
setup_base = os.path.abspath(dist_filename)
# Find the setup.py file
from glob import glob
setup_script = os.path.join(tmpdir, 'setup.py')
setup_script = os.path.join(setup_base, 'setup.py')
if not os.path.exists(setup_script):
setups = glob(os.path.join(tmpdir, '*', 'setup.py'))
setups = glob(os.path.join(setup_base, '*', 'setup.py'))
if not setups:
raise DistutilsError(
"Couldn't find a setup script in %s" % dist_filename
......@@ -437,17 +437,17 @@ class easy_install(Command):
)
setup_script = setups[0]
self.build_egg(tmpdir, setup_script)
dist_dir = os.path.join(os.path.dirname(setup_script),'dist') # XXX
# Now run it, and return the result
return self.build_and_install(setup_script, setup_base, zip_ok)
eggs = []
for egg in glob(os.path.join(dist_dir,'*.egg')):
eggs.append(self.install_egg(egg, zip_ok, tmpdir))
if not eggs and not self.dry_run:
log.warn("No eggs found in %s (setup script problem?)", dist_dir)
return eggs
def egg_distribution(self, egg_path):
if os.path.isdir(egg_path):
......@@ -695,10 +695,10 @@ PYTHONPATH, or by being added to sys.path by your code.)
def build_egg(self, tmpdir, setup_script):
def build_and_install(self, setup_script, setup_base, zip_ok):
sys.modules.setdefault('distutils.command.bdist_egg', bdist_egg)
args = ['bdist_egg']
args = ['bdist_egg', '--dist-dir']
if self.verbose>2:
v = 'v' * self.verbose - 1
args.insert(0,'-'+v)
......@@ -707,33 +707,33 @@ PYTHONPATH, or by being added to sys.path by your code.)
if self.dry_run:
args.insert(0,'-n')
log.info("Running %s %s", setup_script[len(tmpdir)+1:], ' '.join(args))
dist_dir = tempfile.mkdtemp(prefix='egg-dist-tmp-', dir=setup_base)
try:
args.append(dist_dir)
log.info(
"Running %s %s", setup_script[len(setup_base)+1:],
' '.join(args)
)
try:
run_setup(setup_script, args)
except SystemExit, v:
raise DistutilsError(
"Setup script exited with %s" % (v.args[0],)
)
finally:
log.set_verbosity(self.verbose) # restore our log verbosity
eggs = []
for egg in glob(os.path.join(dist_dir,'*.egg')):
eggs.append(self.install_egg(egg, zip_ok, setup_base))
if not eggs and not self.dry_run:
log.warn("No eggs found in %s (setup script problem?)",
dist_dir)
return eggs
finally:
shutil.rmtree(dist_dir)
log.set_verbosity(self.verbose) # restore our log verbosity
def update_pth(self,dist):
......
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