summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.hgtags6
-rw-r--r--.travis.yml4
-rw-r--r--CHANGES.txt52
-rw-r--r--ez_setup.py32
-rw-r--r--release.py32
-rwxr-xr-xsetuptools/command/develop.py9
-rwxr-xr-xsetuptools/command/easy_install.py8
-rwxr-xr-xsetuptools/command/setopt.py4
-rw-r--r--setuptools/compat.py8
-rw-r--r--setuptools/dist.py15
-rwxr-xr-xsetuptools/package_index.py49
-rwxr-xr-xsetuptools/sandbox.py7
-rw-r--r--setuptools/ssl_support.py6
-rw-r--r--setuptools/tests/files.py32
-rw-r--r--setuptools/tests/test_easy_install.py11
-rw-r--r--setuptools/tests/test_egg_info.py70
-rw-r--r--setuptools/tests/test_packageindex.py21
-rw-r--r--setuptools/tests/test_sandbox.py39
-rw-r--r--setuptools/tests/test_setuptools.py2
-rw-r--r--setuptools/version.py2
20 files changed, 307 insertions, 102 deletions
diff --git a/.hgtags b/.hgtags
index 508adf5b..60ce3f94 100644
--- a/.hgtags
+++ b/.hgtags
@@ -227,3 +227,9 @@ dfe190b09908f6b953209d13573063809de451b8 18.6
804f87045a901f1dc121cf9149143d654228dc13 18.6.1
67d07805606aead09349d5b91d7d26c68ddad2fc 18.7
3041e1fc409be90e885968b90faba405420fc161 18.7.1
+c811801ffa1de758cf01fbf6a86e4c04ff0c0935 18.8
+fbf06fa35f93a43f044b1645a7e4ff470edb462c 18.8.1
+cc41477ecf92f221c113736fac2830bf8079d40c 19.0
+834782ce49154e9744e499e00eb392c347f9e034 19.1
+0a2a3d89416e1642cf6f41d22dbc07b3d3c15a4d 19.1.1
+5d24cf9d1ced76c406ab3c4a94c25d1fe79b94bc 19.2
diff --git a/.travis.yml b/.travis.yml
index 0bfb11bb..54d9c395 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -20,4 +20,6 @@ script:
- python bootstrap.py
- python setup.py test --addopts='-rs'
- - python ez_setup.py --version 18.6.1
+
+ # test the bootstrap script
+ - python ez_setup.py
diff --git a/CHANGES.txt b/CHANGES.txt
index cb9bb02d..30e153a4 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -4,6 +4,58 @@ CHANGES
----
+19.3
+----
+
+* Pull Request #164: Replace dual PEP 345 _markerlib implementation
+ and PEP 426 implementation of environment marker support from
+ packaging 15.4 and PEP-508. Fixes Issue #122.
+
+----
+19.2
+----
+
+* Pull Request #163: Add get_command_list method to Distribution.
+* Pull Request #162: Add missing whitespace to multiline string
+ literals.
+
+------
+19.1.1
+------
+
+* Issue #476: Cast version to string (using default encoding)
+ to avoid creating Unicode types on Python 2 clients.
+* Issue #477: In Powershell downloader, use explicit rendering
+ of strings, rather than rely on ``repr``, which can be
+ incorrect (especially on Python 2).
+
+----
+19.1
+----
+
+* Issue #215: The bootstrap script ``ez_setup.py`` now
+ automatically detects
+ the latest version of setuptools (using PyPI JSON API) rather
+ than hard-coding a particular value.
+* Issue #475: Fix incorrect usage in _translate_metadata2.
+
+----
+19.0
+----
+
+* Issue #442: Use RawConfigParser for parsing .pypirc file.
+ Interpolated values are no longer honored in .pypirc files.
+
+------
+18.8.1
+------
+
+* Issue #440: Prevent infinite recursion when a SandboxViolation
+ or other UnpickleableException occurs in a sandbox context
+ with setuptools hidden. Fixes regression introduced in Setuptools
+ 12.0.
+
+----
18.8
----
diff --git a/ez_setup.py b/ez_setup.py
index 975b45c5..9715bdc7 100644
--- a/ez_setup.py
+++ b/ez_setup.py
@@ -16,7 +16,8 @@ import subprocess
import platform
import textwrap
import contextlib
-import warnings
+import json
+import codecs
from distutils import log
@@ -30,7 +31,8 @@ try:
except ImportError:
USER_SITE = None
-DEFAULT_VERSION = "18.7.2"
+LATEST = object()
+DEFAULT_VERSION = LATEST
DEFAULT_URL = "https://pypi.python.org/packages/source/s/setuptools/"
DEFAULT_SAVE_DIR = os.curdir
@@ -140,6 +142,7 @@ def use_setuptools(
Return None. Raise SystemExit if the requested version
or later cannot be installed.
"""
+ version = _resolve_version(version)
to_dir = os.path.abspath(to_dir)
# prior to importing, capture the module state for
@@ -222,8 +225,8 @@ def download_file_powershell(url, target):
ps_cmd = (
"[System.Net.WebRequest]::DefaultWebProxy.Credentials = "
"[System.Net.CredentialCache]::DefaultCredentials; "
- "(new-object System.Net.WebClient).DownloadFile(%(url)r, %(target)r)"
- % vars()
+ '(new-object System.Net.WebClient).DownloadFile("%(url)s", "%(target)s")'
+ % locals()
)
cmd = [
'powershell',
@@ -321,6 +324,7 @@ def download_setuptools(
``downloader_factory`` should be a function taking no arguments and
returning a function for downloading a URL to a target.
"""
+ version = _resolve_version(version)
# making sure we use the absolute path
to_dir = os.path.abspath(to_dir)
zip_name = "setuptools-%s.zip" % version
@@ -333,6 +337,26 @@ def download_setuptools(
return os.path.realpath(saveto)
+def _resolve_version(version):
+ """
+ Resolve LATEST version
+ """
+ if version is not LATEST:
+ return version
+
+ resp = urlopen('https://pypi.python.org/pypi/setuptools/json')
+ with contextlib.closing(resp):
+ try:
+ charset = resp.info().get_content_charset()
+ except Exception:
+ # Python 2 compat; assume UTF-8
+ charset = 'UTF-8'
+ reader = codecs.getreader(charset)
+ doc = json.load(reader(resp))
+
+ return str(doc['info']['version'])
+
+
def _build_install_args(options):
"""
Build the arguments to 'python setup.py install' on the setuptools package.
diff --git a/release.py b/release.py
index a76d2de4..dd1d6a1c 100644
--- a/release.py
+++ b/release.py
@@ -4,24 +4,13 @@ install jaraco.packaging and run 'python -m jaraco.packaging.release'
"""
import os
-import subprocess
import pkg_resources
pkg_resources.require('jaraco.packaging>=2.0')
pkg_resources.require('wheel')
-
-def before_upload():
- BootstrapBookmark.add()
-
-
-def after_push():
- BootstrapBookmark.push()
-
-files_with_versions = (
- 'ez_setup.py', 'setuptools/version.py',
-)
+files_with_versions = 'setuptools/version.py',
# bdist_wheel must be included or pip will break
dist_commands = 'sdist', 'bdist_wheel'
@@ -29,22 +18,3 @@ dist_commands = 'sdist', 'bdist_wheel'
test_info = "Travis-CI tests: http://travis-ci.org/#!/jaraco/setuptools"
os.environ["SETUPTOOLS_INSTALL_WINDOWS_SPECIFIC_FILES"] = "1"
-
-class BootstrapBookmark:
- name = 'bootstrap'
-
- @classmethod
- def add(cls):
- cmd = ['hg', 'bookmark', '-i', cls.name, '-f']
- subprocess.Popen(cmd)
-
- @classmethod
- def push(cls):
- """
- Push the bootstrap bookmark
- """
- push_command = ['hg', 'push', '-B', cls.name]
- # don't use check_call here because mercurial will return a non-zero
- # code even if it succeeds at pushing the bookmark (because there are
- # no changesets to be pushed). !dm mercurial
- subprocess.call(push_command)
diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py
index 3a16cdc7..07b66ccb 100755
--- a/setuptools/command/develop.py
+++ b/setuptools/command/develop.py
@@ -54,8 +54,8 @@ class develop(easy_install):
# pick up setup-dir .egg files only: no .egg-info
self.package_index.scan(glob.glob('*.egg'))
- self.egg_link = os.path.join(self.install_dir, ei.egg_name +
- '.egg-link')
+ egg_link_fn = ei.egg_name + '.egg-link'
+ self.egg_link = os.path.join(self.install_dir, egg_link_fn)
self.egg_base = ei.egg_base
if self.egg_path is None:
self.egg_path = os.path.abspath(ei.egg_base)
@@ -125,9 +125,8 @@ class develop(easy_install):
# create an .egg-link in the installation dir, pointing to our egg
log.info("Creating %s (link to %s)", self.egg_link, self.egg_base)
if not self.dry_run:
- f = open(self.egg_link, "w")
- f.write(self.egg_path + "\n" + self.setup_path)
- f.close()
+ with open(self.egg_link, "w") as f:
+ f.write(self.egg_path + "\n" + self.setup_path)
# postprocess the installed distro, fixing up .pth, installing scripts,
# and handling requirements
self.process_distribution(None, self.dist, not self.no_deps)
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py
index 79f068b1..9ca3b515 100755
--- a/setuptools/command/easy_install.py
+++ b/setuptools/command/easy_install.py
@@ -1402,7 +1402,7 @@ def expand_paths(inputs):
def extract_wininst_cfg(dist_filename):
"""Extract configuration data from a bdist_wininst .exe
- Returns a ConfigParser.RawConfigParser, or None
+ Returns a configparser.RawConfigParser, or None
"""
f = open(dist_filename, 'rb')
try:
@@ -1415,7 +1415,7 @@ def extract_wininst_cfg(dist_filename):
return None
f.seek(prepended - 12)
- from setuptools.compat import StringIO, ConfigParser
+ from setuptools.compat import StringIO, configparser
import struct
tag, cfglen, bmlen = struct.unpack("<iii", f.read(12))
@@ -1423,7 +1423,7 @@ def extract_wininst_cfg(dist_filename):
return None # not a valid tag
f.seek(prepended - (12 + cfglen))
- cfg = ConfigParser.RawConfigParser(
+ cfg = configparser.RawConfigParser(
{'version': '', 'target_version': ''})
try:
part = f.read(cfglen)
@@ -1433,7 +1433,7 @@ def extract_wininst_cfg(dist_filename):
# be text, so decode it.
config = config.decode(sys.getfilesystemencoding())
cfg.readfp(StringIO(config))
- except ConfigParser.Error:
+ except configparser.Error:
return None
if not cfg.has_section('metadata') or not cfg.has_section('Setup'):
return None
diff --git a/setuptools/command/setopt.py b/setuptools/command/setopt.py
index a04d6032..74c7cad8 100755
--- a/setuptools/command/setopt.py
+++ b/setuptools/command/setopt.py
@@ -37,10 +37,10 @@ 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 setuptools.compat import ConfigParser
+ from setuptools.compat import configparser
log.debug("Reading configuration from %s", filename)
- opts = ConfigParser.RawConfigParser()
+ opts = configparser.RawConfigParser()
opts.read([filename])
for section, options in settings.items():
if options is None:
diff --git a/setuptools/compat.py b/setuptools/compat.py
index 73e6e4aa..f0175a5d 100644
--- a/setuptools/compat.py
+++ b/setuptools/compat.py
@@ -7,7 +7,7 @@ PY2 = not PY3
if PY2:
basestring = basestring
import __builtin__ as builtins
- import ConfigParser
+ import ConfigParser as configparser
from StringIO import StringIO
BytesIO = StringIO
func_code = lambda o: o.func_code
@@ -29,6 +29,8 @@ if PY2:
from urllib2 import urlopen, HTTPError, URLError, unquote, splituser
from urlparse import urlparse, urlunparse, urljoin, urlsplit, urlunsplit
filterfalse = itertools.ifilterfalse
+ filter = itertools.ifilter
+ map = itertools.imap
exec("""def reraise(tp, value, tb=None):
raise tp, value, tb""")
@@ -36,7 +38,7 @@ if PY2:
if PY3:
basestring = str
import builtins
- import configparser as ConfigParser
+ import configparser
from io import StringIO, BytesIO
func_code = lambda o: o.__code__
func_globals = lambda o: o.__globals__
@@ -59,6 +61,8 @@ if PY3:
urlunsplit, splittag,
)
filterfalse = itertools.filterfalse
+ filter = filter
+ map = map
def reraise(tp, value, tb=None):
if value.__traceback__ is not tb:
diff --git a/setuptools/dist.py b/setuptools/dist.py
index d7ad4655..db15809d 100644
--- a/setuptools/dist.py
+++ b/setuptools/dist.py
@@ -160,7 +160,7 @@ def check_packages(dist, attr, value):
for pkgname in value:
if not re.match(r'\w+(\.\w+)*', pkgname):
distutils.log.warn(
- "WARNING: %r not a valid package name; please use only"
+ "WARNING: %r not a valid package name; please use only "
".-separated package names in setup.py", pkgname
)
@@ -267,8 +267,7 @@ class Distribution(_Distribution):
if attrs and 'setup_requires' in attrs:
self.fetch_build_eggs(attrs['setup_requires'])
for ep in pkg_resources.iter_entry_points('distutils.setup_keywords'):
- if not hasattr(self,ep.name):
- setattr(self,ep.name,None)
+ vars(self).setdefault(ep.name, None)
_Distribution.__init__(self,attrs)
if isinstance(self.metadata.version, numbers.Number):
# Some people apparently take "version number" too literally :)
@@ -440,6 +439,14 @@ class Distribution(_Distribution):
self.cmdclass[ep.name] = cmdclass
return _Distribution.print_commands(self)
+ def get_command_list(self):
+ for ep in pkg_resources.iter_entry_points('distutils.commands'):
+ if ep.name not in self.cmdclass:
+ # don't require extras as the commands won't be invoked
+ cmdclass = ep.resolve()
+ self.cmdclass[ep.name] = cmdclass
+ return _Distribution.get_command_list(self)
+
def _set_feature(self,name,status):
"""Set feature's inclusion status"""
setattr(self,self._feature_attrname(name),status)
@@ -818,7 +825,7 @@ class Feature:
if not self.available:
raise DistutilsPlatformError(
- self.description+" is required,"
+ self.description+" is required, "
"but is not available on this platform"
)
diff --git a/setuptools/package_index.py b/setuptools/package_index.py
index 525cb645..2c565e88 100755
--- a/setuptools/package_index.py
+++ b/setuptools/package_index.py
@@ -6,6 +6,7 @@ import shutil
import socket
import base64
import hashlib
+import itertools
from functools import wraps
from pkg_resources import (
@@ -16,11 +17,11 @@ from pkg_resources import (
from setuptools import ssl_support
from distutils import log
from distutils.errors import DistutilsError
-from setuptools.compat import (urllib2, httplib, StringIO, HTTPError,
- urlparse, urlunparse, unquote, splituser,
- url2pathname, name2codepoint,
- unichr, urljoin, urlsplit, urlunsplit,
- ConfigParser)
+from setuptools.compat import (
+ urllib2, httplib, StringIO, HTTPError, urlparse, urlunparse, unquote,
+ splituser, url2pathname, name2codepoint, unichr, urljoin, urlsplit,
+ urlunsplit, configparser, filter, map,
+)
from setuptools.compat import filterfalse
from fnmatch import translate
from setuptools.py26compat import strip_fragment
@@ -352,20 +353,30 @@ class PackageIndex(Environment):
self.warn(msg, url)
def scan_egg_links(self, search_path):
- for item in search_path:
- if os.path.isdir(item):
- for entry in os.listdir(item):
- if entry.endswith('.egg-link'):
- self.scan_egg_link(item, entry)
+ dirs = filter(os.path.isdir, search_path)
+ egg_links = (
+ (path, entry)
+ for path in dirs
+ for entry in os.listdir(path)
+ if entry.endswith('.egg-link')
+ )
+ list(itertools.starmap(self.scan_egg_link, egg_links))
def scan_egg_link(self, path, entry):
- lines = [_f for _f in map(str.strip,
- open(os.path.join(path, entry))) if _f]
- if len(lines)==2:
- for dist in find_distributions(os.path.join(path, lines[0])):
- dist.location = os.path.join(path, *lines)
- dist.precedence = SOURCE_DIST
- self.add(dist)
+ with open(os.path.join(path, entry)) as raw_lines:
+ # filter non-empty lines
+ lines = list(filter(None, map(str.strip, raw_lines)))
+
+ if len(lines) != 2:
+ # format is not recognized; punt
+ return
+
+ egg_path, setup_path = lines
+
+ for dist in find_distributions(os.path.join(path, egg_path)):
+ dist.location = os.path.join(path, *lines)
+ dist.precedence = SOURCE_DIST
+ self.add(dist)
def process_index(self,url,page):
"""Process the contents of a PyPI page"""
@@ -934,14 +945,14 @@ class Credential(object):
def __str__(self):
return '%(username)s:%(password)s' % vars(self)
-class PyPIConfig(ConfigParser.ConfigParser):
+class PyPIConfig(configparser.RawConfigParser):
def __init__(self):
"""
Load from ~/.pypirc
"""
defaults = dict.fromkeys(['username', 'password', 'repository'], '')
- ConfigParser.ConfigParser.__init__(self, defaults)
+ configparser.RawConfigParser.__init__(self, defaults)
rc = os.path.join(os.path.expanduser('~'), '.pypirc')
if os.path.exists(rc):
diff --git a/setuptools/sandbox.py b/setuptools/sandbox.py
index 213cebff..85de85ff 100755
--- a/setuptools/sandbox.py
+++ b/setuptools/sandbox.py
@@ -98,8 +98,8 @@ class UnpickleableException(Exception):
"""
An exception representing another Exception that could not be pickled.
"""
- @classmethod
- def dump(cls, type, exc):
+ @staticmethod
+ def dump(type, exc):
"""
Always return a dumped (pickled) type and exc. If exc can't be pickled,
wrap it in UnpickleableException first.
@@ -107,6 +107,8 @@ class UnpickleableException(Exception):
try:
return pickle.dumps(type), pickle.dumps(exc)
except Exception:
+ # get UnpickleableException inside the sandbox
+ from setuptools.sandbox import UnpickleableException as cls
return cls.dump(cls, cls(repr(exc)))
@@ -382,6 +384,7 @@ class DirectorySandbox(AbstractSandbox):
AbstractSandbox.__init__(self)
def _violation(self, operation, *args, **kw):
+ from setuptools.sandbox import SandboxViolation
raise SandboxViolation(operation, args, kw)
if _file:
diff --git a/setuptools/ssl_support.py b/setuptools/ssl_support.py
index cc7db067..7394f4f5 100644
--- a/setuptools/ssl_support.py
+++ b/setuptools/ssl_support.py
@@ -223,6 +223,12 @@ def get_win_certfile():
self.addcerts(certs)
atexit.register(self.close)
+ def close(self):
+ try:
+ super(MyCertFile, self).close()
+ except OSError:
+ pass
+
_wincerts = MyCertFile(stores=['CA', 'ROOT'])
return _wincerts.name
diff --git a/setuptools/tests/files.py b/setuptools/tests/files.py
new file mode 100644
index 00000000..4364241b
--- /dev/null
+++ b/setuptools/tests/files.py
@@ -0,0 +1,32 @@
+import os
+
+
+def build_files(file_defs, prefix=""):
+ """
+ Build a set of files/directories, as described by the file_defs dictionary.
+
+ Each key/value pair in the dictionary is interpreted as a filename/contents
+ pair. If the contents value is a dictionary, a directory is created, and the
+ dictionary interpreted as the files within it, recursively.
+
+ For example:
+
+ {"README.txt": "A README file",
+ "foo": {
+ "__init__.py": "",
+ "bar": {
+ "__init__.py": "",
+ },
+ "baz.py": "# Some code",
+ }
+ }
+ """
+ for name, contents in file_defs.items():
+ full_name = os.path.join(prefix, name)
+ if isinstance(contents, dict):
+ if not os.path.exists(full_name):
+ os.makedirs(full_name)
+ build_files(contents, prefix=full_name)
+ else:
+ with open(full_name, 'w') as f:
+ f.write(contents)
diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py
index 00e16b63..f0330f17 100644
--- a/setuptools/tests/test_easy_install.py
+++ b/setuptools/tests/test_easy_install.py
@@ -446,10 +446,15 @@ class TestScriptHeader:
exe = tmpdir / 'exe.py'
with exe.open('w') as f:
f.write(header)
- exe = str(exe)
+
+ exe = ei.nt_quote_arg(os.path.normpath(str(exe)))
+
+ # Make sure Windows paths are quoted properly before they're sent
+ # through shlex.split by get_script_header
+ executable = '"%s"' % exe if os.path.splitdrive(exe)[0] else exe
header = ei.ScriptWriter.get_script_header('#!/usr/local/bin/python',
- executable=exe)
+ executable=executable)
assert header == '#!/usr/bin/env %s\n' % exe
expect_out = 'stdout' if sys.version_info < (2,7) else 'stderr'
@@ -458,7 +463,7 @@ class TestScriptHeader:
# When options are included, generate a broken shebang line
# with a warning emitted
candidate = ei.ScriptWriter.get_script_header('#!/usr/bin/python -x',
- executable=exe)
+ executable=executable)
assert candidate == '#!%s -x\n' % exe
output = locals()[expect_out]
assert 'Unable to adapt shebang line' in output.getvalue()
diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py
index 645c379c..333d11d6 100644
--- a/setuptools/tests/test_egg_info.py
+++ b/setuptools/tests/test_egg_info.py
@@ -4,6 +4,7 @@ import stat
import pytest
from . import environment
+from .files import build_files
from .textwrap import DALS
from . import contexts
@@ -26,14 +27,13 @@ class TestEggInfo(object):
""")
def _create_project(self):
- with open('setup.py', 'w') as f:
- f.write(self.setup_script)
-
- with open('hello.py', 'w') as f:
- f.write(DALS("""
+ build_files({
+ 'setup.py': self.setup_script,
+ 'hello.py': DALS("""
def run():
print('hello')
- """))
+ """)
+ })
@pytest.yield_fixture
def env(self):
@@ -46,17 +46,48 @@ class TestEggInfo(object):
for dirname in subs
)
list(map(os.mkdir, env.paths.values()))
- config = os.path.join(env.paths['home'], '.pydistutils.cfg')
- with open(config, 'w') as f:
- f.write(DALS("""
+ build_files({
+ env.paths['home']: {
+ '.pydistutils.cfg': DALS("""
[egg_info]
egg-base = %(egg-base)s
- """ % env.paths))
+ """ % env.paths)
+ }
+ })
yield env
def test_egg_base_installed_egg_info(self, tmpdir_cwd, env):
self._create_project()
+ self._run_install_command(tmpdir_cwd, env)
+ actual = self._find_egg_info_files(env.paths['lib'])
+
+ expected = [
+ 'PKG-INFO',
+ 'SOURCES.txt',
+ 'dependency_links.txt',
+ 'entry_points.txt',
+ 'not-zip-safe',
+ 'top_level.txt',
+ ]
+ assert sorted(actual) == expected
+
+ def test_manifest_template_is_read(self, tmpdir_cwd, env):
+ self._create_project()
+ build_files({
+ 'MANIFEST.in': DALS("""
+ recursive-include docs *.rst
+ """),
+ 'docs': {
+ 'usage.rst': "Run 'hi'",
+ }
+ })
+ self._run_install_command(tmpdir_cwd, env)
+ egg_info_dir = self._find_egg_info_files(env.paths['lib']).base
+ sources_txt = os.path.join(egg_info_dir, 'SOURCES.txt')
+ assert 'docs/usage.rst' in open(sources_txt).read().split('\n')
+
+ def _run_install_command(self, tmpdir_cwd, env):
environ = os.environ.copy().update(
HOME=env.paths['home'],
)
@@ -76,21 +107,14 @@ class TestEggInfo(object):
if code:
raise AssertionError(data)
- actual = self._find_egg_info_files(env.paths['lib'])
-
- expected = [
- 'PKG-INFO',
- 'SOURCES.txt',
- 'dependency_links.txt',
- 'entry_points.txt',
- 'not-zip-safe',
- 'top_level.txt',
- ]
- assert sorted(actual) == expected
-
def _find_egg_info_files(self, root):
+ class DirList(list):
+ def __init__(self, files, base):
+ super(DirList, self).__init__(files)
+ self.base = base
+
results = (
- filenames
+ DirList(filenames, dirpath)
for dirpath, dirnames, filenames in os.walk(root)
if os.path.basename(dirpath) == 'EGG-INFO'
)
diff --git a/setuptools/tests/test_packageindex.py b/setuptools/tests/test_packageindex.py
index dcd90d6f..746860d5 100644
--- a/setuptools/tests/test_packageindex.py
+++ b/setuptools/tests/test_packageindex.py
@@ -1,7 +1,11 @@
+from __future__ import absolute_import
+
import sys
+import os
import distutils.errors
from setuptools.compat import httplib, HTTPError, unicode, pathname2url
+from .textwrap import DALS
import pkg_resources
import setuptools.package_index
@@ -201,3 +205,20 @@ class TestContentCheckers:
'http://foo/bar#md5=f12895fdffbd45007040d2e44df98478')
rep = checker.report(lambda x: x, 'My message about %s')
assert rep == 'My message about md5'
+
+
+class TestPyPIConfig:
+ def test_percent_in_password(self, tmpdir, monkeypatch):
+ monkeypatch.setitem(os.environ, 'HOME', str(tmpdir))
+ pypirc = tmpdir / '.pypirc'
+ with pypirc.open('w') as strm:
+ strm.write(DALS("""
+ [pypi]
+ repository=https://pypi.python.org
+ username=jaraco
+ password=pity%
+ """))
+ cfg = setuptools.package_index.PyPIConfig()
+ cred = cfg.creds_by_repository['https://pypi.python.org']
+ assert cred.username == 'jaraco'
+ assert cred.password == 'pity%'
diff --git a/setuptools/tests/test_sandbox.py b/setuptools/tests/test_sandbox.py
index 6e1e9e1c..fefd46f7 100644
--- a/setuptools/tests/test_sandbox.py
+++ b/setuptools/tests/test_sandbox.py
@@ -100,3 +100,42 @@ class TestExceptionSaver:
saved_exc.resume()
assert str(caught.value) == "CantPickleThis('detail',)"
+
+ def test_unpickleable_exception_when_hiding_setuptools(self):
+ """
+ As revealed in #440, an infinite recursion can occur if an unpickleable
+ exception while setuptools is hidden. Ensure this doesn't happen.
+ """
+ class ExceptionUnderTest(Exception):
+ """
+ An unpickleable exception (not in globals).
+ """
+
+ with pytest.raises(setuptools.sandbox.UnpickleableException) as caught:
+ with setuptools.sandbox.save_modules():
+ setuptools.sandbox.hide_setuptools()
+ raise ExceptionUnderTest()
+
+ msg, = caught.value.args
+ assert msg == 'ExceptionUnderTest()'
+
+ def test_sandbox_violation_raised_hiding_setuptools(self, tmpdir):
+ """
+ When in a sandbox with setuptools hidden, a SandboxViolation
+ should reflect a proper exception and not be wrapped in
+ an UnpickleableException.
+ """
+ def write_file():
+ "Trigger a SandboxViolation by writing outside the sandbox"
+ with open('/etc/foo', 'w'):
+ pass
+ sandbox = DirectorySandbox(str(tmpdir))
+ with pytest.raises(setuptools.sandbox.SandboxViolation) as caught:
+ with setuptools.sandbox.save_modules():
+ setuptools.sandbox.hide_setuptools()
+ sandbox.run(write_file)
+
+ cmd, args, kwargs = caught.value.args
+ assert cmd == 'open'
+ assert args == ('/etc/foo', 'w')
+ assert kwargs == {}
diff --git a/setuptools/tests/test_setuptools.py b/setuptools/tests/test_setuptools.py
index 8aca593a..e59800d2 100644
--- a/setuptools/tests/test_setuptools.py
+++ b/setuptools/tests/test_setuptools.py
@@ -23,7 +23,7 @@ def test_findall(example_source):
def test_findall_curdir(example_source):
with example_source.as_cwd():
found = list(setuptools.findall())
- expected = ['readme.txt', 'foo/bar.py']
+ expected = ['readme.txt', os.path.join('foo', 'bar.py')]
assert found == expected
diff --git a/setuptools/version.py b/setuptools/version.py
index 5e40c658..09bbb730 100644
--- a/setuptools/version.py
+++ b/setuptools/version.py
@@ -1 +1 @@
-__version__ = '18.7.2'
+__version__ = '19.3'