diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2013-06-15 15:34:53 +0100 |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2013-06-15 15:34:53 +0100 |
commit | 8e657eac1ef02faedca99df319fff6b63f4a4305 (patch) | |
tree | f3f2ed97342421c6b65c9caaab8ae5d830f04059 /setuptools/command | |
parent | c04abca662dcbffd00d928e06fbf32b9f49f8e57 (diff) | |
download | external_python_setuptools-8e657eac1ef02faedca99df319fff6b63f4a4305.tar.gz external_python_setuptools-8e657eac1ef02faedca99df319fff6b63f4a4305.tar.bz2 external_python_setuptools-8e657eac1ef02faedca99df319fff6b63f4a4305.zip |
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
Diffstat (limited to 'setuptools/command')
-rwxr-xr-x | setuptools/command/alias.py | 10 | ||||
-rw-r--r-- | setuptools/command/bdist_egg.py | 3 | ||||
-rwxr-xr-x | setuptools/command/easy_install.py | 53 | ||||
-rwxr-xr-x | setuptools/command/egg_info.py | 11 | ||||
-rwxr-xr-x | setuptools/command/install_egg_info.py | 1 | ||||
-rwxr-xr-x | setuptools/command/install_scripts.py | 2 | ||||
-rwxr-xr-x | setuptools/command/rotate.py | 1 | ||||
-rwxr-xr-x | setuptools/command/sdist.py | 2 | ||||
-rwxr-xr-x | setuptools/command/setopt.py | 4 | ||||
-rwxr-xr-x | setuptools/command/upload.py | 15 | ||||
-rw-r--r-- | setuptools/command/upload_docs.py | 18 |
11 files changed, 68 insertions, 52 deletions
diff --git a/setuptools/command/alias.py b/setuptools/command/alias.py index 40c00b55..4c08c48d 100755 --- a/setuptools/command/alias.py +++ b/setuptools/command/alias.py @@ -43,10 +43,10 @@ class alias(option_base): aliases = self.distribution.get_option_dict('aliases') if not self.args: - print "Command Aliases" - print "---------------" + print("Command Aliases") + print("---------------") for alias in aliases: - print "setup.py alias", format_alias(alias, aliases) + print("setup.py alias", format_alias(alias, aliases)) return elif len(self.args)==1: @@ -54,10 +54,10 @@ class alias(option_base): if self.remove: command = None elif alias in aliases: - print "setup.py alias", format_alias(alias, aliases) + print("setup.py alias", format_alias(alias, aliases)) return else: - print "No alias definition found for %r" % alias + print("No alias definition found for %r" % alias) return else: alias = self.args[0] diff --git a/setuptools/command/bdist_egg.py b/setuptools/command/bdist_egg.py index 1ba0499e..de72ea04 100644 --- a/setuptools/command/bdist_egg.py +++ b/setuptools/command/bdist_egg.py @@ -21,6 +21,7 @@ from distutils.errors import DistutilsSetupError from pkg_resources import get_build_platform, Distribution, ensure_directory from pkg_resources import EntryPoint from types import CodeType +from setuptools.compat import basestring, next from setuptools.extension import Library def strip_module(filename): @@ -383,7 +384,7 @@ NATIVE_EXTENSIONS = dict.fromkeys('.dll .so .dylib .pyd'.split()) def walk_egg(egg_dir): """Walk an unpacked egg's contents, skipping the metadata directory""" walker = os.walk(egg_dir) - base,dirs,files = walker.next() + base,dirs,files = next(walker) if 'EGG-INFO' in dirs: dirs.remove('EGG-INFO') yield base,dirs,files 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("<iii",f.read(12)) if tag not in (0x1234567A, 0x1234567B): return None # not a valid tag @@ -1567,11 +1575,11 @@ class PthDistributions(Environment): dirty = False def __init__(self, filename, sitedirs=()): - self.filename = filename; self.sitedirs=map(normalize_path, sitedirs) + self.filename = filename; self.sitedirs = list(map(normalize_path, sitedirs)) self.basedir = normalize_path(os.path.dirname(self.filename)) self._load(); Environment.__init__(self, [], None, None) for path in yield_lines(self.paths): - map(self.add, find_distributions(path, True)) + list(map(self.add, find_distributions(path, True))) def _load(self): self.paths = [] @@ -1699,8 +1707,8 @@ def auto_chmod(func, arg, exc): if func is os.remove and os.name=='nt': chmod(arg, stat.S_IWRITE) return func(arg) - exc = sys.exc_info() - raise exc[0], (exc[1][0], exc[1][1] + (" %s %s" % (func,arg))) + et, ev, _ = sys.exc_info() + reraise(et, (ev[0], ev[1] + (" %s %s" % (func,arg)))) def uncache_zipdir(path): """Ensure that the importer caches dont have stale info for `path`""" @@ -1800,7 +1808,8 @@ def chmod(path, mode): log.debug("changing mode of %s to %o", path, mode) try: _chmod(path, mode) - except os.error, e: + except os.error: + e = sys.exc_info()[1] log.debug("chmod failed: %s", e) def fix_jython_executable(executable, options): @@ -1914,7 +1923,7 @@ def rmtree(path, ignore_errors=False, onerror=auto_chmod): names = [] try: names = os.listdir(path) - except os.error, err: + except os.error: onerror(os.listdir, path, sys.exc_info()) for name in names: fullname = os.path.join(path, name) @@ -1927,7 +1936,7 @@ def rmtree(path, ignore_errors=False, onerror=auto_chmod): else: try: os.remove(fullname) - except os.error, err: + except os.error: onerror(os.remove, fullname, sys.exc_info()) try: os.rmdir(path) @@ -1935,7 +1944,7 @@ def rmtree(path, ignore_errors=False, onerror=auto_chmod): onerror(os.rmdir, path, sys.exc_info()) def current_umask(): - tmp = os.umask(022) + tmp = os.umask(0x12) # 022 os.umask(tmp) return tmp diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index cd3ea198..c77bd69d 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -8,11 +8,12 @@ from setuptools import Command from distutils.errors import * from distutils import log from setuptools.command.sdist import sdist +from setuptools.compat import basestring, PY3 from distutils.util import convert_path from distutils.filelist import FileList as _FileList from pkg_resources import parse_requirements, safe_name, parse_version, \ safe_version, yield_lines, EntryPoint, iter_entry_points, to_filename -from sdist import walk_revctrl +from setuptools.command.sdist import walk_revctrl class egg_info(Command): description = "create a distribution's .egg-info directory" @@ -51,7 +52,7 @@ class egg_info(Command): self.vtags = None def save_version_info(self, filename): - from setopt import edit_config + from setuptools.command.setopt import edit_config edit_config( filename, {'egg_info': @@ -282,7 +283,7 @@ class FileList(_FileList): item = item[:-1] path = convert_path(item) - if sys.version_info >= (3,): + if PY3: try: if os.path.exists(path) or os.path.exists(path.encode('utf-8')): self.files.append(path) @@ -336,7 +337,7 @@ class manifest_maker(sdist): named by 'self.manifest'. """ # The manifest must be UTF-8 encodable. See #303. - if sys.version_info >= (3,): + if PY3: files = [] for file in self.filelist.files: try: @@ -415,7 +416,7 @@ def write_pkg_info(cmd, basename, filename): metadata.name, metadata.version = oldname, oldver safe = getattr(cmd.distribution,'zip_safe',None) - import bdist_egg; bdist_egg.write_safety_flag(cmd.egg_info, safe) + from setuptools.command import bdist_egg; bdist_egg.write_safety_flag(cmd.egg_info, safe) def warn_depends_obsolete(cmd, basename, filename): if os.path.exists(filename): diff --git a/setuptools/command/install_egg_info.py b/setuptools/command/install_egg_info.py index f44b34b5..87ddff9c 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -1,5 +1,6 @@ from setuptools import Command from setuptools.archive_util import unpack_archive +from setuptools.compat import PY3 from distutils import log, dir_util import os, shutil, pkg_resources diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index 82456035..4e6b1a9a 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -50,5 +50,5 @@ class install_scripts(_install_scripts): f = open(target,"w"+mode) f.write(contents) f.close() - chmod(target, 0777-mask) + chmod(target, 0o777-mask) diff --git a/setuptools/command/rotate.py b/setuptools/command/rotate.py index 11b6eae8..b10acfb4 100755 --- a/setuptools/command/rotate.py +++ b/setuptools/command/rotate.py @@ -1,5 +1,6 @@ import distutils, os from setuptools import Command +from setuptools.compat import basestring from distutils.util import convert_path from distutils import log from distutils.errors import * diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index f8f964b3..39cd6043 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -210,7 +210,7 @@ class sdist(_sdist): optional = ['test/test*.py', 'setup.cfg'] for pattern in optional: - files = filter(os.path.isfile, glob(pattern)) + files = list(filter(os.path.isfile, glob(pattern))) if files: self.filelist.extend(files) diff --git a/setuptools/command/setopt.py b/setuptools/command/setopt.py index dbf3a94e..aa468c88 100755 --- a/setuptools/command/setopt.py +++ b/setuptools/command/setopt.py @@ -47,9 +47,9 @@ def edit_config(filename, settings, dry_run=False): while a dictionary lists settings to be changed or deleted in that section. A setting of ``None`` means to delete that setting. """ - from ConfigParser import RawConfigParser + from setuptools.compat import ConfigParser log.debug("Reading configuration from %s", filename) - opts = RawConfigParser() + opts = ConfigParser.RawConfigParser() opts.read([filename]) for section, options in settings.items(): if options is None: diff --git a/setuptools/command/upload.py b/setuptools/command/upload.py index 4b500f68..7ef0e6ec 100755 --- a/setuptools/command/upload.py +++ b/setuptools/command/upload.py @@ -13,11 +13,9 @@ except ImportError: import os import socket import platform -import ConfigParser -import httplib import base64 -import urlparse -import cStringIO as StringIO + +from setuptools.compat import urlparse, StringIO, httplib, ConfigParser class upload(Command): @@ -49,7 +47,7 @@ class upload(Command): raise DistutilsOptionError( "Must use --sign for --identity to have meaning" ) - if os.environ.has_key('HOME'): + if 'HOME' in os.environ: rc = os.path.join(os.environ['HOME'], '.pypirc') if os.path.exists(rc): self.announce('Using PyPI login from %s' % rc) @@ -149,14 +147,14 @@ class upload(Command): # We can't use urllib2 since we need to send the Basic # auth right with the first request schema, netloc, url, params, query, fragments = \ - urlparse.urlparse(self.repository) + urlparse(self.repository) assert not params and not query and not fragments if schema == 'http': http = httplib.HTTPConnection(netloc) elif schema == 'https': http = httplib.HTTPSConnection(netloc) else: - raise AssertionError, "unsupported schema "+schema + raise AssertionError("unsupported schema " + schema) data = '' loglevel = log.INFO @@ -181,5 +179,4 @@ class upload(Command): self.announce('Upload failed (%s): %s' % (r.status, r.reason), log.ERROR) if self.show_response: - print '-'*75, r.read(), '-'*75 - + print('-'*75, r.read(), '-'*75) diff --git a/setuptools/command/upload_docs.py b/setuptools/command/upload_docs.py index 6df3f394..0a545789 100644 --- a/setuptools/command/upload_docs.py +++ b/setuptools/command/upload_docs.py @@ -8,8 +8,6 @@ PyPI's pythonhosted.org). import os import socket import zipfile -import httplib -import urlparse import tempfile import sys import shutil @@ -25,12 +23,19 @@ try: except ImportError: from setuptools.command.upload import upload +from setuptools.compat import httplib, urlparse + +if sys.version_info >= (3,): + errors = 'surrogateescape' +else: + errors = 'strict' + # This is not just a replacement for byte literals # but works as a general purpose encoder def b(s, encoding='utf-8'): if isinstance(s, unicode): - return s.encode(encoding) + return s.encode(encoding, errors) return s @@ -154,7 +159,7 @@ class upload_docs(upload): # We can't use urllib2 since we need to send the Basic # auth right with the first request schema, netloc, url, params, query, fragments = \ - urlparse.urlparse(self.repository) + urlparse(self.repository) assert not params and not query and not fragments if schema == 'http': conn = httplib.HTTPConnection(netloc) @@ -174,7 +179,8 @@ class upload_docs(upload): conn.putheader('Authorization', auth) conn.endheaders() conn.send(body) - except socket.error, e: + except socket.error: + e = sys.exc_info()[1] self.announce(str(e), log.ERROR) return @@ -192,4 +198,4 @@ class upload_docs(upload): self.announce('Upload failed (%s): %s' % (r.status, r.reason), log.ERROR) if self.show_response: - print '-'*75, r.read(), '-'*75 + print('-'*75, r.read(), '-'*75) |