diff options
Diffstat (limited to 'setuptools/command/easy_install.py')
| -rwxr-xr-x | setuptools/command/easy_install.py | 41 |
1 files changed, 13 insertions, 28 deletions
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index d329f4cb..9775bffc 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -32,19 +32,7 @@ from distutils import log, dir_util import pkg_resources from setuptools import Command, _dont_write_bytecode from setuptools.sandbox import run_setup -try: - # Python 2.7 or >=3.2 - from sysconfig import get_config_vars, get_path - def _get_platlib(): - return get_path("platlib") - def _get_purelib(): - return get_path("purelib") -except ImportError: - from distutils.sysconfig import get_config_vars, get_python_lib - def _get_platlib(): - return get_python_lib(True) - def _get_purelib(): - return get_python_lib(False) +from setuptools.py31compat import get_path, get_config_vars from distutils.util import get_platform from distutils.util import convert_path, subst_vars @@ -56,7 +44,7 @@ from setuptools.archive_util import unpack_archive from setuptools.package_index import PackageIndex from setuptools.package_index import URL_SCHEME from setuptools.command import bdist_egg, egg_info -from setuptools.compat import (iteritems, maxsize, xrange, basestring, unicode, +from setuptools.compat import (iteritems, maxsize, basestring, unicode, reraise) from pkg_resources import ( yield_lines, normalize_path, resource_string, ensure_directory, @@ -65,18 +53,14 @@ from pkg_resources import ( VersionConflict, DEVELOP_DIST, ) -if '__VENV_LAUNCHER__' in os.environ: - sys_executable = os.environ['__VENV_LAUNCHER__'] -else: - sys_executable = os.path.normpath(sys.executable) +sys_executable = os.environ.get('__VENV_LAUNCHER__', + os.path.normpath(sys.executable)) __all__ = [ 'samefile', 'easy_install', 'PthDistributions', 'extract_wininst_cfg', 'main', 'get_exe_prefixes', ] -HAS_USER_SITE = not sys.version < "2.6" and site.ENABLE_USER_SITE - def is_64bit(): return struct.calcsize("P") == 8 @@ -148,7 +132,7 @@ class easy_install(Command): 'no-deps', 'local-snapshots-ok', 'version' ] - if HAS_USER_SITE: + if site.ENABLE_USER_SITE: help_msg = "install in user site-package '%s'" % site.USER_SITE user_options.append(('user', None, help_msg)) boolean_options.append('user') @@ -157,7 +141,7 @@ class easy_install(Command): create_index = PackageIndex def initialize_options(self): - if HAS_USER_SITE: + if site.ENABLE_USER_SITE: whereami = os.path.abspath(__file__) self.user = whereami.startswith(site.USER_SITE) else: @@ -182,7 +166,7 @@ class easy_install(Command): self.install_data = None self.install_base = None self.install_platbase = None - if HAS_USER_SITE: + if site.ENABLE_USER_SITE: self.install_userbase = site.USER_BASE self.install_usersite = site.USER_SITE else: @@ -240,13 +224,13 @@ class easy_install(Command): 'abiflags': getattr(sys, 'abiflags', ''), } - if HAS_USER_SITE: + if site.ENABLE_USER_SITE: self.config_vars['userbase'] = self.install_userbase self.config_vars['usersite'] = self.install_usersite # fix the install_dir if "--user" was used #XXX: duplicate of the code in the setup command - if self.user and HAS_USER_SITE: + if self.user and site.ENABLE_USER_SITE: self.create_home_path() if self.install_userbase is None: raise DistutilsPlatformError( @@ -376,7 +360,7 @@ class easy_install(Command): outputs = self.outputs if self.root: # strip any package prefix root_len = len(self.root) - for counter in xrange(len(outputs)): + for counter in range(len(outputs)): outputs[counter] = outputs[counter][root_len:] from distutils import file_util self.execute( @@ -1288,10 +1272,11 @@ def get_site_dirs(): 'Python', sys.version[:3], 'site-packages')) - for site_lib in (_get_purelib(), _get_platlib()): + lib_paths = get_path('purelib'), get_path('platlib') + for site_lib in lib_paths: if site_lib not in sitedirs: sitedirs.append(site_lib) - if HAS_USER_SITE: + if site.ENABLE_USER_SITE: sitedirs.append(site.USER_SITE) sitedirs = list(map(normalize_path, sitedirs)) |
