Commit 8d016844 authored by Vinay Sajip's avatar Vinay Sajip

Merged upstream changes.

--HG--
branch : single-codebase
parents 744a61f1 5d9d3930
...@@ -62,3 +62,5 @@ ddca71ae5ceb9b14512dc60ea83802c10e224cf0 0.6.45 ...@@ -62,3 +62,5 @@ ddca71ae5ceb9b14512dc60ea83802c10e224cf0 0.6.45
7f2c08e9ca22023d1499c512fccc1513813b7dc4 0.7 7f2c08e9ca22023d1499c512fccc1513813b7dc4 0.7
024dd30ed702135f5328975042566e48cc479d7d 0.7.1 024dd30ed702135f5328975042566e48cc479d7d 0.7.1
d04c05f035e3a5636006fc34f4be7e6c77035d17 0.7.2 d04c05f035e3a5636006fc34f4be7e6c77035d17 0.7.2
d212e48e0cef689acba57ed017289c027660b23c 0.7.3
74c6c12268059986f9cc0b535399594f1d131201 0.8b1
...@@ -2,12 +2,17 @@ ...@@ -2,12 +2,17 @@
CHANGES CHANGES
======= =======
---
0.8
---
* Code base now runs on Python 2.4 - Python 3.3 without Python 2to3
conversion.
----- -----
0.7.3 0.7.3
----- -----
* Rename DISTRIBUTE_DISABLE_VERSIONED_EASY_INSTALL_SCRIPT environment
variable to SETUPTOOLS_DISABLE_VERSIONED_EASY_INSTALL_SCRIPT.
* Issue #1: Disable installation of Windows-specific files on non-Windows systems. * Issue #1: Disable installation of Windows-specific files on non-Windows systems.
* Use new sysconfig module with Python 2.7 or >=3.2. * Use new sysconfig module with Python 2.7 or >=3.2.
......
...@@ -12,7 +12,7 @@ Installation Instructions ...@@ -12,7 +12,7 @@ Installation Instructions
Upgrading from Distribute Upgrading from Distribute
========================= =========================
Currently, Distribute disallows installing Setuptools 0.7.3 over Distribute. Currently, Distribute disallows installing Setuptools 0.7+ over Distribute.
You must first uninstall any active version of Distribute first (see You must first uninstall any active version of Distribute first (see
`Uninstalling`_). `Uninstalling`_).
...@@ -29,7 +29,7 @@ The recommended way to install setuptools on Windows is to download ...@@ -29,7 +29,7 @@ The recommended way to install setuptools on Windows is to download
`ez_setup.py`_ and run it. The script will download the appropriate .egg `ez_setup.py`_ and run it. The script will download the appropriate .egg
file and install it for you. file and install it for you.
.. _ez_setup.py: https://bitbucket.org/pypa/setuptools/raw/0.7.3/ez_setup.py .. _ez_setup.py: https://bitbucket.org/pypa/setuptools/raw/0.8/ez_setup.py
For best results, uninstall previous versions FIRST (see `Uninstalling`_). For best results, uninstall previous versions FIRST (see `Uninstalling`_).
...@@ -45,7 +45,7 @@ Unix-based Systems including Mac OS X ...@@ -45,7 +45,7 @@ Unix-based Systems including Mac OS X
Download `ez_setup.py`_ and run it using the target Python version. The script Download `ez_setup.py`_ and run it using the target Python version. The script
will download the appropriate version and install it for you:: will download the appropriate version and install it for you::
> wget https://bitbucket.org/pypa/setuptools/raw/0.7.3/ez_setup.py -O - | python > wget https://bitbucket.org/pypa/setuptools/raw/0.8/ez_setup.py -O - | python
Note that you will may need to invoke the command with superuser privileges to Note that you will may need to invoke the command with superuser privileges to
install to the system Python. install to the system Python.
...@@ -53,7 +53,7 @@ install to the system Python. ...@@ -53,7 +53,7 @@ install to the system Python.
Alternatively, on Python 2.6 and later, Setuptools may be installed to a Alternatively, on Python 2.6 and later, Setuptools may be installed to a
user-local path:: user-local path::
> wget https://bitbucket.org/pypa/setuptools/raw/0.7.3/ez_setup.py > wget https://bitbucket.org/pypa/setuptools/raw/0.8/ez_setup.py
> python ez_setup.py --user > python ez_setup.py --user
...@@ -66,7 +66,7 @@ tarball from `Setuptools on PyPI <https://pypi.python.org/pypi/setuptools>`_ ...@@ -66,7 +66,7 @@ tarball from `Setuptools on PyPI <https://pypi.python.org/pypi/setuptools>`_
and run setup.py with any supported distutils and Setuptools options. and run setup.py with any supported distutils and Setuptools options.
For example:: For example::
setuptools-0.7.3$ python setup.py --prefix=/opt/setuptools setuptools-0.8$ python setup.py --prefix=/opt/setuptools
Use ``--help`` to get a full options list, but we recommend consulting Use ``--help`` to get a full options list, but we recommend consulting
the `EasyInstall manual`_ for detailed instructions, especially `the section the `EasyInstall manual`_ for detailed instructions, especially `the section
......
...@@ -48,9 +48,9 @@ copyright = '2009-2013, The fellowship of the packaging' ...@@ -48,9 +48,9 @@ copyright = '2009-2013, The fellowship of the packaging'
# built documents. # built documents.
# #
# The short X.Y version. # The short X.Y version.
version = '0.7.3' version = '0.8'
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = '0.7.3' release = '0.8'
# The language for content autogenerated by Sphinx. Refer to documentation # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.
......
...@@ -28,7 +28,7 @@ try: ...@@ -28,7 +28,7 @@ try:
except ImportError: except ImportError:
USER_SITE = None USER_SITE = None
DEFAULT_VERSION = "0.7.3" DEFAULT_VERSION = "0.8"
DEFAULT_URL = "https://pypi.python.org/packages/source/s/setuptools/" DEFAULT_URL = "https://pypi.python.org/packages/source/s/setuptools/"
def _python_cmd(*args): def _python_cmd(*args):
......
...@@ -13,7 +13,7 @@ The package resource API is designed to work with normal filesystem packages, ...@@ -13,7 +13,7 @@ The package resource API is designed to work with normal filesystem packages,
method. method.
""" """
import sys, os, zipfile, zipimport, time, re, imp, types import sys, os, time, re, imp, types, zipfile, zipimport
try: try:
from urlparse import urlparse, urlunparse from urlparse import urlparse, urlunparse
except ImportError: except ImportError:
......
...@@ -11,32 +11,32 @@ import subprocess ...@@ -11,32 +11,32 @@ import subprocess
import shutil import shutil
import os import os
import sys import sys
import urllib2
import getpass import getpass
import collections import collections
import itertools import itertools
import re import re
try: try:
from urllib2 import urlopen, Request, HTTPError import urllib.request as urllib_request
from itertools import izip_longest
except ImportError: except ImportError:
from urllib.request import urlopen, Request import urllib2 as urllib_request
from urllib.error import HTTPError
raw_input = input try:
from itertools import zip_longest as izip_longest input = raw_input
except NameError:
pass
try: try:
import keyring import keyring
except Exception: except Exception:
pass pass
VERSION = '0.7.3' VERSION = '0.8'
PACKAGE_INDEX = 'https://pypi.python.org/pypi' PACKAGE_INDEX = 'https://pypi.python.org/pypi'
def set_versions(): def set_versions():
global VERSION global VERSION
version = raw_input("Release as version [%s]> " % VERSION) or VERSION version = input("Release as version [%s]> " % VERSION) or VERSION
if version != VERSION: if version != VERSION:
VERSION = bump_versions(version) VERSION = bump_versions(version)
...@@ -108,11 +108,11 @@ def add_milestone_and_version(version): ...@@ -108,11 +108,11 @@ def add_milestone_and_version(version):
for type in 'milestones', 'versions': for type in 'milestones', 'versions':
url = (base + '/1.0/repositories/{repo}/issues/{type}' url = (base + '/1.0/repositories/{repo}/issues/{type}'
.format(repo = get_repo_name(), type=type)) .format(repo = get_repo_name(), type=type))
req = Request(url = url, headers = headers, req = urllib_request.Request(url = url, headers = headers,
data='name='+version) data='name='+version)
try: try:
urlopen(req) urllib_request.urlopen(req)
except HTTPError as e: except urllib_request.HTTPError as e:
print(e.fp.read()) print(e.fp.read())
def bump_versions(target_ver): def bump_versions(target_ver):
...@@ -125,7 +125,10 @@ def bump_versions(target_ver): ...@@ -125,7 +125,10 @@ def bump_versions(target_ver):
def bump_version(filename, target_ver): def bump_version(filename, target_ver):
with open(filename, 'rb') as f: with open(filename, 'rb') as f:
lines = [line.replace(VERSION, target_ver) for line in f] lines = [
line.replace(VERSION.encode('ascii'), target_ver.encode('ascii'))
for line in f
]
with open(filename, 'wb') as f: with open(filename, 'wb') as f:
f.writelines(lines) f.writelines(lines)
...@@ -234,7 +237,7 @@ def _linkified_text(rst_content): ...@@ -234,7 +237,7 @@ def _linkified_text(rst_content):
anchors = [] anchors = []
linkified_parts = [_linkified_part(part, anchors) linkified_parts = [_linkified_part(part, anchors)
for part in plain_text_parts] for part in plain_text_parts]
pairs = izip_longest( pairs = itertools.izip_longest(
linkified_parts, linkified_parts,
HREF_pattern.findall(rst_content), HREF_pattern.findall(rst_content),
fillvalue='', fillvalue='',
......
...@@ -47,7 +47,7 @@ exec(init_file.read(), d) ...@@ -47,7 +47,7 @@ exec(init_file.read(), d)
init_file.close() init_file.close()
SETUP_COMMANDS = d['__all__'] SETUP_COMMANDS = d['__all__']
VERSION = "0.7.3" VERSION = "0.8"
from setuptools import setup, find_packages from setuptools import setup, find_packages
from setuptools.command.build_py import build_py as _build_py from setuptools.command.build_py import build_py as _build_py
...@@ -56,7 +56,7 @@ from setuptools.command.test import test as _test ...@@ -56,7 +56,7 @@ from setuptools.command.test import test as _test
scripts = [] scripts = []
console_scripts = ["easy_install = setuptools.command.easy_install:main"] console_scripts = ["easy_install = setuptools.command.easy_install:main"]
if os.environ.get("SETUPTOOLS_DISABLE_VERSIONED_EASY_INSTALL_SCRIPT") is None: if os.environ.get("DISTRIBUTE_DISABLE_VERSIONED_EASY_INSTALL_SCRIPT") is None:
console_scripts.append("easy_install-%s = setuptools.command.easy_install:main" % sys.version[:3]) console_scripts.append("easy_install-%s = setuptools.command.easy_install:main" % sys.version[:3])
# specific command that is used to generate windows .exe files # specific command that is used to generate windows .exe files
......
[ssl:sys_platform=='win32' and python_version=='2.4']
ctypes==1.0.2
[ssl:sys_platform=='win32'] [ssl:sys_platform=='win32']
wincertstore==0.1 wincertstore==0.1
......
...@@ -8,7 +8,7 @@ from distutils.util import convert_path ...@@ -8,7 +8,7 @@ from distutils.util import convert_path
import os import os
import sys import sys
__version__ = '0.7.3' __version__ = '0.8'
__all__ = [ __all__ = [
'setup', 'Distribution', 'Feature', 'Command', 'Extension', 'Require', 'setup', 'Distribution', 'Feature', 'Command', 'Extension', 'Require',
'find_packages' 'find_packages'
......
...@@ -9,7 +9,7 @@ def shquote(arg): ...@@ -9,7 +9,7 @@ def shquote(arg):
"""Quote an argument for later parsing by shlex.split()""" """Quote an argument for later parsing by shlex.split()"""
for c in '"', "'", "\\", "#": for c in '"', "'", "\\", "#":
if c in arg: return repr(arg) if c in arg: return repr(arg)
if arg.split()!=[arg]: if arg.split() != [arg]:
return repr(arg) return repr(arg)
return arg return arg
...@@ -33,7 +33,7 @@ class alias(option_base): ...@@ -33,7 +33,7 @@ class alias(option_base):
def finalize_options(self): def finalize_options(self):
option_base.finalize_options(self) option_base.finalize_options(self)
if self.remove and len(self.args)!=1: if self.remove and len(self.args) != 1:
raise DistutilsOptionError( raise DistutilsOptionError(
"Must specify exactly one argument (the alias name) when " "Must specify exactly one argument (the alias name) when "
"using --remove" "using --remove"
......
...@@ -412,7 +412,7 @@ def write_safety_flag(egg_dir, safe): ...@@ -412,7 +412,7 @@ def write_safety_flag(egg_dir, safe):
for flag,fn in safety_flags.items(): for flag,fn in safety_flags.items():
fn = os.path.join(egg_dir, fn) fn = os.path.join(egg_dir, fn)
if os.path.exists(fn): if os.path.exists(fn):
if safe is None or bool(safe)!=flag: if safe is None or bool(safe) != flag:
os.unlink(fn) os.unlink(fn)
elif safe is not None and bool(safe)==flag: elif safe is not None and bool(safe)==flag:
f=open(fn,'wt'); f.write('\n'); f.close() f=open(fn,'wt'); f.write('\n'); f.close()
......
...@@ -447,7 +447,7 @@ class easy_install(Command): ...@@ -447,7 +447,7 @@ class easy_install(Command):
self.pth_file = None self.pth_file = None
PYTHONPATH = os.environ.get('PYTHONPATH','').split(os.pathsep) PYTHONPATH = os.environ.get('PYTHONPATH','').split(os.pathsep)
if instdir not in map(normalize_path, filter(None,PYTHONPATH)): if instdir not in map(normalize_path, [_f for _f in PYTHONPATH if _f]):
# only PYTHONPATH dirs need a site.py, so pretend it's there # only PYTHONPATH dirs need a site.py, so pretend it's there
self.sitepy_installed = True self.sitepy_installed = True
elif self.multi_version and not os.path.exists(pth_file): elif self.multi_version and not os.path.exists(pth_file):
...@@ -802,7 +802,7 @@ Please make the appropriate changes for your system and try again. ...@@ -802,7 +802,7 @@ Please make the appropriate changes for your system and try again.
f = open(target,"w"+mode) f = open(target,"w"+mode)
f.write(contents) f.write(contents)
f.close() f.close()
chmod(target,0x1FF - mask) # 0777 chmod(target, 0x1FF-mask) # 0777
...@@ -916,7 +916,7 @@ Please make the appropriate changes for your system and try again. ...@@ -916,7 +916,7 @@ Please make the appropriate changes for your system and try again.
f = open(pkg_inf,'w') f = open(pkg_inf,'w')
f.write('Metadata-Version: 1.0\n') f.write('Metadata-Version: 1.0\n')
for k,v in cfg.items('metadata'): for k,v in cfg.items('metadata'):
if k!='target_version': if k != 'target_version':
f.write('%s: %s\n' % (k.replace('_','-').title(), v)) f.write('%s: %s\n' % (k.replace('_','-').title(), v))
f.close() f.close()
script_dir = os.path.join(egg_info,'scripts') script_dir = os.path.join(egg_info,'scripts')
...@@ -1156,7 +1156,7 @@ See the setuptools documentation for the "develop" command for more info. ...@@ -1156,7 +1156,7 @@ See the setuptools documentation for the "develop" command for more info.
'site_dirs', 'allow_hosts', 'site_dirs', 'allow_hosts',
) )
fetch_options = {} fetch_options = {}
for key, val in iteritems(ei_opts): for key, val in ei_opts.items():
if key not in fetch_directives: continue if key not in fetch_directives: continue
fetch_options[key.replace('_', '-')] = val[1] fetch_options[key.replace('_', '-')] = val[1]
# create a settings dictionary suitable for `edit_config` # create a settings dictionary suitable for `edit_config`
...@@ -1390,7 +1390,8 @@ Please make the appropriate changes for your system and try again.""" % ( ...@@ -1390,7 +1390,8 @@ Please make the appropriate changes for your system and try again.""" % (
def get_site_dirs(): def get_site_dirs():
# return a list of 'site' dirs # return a list of 'site' dirs
sitedirs = list(filter(None,os.environ.get('PYTHONPATH','').split(os.pathsep))) sitedirs = [_f for _f in os.environ.get('PYTHONPATH',
'').split(os.pathsep) if _f]
prefixes = [sys.prefix] prefixes = [sys.prefix]
if sys.exec_prefix != sys.prefix: if sys.exec_prefix != sys.prefix:
prefixes.append(sys.exec_prefix) prefixes.append(sys.exec_prefix)
...@@ -1509,7 +1510,7 @@ def extract_wininst_cfg(dist_filename): ...@@ -1509,7 +1510,7 @@ def extract_wininst_cfg(dist_filename):
# unicode for the RawConfigParser, so decode it. Is this the # unicode for the RawConfigParser, so decode it. Is this the
# right encoding? # right encoding?
config = config.decode('ascii') config = config.decode('ascii')
cfg.readfp(StringIO.StringIO(config)) cfg.readfp(StringIO(config))
except ConfigParser.Error: except ConfigParser.Error:
return None return None
if not cfg.has_section('metadata') or not cfg.has_section('Setup'): if not cfg.has_section('metadata') or not cfg.has_section('Setup'):
...@@ -1544,7 +1545,7 @@ def get_exe_prefixes(exe_filename): ...@@ -1544,7 +1545,7 @@ def get_exe_prefixes(exe_filename):
if parts[1].endswith('.egg-info'): if parts[1].endswith('.egg-info'):
prefixes.insert(0,('/'.join(parts[:2]), 'EGG-INFO/')) prefixes.insert(0,('/'.join(parts[:2]), 'EGG-INFO/'))
break break
if len(parts)!=2 or not name.endswith('.pth'): if len(parts) != 2 or not name.endswith('.pth'):
continue continue
if name.endswith('-nspkg.pth'): if name.endswith('-nspkg.pth'):
continue continue
...@@ -1577,7 +1578,8 @@ class PthDistributions(Environment): ...@@ -1577,7 +1578,8 @@ class PthDistributions(Environment):
dirty = False dirty = False
def __init__(self, filename, sitedirs=()): def __init__(self, filename, sitedirs=()):
self.filename = filename; self.sitedirs = list(map(normalize_path, sitedirs)) self.filename = filename
self.sitedirs = list(map(normalize_path, sitedirs))
self.basedir = normalize_path(os.path.dirname(self.filename)) self.basedir = normalize_path(os.path.dirname(self.filename))
self._load(); Environment.__init__(self, [], None, None) self._load(); Environment.__init__(self, [], None, None)
for path in yield_lines(self.paths): for path in yield_lines(self.paths):
......
...@@ -8,7 +8,7 @@ from setuptools import Command ...@@ -8,7 +8,7 @@ from setuptools import Command
from distutils.errors import * from distutils.errors import *
from distutils import log from distutils import log
from setuptools.command.sdist import sdist from setuptools.command.sdist import sdist
from setuptools.compat import basestring, PY3 from setuptools.compat import basestring
from distutils.util import convert_path from distutils.util import convert_path
from distutils.filelist import FileList as _FileList from distutils.filelist import FileList as _FileList
from pkg_resources import parse_requirements, safe_name, parse_version, \ from pkg_resources import parse_requirements, safe_name, parse_version, \
...@@ -416,7 +416,8 @@ def write_pkg_info(cmd, basename, filename): ...@@ -416,7 +416,8 @@ def write_pkg_info(cmd, basename, filename):
metadata.name, metadata.version = oldname, oldver metadata.name, metadata.version = oldname, oldver
safe = getattr(cmd.distribution,'zip_safe',None) safe = getattr(cmd.distribution,'zip_safe',None)
from setuptools.command 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): def warn_depends_obsolete(cmd, basename, filename):
if os.path.exists(filename): if os.path.exists(filename):
......
...@@ -50,5 +50,5 @@ class install_scripts(_install_scripts): ...@@ -50,5 +50,5 @@ class install_scripts(_install_scripts):
f = open(target,"w"+mode) f = open(target,"w"+mode)
f.write(contents) f.write(contents)
f.close() f.close()
chmod(target,0x1FF - mask) # 0777 chmod(target, 0x1FF-mask) # 0777
...@@ -9,10 +9,9 @@ class saveopts(option_base): ...@@ -9,10 +9,9 @@ class saveopts(option_base):
def run(self): def run(self):
dist = self.distribution dist = self.distribution
commands = dist.command_options.keys()
settings = {} settings = {}
for cmd in commands: for cmd in dist.command_options:
if cmd=='saveopts': if cmd=='saveopts':
continue # don't save our own options! continue # don't save our own options!
......
...@@ -25,7 +25,9 @@ except ImportError: ...@@ -25,7 +25,9 @@ except ImportError:
from setuptools.compat import httplib, urlparse, unicode, iteritems from setuptools.compat import httplib, urlparse, unicode, iteritems
if sys.version_info >= (3,): _IS_PYTHON3 = sys.version > '3'
if _IS_PYTHON3:
errors = 'surrogateescape' errors = 'surrogateescape'
else: else:
errors = 'strict' errors = 'strict'
......
import sys import sys
import itertools
if sys.version_info[0] < 3: if sys.version_info[0] < 3:
PY3 = False PY3 = False
...@@ -14,8 +15,9 @@ if sys.version_info[0] < 3: ...@@ -14,8 +15,9 @@ if sys.version_info[0] < 3:
im_func = lambda o: o.im_func im_func = lambda o: o.im_func
from htmlentitydefs import name2codepoint from htmlentitydefs import name2codepoint
import httplib import httplib
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler from BaseHTTPServer import HTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler from SimpleHTTPServer import SimpleHTTPRequestHandler
from BaseHTTPServer import BaseHTTPRequestHandler
iteritems = lambda o: o.iteritems() iteritems = lambda o: o.iteritems()
long_type = long long_type = long
maxsize = sys.maxint maxsize = sys.maxint
...@@ -29,7 +31,7 @@ if sys.version_info[0] < 3: ...@@ -29,7 +31,7 @@ if sys.version_info[0] < 3:
from urllib2 import urlopen, HTTPError, URLError, unquote, splituser from urllib2 import urlopen, HTTPError, URLError, unquote, splituser
from urlparse import urlparse, urlunparse, urljoin from urlparse import urlparse, urlunparse, urljoin
xrange = xrange xrange = xrange
from itertools import ifilterfalse filterfalse = itertools.ifilterfalse
def exec_(code, globs=None, locs=None): def exec_(code, globs=None, locs=None):
if globs is None: if globs is None:
...@@ -57,7 +59,8 @@ else: ...@@ -57,7 +59,8 @@ else:
im_func = lambda o: o.__func__ im_func = lambda o: o.__func__
from html.entities import name2codepoint from html.entities import name2codepoint
import http.client as httplib import http.client as httplib
from http.server import HTTPServer, SimpleHTTPRequestHandler, BaseHTTPRequestHandler from http.server import HTTPServer, SimpleHTTPRequestHandler
from http.server import BaseHTTPRequestHandler
iteritems = lambda o: o.items() iteritems = lambda o: o.items()
long_type = int long_type = int
maxsize = sys.maxsize maxsize = sys.maxsize
...@@ -71,7 +74,7 @@ else: ...@@ -71,7 +74,7 @@ else:
from urllib.request import urlopen, url2pathname from urllib.request import urlopen, url2pathname
from urllib.parse import urlparse, urlunparse, quote, unquote, splituser, urljoin from urllib.parse import urlparse, urlunparse, quote, unquote, splituser, urljoin
xrange = range xrange = range
from itertools import filterfalse as ifilterfalse filterfalse = itertools.filterfalse
def execfile(fn, globs=None, locs=None): def execfile(fn, globs=None, locs=None):
if globs is None: if globs is None:
......
...@@ -36,7 +36,7 @@ class Require: ...@@ -36,7 +36,7 @@ class Require:
def version_ok(self,version): def version_ok(self,version):
"""Is 'version' sufficiently up-to-date?""" """Is 'version' sufficiently up-to-date?"""
return self.attribute is None or self.format is None or \ return self.attribute is None or self.format is None or \
str(version)!="unknown" and version >= self.requested_version str(version) != "unknown" and version >= self.requested_version
def get_version(self, paths=None, default="unknown"): def get_version(self, paths=None, default="unknown"):
......
"""PyPI and direct package downloading""" """PyPI and direct package downloading"""
import sys, os.path, re, shutil, random, socket import sys, os.path, re, shutil, random, socket
import itertools
import base64
from setuptools import ssl_support
from pkg_resources import * from pkg_resources import *
from distutils import log from distutils import log
from distutils.errors import DistutilsError from distutils.errors import DistutilsError
from setuptools import ssl_support
from setuptools.compat import (urllib2, httplib, StringIO, HTTPError, from setuptools.compat import (urllib2, httplib, StringIO, HTTPError,
urlparse, urlunparse, unquote, splituser, urlparse, urlunparse, unquote, splituser,
url2pathname, name2codepoint, ifilterfalse, url2pathname, name2codepoint,
unichr, urljoin) unichr, urljoin)
from setuptools.compat import filterfalse
try: try:
from hashlib import md5 from hashlib import md5
except ImportError: except ImportError:
...@@ -60,9 +62,9 @@ def parse_bdist_wininst(name): ...@@ -60,9 +62,9 @@ def parse_bdist_wininst(name):
def egg_info_for_url(url): def egg_info_for_url(url):
scheme, server, path, parameters, query, fragment = urlparse(url) scheme, server, path, parameters, query, fragment = urlparse(url)
base = urllib2.unquote(path.split('/')[-1]) base = unquote(path.split('/')[-1])
if server=='sourceforge.net' and base=='download': # XXX Yuck if server=='sourceforge.net' and base=='download': # XXX Yuck
base = urllib2.unquote(path.split('/')[-2]) base = unquote(path.split('/')[-2])
if '#' in base: base, fragment = base.split('#',1) if '#' in base: base, fragment = base.split('#',1)
return base,fragment return base,fragment
...@@ -148,7 +150,7 @@ def unique_everseen(iterable, key=None): ...@@ -148,7 +150,7 @@ def unique_everseen(iterable, key=None):
seen = set() seen = set()
seen_add = seen.add seen_add = seen.add
if key is None: if key is None:
for element in ifilterfalse(seen.__contains__, iterable): for element in filterfalse(seen.__contains__, iterable):
seen_add(element) seen_add(element)
yield element yield element
else: else:
...@@ -292,7 +294,8 @@ class PackageIndex(Environment): ...@@ -292,7 +294,8 @@ class PackageIndex(Environment):
self.scan_egg_link(item, entry) self.scan_egg_link(item, entry)
def scan_egg_link(self, path, entry): def scan_egg_link(self, path, entry):
lines = list(filter(None, map(str.strip, open(os.path.join(path, entry))))) lines = [_f for _f in map(str.strip,
open(os.path.join(path, entry))) if _f]
if len(lines)==2: if len(lines)==2:
for dist in find_distributions(os.path.join(path, lines[0])): for dist in find_distributions(os.path.join(path, lines[0])):
dist.location = os.path.join(path, *lines) dist.location = os.path.join(path, *lines)
...@@ -387,7 +390,7 @@ class PackageIndex(Environment): ...@@ -387,7 +390,7 @@ class PackageIndex(Environment):
def check_md5(self, cs, info, filename, tfp): def check_md5(self, cs, info, filename, tfp):
if re.match('md5=[0-9a-f]{32}$', info): if re.match('md5=[0-9a-f]{32}$', info):
self.debug("Validating md5 checksum for %s", filename) self.debug("Validating md5 checksum for %s", filename)
if cs.hexdigest()!=info[4:]: if cs.hexdigest() != info[4:]:
tfp.close() tfp.close()
os.unlink(filename) os.unlink(filename)
raise DistutilsError( raise DistutilsError(
...@@ -889,7 +892,7 @@ def _encode_auth(auth): ...@@ -889,7 +892,7 @@ def _encode_auth(auth):
>>> _encode_auth('username%3Apassword') >>> _encode_auth('username%3Apassword')
u'dXNlcm5hbWU6cGFzc3dvcmQ=' u'dXNlcm5hbWU6cGFzc3dvcmQ='
""" """
auth_s = urllib2.unquote(auth) auth_s = unquote(auth)
# convert to bytes # convert to bytes
auth_bytes = auth_s.encode() auth_bytes = auth_s.encode()
# use the legacy interface for Python 2.3 support # use the legacy interface for Python 2.3 support
......
...@@ -12,6 +12,8 @@ from distutils.errors import DistutilsError ...@@ -12,6 +12,8 @@ from distutils.errors import DistutilsError
from setuptools.compat import builtins, execfile, reduce from setuptools.compat import builtins, execfile, reduce
from pkg_resources import working_set from pkg_resources import working_set
from setuptools.compat import builtins, execfile, reduce
__all__ = [ __all__ = [
"AbstractSandbox", "DirectorySandbox", "SandboxViolation", "run_setup", "AbstractSandbox", "DirectorySandbox", "SandboxViolation", "run_setup",
] ]
......
import sys, os, socket, atexit, re import sys, os, socket, atexit, re
import pkg_resources import pkg_resources
from pkg_resources import ResolutionError, ExtractionError from pkg_resources import ResolutionError, ExtractionError
from setuptools.compat import urllib2
try: try:
import urllib2 import urllib2
......
...@@ -9,6 +9,7 @@ from distutils.errors import DistutilsOptionError, DistutilsPlatformError ...@@ -9,6 +9,7 @@ from distutils.errors import DistutilsOptionError, DistutilsPlatformError
from distutils.errors import DistutilsSetupError from distutils.errors import DistutilsSetupError
from distutils.core import Extension from distutils.core import Extension
from distutils.version import LooseVersion from distutils.version import LooseVersion
from setuptools.compat import func_code
from setuptools.compat import func_code from setuptools.compat import func_code
import setuptools.dist import setuptools.dist
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
""" """
import sys import sys
import time import time
from threading import Thread import threading
from setuptools.compat import BaseHTTPRequestHandler
from setuptools.compat import (urllib2, URLError, HTTPServer, from setuptools.compat import (urllib2, URLError, HTTPServer,
SimpleHTTPRequestHandler, SimpleHTTPRequestHandler)
BaseHTTPRequestHandler)
class IndexServer(HTTPServer): class IndexServer(HTTPServer):
"""Basic single-threaded http server simulating a package index """Basic single-threaded http server simulating a package index
...@@ -28,7 +28,7 @@ class IndexServer(HTTPServer): ...@@ -28,7 +28,7 @@ class IndexServer(HTTPServer):
self.handle_request() self.handle_request()
def start(self): def start(self):
self.thread = Thread(target=self.serve) self.thread = threading.Thread(target=self.serve)
self.thread.start() self.thread.start()
def stop(self): def stop(self):
...@@ -47,7 +47,7 @@ class IndexServer(HTTPServer): ...@@ -47,7 +47,7 @@ class IndexServer(HTTPServer):
urllib2.urlopen(url, timeout=5) urllib2.urlopen(url, timeout=5)
else: else:
urllib2.urlopen(url) urllib2.urlopen(url)
except urllib2.URLError: except URLError:
# ignore any errors; all that's important is the request # ignore any errors; all that's important is the request
pass pass
self.thread.join() self.thread.join()
...@@ -63,14 +63,14 @@ class RequestRecorder(BaseHTTPRequestHandler): ...@@ -63,14 +63,14 @@ class RequestRecorder(BaseHTTPRequestHandler):
requests.append(self) requests.append(self)
self.send_response(200, 'OK') self.send_response(200, 'OK')
class MockServer(HTTPServer, Thread): class MockServer(HTTPServer, threading.Thread):
""" """
A simple HTTP Server that records the requests made to it. A simple HTTP Server that records the requests made to it.
""" """
def __init__(self, server_address=('', 0), def __init__(self, server_address=('', 0),
RequestHandlerClass=RequestRecorder): RequestHandlerClass=RequestRecorder):
HTTPServer.__init__(self, server_address, RequestHandlerClass) HTTPServer.__init__(self, server_address, RequestHandlerClass)
Thread.__init__(self) threading.Thread.__init__(self)
self.setDaemon(True) self.setDaemon(True)
self.requests = [] self.requests = []
......
...@@ -90,11 +90,15 @@ class TestDevelopTest(unittest.TestCase): ...@@ -90,11 +90,15 @@ class TestDevelopTest(unittest.TestCase):
# Check that we are using the right code. # Check that we are using the right code.
egg_link_file = open(os.path.join(site.USER_SITE, 'foo.egg-link'), 'rt') egg_link_file = open(os.path.join(site.USER_SITE, 'foo.egg-link'), 'rt')
path = egg_link_file.read().split()[0].strip() try:
egg_link_file.close() path = egg_link_file.read().split()[0].strip()
finally:
egg_link_file.close()
init_file = open(os.path.join(path, 'foo', '__init__.py'), 'rt') init_file = open(os.path.join(path, 'foo', '__init__.py'), 'rt')
init = init_file.read().strip() try:
init_file.close() init = init_file.read().strip()
finally:
init_file.close()
if sys.version < "3": if sys.version < "3":
self.assertEqual(init, 'print "foo"') self.assertEqual(init, 'print "foo"')
else: else:
...@@ -116,4 +120,3 @@ class TestDevelopTest(unittest.TestCase): ...@@ -116,4 +120,3 @@ class TestDevelopTest(unittest.TestCase):
pass pass
finally: finally:
os.chdir(old_dir) os.chdir(old_dir)
...@@ -51,30 +51,33 @@ class TestDistInfo(unittest.TestCase): ...@@ -51,30 +51,33 @@ class TestDistInfo(unittest.TestCase):
'VersionedDistribution-2.718.dist-info') 'VersionedDistribution-2.718.dist-info')
os.mkdir(versioned) os.mkdir(versioned)
metadata_file = open(os.path.join(versioned, 'METADATA'), 'w+') metadata_file = open(os.path.join(versioned, 'METADATA'), 'w+')
metadata_file.write(DALS( try:
""" metadata_file.write(DALS(
Metadata-Version: 1.2 """
Name: VersionedDistribution Metadata-Version: 1.2
Requires-Dist: splort (4) Name: VersionedDistribution
Provides-Extra: baz Requires-Dist: splort (4)
Requires-Dist: quux (>=1.1); extra == 'baz' Provides-Extra: baz
""")) Requires-Dist: quux (>=1.1); extra == 'baz'
metadata_file.close() """))
finally:
metadata_file.close()
unversioned = os.path.join(self.tmpdir, unversioned = os.path.join(self.tmpdir,
'UnversionedDistribution.dist-info') 'UnversionedDistribution.dist-info')
os.mkdir(unversioned) os.mkdir(unversioned)
metadata_file = open(os.path.join(unversioned, 'METADATA'), 'w+') metadata_file = open(os.path.join(unversioned, 'METADATA'), 'w+')
metadata_file.write(DALS( try:
""" metadata_file.write(DALS(
Metadata-Version: 1.2 """
Name: UnversionedDistribution Metadata-Version: 1.2
Version: 0.3 Name: UnversionedDistribution
Requires-Dist: splort (==4) Version: 0.3
Provides-Extra: baz Requires-Dist: splort (==4)
Requires-Dist: quux (>=1.1); extra == 'baz' Provides-Extra: baz
""")) Requires-Dist: quux (>=1.1); extra == 'baz'
metadata_file.close() """))
finally:
metadata_file.close()
def tearDown(self): def tearDown(self):
shutil.rmtree(self.tmpdir) shutil.rmtree(self.tmpdir)
...@@ -6,6 +6,8 @@ import shutil ...@@ -6,6 +6,8 @@ import shutil
import tempfile import tempfile
import unittest import unittest
import site import site
from setuptools.compat import StringIO, BytesIO, next
from setuptools.compat import urlparse
import textwrap import textwrap
import tarfile import tarfile
import distutils.core import distutils.core
......
...@@ -69,7 +69,8 @@ class TestPackageIndex(unittest.TestCase): ...@@ -69,7 +69,8 @@ class TestPackageIndex(unittest.TestCase):
try: try:
index.open_url(url) index.open_url(url)
except distutils.errors.DistutilsError: except distutils.errors.DistutilsError:
msg = unicode(sys.exc_info()[1]) error = sys.exc_info()[1]
msg = unicode(error)
assert 'nonnumeric port' in msg or 'getaddrinfo failed' in msg or 'Name or service not known' in msg assert 'nonnumeric port' in msg or 'getaddrinfo failed' in msg or 'Name or service not known' in msg
return return
raise RuntimeError("Did not raise") raise RuntimeError("Did not raise")
......
...@@ -342,7 +342,7 @@ class TestSdistTest(unittest.TestCase): ...@@ -342,7 +342,7 @@ class TestSdistTest(unittest.TestCase):
if sys.version_info >= (3,): if sys.version_info >= (3,):
fs_enc = sys.getfilesystemencoding() fs_enc = sys.getfilesystemencoding()
if sys.platform == 'win32': if sys.platform == 'win32':
if fs_enc == 'cp1252': if fs_enc == 'cp1252':
# Python 3 mangles the UTF-8 filename # Python 3 mangles the UTF-8 filename
filename = filename.decode('cp1252') filename = filename.decode('cp1252')
...@@ -377,14 +377,14 @@ class TestSdistTest(unittest.TestCase): ...@@ -377,14 +377,14 @@ class TestSdistTest(unittest.TestCase):
if sys.version_info >= (3,): if sys.version_info >= (3,):
#not all windows systems have a default FS encoding of cp1252 #not all windows systems have a default FS encoding of cp1252
if sys.platform == 'win32': if sys.platform == 'win32':
# Latin-1 is similar to Windows-1252 however # Latin-1 is similar to Windows-1252 however
# on mbcs filesys it is not in latin-1 encoding # on mbcs filesys it is not in latin-1 encoding
fs_enc = sys.getfilesystemencoding() fs_enc = sys.getfilesystemencoding()
if fs_enc == 'mbcs': if fs_enc == 'mbcs':
filename = filename.decode('mbcs') filename = filename.decode('mbcs')
else: else:
filename = filename.decode('latin-1') filename = filename.decode('latin-1')
self.assertTrue(filename in cmd.filelist.files) self.assertTrue(filename in cmd.filelist.files)
else: else:
# The Latin-1 filename should have been skipped # The Latin-1 filename should have been skipped
......
# -*- coding: UTF-8 -*- # -*- coding: UTF-8 -*-
"""develop tests """develop tests
""" """
...@@ -23,7 +23,7 @@ setup(name='foo', ...@@ -23,7 +23,7 @@ setup(name='foo',
) )
""" """
NS_INIT = """# -*- coding: Latin-1 -*- NS_INIT = """# -*- coding: Latin-1 -*-
# Söme Arbiträry Ünicode to test Issüé 310 # Söme Arbiträry Ünicode to test Issüé 310
try: try:
__import__('pkg_resources').declare_namespace(__name__) __import__('pkg_resources').declare_namespace(__name__)
...@@ -77,7 +77,7 @@ class TestTestTest(unittest.TestCase): ...@@ -77,7 +77,7 @@ class TestTestTest(unittest.TestCase):
f = open(init, 'wt') f = open(init, 'wt')
f.write(TEST_PY) f.write(TEST_PY)
f.close() f.close()
os.chdir(self.dir) os.chdir(self.dir)
self.old_base = site.USER_BASE self.old_base = site.USER_BASE
site.USER_BASE = tempfile.mkdtemp() site.USER_BASE = tempfile.mkdtemp()
...@@ -87,7 +87,7 @@ class TestTestTest(unittest.TestCase): ...@@ -87,7 +87,7 @@ class TestTestTest(unittest.TestCase):
def tearDown(self): def tearDown(self):
if sys.version < "2.6" or hasattr(sys, 'real_prefix'): if sys.version < "2.6" or hasattr(sys, 'real_prefix'):
return return
os.chdir(self.old_cwd) os.chdir(self.old_cwd)
shutil.rmtree(self.dir) shutil.rmtree(self.dir)
shutil.rmtree(site.USER_BASE) shutil.rmtree(site.USER_BASE)
...@@ -98,7 +98,7 @@ class TestTestTest(unittest.TestCase): ...@@ -98,7 +98,7 @@ class TestTestTest(unittest.TestCase):
def test_test(self): def test_test(self):
if sys.version < "2.6" or hasattr(sys, 'real_prefix'): if sys.version < "2.6" or hasattr(sys, 'real_prefix'):
return return
dist = Distribution(dict( dist = Distribution(dict(
name='foo', name='foo',
packages=['name', 'name.space', 'name.space.tests'], packages=['name', 'name.space', 'name.space.tests'],
...@@ -121,4 +121,4 @@ class TestTestTest(unittest.TestCase): ...@@ -121,4 +121,4 @@ class TestTestTest(unittest.TestCase):
pass pass
finally: finally:
sys.stdout = old_stdout sys.stdout = old_stdout
\ No newline at end of file
...@@ -49,37 +49,16 @@ GUI programs, the suffix '-script-pyw' is added.) This is why we ...@@ -49,37 +49,16 @@ GUI programs, the suffix '-script-pyw' is added.) This is why we
named out script the way we did. Now we can run out script by running named out script the way we did. Now we can run out script by running
the wrapper: the wrapper:
>>> from subprocess import Popen, PIPE, STDOUT >>> import subprocess
>>> try: >>> cmd = [os.path.join(sample_directory, 'foo.exe'), 'arg1', 'arg 2',
... unicode=unicode ... 'arg "2\\"', 'arg 4\\', 'arg5 a\\\\b']
... except: >>> proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE)
... unicode=str >>> stdout, stderr = proc.communicate('hello\nworld\n'.encode('ascii'))
>>> def popen4(cmd, *args): >>> bytes = sys.stdout.write(stdout.decode('ascii').replace('\r\n', '\n'))
... if hasattr(os, 'popen4'):
... input, output = os.popen4(cmd + " ".join(args))
... return input, output
... else:
... #emulate popen4 in python 3
... if cmd[0] == '"' and cmd[-1] != '"':
... cmd = cmd[1:]
... cmd += " ".join(args)
... p = Popen(cmd, shell=True, bufsize=0,
... stdin=PIPE, stdout=PIPE, stderr=STDOUT)
... return p.stdin, p.stdout
>>> input, output = popen4('"' + nt_quote_arg(os.path.join(sample_directory, 'foo.exe')),
... r' arg1', r'"arg 2"', r'"arg \"2\\\""', r'"arg 4\\"', r'"arg5 a\\b"')
>>> bytes_written = input.write('hello\nworld\n'.encode('utf-8'))
>>> input.close()
>>> # This is needed for line ending differences between py2 and py3 on win32
>>> msg = unicode(output.read(), encoding='utf-8').split("\n")
>>> for line in msg:
... print(line.strip())
\foo-script.py \foo-script.py
['arg1', 'arg 2', 'arg "2\\"', 'arg 4\\', 'arg5 a\\\\b'] ['arg1', 'arg 2', 'arg "2\\"', 'arg 4\\', 'arg5 a\\\\b']
'hello\nworld\n' 'hello\nworld\n'
non-optimized non-optimized
<BLANKLINE>
This example was a little pathological in that it exercised windows This example was a little pathological in that it exercised windows
(MS C runtime) quoting rules: (MS C runtime) quoting rules:
...@@ -115,18 +94,14 @@ enter the interpreter after running the script, you could use -Oi: ...@@ -115,18 +94,14 @@ enter the interpreter after running the script, you could use -Oi:
... sys.ps1 = '---' ... sys.ps1 = '---'
... """ % dict(python_exe=nt_quote_arg(sys.executable))) ... """ % dict(python_exe=nt_quote_arg(sys.executable)))
>>> f.close() >>> f.close()
>>> cmd = [os.path.join(sample_directory, 'foo.exe')]
>>> input, output = popen4(nt_quote_arg(os.path.join(sample_directory, 'foo.exe'))) >>> proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.STDOUT)
>>> input.close() >>> stdout, stderr = proc.communicate()
>>> # This is needed for line ending differences between py2 and py3 on win32 >>> bytes = sys.stdout.write(stdout.decode('ascii').replace('\r\n', '\n'))
>>> msg = unicode(output.read(), encoding='utf-8').split("\n")
>>> for line in msg:
... print(line.strip())
\foo-script.py \foo-script.py
[] []
'' ''
--- ---
<BLANKLINE>
Testing the GUI Version Testing the GUI Version
----------------------- -----------------------
...@@ -157,18 +132,19 @@ We'll also copy gui.exe to the sample-directory with the name bar.exe: ...@@ -157,18 +132,19 @@ We'll also copy gui.exe to the sample-directory with the name bar.exe:
Finally, we'll run the script and check the result: Finally, we'll run the script and check the result:
>>> input, output = popen4('"'+nt_quote_arg(os.path.join(sample_directory, 'bar.exe')), >>> cmd = [
... r' "%s" "Test Argument"' % os.path.join(sample_directory, 'test_output.txt')) ... os.path.join(sample_directory, 'bar.exe'),
>>> input.close() ... os.path.join(sample_directory, 'test_output.txt'),
>>> # This is needed for line ending differences between py2 and py3 on win32 ... 'Test Argument',
>>> msg = unicode(output.read(), encoding='utf-8').split("\n") ... ]
>>> for line in msg: >>> proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.STDOUT)
... print(line.strip()) >>> stdout, stderr = proc.communicate()
>>> print(stdout.decode('ascii'))
<BLANKLINE> <BLANKLINE>
>>> f = open(os.path.join(sample_directory, 'test_output.txt'), 'rb') >>> f_out = open(os.path.join(sample_directory, 'test_output.txt'), 'rb')
>>> print(unicode(f.read(), encoding='utf-8')) >>> print(f_out.read().decode('ascii'))
'Test Argument' 'Test Argument'
>>> f.close() >>> f_out.close()
We're done with the sample_directory: We're done with the sample_directory:
......
...@@ -16,7 +16,7 @@ import ez_setup ...@@ -16,7 +16,7 @@ import ez_setup
class TestSetup(unittest.TestCase): class TestSetup(unittest.TestCase):
def urlopen(self, url): def urlopen(self, url):
return open(self.tarball) return open(self.tarball, 'rb')
def setUp(self): def setUp(self):
self.old_sys_path = copy.copy(sys.path) self.old_sys_path = copy.copy(sys.path)
...@@ -27,10 +27,7 @@ class TestSetup(unittest.TestCase): ...@@ -27,10 +27,7 @@ class TestSetup(unittest.TestCase):
"--dist-dir", "%s" % self.tmpdir) "--dist-dir", "%s" % self.tmpdir)
tarball = os.listdir(self.tmpdir)[0] tarball = os.listdir(self.tmpdir)[0]
self.tarball = os.path.join(self.tmpdir, tarball) self.tarball = os.path.join(self.tmpdir, tarball)
try: from setuptools.compat import urllib2
import urllib2
except ImportError:
import urllib.request as urllib2
urllib2.urlopen = self.urlopen urllib2.urlopen = self.urlopen
def tearDown(self): def tearDown(self):
...@@ -40,7 +37,7 @@ class TestSetup(unittest.TestCase): ...@@ -40,7 +37,7 @@ class TestSetup(unittest.TestCase):
def test_build_egg(self): def test_build_egg(self):
# making it an egg # making it an egg
egg = _build_egg(self.tarball, self.tmpdir) egg = _build_egg('Egg to be built', self.tarball, self.tmpdir)
# now trying to import it # now trying to import it
sys.path[0] = egg sys.path[0] = egg
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment