Skip to content

Commit

Permalink
Merge pull request #1 from pypa/master
Browse files Browse the repository at this point in the history
Merge recent changes
  • Loading branch information
xoviat committed Dec 23, 2017
2 parents a20d768 + e001996 commit a68a8ff
Show file tree
Hide file tree
Showing 40 changed files with 1,488 additions and 267 deletions.
19 changes: 10 additions & 9 deletions .travis.yml
@@ -1,18 +1,19 @@
dist: trusty
sudo: false
language: python
python:
- &latest_py2 2.7
- 3.3
- 3.4
- 3.5
- &latest_py3 3.6
- nightly
- pypy
- pypy3

jobs:
fast_finish: true
include:
- python: 2.6
- python: &latest_py2 2.7
- python: 3.3
- python: 3.4
- python: 3.5
- python: &latest_py3 3.6
- python: nightly
- python: pypy
- python: pypy3
- python: *latest_py3
env: LANG=C
- python: *latest_py2
Expand Down
63 changes: 63 additions & 0 deletions CHANGES.rst
@@ -1,3 +1,66 @@
v38.2.4
-------

* #1220: Fix `data_files` handling when installing from wheel.

v38.2.3
-------

* fix Travis' Python 3.3 job.

v38.2.2
-------

* #1214: fix handling of namespace packages when installing
from a wheel.

v38.2.1
-------

* #1212: fix encoding handling of metadata when installing
from a wheel.

v38.2.0
-------

* #1200: easy_install now support installing from wheels:
they will be installed as standalone unzipped eggs.

v38.1.0
-------

* #1208: Improve error message when failing to locate scripts
in egg-info metadata.

v38.0.0
-------

* #458: In order to support deterministic builds, Setuptools no
longer allows packages to declare ``install_requires`` as
unordered sequences (sets or dicts).

v37.0.0
-------

* #878: Drop support for Python 2.6. Python 2.6 users should
rely on 'setuptools < 37dev'.

v36.8.0
-------

* #1190: In SSL support for package index operations, use SNI
where available.

v36.7.3
-------

* #1175: Bug fixes to ``build_meta`` module.

v36.7.2
-------

* #701: Fixed duplicate test discovery on Python 3.

v36.7.1
-------

Expand Down
2 changes: 1 addition & 1 deletion README.rst
Expand Up @@ -5,7 +5,7 @@
:target: https://setuptools.readthedocs.io

.. image:: https://img.shields.io/travis/pypa/setuptools/master.svg?label=Linux%20build%20%40%20Travis%20CI
:target: http://travis-ci.org/pypa/setuptools
:target: https://travis-ci.org/pypa/setuptools

.. image:: https://img.shields.io/appveyor/ci/jaraco/setuptools/master.svg?label=Windows%20build%20%40%20Appveyor
:target: https://ci.appveyor.com/project/jaraco/setuptools/branch/master
Expand Down
12 changes: 5 additions & 7 deletions docs/easy_install.txt
Expand Up @@ -35,7 +35,7 @@ Please see the `setuptools PyPI page <https://pypi.python.org/pypi/setuptools>`_
for download links and basic installation instructions for each of the
supported platforms.

You will need at least Python 2.6. An ``easy_install`` script will be
You will need at least Python 3.3 or 2.7. An ``easy_install`` script will be
installed in the normal location for Python scripts on your platform.

Note that the instructions on the setuptools PyPI page assume that you are
Expand Down Expand Up @@ -305,8 +305,7 @@ Regardless of the technique used, the script(s) will be installed to a Scripts
directory (by default in the Python installation directory). It is recommended
for EasyInstall that you ensure this directory is in the PATH environment
variable. The easiest way to ensure the Scripts directory is in the PATH is
to run ``Tools\Scripts\win_add2path.py`` from the Python directory (requires
Python 2.6 or later).
to run ``Tools\Scripts\win_add2path.py`` from the Python directory.

Note that instead of changing your ``PATH`` to include the Python scripts
directory, you can also retarget the installation location for scripts so they
Expand Down Expand Up @@ -987,21 +986,20 @@ The following section lists only the easiest and most relevant approaches [1]_.

`Use "virtualenv"`_

