aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2013-06-17 19:23:33 +0100
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2013-06-17 19:23:33 +0100
commit744a61f18bbfcbf7dfaa08886185b4595d8b7bcb (patch)
tree0a46190af97901b276e7881b2e74ee46d5056d94
parentc003c86fc22b8d20b81226d1e74c95a5c885e314 (diff)
downloadexternal_python_setuptools-744a61f18bbfcbf7dfaa08886185b4595d8b7bcb.tar.gz
external_python_setuptools-744a61f18bbfcbf7dfaa08886185b4595d8b7bcb.tar.bz2
external_python_setuptools-744a61f18bbfcbf7dfaa08886185b4595d8b7bcb.zip
Misc. updates following 2to3 checks.
--HG-- branch : single-codebase
-rw-r--r--docs/conf.py8
-rw-r--r--pkg_resources.py3
-rw-r--r--release.py17
-rw-r--r--setuptools.egg-info/entry_points.txt92
-rw-r--r--setuptools.egg-info/requires.txt6
-rwxr-xr-xsetuptools/command/easy_install.py2
-rwxr-xr-xsetuptools/command/egg_info.py4
-rw-r--r--setuptools/command/test.py2
-rwxr-xr-xsetuptools/command/upload.py4
-rw-r--r--setuptools/command/upload_docs.py4
-rw-r--r--setuptools/extension.py2
-rwxr-xr-xsetuptools/package_index.py4
-rwxr-xr-xsetuptools/sandbox.py2
-rw-r--r--setuptools/script template (dev).py5
-rw-r--r--setuptools/tests/__init__.py2
-rw-r--r--tests/test_ez_setup.py5
-rw-r--r--tests/test_pkg_resources.py107
17 files changed, 147 insertions, 122 deletions
diff --git a/docs/conf.py b/docs/conf.py
index 3861b79a..44d8378a 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -40,8 +40,8 @@ source_suffix = '.txt'
master_doc = 'index'
# General information about the project.
-project = u'Setuptools'
-copyright = u'2009-2013, The fellowship of the packaging'
+project = 'Setuptools'
+copyright = '2009-2013, The fellowship of the packaging'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
@@ -175,8 +175,8 @@ htmlhelp_basename = 'Setuptoolsdoc'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
- ('index', 'Setuptools.tex', ur'Setuptools Documentation',
- ur'The fellowship of the packaging', 'manual'),
+ ('index', 'Setuptools.tex', 'Setuptools Documentation',
+ 'The fellowship of the packaging', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
diff --git a/pkg_resources.py b/pkg_resources.py
index 03aa75ad..521a7e00 100644
--- a/pkg_resources.py
+++ b/pkg_resources.py
@@ -2492,7 +2492,8 @@ class Distribution(object):
self.insert_on(path)
if path is sys.path:
fixup_namespace_packages(self.location)
- map(declare_namespace, self._get_metadata('namespace_packages.txt'))
+ list(map(declare_namespace,
+ self._get_metadata('namespace_packages.txt')))
def egg_name(self):
diff --git a/release.py b/release.py
index 632bf4cb..2e35feb1 100644
--- a/release.py
+++ b/release.py
@@ -18,6 +18,15 @@ import itertools
import re
try:
+ from urllib2 import urlopen, Request, HTTPError
+ from itertools import izip_longest
+except ImportError:
+ from urllib.request import urlopen, Request
+ from urllib.error import HTTPError
+ raw_input = input
+ from itertools import zip_longest as izip_longest
+
+try:
import keyring
except Exception:
pass
@@ -99,11 +108,11 @@ def add_milestone_and_version(version):
for type in 'milestones', 'versions':
url = (base + '/1.0/repositories/{repo}/issues/{type}'
.format(repo = get_repo_name(), type=type))
- req = urllib2.Request(url = url, headers = headers,
+ req = Request(url = url, headers = headers,
data='name='+version)
try:
- urllib2.urlopen(req)
- except urllib2.HTTPError as e:
+ urlopen(req)
+ except HTTPError as e:
print(e.fp.read())
def bump_versions(target_ver):
@@ -225,7 +234,7 @@ def _linkified_text(rst_content):
anchors = []
linkified_parts = [_linkified_part(part, anchors)
for part in plain_text_parts]
- pairs = itertools.izip_longest(
+ pairs = izip_longest(
linkified_parts,
HREF_pattern.findall(rst_content),
fillvalue='',
diff --git a/setuptools.egg-info/entry_points.txt b/setuptools.egg-info/entry_points.txt
index 663882d6..64d16767 100644
--- a/setuptools.egg-info/entry_points.txt
+++ b/setuptools.egg-info/entry_points.txt
@@ -1,61 +1,61 @@
+[console_scripts]
+easy_install = setuptools.command.easy_install:main
+easy_install-3.3 = setuptools.command.easy_install:main
+
+[distutils.setup_keywords]
+namespace_packages = setuptools.dist:check_nsp
+use_2to3_exclude_fixers = setuptools.dist:assert_string_list
+package_data = setuptools.dist:check_package_data
+use_2to3 = setuptools.dist:assert_bool
+install_requires = setuptools.dist:check_requirements
+entry_points = setuptools.dist:check_entry_points
+convert_2to3_doctests = setuptools.dist:assert_string_list
+dependency_links = setuptools.dist:assert_string_list
+test_suite = setuptools.dist:check_test_suite
+test_loader = setuptools.dist:check_importable
+tests_require = setuptools.dist:check_requirements
+packages = setuptools.dist:check_packages
+use_2to3_fixers = setuptools.dist:assert_string_list
+extras_require = setuptools.dist:check_extras
+include_package_data = setuptools.dist:assert_bool
+eager_resources = setuptools.dist:assert_string_list
+exclude_package_data = setuptools.dist:check_package_data
+zip_safe = setuptools.dist:assert_bool
+
[distutils.commands]
-bdist_rpm = setuptools.command.bdist_rpm:bdist_rpm
-rotate = setuptools.command.rotate:rotate
-develop = setuptools.command.develop:develop
+bdist_wininst = setuptools.command.bdist_wininst:bdist_wininst
+test = setuptools.command.test:test
+easy_install = setuptools.command.easy_install:easy_install
+install_egg_info = setuptools.command.install_egg_info:install_egg_info
+upload_docs = setuptools.command.upload_docs:upload_docs
setopt = setuptools.command.setopt:setopt
-build_py = setuptools.command.build_py:build_py
+install = setuptools.command.install:install
+bdist_egg = setuptools.command.bdist_egg:bdist_egg
+alias = setuptools.command.alias:alias
saveopts = setuptools.command.saveopts:saveopts
-egg_info = setuptools.command.egg_info:egg_info
+sdist = setuptools.command.sdist:sdist
+rotate = setuptools.command.rotate:rotate
+develop = setuptools.command.develop:develop
+install_lib = setuptools.command.install_lib:install_lib
register = setuptools.command.register:register
-upload_docs = setuptools.command.upload_docs:upload_docs
-install_egg_info = setuptools.command.install_egg_info:install_egg_info
-alias = setuptools.command.alias:alias
-easy_install = setuptools.command.easy_install:easy_install
+build_py = setuptools.command.build_py:build_py
install_scripts = setuptools.command.install_scripts:install_scripts
-bdist_wininst = setuptools.command.bdist_wininst:bdist_wininst
-bdist_egg = setuptools.command.bdist_egg:bdist_egg
-install = setuptools.command.install:install
-test = setuptools.command.test:test
-install_lib = setuptools.command.install_lib:install_lib
+bdist_rpm = setuptools.command.bdist_rpm:bdist_rpm
+egg_info = setuptools.command.egg_info:egg_info
build_ext = setuptools.command.build_ext:build_ext
-sdist = setuptools.command.sdist:sdist
+
+[setuptools.file_finders]
+svn_cvs = setuptools.command.sdist:_default_revctrl
[egg_info.writers]
-dependency_links.txt = setuptools.command.egg_info:overwrite_arg
requires.txt = setuptools.command.egg_info:write_requirements
-PKG-INFO = setuptools.command.egg_info:write_pkg_info
-eager_resources.txt = setuptools.command.egg_info:overwrite_arg
-top_level.txt = setuptools.command.egg_info:write_toplevel_names
namespace_packages.txt = setuptools.command.egg_info:overwrite_arg
entry_points.txt = setuptools.command.egg_info:write_entries
+top_level.txt = setuptools.command.egg_info:write_toplevel_names
depends.txt = setuptools.command.egg_info:warn_depends_obsolete
-
-[console_scripts]
-easy_install = setuptools.command.easy_install:main
-easy_install-2.7 = setuptools.command.easy_install:main
-
-[setuptools.file_finders]
-svn_cvs = setuptools.command.sdist:_default_revctrl
-
-[distutils.setup_keywords]
-dependency_links = setuptools.dist:assert_string_list
-entry_points = setuptools.dist:check_entry_points
-extras_require = setuptools.dist:check_extras
-use_2to3_exclude_fixers = setuptools.dist:assert_string_list
-package_data = setuptools.dist:check_package_data
-install_requires = setuptools.dist:check_requirements
-use_2to3 = setuptools.dist:assert_bool
-use_2to3_fixers = setuptools.dist:assert_string_list
-include_package_data = setuptools.dist:assert_bool
-exclude_package_data = setuptools.dist:check_package_data
-namespace_packages = setuptools.dist:check_nsp
-test_suite = setuptools.dist:check_test_suite
-eager_resources = setuptools.dist:assert_string_list
-zip_safe = setuptools.dist:assert_bool
-test_loader = setuptools.dist:check_importable
-packages = setuptools.dist:check_packages
-convert_2to3_doctests = setuptools.dist:assert_string_list
-tests_require = setuptools.dist:check_requirements
+PKG-INFO = setuptools.command.egg_info:write_pkg_info
+eager_resources.txt = setuptools.command.egg_info:overwrite_arg
+dependency_links.txt = setuptools.command.egg_info:overwrite_arg
[setuptools.installation]
eggsecutable = setuptools.command.easy_install:bootstrap
diff --git a/setuptools.egg-info/requires.txt b/setuptools.egg-info/requires.txt
index 2f2a364f..5ff415da 100644
--- a/setuptools.egg-info/requires.txt
+++ b/setuptools.egg-info/requires.txt
@@ -1,11 +1,11 @@
-[certs]
-certifi==0.0.8
-
[ssl:sys_platform=='win32']
wincertstore==0.1
+[certs]
+certifi==0.0.8
+
[ssl:python_version in '2.4, 2.5']
ssl==1.16
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:
diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py
index c77bd69d..1a61dfcb 100755
--- a/setuptools/command/egg_info.py
+++ b/setuptools/command/egg_info.py
@@ -235,8 +235,8 @@ class egg_info(Command):
log.warn("unrecognized .svn/entries format; skipping %s", base)
dirs[:] = []
continue
-
- data = map(str.splitlines,data.split('\n\x0c\n'))
+
+ data = list(map(str.splitlines,data.split('\n\x0c\n')))
del data[0][0] # get rid of the '8' or '9' or '10'
dirurl = data[0][3]
localrev = max([int(d[9]) for d in data if len(d)>9 and d[9]]+[0])
diff --git a/setuptools/command/test.py b/setuptools/command/test.py
index a02ac142..db2fc7b1 100644
--- a/setuptools/command/test.py
+++ b/setuptools/command/test.py
@@ -154,7 +154,7 @@ class test(Command):
for name in sys.modules:
if name.startswith(module):
del_modules.append(name)
- map(sys.modules.__delitem__, del_modules)
+ list(map(sys.modules.__delitem__, del_modules))
loader_ep = EntryPoint.parse("x="+self.test_loader)
loader_class = loader_ep.load(require=False)
diff --git a/setuptools/command/upload.py b/setuptools/command/upload.py
index 7ef0e6ec..02d955ed 100755
--- a/setuptools/command/upload.py
+++ b/setuptools/command/upload.py
@@ -11,6 +11,7 @@ try:
except ImportError:
from md5 import md5
import os
+import sys
import socket
import platform
import base64
@@ -167,7 +168,8 @@ class upload(Command):
http.putheader('Authorization', auth)
http.endheaders()
http.send(body)
- except socket.error, e:
+ except socket.error:
+ e = sys.exc_info()[1]
self.announce(str(e), log.ERROR)
return
diff --git a/setuptools/command/upload_docs.py b/setuptools/command/upload_docs.py
index 0a545789..e07b885d 100644
--- a/setuptools/command/upload_docs.py
+++ b/setuptools/command/upload_docs.py
@@ -23,7 +23,7 @@ try:
except ImportError:
from setuptools.command.upload import upload
-from setuptools.compat import httplib, urlparse
+from setuptools.compat import httplib, urlparse, unicode, iteritems
if sys.version_info >= (3,):
errors = 'surrogateescape'
@@ -131,7 +131,7 @@ class upload_docs(upload):
sep_boundary = b('\n--') + b(boundary)
end_boundary = sep_boundary + b('--')
body = []
- for key, values in data.iteritems():
+ for key, values in iteritems(data):
title = '\nContent-Disposition: form-data; name="%s"' % key
# handle multiple entries for the same name
if type(values) != type([]):
diff --git a/setuptools/extension.py b/setuptools/extension.py
index eb8b836c..d7892d3d 100644
--- a/setuptools/extension.py
+++ b/setuptools/extension.py
@@ -35,7 +35,7 @@ class Extension(_Extension):
if source.endswith('.pyx'):
source = source[:-4] + '.c'
return source
- self.sources = map(pyx_to_c, self.sources)
+ self.sources = list(map(pyx_to_c, self.sources))
class Library(Extension):
"""Just like a regular Extension, but built as a library instead"""
diff --git a/setuptools/package_index.py b/setuptools/package_index.py
index 5ee6fd27..25936b91 100755
--- a/setuptools/package_index.py
+++ b/setuptools/package_index.py
@@ -177,7 +177,7 @@ def find_external_links(url, page):
for match in REL.finditer(page):
tag, rel = match.groups()
- rels = map(str.strip, rel.lower().split(','))
+ rels = set(map(str.strip, rel.lower().split(',')))
if 'homepage' in rels or 'download' in rels:
for match in HREF.finditer(tag):
yield urljoin(url, htmldecode(match.group(1)))
@@ -749,7 +749,7 @@ class PackageIndex(Environment):
scheme, netloc, path, p, q, f = urlparse(url)
if not netloc and path.startswith('//') and '/' in path[2:]:
netloc, path = path[2:].split('/',1)
- auth, host = urllib.splituser(netloc)
+ auth, host = splituser(netloc)
if auth:
if ':' in auth:
user, pw = auth.split(':',1)
diff --git a/setuptools/sandbox.py b/setuptools/sandbox.py
index 090cb34c..a5a01a46 100755
--- a/setuptools/sandbox.py
+++ b/setuptools/sandbox.py
@@ -85,7 +85,7 @@ def run_setup(setup_script, args):
# exclude any encodings modules. See #285
and not mod_name.startswith('encodings.')
]
- map(sys.modules.__delitem__, del_modules)
+ list(map(sys.modules.__delitem__, del_modules))
os.chdir(old_dir)
sys.path[:] = save_path
sys.argv[:] = save_argv
diff --git a/setuptools/script template (dev).py b/setuptools/script template (dev).py
index 6dd9dd45..901790e7 100644
--- a/setuptools/script template (dev).py
+++ b/setuptools/script template (dev).py
@@ -3,4 +3,7 @@ __requires__ = """%(spec)r"""
from pkg_resources import require; require("""%(spec)r""")
del require
__file__ = """%(dev_path)r"""
-execfile(__file__)
+try:
+ execfile(__file__)
+except NameError:
+ exec(compile(open(__file__).read(), __file__, 'exec'))
diff --git a/setuptools/tests/__init__.py b/setuptools/tests/__init__.py
index cb26a052..1cd5df2b 100644
--- a/setuptools/tests/__init__.py
+++ b/setuptools/tests/__init__.py
@@ -2,7 +2,7 @@
import sys
import os
import unittest
-import doctest
+from setuptools.tests import doctest
import distutils.core
import distutils.cmd
from distutils.errors import DistutilsOptionError, DistutilsPlatformError
diff --git a/tests/test_ez_setup.py b/tests/test_ez_setup.py
index 922bd884..6dd4c055 100644
--- a/tests/test_ez_setup.py
+++ b/tests/test_ez_setup.py
@@ -27,7 +27,10 @@ class TestSetup(unittest.TestCase):
"--dist-dir", "%s" % self.tmpdir)
tarball = os.listdir(self.tmpdir)[0]
self.tarball = os.path.join(self.tmpdir, tarball)
- import urllib2
+ try:
+ import urllib2
+ except ImportError:
+ import urllib.request as urllib2
urllib2.urlopen = self.urlopen
def tearDown(self):
diff --git a/tests/test_pkg_resources.py b/tests/test_pkg_resources.py
index 7009b4ab..b05ea44b 100644
--- a/tests/test_pkg_resources.py
+++ b/tests/test_pkg_resources.py
@@ -5,57 +5,62 @@ import zipfile
import pkg_resources
+try:
+ unicode
+except NameError:
+ unicode = str
+
class EggRemover(unicode):
- def __call__(self):
- if self in sys.path:
- sys.path.remove(self)
- if os.path.exists(self):
- os.remove(self)
+ def __call__(self):
+ if self in sys.path:
+ sys.path.remove(self)
+ if os.path.exists(self):
+ os.remove(self)
class TestZipProvider(object):
- finalizers = []
-
- @classmethod
- def setup_class(cls):
- "create a zip egg and add it to sys.path"
- egg = tempfile.NamedTemporaryFile(suffix='.egg', delete=False)
- zip_egg = zipfile.ZipFile(egg, 'w')
- zip_info = zipfile.ZipInfo()
- zip_info.filename = 'mod.py'
- zip_info.date_time = 2013, 5, 12, 13, 25, 0
- zip_egg.writestr(zip_info, 'x = 3\n')
- zip_info = zipfile.ZipInfo()
- zip_info.filename = 'data.dat'
- zip_info.date_time = 2013, 5, 12, 13, 25, 0
- zip_egg.writestr(zip_info, 'hello, world!')
- zip_egg.close()
- egg.close()
-
- sys.path.append(egg.name)
- cls.finalizers.append(EggRemover(egg.name))
-
- @classmethod
- def teardown_class(cls):
- for finalizer in cls.finalizers:
- finalizer()
-
- def test_resource_filename_rewrites_on_change(self):
- """
- If a previous call to get_resource_filename has saved the file, but
- the file has been subsequently mutated with different file of the
- same size and modification time, it should not be overwritten on a
- subsequent call to get_resource_filename.
- """
- import mod
- manager = pkg_resources.ResourceManager()
- zp = pkg_resources.ZipProvider(mod)
- filename = zp.get_resource_filename(manager, 'data.dat')
- assert os.stat(filename).st_mtime == 1368379500
- f = open(filename, 'wb')
- f.write('hello, world?')
- f.close()
- os.utime(filename, (1368379500, 1368379500))
- filename = zp.get_resource_filename(manager, 'data.dat')
- f = open(filename)
- assert f.read() == 'hello, world!'
- manager.cleanup_resources()
+ finalizers = []
+
+ @classmethod
+ def setup_class(cls):
+ "create a zip egg and add it to sys.path"
+ egg = tempfile.NamedTemporaryFile(suffix='.egg', delete=False)
+ zip_egg = zipfile.ZipFile(egg, 'w')
+ zip_info = zipfile.ZipInfo()
+ zip_info.filename = 'mod.py'
+ zip_info.date_time = 2013, 5, 12, 13, 25, 0
+ zip_egg.writestr(zip_info, 'x = 3\n')
+ zip_info = zipfile.ZipInfo()
+ zip_info.filename = 'data.dat'
+ zip_info.date_time = 2013, 5, 12, 13, 25, 0
+ zip_egg.writestr(zip_info, 'hello, world!')
+ zip_egg.close()
+ egg.close()
+
+ sys.path.append(egg.name)
+ cls.finalizers.append(EggRemover(egg.name))
+
+ @classmethod
+ def teardown_class(cls):
+ for finalizer in cls.finalizers:
+ finalizer()
+
+ def test_resource_filename_rewrites_on_change(self):
+ """
+ If a previous call to get_resource_filename has saved the file, but
+ the file has been subsequently mutated with different file of the
+ same size and modification time, it should not be overwritten on a
+ subsequent call to get_resource_filename.
+ """
+ import mod
+ manager = pkg_resources.ResourceManager()
+ zp = pkg_resources.ZipProvider(mod)
+ filename = zp.get_resource_filename(manager, 'data.dat')
+ assert os.stat(filename).st_mtime == 1368379500
+ f = open(filename, 'wb')
+ f.write('hello, world?')
+ f.close()
+ os.utime(filename, (1368379500, 1368379500))
+ filename = zp.get_resource_filename(manager, 'data.dat')
+ f = open(filename)
+ assert f.read() == 'hello, world!'
+ manager.cleanup_resources()