Commit 0b3d2302 authored by Ronny Pfannschmidt's avatar Ronny Pfannschmidt

move the rest of the path handling code from develop to easy_install

also resuffle the path handlers a bit, hopefully everything works now

--HG--
branch : distribute
extra : rebase_source : dc8e4217f5832b15e8f7287c95732bc68d1e1cf5
parent c14e1a13
......@@ -35,25 +35,6 @@ class develop(easy_install):
self.always_copy_from = '.' # always copy eggs installed in curdir
def _expand_attrs(self, attrs):
for attr in attrs:
val = getattr(self, attr)
if val is not None:
if os.name == 'posix' or os.name == 'nt':
val = os.path.expanduser(val)
val = subst_vars(val, self.config_vars)
setattr(self, attr, val)
def expand_basedirs(self):
"""Calls `os.path.expanduser` on install_base, install_platbase and
root."""
self._expand_attrs(['install_base', 'install_platbase', 'root'])
def expand_dirs(self):
"""Calls `os.path.expanduser` on install dirs."""
self._expand_attrs(['install_purelib', 'install_platlib',
'install_lib', 'install_headers',
'install_scripts', 'install_data',])
def finalize_options(self):
ei = self.get_finalized_command("egg_info")
......
......@@ -17,13 +17,19 @@ from distutils import log, dir_util
from distutils.util import convert_path, subst_vars
from distutils.sysconfig import get_python_lib, get_config_vars
from distutils.errors import DistutilsArgError, DistutilsOptionError, \
DistutilsError
DistutilsError, DistutilsPlatformError
from distutils.command.install import INSTALL_SCHEMES, SCHEME_KEYS
from setuptools.archive_util import unpack_archive
from setuptools.package_index import PackageIndex, parse_bdist_wininst
from setuptools.package_index import PackageIndex
from setuptools.package_index import URL_SCHEME
from setuptools.command import bdist_egg, egg_info
from pkg_resources import *
from pkg_resources import yield_lines, normalize_path, resource_string, \
ensure_directory, get_distribution, find_distributions, \
Environment, Requirement, Distribution, \
PathMetadata, EggMetadata, WorkingSet, \
DistributionNotFound, VersionConflict, \
DEVELOP_DIST
sys_executable = os.path.normpath(sys.executable)
__all__ = [
......@@ -31,15 +37,8 @@ __all__ = [
'main', 'get_exe_prefixes',
]
if sys.version < "2.6":
USER_BASE = None
USER_SITE = None
HAS_USER_SITE = False
else:
from site import USER_BASE
from site import USER_SITE
HAS_USER_SITE = True
import site
HAS_USER_SITE = not sys.version < "2.6"
def samefile(p1,p2):
if hasattr(os.path,'samefile') and (
......@@ -112,7 +111,7 @@ class easy_install(Command):
if HAS_USER_SITE:
user_options.append(('user', None,
"install in user site-package '%s'" % USER_SITE))
"install in user site-package '%s'" % site.USER_SITE))
boolean_options.append('user')
......@@ -140,8 +139,8 @@ class easy_install(Command):
self.install_data = None
self.install_base = None
self.install_platbase = None
self.install_userbase = USER_BASE
self.install_usersite = USER_SITE
self.install_userbase = site.USER_BASE
self.install_usersite = site.USER_SITE
# Options not specifiable via command line
self.package_index = None
......@@ -209,10 +208,9 @@ class easy_install(Command):
else:
self.select_scheme(os.name + "_user")
if self.user and self.install_purelib:
self.install_dir = self.install_purelib
self.script_dir = self.install_scripts
self.expand_basedirs()
self.expand_dirs()
self._expand('install_dir','script_dir','build_directory','site_dirs')
# If a non-default installation directory was specified, default the
# script directory to match it.
......@@ -229,6 +227,10 @@ class easy_install(Command):
self.set_undefined_options('install_scripts',
('install_dir', 'script_dir')
)
if self.user and self.install_purelib:
self.install_dir = self.install_purelib
self.script_dir = self.install_scripts
# default --record from the install command
self.set_undefined_options('install', ('record', 'record'))
normpath = map(normalize_path, sys.path)
......@@ -294,6 +296,27 @@ class easy_install(Command):
self.outputs = []
def _expand_attrs(self, attrs):
for attr in attrs:
val = getattr(self, attr)
if val is not None:
if os.name == 'posix' or os.name == 'nt':
val = os.path.expanduser(val)
val = subst_vars(val, self.config_vars)
setattr(self, attr, val)
def expand_basedirs(self):
"""Calls `os.path.expanduser` on install_base, install_platbase and
root."""
self._expand_attrs(['install_base', 'install_platbase', 'root'])
def expand_dirs(self):
"""Calls `os.path.expanduser` on install dirs."""
self._expand_attrs(['install_purelib', 'install_platlib',
'install_lib', 'install_headers',
'install_scripts', 'install_data',])
def run(self):
if self.verbose<>self.distribution.verbose:
log.set_verbosity(self.verbose)
......@@ -337,6 +360,7 @@ class easy_install(Command):
def check_site_dir(self):
"""Verify that self.install_dir is .pth-capable dir, if needed"""
print 'install_dir', self.install_dir
instdir = normalize_path(self.install_dir)
pth_file = os.path.join(instdir,'easy-install.pth')
......
......@@ -28,9 +28,9 @@ class TestDevelopTest(unittest.TestCase):
os.chdir(self.dir)
if sys.version >= "2.6":
self.old_base = site.USER_BASE
site.USER_BASE = easy_install_pkg.USER_BASE = tempfile.mkdtemp()
site.USER_BASE = tempfile.mkdtemp()
self.old_site = site.USER_SITE
site.USER_SITE = easy_install_pkg.USER_SITE = tempfile.mkdtemp()
site.USER_SITE = tempfile.mkdtemp()
def tearDown(self):
os.chdir(self.old_cwd)
......@@ -38,8 +38,8 @@ class TestDevelopTest(unittest.TestCase):
if sys.version >= "2.6":
shutil.rmtree(site.USER_BASE)
shutil.rmtree(site.USER_SITE)
easy_install_pkg.USER_BASE = site.USER_BASE = self.old_base
easy_install_pkg.USER_SITE = site.USER_SITE = self.old_site
site.USER_BASE = self.old_base
site.USER_SITE = self.old_site
def test_develop(self):
if sys.version < "2.6":
......@@ -49,6 +49,7 @@ class TestDevelopTest(unittest.TestCase):
cmd = develop(dist)
cmd.user = 1
cmd.ensure_finalized()
cmd.install_dir = site.USER_SITE
cmd.user = 1
old_stdout = sys.stdout
sys.stdout = StringIO()
......
......@@ -3,6 +3,7 @@
import sys
import os, shutil, tempfile, unittest
import site
from StringIO import StringIO
from setuptools.command.easy_install import easy_install, get_script_args, main
from setuptools.command.easy_install import PthDistributions
from setuptools.command import easy_install as easy_install_pkg
......@@ -124,9 +125,9 @@ class TestUserInstallTest(unittest.TestCase):
os.chdir(self.dir)
if sys.version >= "2.6":
self.old_base = site.USER_BASE
site.USER_BASE = easy_install_pkg.USER_BASE = tempfile.mkdtemp()
site.USER_BASE = tempfile.mkdtemp()
self.old_site = site.USER_SITE
site.USER_SITE = easy_install_pkg.USER_SITE = tempfile.mkdtemp()
site.USER_SITE = tempfile.mkdtemp()
def tearDown(self):
os.chdir(self.old_cwd)
......@@ -134,16 +135,19 @@ class TestUserInstallTest(unittest.TestCase):
if sys.version >= "2.6":
shutil.rmtree(site.USER_BASE)
shutil.rmtree(site.USER_SITE)
easy_install_pkg.USER_BASE = site.USER_BASE = self.old_base
easy_install_pkg.USER_SITE = site.USER_SITE = self.old_site
site.USER_BASE = self.old_base
site.USER_SITE = self.old_site
def test_install(self):
#XXX: replace with something meaningfull
return
if sys.version < "2.6":
return
dist = Distribution()
dist.script_name = 'setup.py'
cmd = easy_install(dist)
cmd.user = 1
cmd.args = ['py']
cmd.ensure_finalized()
cmd.user = 1
old_stdout = sys.stdout
......
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