summaryrefslogtreecommitdiff
path: root/setuptools/command/easy_install.py
diff options
context:
space:
mode:
Diffstat (limited to 'setuptools/command/easy_install.py')
-rwxr-xr-xsetuptools/command/easy_install.py58
1 files changed, 34 insertions, 24 deletions
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py
index 50339e8f..3194644e 100755
--- a/setuptools/command/easy_install.py
+++ b/setuptools/command/easy_install.py
@@ -7,7 +7,7 @@ A tool for doing automatic download/extract/build of distutils-based Python
packages. For detailed documentation, see the accompanying EasyInstall.txt
file, or visit the `EasyInstall home page`__.
-__ http://packages.python.org/distribute/easy_install.html
+__ https://pythonhosted.org/setuptools/easy_install.html
"""
import sys
@@ -25,9 +25,22 @@ import pkg_resources
from setuptools import Command, _dont_write_bytecode
from setuptools.sandbox import run_setup
from distutils import log, dir_util
+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 distutils.util import get_platform
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, DistutilsPlatformError
from distutils.command.install import INSTALL_SCHEMES, SCHEME_KEYS
@@ -45,7 +58,10 @@ from pkg_resources import yield_lines, normalize_path, resource_string, \
DistributionNotFound, VersionConflict, \
DEVELOP_DIST
-sys_executable = os.path.normpath(sys.executable)
+if '__VENV_LAUNCHER__' in os.environ:
+ sys_executable = os.environ['__VENV_LAUNCHER__']
+else:
+ sys_executable = os.path.normpath(sys.executable)
__all__ = [
'samefile', 'easy_install', 'PthDistributions', 'extract_wininst_cfg',
@@ -204,7 +220,7 @@ class easy_install(Command):
def finalize_options(self):
if self.version:
- print('distribute %s' % get_distribution('distribute').version)
+ print('setuptools %s' % get_distribution('setuptools').version)
sys.exit()
py_version = sys.version.split()[0]
@@ -269,6 +285,8 @@ class easy_install(Command):
self.script_dir = self.install_scripts
# default --record from the install command
self.set_undefined_options('install', ('record', 'record'))
+ # Should this be moved to the if statement below? It's not used
+ # elsewhere
normpath = map(normalize_path, sys.path)
self.all_site_dirs = get_site_dirs()
if self.site_dirs is not None:
@@ -285,7 +303,7 @@ class easy_install(Command):
else:
self.all_site_dirs.append(normalize_path(d))
if not self.editable: self.check_site_dir()
- self.index_url = self.index_url or "http://pypi.python.org/simple"
+ self.index_url = self.index_url or "https://pypi.python.org/simple"
self.shadow_path = self.all_site_dirs[:]
for path_item in self.install_dir, normalize_path(self.script_dir):
if path_item not in self.shadow_path:
@@ -404,7 +422,7 @@ class easy_install(Command):
# Is it a configured, PYTHONPATH, implicit, or explicit site dir?
is_site_dir = instdir in self.all_site_dirs
- if not is_site_dir:
+ if not is_site_dir and not self.multi_version:
# No? Then directly test whether it does .pth file processing
is_site_dir = self.check_pth_processing()
else:
@@ -469,7 +487,7 @@ variable.
For information on other options, you may wish to consult the
documentation at:
- http://packages.python.org/distribute/easy_install.html
+ https://pythonhosted.org/setuptools/easy_install.html
Please make the appropriate changes for your system and try again.
"""
@@ -592,7 +610,6 @@ Please make the appropriate changes for your system and try again.
spec, tmpdir, self.upgrade, self.editable, not self.always_copy,
self.local_index
)
-
if dist is None:
msg = "Could not find suitable distribution for %r" % spec
if self.always_copy:
@@ -663,8 +680,7 @@ Please make the appropriate changes for your system and try again.
self.update_pth(dist)
self.package_index.add(dist)
self.local_index.add(dist)
- if not self.editable:
- self.install_egg_scripts(dist)
+ self.install_egg_scripts(dist)
self.installed_projects[dist.key] = dist
log.info(self.installation_report(requirement, dist, *info))
if (dist.has_metadata('dependency_links.txt') and
@@ -714,7 +730,7 @@ Please make the appropriate changes for your system and try again.
return True
if not dist.has_metadata('zip-safe'):
return True
- return True
+ return False
def maybe_move(self, spec, dist_filename, setup_base):
dst = os.path.join(self.build_directory, spec.key)
@@ -1175,7 +1191,8 @@ See the setuptools documentation for the "develop" command for more info.
if not self.dry_run:
self.pth_file.save()
- if dist.key=='distribute':
+
+ if dist.key=='setuptools':
# Ensure that setuptools itself never becomes unavailable!
# XXX should this check for latest version?
filename = os.path.join(self.install_dir,'setuptools.pth')
@@ -1195,7 +1212,6 @@ See the setuptools documentation for the "develop" command for more info.
def pf(src,dst):
if dst.endswith('.py') and not src.startswith('EGG-INFO/'):
to_compile.append(dst)
- to_chmod.append(dst)
elif dst.endswith('.dll') or dst.endswith('.so'):
to_chmod.append(dst)
self.unpack_progress(src,dst)
@@ -1234,6 +1250,7 @@ See the setuptools documentation for the "develop" command for more info.
+
def no_default_version_msg(self):
return """bad install directory or PYTHONPATH
@@ -1260,7 +1277,7 @@ Here are some of your options for correcting the problem:
* You can set up the installation directory to support ".pth" files by
using one of the approaches described here:
- http://packages.python.org/distribute/easy_install.html#custom-installation-locations
+ https://pythonhosted.org/setuptools/easy_install.html#custom-installation-locations
Please make the appropriate changes for your system and try again.""" % (
self.install_dir, os.environ.get('PYTHONPATH','')
@@ -1405,8 +1422,7 @@ def get_site_dirs():
'Python',
sys.version[:3],
'site-packages'))
- for plat_specific in (0,1):
- site_lib = get_python_lib(plat_specific)
+ for site_lib in (_get_purelib(), _get_platlib()):
if site_lib not in sitedirs: sitedirs.append(site_lib)
if HAS_USER_SITE:
@@ -1519,7 +1535,7 @@ def get_exe_prefixes(exe_filename):
('PURELIB/', ''), ('PLATLIB/pywin32_system32', ''),
('PLATLIB/', ''),
('SCRIPTS/', 'EGG-INFO/scripts/'),
- ('DATA/LIB/site-packages', ''),
+ ('DATA/lib/site-packages', ''),
]
z = zipfile.ZipFile(exe_filename)
try:
@@ -1851,7 +1867,7 @@ def get_script_args(dist, executable=sys_executable, wininst=False):
ext = '-script.py'
old = ['.py','.pyc','.pyo']
new_header = re.sub('(?i)pythonw.exe','python.exe',header)
- if os.path.exists(new_header[2:-1]) or sys.platform!='win32':
+ if os.path.exists(new_header[2:-1].strip('"')) or sys.platform!='win32':
hdr = new_header
else:
hdr = header
@@ -1970,12 +1986,6 @@ usage: %(script)s [options] requirement_or_url ...
def _show_help(self,*args,**kw):
with_ei_usage(lambda: Distribution._show_help(self,*args,**kw))
- def find_config_files(self):
- files = Distribution.find_config_files(self)
- if 'setup.cfg' in files:
- files.remove('setup.cfg')
- return files
-
if argv is None:
argv = sys.argv[1:]