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