Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
language: python
python:
- 2.6
- 2.7
- 3.3
- 3.4
Expand Down
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
v31.0.0
-------

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

v30.3.0
-------

Expand Down
4 changes: 1 addition & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ The recommended way to bootstrap setuptools on any system is to download
operating systems have different recommended techniques to accomplish this
basic routine, so below are some examples to get you started.

Setuptools requires Python 2.6 or later. To install setuptools
on Python 2.4 or Python 2.5, use the `bootstrap script for Setuptools 1.x
<https://raw.githubusercontent.com/pypa/setuptools/bootstrap-py24/ez_setup.py>`_.
Setuptools requires Python 3.3 or later (or Python 2.7).

The link provided to ez_setup.py is a bookmark to bootstrap script for the
latest known stable release.
Expand Down
12 changes: 5 additions & 7 deletions docs/easy_install.txt
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -622,8 +622,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 @@ -1660,19 +1660,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
30 changes: 25 additions & 5 deletions docs/setuptools.txt
Original file line number Diff line number Diff line change
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 Expand Up @@ -2448,6 +2448,11 @@ boilerplate code in some cases.
pdf = ReportLab>=1.2; RXP
rest = docutils>=0.3; pack ==1.1, ==1.3

[options.packages.find]
exclude =
src.subpackage1
src.subpackage2


Metadata and options could be set in sections with the same names.

Expand Down Expand Up @@ -2486,13 +2491,13 @@ Type names used below:
* ``list-semi`` - dangling list or semicolon-separated values string
* ``bool`` - ``True`` is 1, yes, true
* ``dict`` - list-comma where keys from values are separated by =
* ``section`` - values could be read from a dedicated (sub)section


Special directives:

* ``attr:`` - value could be read from module attribute
* ``file:`` - value could be read from a file
* ``section:`` - values could be read from a dedicated (sub)section


.. note::
Expand Down Expand Up @@ -2529,8 +2534,10 @@ requires list-comma
obsoletes list-comma
================= ================= =====

**version** - ``attr:`` supports callables; supports iterables;
unsupported types are casted using ``str()``.
.. note::

**version** - ``attr:`` supports callables; supports iterables;
unsupported types are casted using ``str()``.


Options
Expand All @@ -2543,7 +2550,7 @@ zip_safe bool
setup_requires list-semi
install_requires list-semi
extras_require section
entry_points file, section
entry_points file:, section
use_2to3 bool
use_2to3_fixers list-comma
use_2to3_exclude_fixers list-comma
Expand All @@ -2560,6 +2567,13 @@ exclude_package_data section
namespace_packages list-comma
======================= =====

.. note::

**packages** - ``find:`` directive can be further configured
in a dedicated subsection `options.packages.find`. This subsection
accepts the same keys as `setuptools.find` function:
`where`, `include`, `exclude`.


Configuration API
=================
Expand All @@ -2582,6 +2596,12 @@ in the first argument. To include values from other configuration files
which could be in various places set `find_others` function argument
to ``True``.

If you have only a configuration file but not the whole package you can still
try to get data out of it with the help of `ignore_option_errors` function
argument. When it is set to ``True`` all options with errors possibly produced
by directives, such as ``attr:`` and others will be silently ignored.
As a consequence the resulting dictionary will include no such options.


--------------------------------
Extending and Reusing Setuptools
Expand Down
24 changes: 2 additions & 22 deletions pkg_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1611,7 +1611,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 @@ -1644,26 +1644,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 @@ -1861,7 +1841,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ def pypi_link(pkg_filename):
Intended Audience :: Developers
License :: OSI Approved :: MIT License
Operating System :: OS Independent
Programming Language :: Python :: 2.6
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.3
Expand All @@ -156,7 +155,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
Original file line number Diff line number Diff line change
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
4 changes: 1 addition & 3 deletions setuptools/command/egg_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,7 @@ def save_version_info(self, filename):
build tag. Install these keys in a deterministic order
to avoid arbitrary reordering on subsequent builds.
"""
# python 2.6 compatibility
odict = getattr(collections, 'OrderedDict', dict)
egg_info = odict()
egg_info = collections.OrderedDict()
# follow the order these keys would have been added
# when PYTHONHASHSEED=0
egg_info['tag_build'] = self.tags()
Expand Down
7 changes: 0 additions & 7 deletions setuptools/command/sdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,6 @@ def run(self):
for cmd_name in self.get_sub_commands():
self.run_command(cmd_name)

# Call check_metadata only if no 'check' command
# (distutils <= 2.6)
import distutils.command

if 'check' not in distutils.command.__all__:
self.check_metadata()

self.make_distribution()

dist_files = getattr(self.distribution, 'dist_files', [])
Expand Down
Loading