.. [1] There are older ways to achieve custom installation using various ``easy_install`` and ``setup.py install`` options, combined with ``PYTHONPATH`` and/or ``PYTHONUSERBASE`` alterations, but all of these are effectively deprecated by the User scheme brought in by `PEP-370`_ in Python 2.6.
.. [1] There are older ways to achieve custom installation using various ``easy_install`` and ``setup.py install`` options, combined with ``PYTHONPATH`` and/or ``PYTHONUSERBASE`` alterations, but all of these are effectively deprecated by the User scheme brought in by `PEP-370`_.

.. _PEP-370: http://www.python.org/dev/peps/pep-0370/


Use the "--user" option
~~~~~~~~~~~~~~~~~~~~~~~
With Python 2.6 came the User scheme for installation, which means that all
python distributions support an alternative install location that is specific to a user [2]_ [3]_.
Python provides a User scheme for installation, which means that all
python distributions support an alternative install location that is specific to a user [3]_.
The Default location for each OS is explained in the python documentation
for the ``site.USER_BASE`` variable. This mode of installation can be turned on by
specifying the ``--user`` option to ``setup.py install`` or ``easy_install``.
This approach serves the need to have a user-specific stash of packages.

.. [2] Prior to Python2.6, Mac OS X offered a form of the User scheme. That is now subsumed into the User scheme introduced in Python 2.6.
.. [3] Prior to the User scheme, there was the Home scheme, which is still available, but requires more effort than the User scheme to get packages recognized.

Use the "--user" option and customize "PYTHONUSERBASE"
Expand Down
2 changes: 1 addition & 1 deletion docs/formats.txt
Expand Up @@ -110,7 +110,7 @@ the need to create a directory just to store one file. This option is
other metadata. (In fact, setuptools itself never generates
``.egg-info`` files, either; the support for using files was added so
that the requirement could easily be satisfied by other tools, such
as the distutils in Python 2.5).
as distutils).

In addition to the ``PKG-INFO`` file, an egg's metadata directory may
also include files and directories representing various forms of
Expand Down
18 changes: 3 additions & 15 deletions docs/pkg_resources.txt
Expand Up @@ -620,8 +620,8 @@ Requirements Parsing
The "markers" in a requirement are used to specify when a requirement
should be installed -- the requirement will be installed if the marker
evaluates as true in the current environment. For example, specifying
``argparse;python_version<"2.7"`` will not install in an Python 2.7 or 3.3
environment, but will in a Python 2.6 environment.
``argparse;python_version<"3.0"`` will not install in an Python 3
environment, but will in a Python 2 environment.

``Requirement`` Methods and Attributes
--------------------------------------
Expand Down Expand Up @@ -1658,19 +1658,7 @@ PEP 302 Utilities
-----------------

``get_importer(path_item)``
Retrieve a PEP 302 "importer" for the given path item (which need not
actually be on ``sys.path``). This routine simulates the PEP 302 protocol
for obtaining an "importer" object. It first checks for an importer for
the path item in ``sys.path_importer_cache``, and if not found it calls
each of the ``sys.path_hooks`` and caches the result if a good importer is
found. If no importer is found, this routine returns an ``ImpWrapper``
instance that wraps the builtin import machinery as a PEP 302-compliant
"importer" object. This ``ImpWrapper`` is *not* cached; instead a new
instance is returned each time.

(Note: When run under Python 2.5, this function is simply an alias for
``pkgutil.get_importer()``, and instead of ``pkg_resources.ImpWrapper``
instances, it may return ``pkgutil.ImpImporter`` instances.)
A deprecated alias for ``pkgutil.get_importer()``


File/Path Utilities
Expand Down
2 changes: 1 addition & 1 deletion docs/setuptools.txt
Expand Up @@ -3,7 +3,7 @@ Building and Distributing Packages with Setuptools
==================================================

``Setuptools`` is a collection of enhancements to the Python ``distutils``
(for Python 2.6 and up) that allow developers to more easily build and
that allow developers to more easily build and
distribute Python packages, especially ones that have dependencies on other
packages.

