Commit 78f01306 authored by Philip Thiem's avatar Philip Thiem

Merge with default

--HG--
extra : rebase_source : d9c70d5bebd4290f568c828c5bc3a9b93a817ff2
parents 30bb58f0 49ce8061
......@@ -87,3 +87,16 @@ e3d70539e79f39a97f69674ab038661961a1eb43 0.8
1aef141fc968113e4c521d1edf6ea863c4ff7e00 0.9.4
88e3d6788facbb2dd6467a23c4f35529a5ce20a1 0.9.5
acc6c5d61d0f82040c237ac7ea010c0fc9e67d66 0.9.6
19965a03c1d5231c894e0fabfaf45af1fd99f484 0.9.7
e0a6e225ad6b28471cd42cfede6e8a334bb548fb 0.9.8
7b91ff93a30ef78634b7bb34f4a6229a5de281ee 1.0b1
aba16323ec9382da7bc77c633990ccb3bd58d050 1.0b2
8a98492f0d852402c93ddbbf3f07081909a9105f 1.0b3
c385fdf1f976fb1d2a6accc9292d8eca419180fa 1.0
d943b67fe80dbd61326014e4acedfc488adfa1c9 1.1
2e42e86546100c9f6845b04eb31b75c5add05f78 1.1.1
462fe5ccd8befeb2a235e8295d6d73eb3a49cc78 1.1.2
ddf3561d6a54087745f4bf6ea2048b86195d6fe2 1.1.3
f94c7e4fa03077e069c1c3cef93ead735559e706 1.1.4
d9bb58331007ee3f69d31983a180f56b15c731c3 1.1.5
5e426bdeb46b87e299422adc419f4163b6c78d13 1.1.6
......@@ -5,5 +5,6 @@ python:
- 2.7
- 3.2
- 3.3
- pypy
# command to run tests
script: python setup.py test
This diff is collapsed.
......@@ -21,6 +21,7 @@ Contributors
* Marc Abramowitz
* Martin von Löwis
* Noufal Ibrahim
* Pedro Algarvio
* Pete Hollobon
* Phillip J. Eby
* Philip Jenvey
......
......@@ -14,8 +14,7 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys, os
import setuptools
import setup as setup_script
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
......@@ -49,9 +48,9 @@ copyright = '2009-2013, The fellowship of the packaging'
# built documents.
#
# The short X.Y version.
version = setuptools.__version__
version = setup_script.setup_params['version']
# The full version, including alpha/beta/rc tags.
release = setuptools.__version__
release = setup_script.setup_params['version']
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
......
-------------------------
Development on Setuptools
-------------------------
Setuptools is maintained by the Python community under the Python Packaging
Authority (PyPA) and led by Jason R. Coombs.
This document describes the process by which Setuptools is developed.
This document assumes the reader has some passing familiarity with
*using* setuptools, the ``pkg_resources`` module, and EasyInstall. It
does not attempt to explain basic concepts like inter-project
dependencies, nor does it contain detailed lexical syntax for most
file formats. Neither does it explain concepts like "namespace
packages" or "resources" in any detail, as all of these subjects are
covered at length in the setuptools developer's guide and the
``pkg_resources`` reference manual.
Instead, this is **internal** documentation for how those concepts and
features are *implemented* in concrete terms. It is intended for people
who are working on the setuptools code base, who want to be able to
troubleshoot setuptools problems, want to write code that reads the file
formats involved, or want to otherwise tinker with setuptools-generated
files and directories.
Note, however, that these are all internal implementation details and
are therefore subject to change; stick to the published API if you don't
want to be responsible for keeping your code from breaking when
setuptools changes. You have been warned.
.. toctree::
:maxdepth: 1
formats
releases
......@@ -35,9 +35,8 @@ 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.3.5, or if you are on a 64-bit platform, Python
2.4. An ``easy_install`` script will be installed in the normal location for
Python scripts on your platform.
You will need at least Python 2.4. 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
are installling to Python's primary ``site-packages`` directory. If this is
......@@ -77,25 +76,10 @@ section on `Custom Installation Locations`_ for more details.
Windows Notes
~~~~~~~~~~~~~
On Windows, an ``easy_install.exe`` launcher will also be installed, so that
you can just type ``easy_install`` as long as it's on your ``PATH``. If typing
``easy_install`` at the command prompt doesn't work, check to make sure your
``PATH`` includes the appropriate ``C:\\Python2X\\Scripts`` directory. On
most current versions of Windows, you can change the ``PATH`` by right-clicking
"My Computer", choosing "Properties" and selecting the "Advanced" tab, then
clicking the "Environment Variables" button. ``PATH`` will be in the "System
Variables" section, and you will need to exit and restart your command shell
(command.com, cmd.exe, bash, or other) for the change to take effect. Be sure
to add a ``;`` after the last item on ``PATH`` before adding the scripts
directory to it.
Note that instead of changing your ``PATH`` to include the Python scripts
directory, you can also retarget the installation location for scripts so they
go on a directory that's already on the ``PATH``. For more information see the
sections below on `Command-Line Options`_ and `Configuration Files`_. You
can pass command line options (such as ``--script-dir``) to
``ez_setup.py`` to control where ``easy_install.exe`` will be installed.
Installing setuptools will provide an ``easy_install`` command according to
the techniques described in `Executables and Launchers`_. If the
``easy_install`` command is not available after installation, that section
provides details on how to configure Windows to make the commands available.
Downloading and Installing a Package
......@@ -305,24 +289,80 @@ installations, so that Python won't lock us out of using anything but the most
recently-installed version of the package.)
Executables and Launchers
-------------------------
On Unix systems, scripts are installed with as natural files with a "#!"
header and no extension and they launch under the Python version indicated in
the header.
On Windows, there is no mechanism to "execute" files without extensions, so
EasyInstall provides two techniques to mirror the Unix behavior. The behavior
is indicated by the SETUPTOOLS_LAUNCHER environment variable, which may be
"executable" (default) or "natural".
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).
Note that instead of changing your ``PATH`` to include the Python scripts
directory, you can also retarget the installation location for scripts so they
go on a directory that's already on the ``PATH``. For more information see
`Command-Line Options`_ and `Configuration Files`_. During installation,
pass command line options (such as ``--script-dir``) to
``ez_setup.py`` to control where ``easy_install.exe`` will be installed.
Windows Executable Launcher
~~~~~~~~~~~~~~~~~~~~~~~~~~~
If the "executable" launcher is used, EasyInstall will create a '.exe'
launcher of the same name beside each installed script (including
``easy_install`` itself). These small .exe files launch the script of the
same name using the Python version indicated in the '#!' header.
This behavior is currently default. To force
the use of executable launchers, set ``SETUPTOOLS_LAUNCHER`` to "executable".
Natural Script Launcher
~~~~~~~~~~~~~~~~~~~~~~~
EasyInstall also supports deferring to an external launcher such as
`pylauncher <https://bitbucket.org/pypa/pylauncher>`_ for launching scripts.
Enable this experimental functionality by setting the
``SETUPTOOLS_LAUNCHER`` environment variable to "natural". EasyInstall will
then install scripts as simple
scripts with a .pya (or .pyw) extension appended. If these extensions are
associated with the pylauncher and listed in the PATHEXT environment variable,
these scripts can then be invoked simply and directly just like any other
executable. This behavior may become default in a future version.
EasyInstall uses the .pya extension instead of simply
the typical '.py' extension. This distinct extension is necessary to prevent
Python
from treating the scripts as importable modules (where name conflicts exist).
Current releases of pylauncher do not yet associate with .pya files by
default, but future versions should do so.
Tips & Techniques
-----------------
Multiple Python Versions
~~~~~~~~~~~~~~~~~~~~~~~~
As of version 0.6a11, EasyInstall installs itself under two names:
EasyInstall installs itself under two names:
``easy_install`` and ``easy_install-N.N``, where ``N.N`` is the Python version
used to install it. Thus, if you install EasyInstall for both Python 2.3 and
2.4, you can use the ``easy_install-2.3`` or ``easy_install-2.4`` scripts to
install packages for Python 2.3 or 2.4, respectively.
Also, if you're working with Python version 2.4 or higher, you can run Python
with ``-m easy_install`` to run that particular Python version's
``easy_install`` command.
used to install it. Thus, if you install EasyInstall for both Python 3.2 and
2.7, you can use the ``easy_install-3.2`` or ``easy_install-2.7`` scripts to
install packages for the respective Python version.
Setuptools also supplies easy_install as a runnable module which may be
invoked using ``python -m easy_install`` for any Python with Setuptools
installed.
Restricting Downloads with ``--allow-hosts``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......@@ -532,14 +572,12 @@ install``, becuase the ``distutils`` just install new packages on top of old
ones, possibly combining two unrelated packages or leaving behind modules that
have been deleted in the newer version of the package.)
By default, EasyInstall will stop the installation if it detects a conflict
EasyInstall will stop the installation if it detects a conflict
between an existing, "unmanaged" package, and a module or package in any of
the distributions you're installing. It will display a list of all of the
existing files and directories that would need to be deleted for the new
package to be able to function correctly. You can then either delete these
conflicting files and directories yourself and re-run EasyInstall, or you can
just use the ``--delete-conflicting`` or ``--ignore-conflicts-at-my-risk``
options, as described under `Command-Line Options`_, below.
package to be able to function correctly. To proceed, you must manually
delete these conflicting files and directories and re-run EasyInstall.
Of course, once you've replaced all of your existing "unmanaged" packages with
versions managed by EasyInstall, you won't have any more conflicts to worry
......@@ -783,27 +821,6 @@ Command-Line Options
Added in Distribute 0.6.11 and Setuptools 0.7.
``--delete-conflicting, -D`` (Removed in 0.6a11)
(As of 0.6a11, this option is no longer necessary; please do not use it!)
If you are replacing a package that was previously installed *without*
using EasyInstall, the old version may end up on ``sys.path`` before the
version being installed with EasyInstall. EasyInstall will normally abort
the installation of a package if it detects such a conflict, and ask you to
manually remove the conflicting files or directories. If you specify this
option, however, EasyInstall will attempt to delete the files or
directories itself, and then proceed with the installation.
``--ignore-conflicts-at-my-risk`` (Removed in 0.6a11)
(As of 0.6a11, this option is no longer necessary; please do not use it!)
Ignore conflicting packages and proceed with installation anyway, even
though it means the package probably won't work properly. If the
conflicting package is in a directory you can't write to, this may be your
only option, but you will need to take more invasive measures to get the
installed package to work, like manually adding it to ``PYTHONPATH`` or to
``sys.path`` at runtime.
``--index-url=URL, -i URL`` (New in 0.4a1; default changed in 0.6c7)
Specifies the base URL of the Python Package Index. The default is
https://pypi.python.org/simple if not specified. When a package is requested
......
......@@ -4,26 +4,6 @@ The Internal Structure of Python Eggs
STOP! This is not the first document you should read!
This document assumes you have at least some passing familiarity with
*using* setuptools, the ``pkg_resources`` module, and EasyInstall. It
does not attempt to explain basic concepts like inter-project
dependencies, nor does it contain detailed lexical syntax for most
file formats. Neither does it explain concepts like "namespace
packages" or "resources" in any detail, as all of these subjects are
covered at length in the setuptools developer's guide and the
``pkg_resources`` reference manual.
Instead, this is **internal** documentation for how those concepts and
features are *implemented* in concrete terms. It is intended for people
who are working on the setuptools code base, who want to be able to
troubleshoot setuptools problems, want to write code that reads the file
formats involved, or want to otherwise tinker with setuptools-generated
files and directories.
Note, however, that these are all internal implementation details and
are therefore subject to change; stick to the published API if you don't
want to be responsible for keeping your code from breaking when
setuptools changes. You have been warned.
.. contents:: **Table of Contents**
......
......@@ -23,3 +23,4 @@ Documentation content:
setuptools
easy_install
pkg_resources
development
......@@ -18,19 +18,31 @@ packages.
Overview
--------
Eggs are a distribution format for Python modules, similar in concept to Java's
"jars" or Ruby's "gems". They differ from previous Python distribution formats
in that they are importable (i.e. they can be added to ``sys.path``), and they
are *discoverable*, meaning that they carry metadata that unambiguously
identifies their contents and dependencies, and thus can be *automatically*
found and added to ``sys.path`` in response to simple requests of the form,
"get me everything I need to use docutils' PDF support".
The ``pkg_resources`` module provides runtime facilities for finding,
introspecting, activating and using eggs and other "pluggable" distribution
formats. Because these are new concepts in Python (and not that well-
established in other languages either), it helps to have a few special terms
for talking about eggs and how they can be used:
introspecting, activating and using installed Python distributions. Some
of the more advanced features (notably the support for parallel installation
of multiple versions) rely specifically on the "egg" format (either as a
zip archive or subdirectory), while others (such as plugin discovery) will
work correctly so long as "egg-info" metadata directories are available for
relevant distributions.
Eggs are a distribution format for Python modules, similar in concept to
Java's "jars" or Ruby's "gems", or the "wheel" format defined in PEP 427.
However, unlike a pure distribution format, eggs can also be installed and
added directly to ``sys.path`` as an import location. When installed in
this way, eggs are *discoverable*, meaning that they carry metadata that
unambiguously identifies their contents and dependencies. This means that
an installed egg can be *automatically* found and added to ``sys.path`` in
response to simple requests of the form, "get me everything I need to use
docutils' PDF support". This feature allows mutually conflicting versions of
a distribution to co-exist in the same Python installation, with individual
applications activating the desired version at runtime by manipulating the
contents of ``sys.path`` (this differs from the virtual environment
approach, which involves creating isolated environments for each
application).
The following terms are needed in order to explain the capabilities offered
by this module:
project
A library, framework, script, plugin, application, or collection of data
......@@ -79,9 +91,13 @@ eggs
with ``.egg`` and follows the egg naming conventions, and contain an
``EGG-INFO`` subdirectory (zipped or otherwise). Development eggs are
normal directories of Python code with one or more ``ProjectName.egg-info``
subdirectories. And egg links are ``*.egg-link`` files that contain the
name of a built or development egg, to support symbolic linking on
platforms that do not have native symbolic links.
subdirectories. The development egg format is also used to provide a
default version of a distribution that is available to software that
doesn't use ``pkg_resources`` to request specific versions. Egg links
are ``*.egg-link`` files that contain the name of a built or
development egg, to support symbolic linking on platforms that do not
have native symbolic links (or where the symbolic link support is
limited).
(For more information about these terms and concepts, see also this
`architectural overview`_ of ``pkg_resources`` and Python Eggs in general.)
......@@ -190,6 +206,17 @@ not provide any way to detect arbitrary changes to a list object like
is designed so that the ``working_set`` is used by default, such that you
don't have to explicitly refer to it most of the time.
All distributions available directly on ``sys.path`` will be activated
automatically when ``pkg_resources`` is imported. This behaviour can cause
version conflicts for applications which require non-default versions of
those distributions. To handle this situation, ``pkg_resources`` checks for a
``__requires__`` attribute in the ``__main__`` module when initializing the
default working set, and uses this to ensure a suitable version of each
affected distribution is activated. For example::
__requires__ = ["CherryPy < 3"] # Must be set before pkg_resources import
import pkg_resources
Basic ``WorkingSet`` Methods
----------------------------
......
===============
Release Process
===============
In order to allow for rapid, predictable releases, Setuptools uses a
mechanical technique for releases. The release script, ``release.py`` in the
repository, defines the details of the releases, and is executed by the
`jaraco.packaging <https://bitbucket.org/jaraco/jaraco.packaging>`_ release
module. The script does some checks (some interactive) and fully automates
the release process.
A Setuptools release manager must have maintainer access on PyPI to the
project and administrative access to the BitBucket project.
Release Managers
----------------
Currently, the project has one release manager, Jason R. Coombs.
This diff is collapsed.
......@@ -4,7 +4,7 @@ Using Setuptools in your project
To use Setuptools in your project, the recommended way is to ship
`ez_setup.py` alongside your `setup.py` script and call
it at the very begining of `setup.py` like this::
it at the very beginning of `setup.py` like this::
from ez_setup import use_setuptools
use_setuptools()
......@@ -20,6 +20,7 @@ import tempfile
import tarfile
import optparse
import subprocess
import platform
from distutils import log
......@@ -28,13 +29,22 @@ try:
except ImportError:
USER_SITE = None
DEFAULT_VERSION = "0.9.7"
DEFAULT_VERSION = "1.1.7"
DEFAULT_URL = "https://pypi.python.org/packages/source/s/setuptools/"
def _python_cmd(*args):
args = (sys.executable,) + args
return subprocess.call(args) == 0
def _check_call_py24(cmd, *args, **kwargs):
res = subprocess.call(cmd, *args, **kwargs)
class CalledProcessError(Exception):
pass
if not res == 0:
msg = "Command '%s' return non-zero exit status %d" % (cmd, res)
raise CalledProcessError(msg)
vars(subprocess).setdefault('check_call', _check_call_py24)
def _install(tarball, install_args=()):
# extracting the tarball
tmpdir = tempfile.mkdtemp()
......@@ -141,9 +151,123 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
return _do_download(version, download_base, to_dir,
download_delay)
def _clean_check(cmd, target):
"""
Run the command to download target. If the command fails, clean up before
re-raising the error.
"""
try:
subprocess.check_call(cmd)
except subprocess.CalledProcessError:
if os.access(target, os.F_OK):
os.unlink(target)
raise
def download_file_powershell(url, target):
"""
Download the file at url to target using Powershell (which will validate
trust). Raise an exception if the command cannot complete.
"""
target = os.path.abspath(target)
cmd = [
'powershell',
'-Command',
"(new-object System.Net.WebClient).DownloadFile(%(url)r, %(target)r)" % vars(),
]
_clean_check(cmd, target)
def has_powershell():
if platform.system() != 'Windows':
return False
cmd = ['powershell', '-Command', 'echo test']
devnull = open(os.path.devnull, 'wb')
try:
try:
subprocess.check_call(cmd, stdout=devnull, stderr=devnull)
except:
return False
finally:
devnull.close()
return True
download_file_powershell.viable = has_powershell
def download_file_curl(url, target):
cmd = ['curl', url, '--silent', '--output', target]
_clean_check(cmd, target)
def has_curl():
cmd = ['curl', '--version']
devnull = open(os.path.devnull, 'wb')
try:
try:
subprocess.check_call(cmd, stdout=devnull, stderr=devnull)
except:
return False
finally:
devnull.close()
return True
download_file_curl.viable = has_curl
def download_file_wget(url, target):
cmd = ['wget', url, '--quiet', '--output-document', target]
_clean_check(cmd, target)
def has_wget():
cmd = ['wget', '--version']
devnull = open(os.path.devnull, 'wb')
try:
try:
subprocess.check_call(cmd, stdout=devnull, stderr=devnull)
except:
return False
finally:
devnull.close()
return True
download_file_wget.viable = has_wget
def download_file_insecure(url, target):
"""
Use Python to download the file, even though it cannot authenticate the
connection.
"""
try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
src = dst = None
try:
src = urlopen(url)
# Read/write all in one block, so we don't create a corrupt file
# if the download is interrupted.
data = src.read()
dst = open(target, "wb")
dst.write(data)
finally:
if src:
src.close()
if dst:
dst.close()
download_file_insecure.viable = lambda: True
def get_best_downloader():
downloaders = [
download_file_powershell,
download_file_curl,
download_file_wget,
download_file_insecure,
]
for dl in downloaders:
if dl.viable():
return dl
def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
to_dir=os.curdir, delay=15):
to_dir=os.curdir, delay=15,
downloader_factory=get_best_downloader):
"""Download setuptools from a specified location and return its filename
`version` should be a valid setuptools version number that is available
......@@ -151,31 +275,19 @@ def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
with a '/'). `to_dir` is the directory where the egg will be downloaded.
`delay` is the number of seconds to pause before an actual download
attempt.
``downloader_factory`` should be a function taking no arguments and
returning a function for downloading a URL to a target.
"""
# making sure we use the absolute path
to_dir = os.path.abspath(to_dir)
try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
tgz_name = "setuptools-%s.tar.gz" % version
url = download_base + tgz_name
saveto = os.path.join(to_dir, tgz_name)
src = dst = None
if not os.path.exists(saveto): # Avoid repeated downloads
try:
log.warn("Downloading %s", url)
src = urlopen(url)
# Read/write all in one block, so we don't create a corrupt file
# if the download is interrupted.
data = src.read()
dst = open(saveto, "wb")
dst.write(data)
finally:
if src:
src.close()
if dst:
dst.close()
log.warn("Downloading %s", url)
downloader = downloader_factory()
downloader(url, saveto)
return os.path.realpath(saveto)
......@@ -250,6 +362,11 @@ def _parse_args():
'--download-base', dest='download_base', metavar="URL",
default=DEFAULT_URL,
help='alternative URL from where to download the setuptools package')
parser.add_option(
'--insecure', dest='downloader_factory', action='store_const',
const=lambda: download_file_insecure, default=get_best_downloader,
help='Use internal, non-validating downloader'
)
options, args = parser.parse_args()
# positional arguments are ignored
return options
......@@ -257,7 +374,8 @@ def _parse_args():
def main(version=DEFAULT_VERSION):
"""Install or upgrade setuptools and EasyInstall"""
options = _parse_args()
tarball = download_setuptools(download_base=options.download_base)
tarball = download_setuptools(download_base=options.download_base,
downloader_factory=options.downloader_factory)
return _install(tarball, _build_install_args(options))
if __name__ == '__main__':
......
This diff is collapsed.
......@@ -7,13 +7,22 @@ import re
import os
import subprocess
import pkg_resources
pkg_resources.require('jaraco.packaging>=2.0')
def before_upload():
_linkify('CHANGES.txt', 'CHANGES (links).txt')
_add_bootstrap_bookmark()
BootstrapBookmark.add()
def after_push():
os.remove('CHANGES (links).txt')
BootstrapBookmark.push()
files_with_versions = (
'ez_setup.py', 'setuptools/__init__.py',
'ez_setup.py', 'setuptools/version.py',
)
test_info = "Travis-CI tests: http://travis-ci.org/#!/jaraco/setuptools"
......@@ -55,7 +64,21 @@ def replacer(match):
url = issue_urls[key].format(**match_dict)
return "`{text} <{url}>`_".format(text=text, url=url)
class BootstrapBookmark:
name = 'bootstrap'
@classmethod
def add(cls):
cmd = ['hg', 'bookmark', '-i', cls.name, '-f']
subprocess.Popen(cmd)
def _add_bootstrap_bookmark():
cmd = ['hg', 'bookmark', '-i', 'bootstrap', '-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)
......@@ -16,3 +16,6 @@ upload-dir = docs/build/html
[sdist]
formats=gztar
[wheel]
universal=1
......@@ -20,10 +20,10 @@ init_file.close()
SETUP_COMMANDS = command_ns['__all__']
main_ns = {}
init_path = convert_path('setuptools/__init__.py')
init_file = open(init_path)
exec(init_file.read(), main_ns)
init_file.close()
ver_path = convert_path('setuptools/version.py')
ver_file = open(ver_path)
exec(ver_file.read(), main_ns)
ver_file.close()
import setuptools
from setuptools.command.build_py import build_py as _build_py
......
[setuptools.installation]
eggsecutable = setuptools.command.easy_install:bootstrap
[console_scripts]
easy_install = setuptools.command.easy_install:main
easy_install-3.3 = setuptools.command.easy_install:main
[distutils.setup_keywords]
use_2to3 = setuptools.dist:assert_bool
namespace_packages = setuptools.dist:check_nsp
package_data = setuptools.dist:check_package_data
use_2to3_exclude_fixers = setuptools.dist:assert_string_list
dependency_links = setuptools.dist:assert_string_list
use_2to3_fixers = setuptools.dist:assert_string_list
test_suite = setuptools.dist:check_test_suite
exclude_package_data = setuptools.dist:check_package_data
extras_require = setuptools.dist:check_extras
install_requires = setuptools.dist:check_requirements
eager_resources = setuptools.dist:assert_string_list
include_package_data = setuptools.dist:assert_bool
packages = setuptools.dist:check_packages
entry_points = setuptools.dist:check_entry_points
zip_safe = setuptools.dist:assert_bool
tests_require = setuptools.dist:check_requirements
convert_2to3_doctests = setuptools.dist:assert_string_list
test_loader = setuptools.dist:check_importable
[setuptools.file_finders]
svn_cvs = setuptools.command.sdist:_default_revctrl
[egg_info.writers]
top_level.txt = setuptools.command.egg_info:write_toplevel_names
PKG-INFO = setuptools.command.egg_info:write_pkg_info
eager_resources.txt = setuptools.command.egg_info:overwrite_arg
namespace_packages.txt = setuptools.command.egg_info:overwrite_arg
depends.txt = setuptools.command.egg_info:warn_depends_obsolete
dependency_links.txt = setuptools.command.egg_info:overwrite_arg
entry_points.txt = setuptools.command.egg_info:write_entries
requires.txt = setuptools.command.egg_info:write_requirements
[distutils.commands]
test = setuptools.command.test:test
bdist_wininst = setuptools.command.bdist_wininst:bdist_wininst
alias = setuptools.command.alias:alias
sdist = setuptools.command.sdist:sdist
develop = setuptools.command.develop:develop
bdist_egg = setuptools.command.bdist_egg:bdist_egg
setopt = setuptools.command.setopt:setopt
egg_info = setuptools.command.egg_info:egg_info
build_ext = setuptools.command.build_ext:build_ext
upload_docs = setuptools.command.upload_docs:upload_docs
easy_install = setuptools.command.easy_install:easy_install
install = setuptools.command.install:install
install_egg_info = setuptools.command.install_egg_info:install_egg_info
bdist_rpm = setuptools.command.bdist_rpm:bdist_rpm
install_lib = setuptools.command.install_lib:install_lib
rotate = setuptools.command.rotate:rotate
saveopts = setuptools.command.saveopts:saveopts
install_scripts = setuptools.command.install_scripts:install_scripts
build_py = setuptools.command.build_py:build_py
register = setuptools.command.register:register
[distutils.setup_keywords]
packages = setuptools.dist:check_packages
install_requires = setuptools.dist:check_requirements
eager_resources = setuptools.dist:assert_string_list
include_package_data = setuptools.dist:assert_bool
convert_2to3_doctests = setuptools.dist:assert_string_list
package_data = setuptools.dist:check_package_data
use_2to3_exclude_fixers = setuptools.dist:assert_string_list
test_suite = setuptools.dist:check_test_suite
tests_require = setuptools.dist:check_requirements
use_2to3 = setuptools.dist:assert_bool
exclude_package_data = setuptools.dist:check_package_data
test_loader = setuptools.dist:check_importable
extras_require = setuptools.dist:check_extras
use_2to3_fixers = setuptools.dist:assert_string_list
namespace_packages = setuptools.dist:check_nsp
zip_safe = setuptools.dist:assert_bool
dependency_links = setuptools.dist:assert_string_list
entry_points = setuptools.dist:check_entry_points
[setuptools.file_finders]
svn_cvs = setuptools.command.sdist:_default_revctrl
[egg_info.writers]
depends.txt = setuptools.command.egg_info:warn_depends_obsolete
top_level.txt = setuptools.command.egg_info:write_toplevel_names
entry_points.txt = setuptools.command.egg_info:write_entries
requires.txt = setuptools.command.egg_info:write_requirements
PKG-INFO = setuptools.command.egg_info:write_pkg_info
eager_resources.txt = setuptools.command.egg_info:overwrite_arg
dependency_links.txt = setuptools.command.egg_info:overwrite_arg
namespace_packages.txt = setuptools.command.egg_info:overwrite_arg
[distutils.commands]
rotate = setuptools.command.rotate:rotate
bdist_egg = setuptools.command.bdist_egg:bdist_egg
install_scripts = setuptools.command.install_scripts:install_scripts
install_egg_info = setuptools.command.install_egg_info:install_egg_info
build_py = setuptools.command.build_py:build_py
build_ext = setuptools.command.build_ext:build_ext
install = setuptools.command.install:install
sdist = setuptools.command.sdist:sdist
upload_docs = setuptools.command.upload_docs:upload_docs
saveopts = setuptools.command.saveopts:saveopts
develop = setuptools.command.develop:develop
alias = setuptools.command.alias:alias
register = setuptools.command.register:register
setopt = setuptools.command.setopt:setopt
egg_info = setuptools.command.egg_info:egg_info
test = setuptools.command.test:test
easy_install = setuptools.command.easy_install:easy_install
install_lib = setuptools.command.install_lib:install_lib
bdist_wininst = setuptools.command.bdist_wininst:bdist_wininst
bdist_rpm = setuptools.command.bdist_rpm:bdist_rpm
[setuptools.installation]
eggsecutable = setuptools.command.easy_install:bootstrap
[console_scripts]
easy_install = setuptools.command.easy_install:main
easy_install-3.3 = setuptools.command.easy_install:main
[ssl:python_version in '2.4, 2.5']
ssl==1.16
[ssl:sys_platform=='win32' and python_version=='2.4']
ctypes==1.0.2
[ssl:python_version in '2.4, 2.5']
ssl==1.16
[certs]
certifi==0.0.8
......
"""Extensions to the 'distutils' for large or complex distributions"""
from setuptools.extension import Extension, Library
from setuptools.dist import Distribution, Feature, _get_unpatched
import distutils.core, setuptools.command
from setuptools.depends import Require
from distutils.core import Command as _Command
from distutils.util import convert_path
import os
import sys
import distutils.core
import distutils.filelist
from distutils.core import Command as _Command
from distutils.util import convert_path
import setuptools.version
from setuptools.extension import Extension
from setuptools.dist import Distribution, Feature, _get_unpatched
from setuptools.depends import Require
__version__ = '0.9.7'
__all__ = [
'setup', 'Distribution', 'Feature', 'Command', 'Extension', 'Require',
'find_packages'
]
__version__ = setuptools.version.__version__
bootstrap_install_from = None
# If we run 2to3 on .py files, should we also convert docstrings?
......@@ -37,10 +42,14 @@ def find_packages(where='.', exclude=()):
where,prefix = stack.pop(0)
for name in os.listdir(where):
fn = os.path.join(where,name)
if ('.' not in name and os.path.isdir(fn) and
os.path.isfile(os.path.join(fn,'__init__.py'))
):
out.append(prefix+name); stack.append((fn,prefix+name+'.'))
looks_like_package = (
'.' not in name
and os.path.isdir(fn)
and os.path.isfile(os.path.join(fn, '__init__.py'))
)
if looks_like_package:
out.append(prefix+name)
stack.append((fn, prefix+name+'.'))
for pat in list(exclude)+['ez_setup']:
from fnmatch import fnmatchcase
out = [item for item in out if not fnmatchcase(item,pat)]
......@@ -67,7 +76,6 @@ class Command(_Command):
setattr(cmd,k,v) # update command with keywords
return cmd
import distutils.core
distutils.core.Command = Command # we can't patch distutils.cmd, alas
def findall(dir = os.curdir):
......@@ -83,12 +91,8 @@ def findall(dir = os.curdir):
all_files.extend(filter(os.path.isfile, files))
return all_files
import distutils.filelist
distutils.filelist.findall = findall # fix findall bug in distutils.
# sys.dont_write_bytecode was introduced in Python 2.6.
if ((hasattr(sys, "dont_write_bytecode") and sys.dont_write_bytecode) or
(not hasattr(sys, "dont_write_bytecode") and os.environ.get("PYTHONDONTWRITEBYTECODE"))):
_dont_write_bytecode = True
else:
_dont_write_bytecode = False
_dont_write_bytecode = getattr(sys, 'dont_write_bytecode',
bool(os.environ.get("PYTHONDONTWRITEBYTECODE")))
This diff is collapsed.
import os
import re
import sys
from glob import glob
import pkg_resources
from distutils.command.sdist import sdist as _sdist
from distutils.util import convert_path
from distutils import log
from glob import glob
import os, re, sys, pkg_resources
from glob import glob
from setuptools import svn_utils
READMES = ('README', 'README.rst', 'README.txt')
......@@ -37,7 +40,6 @@ class re_finder(object):
#was an re_finder for calling unescape
path = postproc(path)
yield svn_utils.joinpath(dirname,path)
def __call__(self, dirname=''):
path = svn_utils.joinpath(dirname, self.path)
......@@ -64,16 +66,6 @@ finders = [
class sdist(_sdist):
"""Smart sdist that finds anything supported by revision control"""
......@@ -128,11 +120,12 @@ class sdist(_sdist):
# Beginning with Python 2.7.2, 3.1.4, and 3.2.1, this leaky file handle
# has been fixed, so only override the method if we're using an earlier
# Python.
if (
sys.version_info < (2,7,2)
or (3,0) <= sys.version_info < (3,1,4)
or (3,2) <= sys.version_info < (3,2,1)
):
has_leaky_handle = (
sys.version_info < (2,7,2)
or (3,0) <= sys.version_info < (3,1,4)
or (3,2) <= sys.version_info < (3,2,1)
)
if has_leaky_handle:
read_template = __read_template_hack
def add_defaults(self):
......@@ -197,7 +190,6 @@ class sdist(_sdist):
"standard file not found: should have one of " +', '.join(READMES)
)
def make_release_tree(self, base_dir, files):
_sdist.make_release_tree(self, base_dir, files)
......@@ -244,10 +236,3 @@ class sdist(_sdist):
continue
self.filelist.append(line)
manifest.close()
#
......@@ -2,10 +2,10 @@
Implements the Distutils 'upload' subcommand (upload package to PyPI)."""
from distutils.errors import *
from distutils import errors
from distutils import log
from distutils.core import Command
from distutils.spawn import spawn
from distutils import log
try:
from hashlib import md5
except ImportError:
......@@ -45,7 +45,7 @@ class upload(Command):
def finalize_options(self):
if self.identity and not self.sign:
raise DistutilsOptionError(
raise errors.DistutilsOptionError(
"Must use --sign for --identity to have meaning"
)
if 'HOME' in os.environ:
......@@ -68,7 +68,7 @@ class upload(Command):
def run(self):
if not self.distribution.dist_files:
raise DistutilsOptionError("No dist file created in earlier command")
raise errors.DistutilsOptionError("No dist file created in earlier command")
for command, pyversion, filename in self.distribution.dist_files:
self.upload_file(command, pyversion, filename)
......@@ -119,10 +119,10 @@ class upload(Command):
boundary = '--------------GHSKFJDLGDS7543FJKLFHRE75642756743254'
sep_boundary = '\n--' + boundary
end_boundary = sep_boundary + '--'
body = StringIO.StringIO()
body = StringIO()
for key, value in data.items():
# handle multiple entries for the same name
if type(value) != type([]):
if not isinstance(value, list):
value = [value]
for value in value:
if type(value) is tuple:
......@@ -158,7 +158,6 @@ class upload(Command):
raise AssertionError("unsupported schema " + schema)
data = ''
loglevel = log.INFO
try:
http.connect()
http.putrequest("POST", url)
......
......@@ -27,10 +27,10 @@ if sys.version_info[0] < 3:
unichr = unichr
unicode = unicode
bytes = str
from urllib import url2pathname
from urllib import url2pathname, splittag
import urllib2
from urllib2 import urlopen, HTTPError, URLError, unquote, splituser
from urlparse import urlparse, urlunparse, urljoin
from urlparse import urlparse, urlunparse, urljoin, urlsplit, urlunsplit
xrange = xrange
filterfalse = itertools.ifilterfalse
......@@ -74,7 +74,10 @@ else:
from urllib.error import HTTPError, URLError
import urllib.request as urllib2
from urllib.request import urlopen, url2pathname
from urllib.parse import urlparse, urlunparse, unquote, splituser, urljoin
from urllib.parse import (
urlparse, urlunparse, unquote, splituser, urljoin, urlsplit,
urlunsplit, splittag,
)
xrange = range
filterfalse = itertools.filterfalse
......@@ -83,7 +86,7 @@ else:
globs = globals()
if locs is None:
locs = globs
f = open(fn)
f = open(fn, 'rb')
try:
source = f.read()
finally:
......
__all__ = ['Distribution']
import re
import os
import sys
import warnings
import distutils.log
import distutils.core
import distutils.cmd
from distutils.core import Distribution as _Distribution
from distutils.errors import (DistutilsOptionError, DistutilsPlatformError,
DistutilsSetupError)
from setuptools.depends import Require
from setuptools.command.install import install
from setuptools.command.sdist import sdist
from setuptools.command.install_lib import install_lib
from setuptools.compat import numeric_types, basestring
from distutils.errors import DistutilsOptionError, DistutilsPlatformError
from distutils.errors import DistutilsSetupError
import setuptools, pkg_resources, distutils.core, distutils.dist, distutils.cmd
import os, distutils.log
import pkg_resources
def _get_unpatched(cls):
"""Protect against re-patching the distutils if reloaded
......@@ -132,38 +134,6 @@ def check_packages(dist, attr, value):
"WARNING: %r not a valid package name; please use only"
".-separated package names in setup.py", pkgname
)
class Distribution(_Distribution):
......@@ -194,7 +164,8 @@ class Distribution(_Distribution):
EasyInstall and requests one of your extras, the corresponding
additional requirements will be installed if needed.
'features' -- a dictionary mapping option names to 'setuptools.Feature'
'features' **deprecated** -- a dictionary mapping option names to
'setuptools.Feature'
objects. Features are a portion of the distribution that can be
included or excluded based on user options, inter-feature dependencies,
and availability on the current system. Excluded features are omitted
......@@ -248,10 +219,13 @@ class Distribution(_Distribution):
dist._version = pkg_resources.safe_version(str(attrs['version']))
self._patched_dist = dist
def __init__ (self, attrs=None):
def __init__(self, attrs=None):
have_package_data = hasattr(self, "package_data")
if not have_package_data:
self.package_data = {}
_attrs_dict = attrs or {}
if 'features' in _attrs_dict or 'require_features' in _attrs_dict:
Feature.warn_deprecated()
self.require_features = []
self.features = {}
self.dist_files = []
......@@ -362,23 +336,6 @@ class Distribution(_Distribution):
self.global_options = self.feature_options = go + self.global_options
self.negative_opt = self.feature_negopt = no
def _finalize_features(self):
"""Add/remove features and resolve dependencies between them"""
......@@ -396,7 +353,6 @@ class Distribution(_Distribution):
feature.exclude_from(self)
self._set_feature(name,0)
def get_command_class(self, command):
"""Pluggable version of get_command_class()"""
if command in self.cmdclass:
......@@ -416,10 +372,6 @@ class Distribution(_Distribution):
self.cmdclass[ep.name] = cmdclass
return _Distribution.print_commands(self)
def _set_feature(self,name,status):
"""Set feature's inclusion status"""
setattr(self,self._feature_attrname(name),status)
......@@ -434,8 +386,8 @@ class Distribution(_Distribution):
if self.feature_is_included(name)==0:
descr = self.features[name].description
raise DistutilsOptionError(
descr + " is required, but was excluded or is not available"
)
descr + " is required, but was excluded or is not available"
)
self.features[name].include_in(self)
self._set_feature(name,1)
......@@ -483,7 +435,6 @@ class Distribution(_Distribution):
if p.name != package and not p.name.startswith(pfx)
]
def has_contents_for(self,package):
"""Return true if 'exclude_package(package)' would do something"""
......@@ -493,15 +444,6 @@ class Distribution(_Distribution):
if p==package or p.startswith(pfx):
return True
def _exclude_misc(self,name,value):
"""Handle 'exclude()' for list/tuple attrs without a special handler"""
if not isinstance(value,sequence):
......@@ -573,17 +515,6 @@ class Distribution(_Distribution):
)
list(map(self.exclude_package, packages))
def _parse_command_opts(self, parser, args):
# Remove --with-X/--without-X options when processing command args
self.global_options = self.__class__.global_options
......@@ -610,21 +541,6 @@ class Distribution(_Distribution):
return nargs
def get_cmdline_options(self):
"""Return a '{cmd: {opt:val}}' map of all command-line options
......@@ -665,7 +581,6 @@ class Distribution(_Distribution):
return d
def iter_distribution_names(self):
"""Yield all packages, modules, and extension names in distribution"""
......@@ -684,7 +599,6 @@ class Distribution(_Distribution):
name = name[:-6]
yield name
def handle_display_options(self, option_order):
"""If there were any non-global "display-only" options
(--help-commands or the metadata display options) on the command
......@@ -726,26 +640,14 @@ for module in distutils.dist, distutils.core, distutils.cmd:
module.Distribution = Distribution
class Feature:
"""A subset of the distribution that can be excluded if unneeded/wanted
"""
**deprecated** -- The `Feature` facility was never completely implemented
or supported, `has reported issues
<https://bitbucket.org/pypa/setuptools/issue/58>`_ and will be removed in
a future version.
A subset of the distribution that can be excluded if unneeded/wanted
Features are created using these keyword arguments:
......@@ -794,9 +696,19 @@ class Feature:
Aside from the methods, the only feature attributes that distributions look
at are 'description' and 'optional'.
"""
@staticmethod
def warn_deprecated():
warnings.warn(
"Features are deprecated and will be removed in a future "
"version. See http://bitbucket.org/pypa/setuptools/65.",
DeprecationWarning,
stacklevel=3,
)
def __init__(self, description, standard=False, available=True,
optional=True, require_features=(), remove=(), **extras
):
optional=True, require_features=(), remove=(), **extras):
self.warn_deprecated()
self.description = description
self.standard = standard
......@@ -847,8 +759,6 @@ class Feature:
for f in self.require_features:
dist.include_feature(f)
def exclude_from(self,dist):
"""Ensure feature is excluded from distribution
......@@ -865,8 +775,6 @@ class Feature:
for item in self.remove:
dist.exclude_package(item)
def validate(self,dist):
"""Verify that feature makes sense in context of distribution
......@@ -886,7 +794,3 @@ class Feature:
" doesn't contain any packages or modules under %s"
% (self.description, item, item)
)
"""PyPI and direct package downloading"""
import sys, os.path, re, shutil, random, socket
import itertools
import sys
import os
import re
import shutil
import socket
import base64
from pkg_resources import (
CHECKOUT_DIST, Distribution, BINARY_DIST, normalize_path, SOURCE_DIST,
require, Environment, find_distributions, safe_name, safe_version,
to_filename, Requirement, DEVELOP_DIST,
)
from setuptools import ssl_support
from pkg_resources import *
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)
unichr, urljoin, urlsplit, urlunsplit)
from setuptools.compat import filterfalse
from fnmatch import translate
from setuptools.py24compat import hashlib
from setuptools.py24compat import wraps
from setuptools.py26compat import strip_fragment
from setuptools.py27compat import get_all_headers
EGG_FRAGMENT = re.compile(r'^egg=([-A-Za-z0-9_.]+)$')
......@@ -105,9 +114,10 @@ def distros_for_filename(filename, metadata=None):
)
def interpret_distro_name(location, basename, metadata,
py_version=None, precedence=SOURCE_DIST, platform=None
):
def interpret_distro_name(
location, basename, metadata, py_version=None, precedence=SOURCE_DIST,
platform=None
):
"""Generate alternative interpretations of a source distro name
Note: if `location` is a filesystem filename, you should call
......@@ -222,6 +232,7 @@ class HashChecker(ContentChecker):
)
def __init__(self, hash_name, expected):
self.hash_name = hash_name
self.hash = hashlib.new(hash_name)
self.expected = expected
......@@ -242,32 +253,18 @@ class HashChecker(ContentChecker):
def is_valid(self):
return self.hash.hexdigest() == self.expected
def _get_hash_name(self):
"""
Python 2.4 implementation of MD5 doesn't supply a .name attribute
so provide that name.
When Python 2.4 is no longer required, replace invocations of this
method with simply 'self.hash.name'.
"""
try:
return self.hash.name
except AttributeError:
if 'md5' in str(type(self.hash)):
return 'md5'
raise
def report(self, reporter, template):
msg = template % self._get_hash_name()
msg = template % self.hash_name
return reporter(msg)
class PackageIndex(Environment):
"""A distribution index that scans web pages for download URLs"""
def __init__(self, index_url="https://pypi.python.org/simple", hosts=('*',),
ca_bundle=None, verify_ssl=True, *args, **kw
):
def __init__(
self, index_url="https://pypi.python.org/simple", hosts=('*',),
ca_bundle=None, verify_ssl=True, *args, **kw
):
Environment.__init__(self,*args,**kw)
self.index_url = index_url + "/"[:not index_url.endswith('/')]
self.scanned_urls = {}
......@@ -347,7 +344,8 @@ class PackageIndex(Environment):
s = URL_SCHEME(url)
if (s and s.group(1).lower()=='file') or self.allows(urlparse(url)[1]):
return True
msg = "\nLink to % s ***BLOCKED*** by --allow-hosts\n"
msg = ("\nNote: Bypassing %s (disallowed host; see "
"http://bit.ly/1dg9ijs for details).\n")
if fatal:
raise DistutilsError(msg % url)
else:
......@@ -388,7 +386,7 @@ class PackageIndex(Environment):
# process an index page into the package-page index
for match in HREF.finditer(page):
try:
scan( urljoin(url, htmldecode(match.group(1))) )
scan(urljoin(url, htmldecode(match.group(1))))
except ValueError:
pass
......@@ -411,8 +409,6 @@ class PackageIndex(Environment):
else:
return "" # no sense double-scanning non-package pages
def need_version_info(self, url):
self.scan_all(
"Page at %s links to .py file(s) without version info; an index "
......@@ -443,17 +439,14 @@ class PackageIndex(Environment):
self.scan_url(url)
def obtain(self, requirement, installer=None):
self.prescan(); self.find_packages(requirement)
self.prescan()
self.find_packages(requirement)
for dist in self[requirement.key]:
if dist in requirement:
return dist
self.debug("%s does not match %s", requirement, dist)
return super(PackageIndex, self).obtain(requirement,installer)
def check_hash(self, checker, filename, tfp):
"""
checker is a ContentChecker
......@@ -539,11 +532,10 @@ class PackageIndex(Environment):
)
return getattr(self.fetch_distribution(spec, tmpdir),'location',None)
def fetch_distribution(self,
requirement, tmpdir, force_scan=False, source=False, develop_ok=False,
local_index=None
):
def fetch_distribution(
self, requirement, tmpdir, force_scan=False, source=False,
develop_ok=False, local_index=None
):
"""Obtain a distribution suitable for fulfilling `requirement`
`requirement` must be a ``pkg_resources.Requirement`` instance.
......@@ -581,8 +573,6 @@ class PackageIndex(Environment):
if dist in req and (dist.precedence<=SOURCE_DIST or not source):
return dist
if force_scan:
self.prescan()
self.find_packages(requirement)
......@@ -609,7 +599,6 @@ class PackageIndex(Environment):
self.info("Best match: %s", dist)
return dist.clone(location=self.download(dist.location, tmpdir))
def fetch(self, requirement, tmpdir, force_scan=False, source=False):
"""Obtain a file suitable for fulfilling `requirement`
......@@ -623,10 +612,10 @@ class PackageIndex(Environment):
return dist.location
return None
def gen_setup(self, filename, fragment, tmpdir):
match = EGG_FRAGMENT.match(fragment)
dists = match and [d for d in
dists = match and [
d for d in
interpret_distro_name(filename, match.group(1), None) if d.version
] or []
......@@ -672,7 +661,7 @@ class PackageIndex(Environment):
fp, tfp, info = None, None, None
try:
checker = HashChecker.from_url(url)
fp = self.open_url(url)
fp = self.open_url(strip_fragment(url))
if isinstance(fp, HTTPError):
raise DistutilsError(
"Can't download %s: %s %s" % (url, fp.code,fp.msg)
......@@ -732,9 +721,11 @@ class PackageIndex(Environment):
if warning:
self.warn(warning, v.line)
else:
raise DistutilsError('%s returned a bad status line. '
'The server might be down, %s' % \
(url, v.line))
raise DistutilsError(
'%s returned a bad status line. The server might be '
'down, %s' %
(url, v.line)
)
except httplib.HTTPException:
v = sys.exc_info()[1]
if warning:
......@@ -775,7 +766,6 @@ class PackageIndex(Environment):
def scan_url(self, url):
self.process_url(url, True)
def _attempt_download(self, url, filename):
headers = self._download_to(url, filename)
if 'html' in headers.get('content-type','').lower():
......@@ -798,21 +788,6 @@ class PackageIndex(Environment):
os.unlink(filename)
raise DistutilsError("Unexpected HTML page found at "+url)
def _download_svn(self, url, filename):
url = url.split('#',1)[0] # remove any fragment for svn's sake
creds = ''
......@@ -833,7 +808,8 @@ class PackageIndex(Environment):
os.system("svn checkout%s -q %s %s" % (creds, url, filename))
return filename
def _vcs_split_rev_from_url(self, url, pop_prefix=False):
@staticmethod
def _vcs_split_rev_from_url(url, pop_prefix=False):
scheme, netloc, path, query, frag = urlsplit(url)
scheme = scheme.split('+', 1)[-1]
......@@ -891,18 +867,6 @@ class PackageIndex(Environment):
def warn(self, msg, *args):
log.warn(msg, *args)
# This pattern matches a character entity reference (a decimal numeric
# references, a hexadecimal numeric reference, or a named reference).
entity_sub = re.compile(r'&(#(\d+|x[\da-fA-F]+)|[\w.:-]+);?').sub
......@@ -927,20 +891,6 @@ def htmldecode(text):
"""Decode HTML entities in the given text."""
return entity_sub(decode_entity, text)
def socket_timeout(timeout=15):
def _socket_timeout(func):
def _socket_timeout(*args, **kwargs):
......@@ -1009,15 +959,6 @@ def open_with_auth(url, opener=urllib2.urlopen):
open_with_auth = socket_timeout(_SOCKET_TIMEOUT)(open_with_auth)
def fix_sf_url(url):
return url # backward compatibility
......@@ -1047,17 +988,3 @@ def local_open(url):
return HTTPError(url, status, message,
{'content-type':'text/html'}, StringIO(body))
# this line is a kludge to keep the trailing blank lines for pje's editor
"""
Compatibility Support for Python 2.6 and earlier
"""
import sys
from setuptools.compat import splittag
def strip_fragment(url):
"""
In `Python 8280 <http://bugs.python.org/issue8280>`_, Python 2.7 and
later was patched to disregard the fragment when making URL requests.
Do the same for Python 2.6 and earlier.
"""
url, fragment = splittag(url)
return url
if sys.version_info >= (2,7):
strip_fragment = lambda x: x
# EASY-INSTALL-DEV-SCRIPT: %(spec)r,%(script_name)r
__requires__ = """%(spec)r"""
from pkg_resources import require; require("""%(spec)r""")
import sys
from pkg_resources import require
require("""%(spec)r""")
del require
__file__ = """%(dev_path)r"""
try:
if sys.version_info < (3, 0):
execfile(__file__)
except NameError:
else:
exec(compile(open(__file__).read(), __file__, 'exec'))
......@@ -194,6 +194,12 @@ class VerifyingHTTPSConn(HTTPSConnection):
sock = create_connection(
(self.host, self.port), getattr(self,'source_address',None)
)
# Handle the socket if a (proxy) tunnel is present
if hasattr(self, '_tunnel') and getattr(self, '_tunnel_host', None):
self.sock = sock
self._tunnel()
self.sock = ssl.wrap_socket(
sock, cert_reqs=ssl.CERT_REQUIRED, ca_certs=self.ca_bundle
)
......
# -*- coding: utf-8 -*-
result = 'passed'
......@@ -14,7 +14,7 @@ import distutils.core
from setuptools.compat import StringIO, BytesIO, next, urlparse
from setuptools.sandbox import run_setup, SandboxViolation
from setuptools.command.easy_install import easy_install, fix_jython_executable, get_script_args
from setuptools.command.easy_install import easy_install, fix_jython_executable, get_script_args, nt_quote_arg
from setuptools.command.easy_install import PthDistributions
from setuptools.command import easy_install as easy_install_pkg
from setuptools.dist import Distribution
......@@ -52,7 +52,7 @@ if __name__ == '__main__':
sys.exit(
load_entry_point('spec', 'console_scripts', 'name')()
)
""" % fix_jython_executable(sys.executable, "")
""" % nt_quote_arg(fix_jython_executable(sys.executable, ""))
SETUP_PY = """\
from setuptools import setup
......
......@@ -142,6 +142,15 @@ class TestPackageIndex(unittest.TestCase):
self.assertEqual(setuptools.package_index.parse_bdist_wininst(
'reportlab-2.5.win-amd64.exe'), ('reportlab-2.5', None, 'win-amd64'))
def test__vcs_split_rev_from_url(self):
"""
Test the basic usage of _vcs_split_rev_from_url
"""
vsrfu = setuptools.package_index.PackageIndex._vcs_split_rev_from_url
url, rev = vsrfu('https://example.com/bar@2995')
self.assertEqual(url, 'https://example.com/bar')
self.assertEqual(rev, '2995')
class TestContentCheckers(unittest.TestCase):
def test_md5(self):
......@@ -169,11 +178,7 @@ class TestContentCheckers(unittest.TestCase):
def test_get_hash_name_md5(self):
checker = setuptools.package_index.HashChecker.from_url(
'http://foo/bar#md5=f12895fdffbd45007040d2e44df98478')
if sys.version_info >= (2,5):
self.assertEqual(checker.hash.name, 'md5')
else:
# Python 2.4 compatability
self.assertEqual(checker._get_hash_name(), 'md5')
self.assertEqual(checker.hash_name, 'md5')
def test_report(self):
checker = setuptools.package_index.HashChecker.from_url(
......
This diff is collapsed.
This diff is collapsed.
__version__ = '1.1.7'
This diff is collapsed.
This diff is collapsed.
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