From 8e657eac1ef02faedca99df319fff6b63f4a4305 Mon Sep 17 00:00:00 2001 From: Vinay Sajip Date: Sat, 15 Jun 2013 15:34:53 +0100 Subject: Initial commit. All tests pass on 2.7, 3.2 and 3.3, though there are some atexit errors in the multiprocessing module in 2.7/3.2 (seemingly unrelated to setuptools). --HG-- branch : single-codebase --- setuptools/command/easy_install.py | 53 ++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 22 deletions(-) (limited to 'setuptools/command/easy_install.py') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 60b3e011..f71128b0 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -49,6 +49,8 @@ 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, + reraise) from pkg_resources import yield_lines, normalize_path, resource_string, \ ensure_directory, get_distribution, find_distributions, \ Environment, Requirement, Distribution, \ @@ -56,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', @@ -215,7 +220,7 @@ class easy_install(Command): def finalize_options(self): if self.version: - print 'setuptools %s' % get_distribution('setuptools').version + print('setuptools %s' % get_distribution('setuptools').version) sys.exit() py_version = sys.version.split()[0] @@ -395,7 +400,7 @@ class easy_install(Command): try: pid = os.getpid() except: - pid = random.randint(0,sys.maxint) + pid = random.randint(0, maxsize) return os.path.join(self.install_dir, "test-easy-install-%s" % pid) def warn_deprecated_options(self): @@ -698,11 +703,13 @@ Please make the appropriate changes for your system and try again. distros = WorkingSet([]).resolve( [requirement], self.local_index, self.easy_install ) - except DistributionNotFound, e: + except DistributionNotFound: + e = sys.exc_info()[1] raise DistutilsError( "Could not find required distribution %s" % e.args ) - except VersionConflict, e: + except VersionConflict: + e = sys.exc_info()[1] raise DistutilsError( "Installed distribution %s conflicts with requirement %s" % e.args @@ -793,7 +800,7 @@ Please make the appropriate changes for your system and try again. f = open(target,"w"+mode) f.write(contents) f.close() - chmod(target, 0777-mask) + chmod(target, 0o777-mask) @@ -1104,7 +1111,8 @@ See the setuptools documentation for the "develop" command for more info. ) try: run_setup(setup_script, args) - except SystemExit, v: + except SystemExit: + v = sys.exc_info()[1] raise DistutilsError("Setup script exited with %s" % (v.args[0],)) def build_and_install(self, setup_script, setup_base): @@ -1146,7 +1154,7 @@ See the setuptools documentation for the "develop" command for more info. 'site_dirs', 'allow_hosts', ) fetch_options = {} - for key, val in ei_opts.iteritems(): + for key, val in iteritems(ei_opts): if key not in fetch_directives: continue fetch_options[key.replace('_', '-')] = val[1] # create a settings dictionary suitable for `edit_config` @@ -1211,7 +1219,7 @@ See the setuptools documentation for the "develop" command for more info. self.byte_compile(to_compile) if not self.dry_run: for f in to_chmod: - mode = ((os.stat(f)[stat.ST_MODE]) | 0555) & 07755 + mode = ((os.stat(f)[stat.ST_MODE]) | 0x16D) & 0xFED # 0555, 07755 chmod(f, mode) def byte_compile(self, to_compile): @@ -1326,10 +1334,10 @@ Please make the appropriate changes for your system and try again.""" % ( if not self.user: return home = convert_path(os.path.expanduser("~")) - for name, path in self.config_vars.iteritems(): + for name, path in iteritems(self.config_vars): if path.startswith(home) and not os.path.isdir(path): self.debug_print("os.makedirs('%s', 0700)" % path) - os.makedirs(path, 0700) + os.makedirs(path, 0x1C0) # 0700 @@ -1380,7 +1388,7 @@ Please make the appropriate changes for your system and try again.""" % ( def get_site_dirs(): # return a list of 'site' dirs - sitedirs = filter(None,os.environ.get('PYTHONPATH','').split(os.pathsep)) + sitedirs = list(filter(None,os.environ.get('PYTHONPATH','').split(os.pathsep))) prefixes = [sys.prefix] if sys.exec_prefix != sys.prefix: prefixes.append(sys.exec_prefix) @@ -1417,7 +1425,7 @@ def get_site_dirs(): if HAS_USER_SITE: sitedirs.append(site.USER_SITE) - sitedirs = map(normalize_path, sitedirs) + sitedirs = list(map(normalize_path, sitedirs)) return sitedirs @@ -1479,7 +1487,7 @@ def extract_wininst_cfg(dist_filename): return None f.seek(prepended-12) - import struct, StringIO, ConfigParser + from setuptools.compat import StringIO, ConfigParser tag, cfglen, bmlen = struct.unpack(" Date: Sat, 15 Jun 2013 15:56:28 +0100 Subject: Updated to fix errors on 2.5. --HG-- branch : single-codebase --- setuptools/command/easy_install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/easy_install.py') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index f71128b0..cf80926c 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -800,7 +800,7 @@ Please make the appropriate changes for your system and try again. f = open(target,"w"+mode) f.write(contents) f.close() - chmod(target, 0o777-mask) + chmod(target,0x1FF - mask) # 0777 -- cgit v1.2.1 From 744a61f18bbfcbf7dfaa08886185b4595d8b7bcb Mon Sep 17 00:00:00 2001 From: Vinay Sajip Date: Mon, 17 Jun 2013 19:23:33 +0100 Subject: Misc. updates following 2to3 checks. --HG-- branch : single-codebase --- setuptools/command/easy_install.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'setuptools/command/easy_install.py') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index cf80926c..c53ca9f2 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -285,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: -- cgit v1.2.1 From f91bf3924a2f4e3d4c7f075b792002dae97d46b4 Mon Sep 17 00:00:00 2001 From: Vinay Sajip Date: Wed, 19 Jun 2013 12:19:32 +0100 Subject: Add back accidentally deleted import. --HG-- branch : single-codebase --- setuptools/command/easy_install.py | 1 + 1 file changed, 1 insertion(+) (limited to 'setuptools/command/easy_install.py') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 000fefa0..3194644e 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -1491,6 +1491,7 @@ def extract_wininst_cfg(dist_filename): f.seek(prepended-12) from setuptools.compat import StringIO, ConfigParser + import struct tag, cfglen, bmlen = struct.unpack("