Expand Down
29 changes: 6 additions & 23 deletions pkg_resources/__init__.py
Expand Up @@ -1513,7 +1513,10 @@ def metadata_listdir(self, name):
def run_script(self, script_name, namespace):
script = 'scripts/' + script_name
if not self.has_metadata(script):
raise ResolutionError("No script named %r" % script_name)
raise ResolutionError(
"Script {script!r} not found in metadata at {self.egg_info!r}"
.format(**locals()),
)
script_text = self.get_metadata(script).replace('\r\n', '\n')
script_text = script_text.replace('\r', '\n')
script_filename = self._fn(self.egg_info, script)
Expand Down Expand Up @@ -1644,7 +1647,7 @@ def build(cls, path):
Use a platform-specific path separator (os.sep) for the path keys
for compatibility with pypy on Windows.
"""
with ContextualZipFile(path) as zfile:
with zipfile.ZipFile(path) as zfile:
items = (
(
name.replace('/', os.sep),
Expand Down Expand Up @@ -1677,26 +1680,6 @@ def load(self, path):
return self[path].manifest


class ContextualZipFile(zipfile.ZipFile):
"""
Supplement ZipFile class to support context manager for Python 2.6
"""

def __enter__(self):
return self

def __exit__(self, type, value, traceback):
self.close()

def __new__(cls, *args, **kwargs):
"""
Construct a ZipFile or ContextualZipFile as appropriate
"""
if hasattr(zipfile.ZipFile, '__exit__'):
return zipfile.ZipFile(*args, **kwargs)
return super(ContextualZipFile, cls).__new__(cls)


class ZipProvider(EggProvider):
"""Resource support for zips and eggs"""

Expand Down Expand Up @@ -1897,7 +1880,7 @@ def get_metadata(self, name):
return metadata

def _warn_on_replacement(self, metadata):
# Python 2.6 and 3.2 compat for: replacement_char = '�'
# Python 2.7 compat for: replacement_char = '�'
replacement_char = b'\xef\xbf\xbd'.decode('utf-8')
if replacement_char in metadata:
tmpl = "{self.path} could not be properly decoded in UTF-8"
Expand Down
4 changes: 2 additions & 2 deletions pkg_resources/api_tests.txt
Expand Up @@ -385,10 +385,10 @@ Environment Markers
>>> em("sys_platform=='win32'") == (sys.platform=='win32')
True

>>> em("python_version >= '2.6'")
>>> em("python_version >= '2.7'")
True

>>> em("python_version > '2.5'")
>>> em("python_version > '2.6'")
True

>>> im("implementation_name=='cpython'")
Expand Down
28 changes: 10 additions & 18 deletions pkg_resources/tests/test_resources.py
Expand Up @@ -206,12 +206,10 @@ def test_marker_evaluation_with_extras(self):
"""Extras are also evaluated as markers at resolution time."""
ad = pkg_resources.Environment([])
ws = WorkingSet([])
# Metadata needs to be native strings due to cStringIO behaviour in
# 2.6, so use str().
Foo = Distribution.from_filename(
"/foo_dir/Foo-1.2.dist-info",
metadata=Metadata(("METADATA", str("Provides-Extra: baz\n"
"Requires-Dist: quux; extra=='baz'")))
metadata=Metadata(("METADATA", "Provides-Extra: baz\n"
"Requires-Dist: quux; extra=='baz'"))
)
ad.add(Foo)
assert list(ws.resolve(parse_requirements("Foo"), ad)) == [Foo]
Expand All @@ -224,12 +222,10 @@ def test_marker_evaluation_with_extras_normlized(self):
"""Extras are also evaluated as markers at resolution time."""
ad = pkg_resources.Environment([])
ws = WorkingSet([])
# Metadata needs to be native strings due to cStringIO behaviour in
# 2.6, so use str().
Foo = Distribution.from_filename(
"/foo_dir/Foo-1.2.dist-info",
metadata=Metadata(("METADATA", str("Provides-Extra: baz-lightyear\n"
"Requires-Dist: quux; extra=='baz-lightyear'")))
metadata=Metadata(("METADATA", "Provides-Extra: baz-lightyear\n"
"Requires-Dist: quux; extra=='baz-lightyear'"))
)
ad.add(Foo)
assert list(ws.resolve(parse_requirements("Foo"), ad)) == [Foo]
Expand All @@ -241,14 +237,12 @@ def test_marker_evaluation_with_extras_normlized(self):
def test_marker_evaluation_with_multiple_extras(self):
ad = pkg_resources.Environment([])
ws = WorkingSet([])
# Metadata needs to be native strings due to cStringIO behaviour in
# 2.6, so use str().
Foo = Distribution.from_filename(
"/foo_dir/Foo-1.2.dist-info",
metadata=Metadata(("METADATA", str("Provides-Extra: baz\n"
metadata=Metadata(("METADATA", "Provides-Extra: baz\n"
"Requires-Dist: quux; extra=='baz'\n"
"Provides-Extra: bar\n"
"Requires-Dist: fred; extra=='bar'\n")))
"Requires-Dist: fred; extra=='bar'\n"))
)
ad.add(Foo)
quux = Distribution.from_filename("/foo_dir/quux-1.0.dist-info")
Expand All @@ -261,22 +255,20 @@ def test_marker_evaluation_with_multiple_extras(self):
def test_marker_evaluation_with_extras_loop(self):
ad = pkg_resources.Environment([])
ws = WorkingSet([])
# Metadata needs to be native strings due to cStringIO behaviour in
# 2.6, so use str().
a = Distribution.from_filename(
"/foo_dir/a-0.2.dist-info",
metadata=Metadata(("METADATA", str("Requires-Dist: c[a]")))
metadata=Metadata(("METADATA", "Requires-Dist: c[a]"))
)
b = Distribution.from_filename(
"/foo_dir/b-0.3.dist-info",
metadata=Metadata(("METADATA", str("Requires-Dist: c[b]")))
metadata=Metadata(("METADATA", "Requires-Dist: c[b]"))
)
c = Distribution.from_filename(
"/foo_dir/c-1.0.dist-info",
metadata=Metadata(("METADATA", str("Provides-Extra: a\n"
metadata=Metadata(("METADATA", "Provides-Extra: a\n"
"Requires-Dist: b;extra=='a'\n"
"Provides-Extra: b\n"
"Requires-Dist: foo;extra=='b'")))
"Requires-Dist: foo;extra=='b'"))
)
foo = Distribution.from_filename("/foo_dir/foo-0.1.dist-info")
for dist in (a, b, c, foo):
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 36.7.1
current_version = 38.2.4
commit = True
tag = True

Expand Down
5 changes: 2 additions & 3 deletions setup.py
Expand Up @@ -89,7 +89,7 @@ def pypi_link(pkg_filename):

setup_params = dict(
name="setuptools",
version="36.7.1",
version="38.2.4",
description="Easily download, build, install, upgrade, and uninstall "
"Python packages",
author="Python Packaging Authority",
Expand Down Expand Up @@ -151,7 +151,6 @@ def pypi_link(pkg_filename):
License :: OSI Approved :: MIT License
Operating System :: OS Independent
Programming Language :: Python :: 2
Programming Language :: Python :: 2.6
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.3
Expand All @@ -163,7 +162,7 @@ def pypi_link(pkg_filename):
Topic :: System :: Systems Administration
Topic :: Utilities
""").strip().splitlines(),
python_requires='>=2.6,!=3.0.*,!=3.1.*,!=3.2.*',
python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*',
extras_require={
"ssl:sys_platform=='win32'": "wincertstore==0.2",
"certs": "certifi==2016.9.26",
Expand Down
4 changes: 2 additions & 2 deletions setuptools/archive_util.py
Expand Up @@ -8,7 +8,7 @@
import contextlib
from distutils.errors import DistutilsError

from pkg_resources import ensure_directory, ContextualZipFile
from pkg_resources import ensure_directory

__all__ = [
"unpack_archive", "unpack_zipfile", "unpack_tarfile", "default_filter",
Expand Down Expand Up @@ -98,7 +98,7 @@ def unpack_zipfile(filename, extract_dir, progress_filter=default_filter):
if not zipfile.is_zipfile(filename):
raise UnrecognizedFormat("%s is not a zip file" % (filename,))

with ContextualZipFile(filename) as z:
with zipfile.ZipFile(filename) as z:
for info in z.infolist():
name = info.filename

Expand Down

0 comments on commit a68a8ff

Please sign in to comment.