mirror of
https://github.com/kennethreitz/heroku-buildpack-python.git
synced 2026-06-05 23:10:16 +00:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5645a433dc | |||
| 715ab8b96a | |||
| b7f1157693 | |||
| ae7b6fc715 | |||
| e0c3b72950 | |||
| 566f7f4555 | |||
| 4ff62b2b41 | |||
| d47970fd81 | |||
| 69bdca063f |
@@ -1,21 +0,0 @@
|
||||
tests:
|
||||
./bin/test
|
||||
|
||||
docs:
|
||||
mkdir -p site
|
||||
shocco -t 'Python Buildpack Compiler' ./bin/compile > site/index.html
|
||||
shocco -t 'Django Buildpack Compiler' ./bin/steps/django > site/django.html
|
||||
shocco -t 'Python Buildpack Detector' ./bin/detect > site/detect.html
|
||||
shocco -t 'Pylibmc Buildpack Compiler' ./bin/steps/pylibmc > site/pylibmc.html
|
||||
shocco -t 'Python Buildpack Changelog' ./Changelog.md > site/changelog.html
|
||||
|
||||
site: docs
|
||||
cd site && git add -A && git commit -m 'update' && git push heroku master
|
||||
|
||||
pip:
|
||||
git clone git@github.com:kennethreitz/pip.git --branch heroku --depth 1
|
||||
rm -fr vendor/virtualenv-1.8.4/virtualenv_support/pip-1.2.1.tar.gz
|
||||
rm -fr pip/.git
|
||||
tar -pczf vendor/virtualenv-1.8.4/virtualenv_support/pip-1.2.1.tar.gz pip
|
||||
rm -fr pip
|
||||
|
||||
@@ -19,11 +19,11 @@ Example usage:
|
||||
...
|
||||
-----> Fetching custom git buildpack... done
|
||||
-----> Python app detected
|
||||
-----> No runtime.txt provided; assuming python-2.7.3.
|
||||
-----> Preparing Python runtime (python-2.7.3)
|
||||
-----> Installing Distribute (0.6.34)
|
||||
-----> Installing Pip (1.2.1)
|
||||
-----> Installing dependencies using Pip (1.2.1)
|
||||
-----> No runtime.txt provided; assuming python-2.7.6.
|
||||
-----> Preparing Python runtime (python-2.7.6)
|
||||
-----> Installing Setuptools (2.1)
|
||||
-----> Installing Pip (1.5.2)
|
||||
-----> Installing dependencies using Pip (1.5.2)
|
||||
Downloading/unpacking Flask==0.7.2 (from -r requirements.txt (line 1))
|
||||
Downloading/unpacking Werkzeug>=0.6.1 (from Flask==0.7.2->-r requirements.txt (line 1))
|
||||
Downloading/unpacking Jinja2>=2.4 (from Flask==0.7.2->-r requirements.txt (line 1))
|
||||
@@ -35,9 +35,9 @@ You can also add it to upcoming builds of an existing application:
|
||||
|
||||
$ heroku config:add BUILDPACK_URL=git://github.com/heroku/heroku-buildpack-python.git
|
||||
|
||||
The buildpack will detect your app as Python if it has the file `requirements.txt` in the root.
|
||||
The buildpack will detect your app as Python if it has the file `requirements.txt` in the root.
|
||||
|
||||
It will use Pip to install your dependencies, vendoring a copy of the Python runtime into your slug.
|
||||
It will use Pip to install your dependencies, vendoring a copy of the Python runtime into your slug.
|
||||
|
||||
Specify a Runtime
|
||||
-----------------
|
||||
@@ -45,10 +45,12 @@ Specify a Runtime
|
||||
You can also provide arbitrary releases Python with a `runtime.txt` file.
|
||||
|
||||
$ cat runtime.txt
|
||||
python-3.3.2
|
||||
|
||||
python-3.3.3
|
||||
|
||||
Runtime options include:
|
||||
|
||||
- python-2.7.4
|
||||
- python-3.3.2
|
||||
- python-2.7.6
|
||||
- python-3.3.3
|
||||
- pypy-1.9 (experimental)
|
||||
|
||||
Other [unsupported runtimes](https://github.com/kennethreitz/python-versions/tree/master/formula) are available as well.
|
||||
|
||||
+13
-9
@@ -15,7 +15,7 @@ BIN_DIR=$(cd $(dirname $0); pwd) # absolute path
|
||||
ROOT_DIR=$(dirname $BIN_DIR)
|
||||
BUILD_DIR=$1
|
||||
CACHE_DIR=$2
|
||||
ENV_FILE=$3
|
||||
ENV_DIR=$3
|
||||
|
||||
|
||||
CACHED_DIRS=".heroku"
|
||||
@@ -25,11 +25,10 @@ VIRTUALENV_LOC=".heroku/venv"
|
||||
LEGACY_TRIGGER="lib/python2.7"
|
||||
PROFILE_PATH="$BUILD_DIR/.profile.d/python.sh"
|
||||
|
||||
# Python version. This will be used in the future to specify custom Pythons.
|
||||
DEFAULT_PYTHON_VERSION="python-2.7.4"
|
||||
DEFAULT_PYTHON_VERSION="python-2.7.6"
|
||||
PYTHON_EXE="/app/.heroku/python/bin/python"
|
||||
PIP_VERSION="1.3.1"
|
||||
DISTRIBUTE_VERSION="0.6.36"
|
||||
PIP_VERSION="1.5.2"
|
||||
SETUPTOOLS_VERSION="2.1"
|
||||
|
||||
# Setup bpwatch
|
||||
export PATH=$PATH:$ROOT_DIR/vendor/bpwatch
|
||||
@@ -103,6 +102,11 @@ if [ ! -f requirements.txt ]; then
|
||||
echo "-e ." > requirements.txt
|
||||
fi
|
||||
|
||||
# Sticky runtimes.
|
||||
if [ -f $CACHE_DIR/.heroku/python-version ]; then
|
||||
DEFAULT_PYTHON_VERSION=$(cat $CACHE_DIR/.heroku/python-version)
|
||||
fi
|
||||
|
||||
# If no runtime given, assume default version.
|
||||
if [ ! -f runtime.txt ]; then
|
||||
puts-step "No runtime.txt provided; assuming $DEFAULT_PYTHON_VERSION."
|
||||
@@ -175,13 +179,13 @@ if [ "$FRESH_PYTHON" ] || [[ ! $(pip --version) == *$PIP_VERSION* ]]; then
|
||||
|
||||
bpwatch start prepare_environment
|
||||
|
||||
bpwatch start install_distribute
|
||||
bpwatch start install_setuptools
|
||||
# Prepare it for the real world
|
||||
puts-step "Installing Distribute ($DISTRIBUTE_VERSION)"
|
||||
cd $ROOT_DIR/vendor/distribute-$DISTRIBUTE_VERSION/
|
||||
puts-step "Installing Setuptools ($SETUPTOOLS_VERSION)"
|
||||
cd $ROOT_DIR/vendor/setuptools-$SETUPTOOLS_VERSION/
|
||||
python setup.py install &> /dev/null
|
||||
cd $WORKING_DIR
|
||||
bpwatch stop install_distribute
|
||||
bpwatch stop install_setuptoools
|
||||
|
||||
bpwatch start install_pip
|
||||
puts-step "Installing Pip ($PIP_VERSION)"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#
|
||||
# Create a Heroku app with the following buildpack:
|
||||
# https://github.com/ddollar/buildpack-tet
|
||||
# https://github.com/ddollar/buildpack-test
|
||||
#
|
||||
# Push this Python buildpack to that Heroku app to
|
||||
# run the tests.
|
||||
|
||||
@@ -59,6 +59,22 @@ function deep-rm (){
|
||||
find -H $1 -maxdepth 1 -name '.*' -a \( -type d -o -type f -o -type l \) -exec rm -fr '{}' \;
|
||||
}
|
||||
|
||||
function sub-env (){
|
||||
(export $(egrep -v '^(GIT_DIR|PYTHONHOME|PYTHONPATH|LD_LIBRARY_PATH|LIBRARY_PATH|PATH)' $ENV_FILE); $1)
|
||||
}
|
||||
|
||||
sub-env() {
|
||||
|
||||
WHITELIST=${2:-''}
|
||||
BLACKLIST=${3:-'^(GIT_DIR|PYTHONHOME|PYTHONPATH|LD_LIBRARY_PATH|LIBRARY_PATH|PATH)$'}
|
||||
|
||||
(
|
||||
if [ -d "$ENV_DIR" ]; then
|
||||
for e in $(ls $ENV_DIR); do
|
||||
echo "$e" | grep -E "$WHITELIST" | grep -qvE "$BLACKLIST" &&
|
||||
export "$e=$(cat $ENV_DIR/$e)"
|
||||
:
|
||||
done
|
||||
fi
|
||||
|
||||
$1
|
||||
|
||||
)
|
||||
}
|
||||
@@ -1 +1,2 @@
|
||||
httpbin
|
||||
requests
|
||||
distribute==0.6.49
|
||||
@@ -1 +1 @@
|
||||
python-2.7.3
|
||||
python-3.3.2
|
||||
Vendored
-509
@@ -1,509 +0,0 @@
|
||||
=======
|
||||
CHANGES
|
||||
=======
|
||||
|
||||
------
|
||||
0.6.36
|
||||
------
|
||||
|
||||
* Pull Request #35: In `Buildout issue 64
|
||||
<https://github.com/buildout/buildout/issues/64>`_, it was reported that
|
||||
under Python 3, installation of distutils scripts could attempt to copy
|
||||
the ``__pycache__`` directory as a file, causing an error, apparently only
|
||||
under Windows. Easy_install now skips all directories when processing
|
||||
metadata scripts.
|
||||
|
||||
------
|
||||
0.6.35
|
||||
------
|
||||
|
||||
Note this release is backward-incompatible with distribute 0.6.23-0.6.34 in
|
||||
how it parses version numbers.
|
||||
|
||||
* Issue #278: Restored compatibility with distribute 0.6.22 and setuptools
|
||||
0.6. Updated the documentation to match more closely with the version
|
||||
parsing as intended in setuptools 0.6.
|
||||
|
||||
------
|
||||
0.6.34
|
||||
------
|
||||
|
||||
* Issue #341: 0.6.33 fails to build under Python 2.4.
|
||||
|
||||
------
|
||||
0.6.33
|
||||
------
|
||||
|
||||
* Fix 2 errors with Jython 2.5.
|
||||
* Fix 1 failure with Jython 2.5 and 2.7.
|
||||
* Disable workaround for Jython scripts on Linux systems.
|
||||
* Issue #336: `setup.py` no longer masks failure exit code when tests fail.
|
||||
* Fix issue in pkg_resources where try/except around a platform-dependent
|
||||
import would trigger hook load failures on Mercurial. See pull request 32
|
||||
for details.
|
||||
* Issue #341: Fix a ResourceWarning.
|
||||
|
||||
------
|
||||
0.6.32
|
||||
------
|
||||
|
||||
* Fix test suite with Python 2.6.
|
||||
* Fix some DeprecationWarnings and ResourceWarnings.
|
||||
* Issue #335: Backed out `setup_requires` superceding installed requirements
|
||||
until regression can be addressed.
|
||||
|
||||
------
|
||||
0.6.31
|
||||
------
|
||||
|
||||
* Issue #303: Make sure the manifest only ever contains UTF-8 in Python 3.
|
||||
* Issue #329: Properly close files created by tests for compatibility with
|
||||
Jython.
|
||||
* Work around Jython bugs `#1980 <http://bugs.jython.org/issue1980>`_ and
|
||||
`#1981 <http://bugs.jython.org/issue1981>`_.
|
||||
* Issue #334: Provide workaround for packages that reference `sys.__stdout__`
|
||||
such as numpy does. This change should address
|
||||
`virtualenv #359 <https://github.com/pypa/virtualenv/issues/359>`_ as long
|
||||
as the system encoding is UTF-8 or the IO encoding is specified in the
|
||||
environment, i.e.::
|
||||
|
||||
PYTHONIOENCODING=utf8 pip install numpy
|
||||
|
||||
* Fix for encoding issue when installing from Windows executable on Python 3.
|
||||
* Issue #323: Allow `setup_requires` requirements to supercede installed
|
||||
requirements. Added some new keyword arguments to existing pkg_resources
|
||||
methods. Also had to updated how __path__ is handled for namespace packages
|
||||
to ensure that when a new egg distribution containing a namespace package is
|
||||
placed on sys.path, the entries in __path__ are found in the same order they
|
||||
would have been in had that egg been on the path when pkg_resources was
|
||||
first imported.
|
||||
|
||||
------
|
||||
0.6.30
|
||||
------
|
||||
|
||||
* Issue #328: Clean up temporary directories in distribute_setup.py.
|
||||
* Fix fatal bug in distribute_setup.py.
|
||||
|
||||
------
|
||||
0.6.29
|
||||
------
|
||||
|
||||
* Pull Request #14: Honor file permissions in zip files.
|
||||
* Issue #327: Merged pull request #24 to fix a dependency problem with pip.
|
||||
* Merged pull request #23 to fix https://github.com/pypa/virtualenv/issues/301.
|
||||
* If Sphinx is installed, the `upload_docs` command now runs `build_sphinx`
|
||||
to produce uploadable documentation.
|
||||
* Issue #326: `upload_docs` provided mangled auth credentials under Python 3.
|
||||
* Issue #320: Fix check for "createable" in distribute_setup.py.
|
||||
* Issue #305: Remove a warning that was triggered during normal operations.
|
||||
* Issue #311: Print metadata in UTF-8 independent of platform.
|
||||
* Issue #303: Read manifest file with UTF-8 encoding under Python 3.
|
||||
* Issue #301: Allow to run tests of namespace packages when using 2to3.
|
||||
* Issue #304: Prevent import loop in site.py under Python 3.3.
|
||||
* Issue #283: Reenable scanning of `*.pyc` / `*.pyo` files on Python 3.3.
|
||||
* Issue #299: The develop command didn't work on Python 3, when using 2to3,
|
||||
as the egg link would go to the Python 2 source. Linking to the 2to3'd code
|
||||
in build/lib makes it work, although you will have to rebuild the module
|
||||
before testing it.
|
||||
* Issue #306: Even if 2to3 is used, we build in-place under Python 2.
|
||||
* Issue #307: Prints the full path when .svn/entries is broken.
|
||||
* Issue #313: Support for sdist subcommands (Python 2.7)
|
||||
* Issue #314: test_local_index() would fail an OS X.
|
||||
* Issue #310: Non-ascii characters in a namespace __init__.py causes errors.
|
||||
* Issue #218: Improved documentation on behavior of `package_data` and
|
||||
`include_package_data`. Files indicated by `package_data` are now included
|
||||
in the manifest.
|
||||
* `distribute_setup.py` now allows a `--download-base` argument for retrieving
|
||||
distribute from a specified location.
|
||||
|
||||
------
|
||||
0.6.28
|
||||
------
|
||||
|
||||
* Issue #294: setup.py can now be invoked from any directory.
|
||||
* Scripts are now installed honoring the umask.
|
||||
* Added support for .dist-info directories.
|
||||
* Issue #283: Fix and disable scanning of `*.pyc` / `*.pyo` files on
|
||||
Python 3.3.
|
||||
|
||||
------
|
||||
0.6.27
|
||||
------
|
||||
|
||||
* Support current snapshots of CPython 3.3.
|
||||
* Distribute now recognizes README.rst as a standard, default readme file.
|
||||
* Exclude 'encodings' modules when removing modules from sys.modules.
|
||||
Workaround for #285.
|
||||
* Issue #231: Don't fiddle with system python when used with buildout
|
||||
(bootstrap.py)
|
||||
|
||||
------
|
||||
0.6.26
|
||||
------
|
||||
|
||||
* Issue #183: Symlinked files are now extracted from source distributions.
|
||||
* Issue #227: Easy_install fetch parameters are now passed during the
|
||||
installation of a source distribution; now fulfillment of setup_requires
|
||||
dependencies will honor the parameters passed to easy_install.
|
||||
|
||||
------
|
||||
0.6.25
|
||||
------
|
||||
|
||||
* Issue #258: Workaround a cache issue
|
||||
* Issue #260: distribute_setup.py now accepts the --user parameter for
|
||||
Python 2.6 and later.
|
||||
* Issue #262: package_index.open_with_auth no longer throws LookupError
|
||||
on Python 3.
|
||||
* Issue #269: AttributeError when an exception occurs reading Manifest.in
|
||||
on late releases of Python.
|
||||
* Issue #272: Prevent TypeError when namespace package names are unicode
|
||||
and single-install-externally-managed is used. Also fixes PIP issue
|
||||
449.
|
||||
* Issue #273: Legacy script launchers now install with Python2/3 support.
|
||||
|
||||
------
|
||||
0.6.24
|
||||
------
|
||||
|
||||
* Issue #249: Added options to exclude 2to3 fixers
|
||||
|
||||
------
|
||||
0.6.23
|
||||
------
|
||||
|
||||
* Issue #244: Fixed a test
|
||||
* Issue #243: Fixed a test
|
||||
* Issue #239: Fixed a test
|
||||
* Issue #240: Fixed a test
|
||||
* Issue #241: Fixed a test
|
||||
* Issue #237: Fixed a test
|
||||
* Issue #238: easy_install now uses 64bit executable wrappers on 64bit Python
|
||||
* Issue #208: Fixed parsed_versions, it now honors post-releases as noted in the documentation
|
||||
* Issue #207: Windows cli and gui wrappers pass CTRL-C to child python process
|
||||
* Issue #227: easy_install now passes its arguments to setup.py bdist_egg
|
||||
* Issue #225: Fixed a NameError on Python 2.5, 2.4
|
||||
|
||||
------
|
||||
0.6.21
|
||||
------
|
||||
|
||||
* Issue #225: FIxed a regression on py2.4
|
||||
|
||||
------
|
||||
0.6.20
|
||||
------
|
||||
|
||||
* Issue #135: Include url in warning when processing URLs in package_index.
|
||||
* Issue #212: Fix issue where easy_instal fails on Python 3 on windows installer.
|
||||
* Issue #213: Fix typo in documentation.
|
||||
|
||||
------
|
||||
0.6.19
|
||||
------
|
||||
|
||||
* Issue 206: AttributeError: 'HTTPMessage' object has no attribute 'getheaders'
|
||||
|
||||
------
|
||||
0.6.18
|
||||
------
|
||||
|
||||
* Issue 210: Fixed a regression introduced by Issue 204 fix.
|
||||
|
||||
------
|
||||
0.6.17
|
||||
------
|
||||
|
||||
* Support 'DISTRIBUTE_DISABLE_VERSIONED_EASY_INSTALL_SCRIPT' environment
|
||||
variable to allow to disable installation of easy_install-${version} script.
|
||||
* Support Python >=3.1.4 and >=3.2.1.
|
||||
* Issue 204: Don't try to import the parent of a namespace package in
|
||||
declare_namespace
|
||||
* Issue 196: Tolerate responses with multiple Content-Length headers
|
||||
* Issue 205: Sandboxing doesn't preserve working_set. Leads to setup_requires
|
||||
problems.
|
||||
|
||||
------
|
||||
0.6.16
|
||||
------
|
||||
|
||||
* Builds sdist gztar even on Windows (avoiding Issue 193).
|
||||
* Issue 192: Fixed metadata omitted on Windows when package_dir
|
||||
specified with forward-slash.
|
||||
* Issue 195: Cython build support.
|
||||
* Issue 200: Issues with recognizing 64-bit packages on Windows.
|
||||
|
||||
------
|
||||
0.6.15
|
||||
------
|
||||
|
||||
* Fixed typo in bdist_egg
|
||||
* Several issues under Python 3 has been solved.
|
||||
* Issue 146: Fixed missing DLL files after easy_install of windows exe package.
|
||||
|
||||
------
|
||||
0.6.14
|
||||
------
|
||||
|
||||
* Issue 170: Fixed unittest failure. Thanks to Toshio.
|
||||
* Issue 171: Fixed race condition in unittests cause deadlocks in test suite.
|
||||
* Issue 143: Fixed a lookup issue with easy_install.
|
||||
Thanks to David and Zooko.
|
||||
* Issue 174: Fixed the edit mode when its used with setuptools itself
|
||||
|
||||
------
|
||||
0.6.13
|
||||
------
|
||||
|
||||
* Issue 160: 2.7 gives ValueError("Invalid IPv6 URL")
|
||||
* Issue 150: Fixed using ~/.local even in a --no-site-packages virtualenv
|
||||
* Issue 163: scan index links before external links, and don't use the md5 when
|
||||
comparing two distributions
|
||||
|
||||
------
|
||||
0.6.12
|
||||
------
|
||||
|
||||
* Issue 149: Fixed various failures on 2.3/2.4
|
||||
|
||||
------
|
||||
0.6.11
|
||||
------
|
||||
|
||||
* Found another case of SandboxViolation - fixed
|
||||
* Issue 15 and 48: Introduced a socket timeout of 15 seconds on url openings
|
||||
* Added indexsidebar.html into MANIFEST.in
|
||||
* Issue 108: Fixed TypeError with Python3.1
|
||||
* Issue 121: Fixed --help install command trying to actually install.
|
||||
* Issue 112: Added an os.makedirs so that Tarek's solution will work.
|
||||
* Issue 133: Added --no-find-links to easy_install
|
||||
* Added easy_install --user
|
||||
* Issue 100: Fixed develop --user not taking '.' in PYTHONPATH into account
|
||||
* Issue 134: removed spurious UserWarnings. Patch by VanLindberg
|
||||
* Issue 138: cant_write_to_target error when setup_requires is used.
|
||||
* Issue 147: respect the sys.dont_write_bytecode flag
|
||||
|
||||
------
|
||||
0.6.10
|
||||
------
|
||||
|
||||
* Reverted change made for the DistributionNotFound exception because
|
||||
zc.buildout uses the exception message to get the name of the
|
||||
distribution.
|
||||
|
||||
-----
|
||||
0.6.9
|
||||
-----
|
||||
|
||||
* Issue 90: unknown setuptools version can be added in the working set
|
||||
* Issue 87: setupt.py doesn't try to convert distribute_setup.py anymore
|
||||
Initial Patch by arfrever.
|
||||
* Issue 89: added a side bar with a download link to the doc.
|
||||
* Issue 86: fixed missing sentence in pkg_resources doc.
|
||||
* Added a nicer error message when a DistributionNotFound is raised.
|
||||
* Issue 80: test_develop now works with Python 3.1
|
||||
* Issue 93: upload_docs now works if there is an empty sub-directory.
|
||||
* Issue 70: exec bit on non-exec files
|
||||
* Issue 99: now the standalone easy_install command doesn't uses a
|
||||
"setup.cfg" if any exists in the working directory. It will use it
|
||||
only if triggered by ``install_requires`` from a setup.py call
|
||||
(install, develop, etc).
|
||||
* Issue 101: Allowing ``os.devnull`` in Sandbox
|
||||
* Issue 92: Fixed the "no eggs" found error with MacPort
|
||||
(platform.mac_ver() fails)
|
||||
* Issue 103: test_get_script_header_jython_workaround not run
|
||||
anymore under py3 with C or POSIX local. Contributed by Arfrever.
|
||||
* Issue 104: remvoved the assertion when the installation fails,
|
||||
with a nicer message for the end user.
|
||||
* Issue 100: making sure there's no SandboxViolation when
|
||||
the setup script patches setuptools.
|
||||
|
||||
-----
|
||||
0.6.8
|
||||
-----
|
||||
|
||||
* Added "check_packages" in dist. (added in Setuptools 0.6c11)
|
||||
* Fixed the DONT_PATCH_SETUPTOOLS state.
|
||||
|
||||
-----
|
||||
0.6.7
|
||||
-----
|
||||
|
||||
* Issue 58: Added --user support to the develop command
|
||||
* Issue 11: Generated scripts now wrap their call to the script entry point
|
||||
in the standard "if name == 'main'"
|
||||
* Added the 'DONT_PATCH_SETUPTOOLS' environment variable, so virtualenv
|
||||
can drive an installation that doesn't patch a global setuptools.
|
||||
* Reviewed unladen-swallow specific change from
|
||||
http://code.google.com/p/unladen-swallow/source/detail?spec=svn875&r=719
|
||||
and determined that it no longer applies. Distribute should work fine with
|
||||
Unladen Swallow 2009Q3.
|
||||
* Issue 21: Allow PackageIndex.open_url to gracefully handle all cases of a
|
||||
httplib.HTTPException instead of just InvalidURL and BadStatusLine.
|
||||
* Removed virtual-python.py from this distribution and updated documentation
|
||||
to point to the actively maintained virtualenv instead.
|
||||
* Issue 64: use_setuptools no longer rebuilds the distribute egg every
|
||||
time it is run
|
||||
* use_setuptools now properly respects the requested version
|
||||
* use_setuptools will no longer try to import a distribute egg for the
|
||||
wrong Python version
|
||||
* Issue 74: no_fake should be True by default.
|
||||
* Issue 72: avoid a bootstrapping issue with easy_install -U
|
||||
|
||||
-----
|
||||
0.6.6
|
||||
-----
|
||||
|
||||
* Unified the bootstrap file so it works on both py2.x and py3k without 2to3
|
||||
(patch by Holger Krekel)
|
||||
|
||||
-----
|
||||
0.6.5
|
||||
-----
|
||||
|
||||
* Issue 65: cli.exe and gui.exe are now generated at build time,
|
||||
depending on the platform in use.
|
||||
|
||||
* Issue 67: Fixed doc typo (PEP 381/382)
|
||||
|
||||
* Distribute no longer shadows setuptools if we require a 0.7-series
|
||||
setuptools. And an error is raised when installing a 0.7 setuptools with
|
||||
distribute.
|
||||
|
||||
* When run from within buildout, no attempt is made to modify an existing
|
||||
setuptools egg, whether in a shared egg directory or a system setuptools.
|
||||
|
||||
* Fixed a hole in sandboxing allowing builtin file to write outside of
|
||||
the sandbox.
|
||||
|
||||
-----
|
||||
0.6.4
|
||||
-----
|
||||
|
||||
* Added the generation of `distribute_setup_3k.py` during the release.
|
||||
This closes issue #52.
|
||||
|
||||
* Added an upload_docs command to easily upload project documentation to
|
||||
PyPI's http://packages.python.org. This close issue #56.
|
||||
|
||||
* Fixed a bootstrap bug on the use_setuptools() API.
|
||||
|
||||
-----
|
||||
0.6.3
|
||||
-----
|
||||
|
||||
setuptools
|
||||
==========
|
||||
|
||||
* Fixed a bunch of calls to file() that caused crashes on Python 3.
|
||||
|
||||
bootstrapping
|
||||
=============
|
||||
|
||||
* Fixed a bug in sorting that caused bootstrap to fail on Python 3.
|
||||
|
||||
-----
|
||||
0.6.2
|
||||
-----
|
||||
|
||||
setuptools
|
||||
==========
|
||||
|
||||
* Added Python 3 support; see docs/python3.txt.
|
||||
This closes http://bugs.python.org/setuptools/issue39.
|
||||
|
||||
* Added option to run 2to3 automatically when installing on Python 3.
|
||||
This closes issue #31.
|
||||
|
||||
* Fixed invalid usage of requirement.parse, that broke develop -d.
|
||||
This closes http://bugs.python.org/setuptools/issue44.
|
||||
|
||||
* Fixed script launcher for 64-bit Windows.
|
||||
This closes http://bugs.python.org/setuptools/issue2.
|
||||
|
||||
* KeyError when compiling extensions.
|
||||
This closes http://bugs.python.org/setuptools/issue41.
|
||||
|
||||
bootstrapping
|
||||
=============
|
||||
|
||||
* Fixed bootstrap not working on Windows. This closes issue #49.
|
||||
|
||||
* Fixed 2.6 dependencies. This closes issue #50.
|
||||
|
||||
* Make sure setuptools is patched when running through easy_install
|
||||
This closes http://bugs.python.org/setuptools/issue40.
|
||||
|
||||
-----
|
||||
0.6.1
|
||||
-----
|
||||
|
||||
setuptools
|
||||
==========
|
||||
|
||||
* package_index.urlopen now catches BadStatusLine and malformed url errors.
|
||||
This closes issue #16 and issue #18.
|
||||
|
||||
* zip_ok is now False by default. This closes
|
||||
http://bugs.python.org/setuptools/issue33.
|
||||
|
||||
* Fixed invalid URL error catching. http://bugs.python.org/setuptools/issue20.
|
||||
|
||||
* Fixed invalid bootstraping with easy_install installation (issue #40).
|
||||
Thanks to Florian Schulze for the help.
|
||||
|
||||
* Removed buildout/bootstrap.py. A new repository will create a specific
|
||||
bootstrap.py script.
|
||||
|
||||
|
||||
bootstrapping
|
||||
=============
|
||||
|
||||
* The boostrap process leave setuptools alone if detected in the system
|
||||
and --root or --prefix is provided, but is not in the same location.
|
||||
This closes issue #10.
|
||||
|
||||
---
|
||||
0.6
|
||||
---
|
||||
|
||||
setuptools
|
||||
==========
|
||||
|
||||
* Packages required at build time where not fully present at install time.
|
||||
This closes issue #12.
|
||||
|
||||
* Protected against failures in tarfile extraction. This closes issue #10.
|
||||
|
||||
* Made Jython api_tests.txt doctest compatible. This closes issue #7.
|
||||
|
||||
* sandbox.py replaced builtin type file with builtin function open. This
|
||||
closes issue #6.
|
||||
|
||||
* Immediately close all file handles. This closes issue #3.
|
||||
|
||||
* Added compatibility with Subversion 1.6. This references issue #1.
|
||||
|
||||
pkg_resources
|
||||
=============
|
||||
|
||||
* Avoid a call to /usr/bin/sw_vers on OSX and use the official platform API
|
||||
instead. Based on a patch from ronaldoussoren. This closes issue #5.
|
||||
|
||||
* Fixed a SandboxViolation for mkdir that could occur in certain cases.
|
||||
This closes issue #13.
|
||||
|
||||
* Allow to find_on_path on systems with tight permissions to fail gracefully.
|
||||
This closes issue #9.
|
||||
|
||||
* Corrected inconsistency between documentation and code of add_entry.
|
||||
This closes issue #8.
|
||||
|
||||
* Immediately close all file handles. This closes issue #3.
|
||||
|
||||
easy_install
|
||||
============
|
||||
|
||||
* Immediately close all file handles. This closes issue #3.
|
||||
|
||||
Vendored
-883
@@ -1,883 +0,0 @@
|
||||
Metadata-Version: 1.1
|
||||
Name: distribute
|
||||
Version: 0.6.36
|
||||
Summary: Easily download, build, install, upgrade, and uninstall Python packages
|
||||
Home-page: http://packages.python.org/distribute
|
||||
Author: The fellowship of the packaging
|
||||
Author-email: distutils-sig@python.org
|
||||
License: PSF or ZPL
|
||||
Description: ===============================
|
||||
Installing and Using Distribute
|
||||
===============================
|
||||
|
||||
.. contents:: **Table of Contents**
|
||||
|
||||
-----------
|
||||
Disclaimers
|
||||
-----------
|
||||
|
||||
About the fork
|
||||
==============
|
||||
|
||||
`Distribute` is a fork of the `Setuptools` project.
|
||||
|
||||
Distribute is intended to replace Setuptools as the standard method
|
||||
for working with Python module distributions.
|
||||
|
||||
The fork has two goals:
|
||||
|
||||
- Providing a backward compatible version to replace Setuptools
|
||||
and make all distributions that depend on Setuptools work as
|
||||
before, but with less bugs and behaviorial issues.
|
||||
|
||||
This work is done in the 0.6.x series.
|
||||
|
||||
Starting with version 0.6.2, Distribute supports Python 3.
|
||||
Installing and using distribute for Python 3 code works exactly
|
||||
the same as for Python 2 code, but Distribute also helps you to support
|
||||
Python 2 and Python 3 from the same source code by letting you run 2to3
|
||||
on the code as a part of the build process, by setting the keyword parameter
|
||||
``use_2to3`` to True. See http://packages.python.org/distribute for more
|
||||
information.
|
||||
|
||||
- Refactoring the code, and releasing it in several distributions.
|
||||
This work is being done in the 0.7.x series but not yet released.
|
||||
|
||||
The roadmap is still evolving, and the page that is up-to-date is
|
||||
located at : `http://packages.python.org/distribute/roadmap`.
|
||||
|
||||
If you install `Distribute` and want to switch back for any reason to
|
||||
`Setuptools`, get to the `Uninstallation instructions`_ section.
|
||||
|
||||
More documentation
|
||||
==================
|
||||
|
||||
You can get more information in the Sphinx-based documentation, located
|
||||
at http://packages.python.org/distribute. This documentation includes the old
|
||||
Setuptools documentation that is slowly replaced, and brand new content.
|
||||
|
||||
About the installation process
|
||||
==============================
|
||||
|
||||
The `Distribute` installer modifies your installation by de-activating an
|
||||
existing installation of `Setuptools` in a bootstrap process. This process
|
||||
has been tested in various installation schemes and contexts but in case of a
|
||||
bug during this process your Python installation might be left in a broken
|
||||
state. Since all modified files and directories are copied before the
|
||||
installation starts, you will be able to get back to a normal state by reading
|
||||
the instructions in the `Uninstallation instructions`_ section.
|
||||
|
||||
In any case, it is recommended to save you `site-packages` directory before
|
||||
you start the installation of `Distribute`.
|
||||
|
||||
-------------------------
|
||||
Installation Instructions
|
||||
-------------------------
|
||||
|
||||
Distribute is only released as a source distribution.
|
||||
|
||||
It can be installed using pip, and can be done so with the source tarball,
|
||||
or by using the ``distribute_setup.py`` script provided online.
|
||||
|
||||
``distribute_setup.py`` is the simplest and preferred way on all systems.
|
||||
|
||||
distribute_setup.py
|
||||
===================
|
||||
|
||||
Download
|
||||
`distribute_setup.py <http://python-distribute.org/distribute_setup.py>`_
|
||||
and execute it, using the Python interpreter of your choice.
|
||||
|
||||
If your shell has the ``curl`` program you can do::
|
||||
|
||||
$ curl -O http://python-distribute.org/distribute_setup.py
|
||||
$ python distribute_setup.py
|
||||
|
||||
Notice this file is also provided in the source release.
|
||||
|
||||
pip
|
||||
===
|
||||
|
||||
Run easy_install or pip::
|
||||
|
||||
$ pip install distribute
|
||||
|
||||
Source installation
|
||||
===================
|
||||
|
||||
Download the source tarball, uncompress it, then run the install command::
|
||||
|
||||
$ curl -O http://pypi.python.org/packages/source/d/distribute/distribute-0.6.36.tar.gz
|
||||
$ tar -xzvf distribute-0.6.36.tar.gz
|
||||
$ cd distribute-0.6.36
|
||||
$ python setup.py install
|
||||
|
||||
---------------------------
|
||||
Uninstallation Instructions
|
||||
---------------------------
|
||||
|
||||
Like other distutils-based distributions, Distribute doesn't provide an
|
||||
uninstaller yet. It's all done manually! We are all waiting for PEP 376
|
||||
support in Python.
|
||||
|
||||
Distribute is installed in three steps:
|
||||
|
||||
1. it gets out of the way an existing installation of Setuptools
|
||||
2. it installs a `fake` setuptools installation
|
||||
3. it installs distribute
|
||||
|
||||
Distribute can be removed like this:
|
||||
|
||||
- remove the ``distribute*.egg`` file located in your site-packages directory
|
||||
- remove the ``setuptools.pth`` file located in you site-packages directory
|
||||
- remove the easy_install script located in you ``sys.prefix/bin`` directory
|
||||
- remove the ``setuptools*.egg`` directory located in your site-packages directory,
|
||||
if any.
|
||||
|
||||
If you want to get back to setuptools:
|
||||
|
||||
- reinstall setuptools using its instruction.
|
||||
|
||||
Lastly:
|
||||
|
||||
- remove the *.OLD.* directory located in your site-packages directory if any,
|
||||
**once you have checked everything was working correctly again**.
|
||||
|
||||
-------------------------
|
||||
Quick help for developers
|
||||
-------------------------
|
||||
|
||||
To create an egg which is compatible with Distribute, use the same
|
||||
practice as with Setuptools, e.g.::
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
setup(...
|
||||
)
|
||||
|
||||
To use `pkg_resources` to access data files in the egg, you should
|
||||
require the Setuptools distribution explicitly::
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
setup(...
|
||||
install_requires=['setuptools']
|
||||
)
|
||||
|
||||
Only if you need Distribute-specific functionality should you depend
|
||||
on it explicitly. In this case, replace the Setuptools dependency::
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
setup(...
|
||||
install_requires=['distribute']
|
||||
)
|
||||
|
||||
-----------
|
||||
Install FAQ
|
||||
-----------
|
||||
|
||||
- **Why is Distribute wrapping my Setuptools installation?**
|
||||
|
||||
Since Distribute is a fork, and since it provides the same package
|
||||
and modules, it renames the existing Setuptools egg and inserts a
|
||||
new one which merely wraps the Distribute code. This way, full
|
||||
backwards compatibility is kept for packages which rely on the
|
||||
Setuptools modules.
|
||||
|
||||
At the same time, packages can meet their dependency on Setuptools
|
||||
without actually installing it (which would disable Distribute).
|
||||
|
||||
- **How does Distribute interact with virtualenv?**
|
||||
|
||||
Everytime you create a virtualenv it will install setuptools by default.
|
||||
You either need to re-install Distribute in it right after or pass the
|
||||
``--distribute`` option when creating it.
|
||||
|
||||
Once installed, your virtualenv will use Distribute transparently.
|
||||
|
||||
Although, if you have Setuptools installed in your system-wide Python,
|
||||
and if the virtualenv you are in was generated without the `--no-site-packages`
|
||||
option, the Distribute installation will stop.
|
||||
|
||||
You need in this case to build a virtualenv with the `--no-site-packages`
|
||||
option or to install `Distribute` globally.
|
||||
|
||||
- **How does Distribute interacts with zc.buildout?**
|
||||
|
||||
You can use Distribute in your zc.buildout, with the --distribute option,
|
||||
starting at zc.buildout 1.4.2::
|
||||
|
||||
$ python bootstrap.py --distribute
|
||||
|
||||
For previous zc.buildout versions, *the only thing* you need to do
|
||||
is use the bootstrap at `http://python-distribute.org/bootstrap.py`. Run
|
||||
that bootstrap and ``bin/buildout`` (and all other buildout-generated
|
||||
scripts) will transparently use distribute instead of setuptools. You do
|
||||
not need a specific buildout release.
|
||||
|
||||
A shared eggs directory is no problem (since 0.6.6): the setuptools egg is
|
||||
left in place unmodified. So other buildouts that do not yet use the new
|
||||
bootstrap continue to work just fine. And there is no need to list
|
||||
``distribute`` somewhere in your eggs: using the bootstrap is enough.
|
||||
|
||||
The source code for the bootstrap script is located at
|
||||
`http://bitbucket.org/tarek/buildout-distribute`.
|
||||
|
||||
|
||||
|
||||
-----------------------------
|
||||
Feedback and getting involved
|
||||
-----------------------------
|
||||
|
||||
- Mailing list: http://mail.python.org/mailman/listinfo/distutils-sig
|
||||
- Issue tracker: http://bitbucket.org/tarek/distribute/issues/
|
||||
- Code Repository: http://bitbucket.org/tarek/distribute
|
||||
|
||||
=======
|
||||
CHANGES
|
||||
=======
|
||||
|
||||
------
|
||||
0.6.36
|
||||
------
|
||||
|
||||
* Pull Request #35: In `Buildout `issue 64`_
|
||||
<https://github.com/buildout/buildout/issues/64>`_, it was reported that
|
||||
under Python 3, installation of distutils scripts could attempt to copy
|
||||
the ``__pycache__`` directory as a file, causing an error, apparently only
|
||||
under Windows. Easy_install now skips all directories when processing
|
||||
metadata scripts.
|
||||
|
||||
------
|
||||
0.6.35
|
||||
------
|
||||
|
||||
Note this release is backward-incompatible with distribute 0.6.23-0.6.34 in
|
||||
how it parses version numbers.
|
||||
|
||||
* `Issue #278`_: Restored compatibility with distribute 0.6.22 and setuptools
|
||||
0.6. Updated the documentation to match more closely with the version
|
||||
parsing as intended in setuptools 0.6.
|
||||
|
||||
------
|
||||
0.6.34
|
||||
------
|
||||
|
||||
* `Issue #341`_: 0.6.33 fails to build under Python 2.4.
|
||||
|
||||
------
|
||||
0.6.33
|
||||
------
|
||||
|
||||
* Fix 2 errors with Jython 2.5.
|
||||
* Fix 1 failure with Jython 2.5 and 2.7.
|
||||
* Disable workaround for Jython scripts on Linux systems.
|
||||
* `Issue #336`_: `setup.py` no longer masks failure exit code when tests fail.
|
||||
* Fix issue in pkg_resources where try/except around a platform-dependent
|
||||
import would trigger hook load failures on Mercurial. See pull request 32
|
||||
for details.
|
||||
* `Issue #341`_: Fix a ResourceWarning.
|
||||
|
||||
------
|
||||
0.6.32
|
||||
------
|
||||
|
||||
* Fix test suite with Python 2.6.
|
||||
* Fix some DeprecationWarnings and ResourceWarnings.
|
||||
* `Issue #335`_: Backed out `setup_requires` superceding installed requirements
|
||||
until regression can be addressed.
|
||||
|
||||
------
|
||||
0.6.31
|
||||
------
|
||||
|
||||
* `Issue #303`_: Make sure the manifest only ever contains UTF-8 in Python 3.
|
||||
* `Issue #329`_: Properly close files created by tests for compatibility with
|
||||
Jython.
|
||||
* Work around Jython bugs `#1980 <http://bugs.jython.org/issue1980>`_ and
|
||||
`#1981 <http://bugs.jython.org/issue1981>`_.
|
||||
* `Issue #334`_: Provide workaround for packages that reference `sys.__stdout__`
|
||||
such as numpy does. This change should address
|
||||
`virtualenv #359 <https://github.com/pypa/virtualenv/issues/359>`_ as long
|
||||
as the system encoding is UTF-8 or the IO encoding is specified in the
|
||||
environment, i.e.::
|
||||
|
||||
PYTHONIOENCODING=utf8 pip install numpy
|
||||
|
||||
* Fix for encoding issue when installing from Windows executable on Python 3.
|
||||
* `Issue #323`_: Allow `setup_requires` requirements to supercede installed
|
||||
requirements. Added some new keyword arguments to existing pkg_resources
|
||||
methods. Also had to updated how __path__ is handled for namespace packages
|
||||
to ensure that when a new egg distribution containing a namespace package is
|
||||
placed on sys.path, the entries in __path__ are found in the same order they
|
||||
would have been in had that egg been on the path when pkg_resources was
|
||||
first imported.
|
||||
|
||||
------
|
||||
0.6.30
|
||||
------
|
||||
|
||||
* `Issue #328`_: Clean up temporary directories in distribute_setup.py.
|
||||
* Fix fatal bug in distribute_setup.py.
|
||||
|
||||
------
|
||||
0.6.29
|
||||
------
|
||||
|
||||
* Pull Request #14: Honor file permissions in zip files.
|
||||
* `Issue #327`_: Merged pull request #24 to fix a dependency problem with pip.
|
||||
* Merged pull request #23 to fix https://github.com/pypa/virtualenv/issues/301.
|
||||
* If Sphinx is installed, the `upload_docs` command now runs `build_sphinx`
|
||||
to produce uploadable documentation.
|
||||
* `Issue #326`_: `upload_docs` provided mangled auth credentials under Python 3.
|
||||
* `Issue #320`_: Fix check for "createable" in distribute_setup.py.
|
||||
* `Issue #305`_: Remove a warning that was triggered during normal operations.
|
||||
* `Issue #311`_: Print metadata in UTF-8 independent of platform.
|
||||
* `Issue #303`_: Read manifest file with UTF-8 encoding under Python 3.
|
||||
* `Issue #301`_: Allow to run tests of namespace packages when using 2to3.
|
||||
* `Issue #304`_: Prevent import loop in site.py under Python 3.3.
|
||||
* `Issue #283`_: Reenable scanning of `*.pyc` / `*.pyo` files on Python 3.3.
|
||||
* `Issue #299`_: The develop command didn't work on Python 3, when using 2to3,
|
||||
as the egg link would go to the Python 2 source. Linking to the 2to3'd code
|
||||
in build/lib makes it work, although you will have to rebuild the module
|
||||
before testing it.
|
||||
* `Issue #306`_: Even if 2to3 is used, we build in-place under Python 2.
|
||||
* `Issue #307`_: Prints the full path when .svn/entries is broken.
|
||||
* `Issue #313`_: Support for sdist subcommands (Python 2.7)
|
||||
* `Issue #314`_: test_local_index() would fail an OS X.
|
||||
* `Issue #310`_: Non-ascii characters in a namespace __init__.py causes errors.
|
||||
* `Issue #218`_: Improved documentation on behavior of `package_data` and
|
||||
`include_package_data`. Files indicated by `package_data` are now included
|
||||
in the manifest.
|
||||
* `distribute_setup.py` now allows a `--download-base` argument for retrieving
|
||||
distribute from a specified location.
|
||||
|
||||
------
|
||||
0.6.28
|
||||
------
|
||||
|
||||
* `Issue #294`_: setup.py can now be invoked from any directory.
|
||||
* Scripts are now installed honoring the umask.
|
||||
* Added support for .dist-info directories.
|
||||
* `Issue #283`_: Fix and disable scanning of `*.pyc` / `*.pyo` files on
|
||||
Python 3.3.
|
||||
|
||||
------
|
||||
0.6.27
|
||||
------
|
||||
|
||||
* Support current snapshots of CPython 3.3.
|
||||
* Distribute now recognizes README.rst as a standard, default readme file.
|
||||
* Exclude 'encodings' modules when removing modules from sys.modules.
|
||||
Workaround for #285.
|
||||
* `Issue #231`_: Don't fiddle with system python when used with buildout
|
||||
(bootstrap.py)
|
||||
|
||||
------
|
||||
0.6.26
|
||||
------
|
||||
|
||||
* `Issue #183`_: Symlinked files are now extracted from source distributions.
|
||||
* `Issue #227`_: Easy_install fetch parameters are now passed during the
|
||||
installation of a source distribution; now fulfillment of setup_requires
|
||||
dependencies will honor the parameters passed to easy_install.
|
||||
|
||||
------
|
||||
0.6.25
|
||||
------
|
||||
|
||||
* `Issue #258`_: Workaround a cache issue
|
||||
* `Issue #260`_: distribute_setup.py now accepts the --user parameter for
|
||||
Python 2.6 and later.
|
||||
* `Issue #262`_: package_index.open_with_auth no longer throws LookupError
|
||||
on Python 3.
|
||||
* `Issue #269`_: AttributeError when an exception occurs reading Manifest.in
|
||||
on late releases of Python.
|
||||
* `Issue #272`_: Prevent TypeError when namespace package names are unicode
|
||||
and single-install-externally-managed is used. Also fixes PIP `issue
|
||||
449`_.
|
||||
* `Issue #273`_: Legacy script launchers now install with Python2/3 support.
|
||||
|
||||
------
|
||||
0.6.24
|
||||
------
|
||||
|
||||
* `Issue #249`_: Added options to exclude 2to3 fixers
|
||||
|
||||
------
|
||||
0.6.23
|
||||
------
|
||||
|
||||
* `Issue #244`_: Fixed a test
|
||||
* `Issue #243`_: Fixed a test
|
||||
* `Issue #239`_: Fixed a test
|
||||
* `Issue #240`_: Fixed a test
|
||||
* `Issue #241`_: Fixed a test
|
||||
* `Issue #237`_: Fixed a test
|
||||
* `Issue #238`_: easy_install now uses 64bit executable wrappers on 64bit Python
|
||||
* `Issue #208`_: Fixed parsed_versions, it now honors post-releases as noted in the documentation
|
||||
* `Issue #207`_: Windows cli and gui wrappers pass CTRL-C to child python process
|
||||
* `Issue #227`_: easy_install now passes its arguments to setup.py bdist_egg
|
||||
* `Issue #225`_: Fixed a NameError on Python 2.5, 2.4
|
||||
|
||||
------
|
||||
0.6.21
|
||||
------
|
||||
|
||||
* `Issue #225`_: FIxed a regression on py2.4
|
||||
|
||||
------
|
||||
0.6.20
|
||||
------
|
||||
|
||||
* `Issue #135`_: Include url in warning when processing URLs in package_index.
|
||||
* `Issue #212`_: Fix issue where easy_instal fails on Python 3 on windows installer.
|
||||
* `Issue #213`_: Fix typo in documentation.
|
||||
|
||||
------
|
||||
0.6.19
|
||||
------
|
||||
|
||||
* `Issue 206`_: AttributeError: 'HTTPMessage' object has no attribute 'getheaders'
|
||||
|
||||
------
|
||||
0.6.18
|
||||
------
|
||||
|
||||
* `Issue 210`_: Fixed a regression introduced by `Issue 204`_ fix.
|
||||
|
||||
------
|
||||
0.6.17
|
||||
------
|
||||
|
||||
* Support 'DISTRIBUTE_DISABLE_VERSIONED_EASY_INSTALL_SCRIPT' environment
|
||||
variable to allow to disable installation of easy_install-${version} script.
|
||||
* Support Python >=3.1.4 and >=3.2.1.
|
||||
* `Issue 204`_: Don't try to import the parent of a namespace package in
|
||||
declare_namespace
|
||||
* `Issue 196`_: Tolerate responses with multiple Content-Length headers
|
||||
* `Issue 205`_: Sandboxing doesn't preserve working_set. Leads to setup_requires
|
||||
problems.
|
||||
|
||||
------
|
||||
0.6.16
|
||||
------
|
||||
|
||||
* Builds sdist gztar even on Windows (avoiding `Issue 193`_).
|
||||
* `Issue 192`_: Fixed metadata omitted on Windows when package_dir
|
||||
specified with forward-slash.
|
||||
* `Issue 195`_: Cython build support.
|
||||
* `Issue 200`_: Issues with recognizing 64-bit packages on Windows.
|
||||
|
||||
------
|
||||
0.6.15
|
||||
------
|
||||
|
||||
* Fixed typo in bdist_egg
|
||||
* Several issues under Python 3 has been solved.
|
||||
* `Issue 146`_: Fixed missing DLL files after easy_install of windows exe package.
|
||||
|
||||
------
|
||||
0.6.14
|
||||
------
|
||||
|
||||
* `Issue 170`_: Fixed unittest failure. Thanks to Toshio.
|
||||
* `Issue 171`_: Fixed race condition in unittests cause deadlocks in test suite.
|
||||
* `Issue 143`_: Fixed a lookup issue with easy_install.
|
||||
Thanks to David and Zooko.
|
||||
* `Issue 174`_: Fixed the edit mode when its used with setuptools itself
|
||||
|
||||
------
|
||||
0.6.13
|
||||
------
|
||||
|
||||
* `Issue 160`_: 2.7 gives ValueError("Invalid IPv6 URL")
|
||||
* `Issue 150`_: Fixed using ~/.local even in a --no-site-packages virtualenv
|
||||
* `Issue 163`_: scan index links before external links, and don't use the md5 when
|
||||
comparing two distributions
|
||||
|
||||
------
|
||||
0.6.12
|
||||
------
|
||||
|
||||
* `Issue 149`_: Fixed various failures on 2.3/2.4
|
||||
|
||||
------
|
||||
0.6.11
|
||||
------
|
||||
|
||||
* Found another case of SandboxViolation - fixed
|
||||
* `Issue 15`_ and 48: Introduced a socket timeout of 15 seconds on url openings
|
||||
* Added indexsidebar.html into MANIFEST.in
|
||||
* `Issue 108`_: Fixed TypeError with Python3.1
|
||||
* `Issue 121`_: Fixed --help install command trying to actually install.
|
||||
* `Issue 112`_: Added an os.makedirs so that Tarek's solution will work.
|
||||
* `Issue 133`_: Added --no-find-links to easy_install
|
||||
* Added easy_install --user
|
||||
* `Issue 100`_: Fixed develop --user not taking '.' in PYTHONPATH into account
|
||||
* `Issue 134`_: removed spurious UserWarnings. Patch by VanLindberg
|
||||
* `Issue 138`_: cant_write_to_target error when setup_requires is used.
|
||||
* `Issue 147`_: respect the sys.dont_write_bytecode flag
|
||||
|
||||
------
|
||||
0.6.10
|
||||
------
|
||||
|
||||
* Reverted change made for the DistributionNotFound exception because
|
||||
zc.buildout uses the exception message to get the name of the
|
||||
distribution.
|
||||
|
||||
-----
|
||||
0.6.9
|
||||
-----
|
||||
|
||||
* `Issue 90`_: unknown setuptools version can be added in the working set
|
||||
* `Issue 87`_: setupt.py doesn't try to convert distribute_setup.py anymore
|
||||
Initial Patch by arfrever.
|
||||
* `Issue 89`_: added a side bar with a download link to the doc.
|
||||
* `Issue 86`_: fixed missing sentence in pkg_resources doc.
|
||||
* Added a nicer error message when a DistributionNotFound is raised.
|
||||
* `Issue 80`_: test_develop now works with Python 3.1
|
||||
* `Issue 93`_: upload_docs now works if there is an empty sub-directory.
|
||||
* `Issue 70`_: exec bit on non-exec files
|
||||
* `Issue 99`_: now the standalone easy_install command doesn't uses a
|
||||
"setup.cfg" if any exists in the working directory. It will use it
|
||||
only if triggered by ``install_requires`` from a setup.py call
|
||||
(install, develop, etc).
|
||||
* `Issue 101`_: Allowing ``os.devnull`` in Sandbox
|
||||
* `Issue 92`_: Fixed the "no eggs" found error with MacPort
|
||||
(platform.mac_ver() fails)
|
||||
* `Issue 103`_: test_get_script_header_jython_workaround not run
|
||||
anymore under py3 with C or POSIX local. Contributed by Arfrever.
|
||||
* `Issue 104`_: remvoved the assertion when the installation fails,
|
||||
with a nicer message for the end user.
|
||||
* `Issue 100`_: making sure there's no SandboxViolation when
|
||||
the setup script patches setuptools.
|
||||
|
||||
-----
|
||||
0.6.8
|
||||
-----
|
||||
|
||||
* Added "check_packages" in dist. (added in Setuptools 0.6c11)
|
||||
* Fixed the DONT_PATCH_SETUPTOOLS state.
|
||||
|
||||
-----
|
||||
0.6.7
|
||||
-----
|
||||
|
||||
* `Issue 58`_: Added --user support to the develop command
|
||||
* `Issue 11`_: Generated scripts now wrap their call to the script entry point
|
||||
in the standard "if name == 'main'"
|
||||
* Added the 'DONT_PATCH_SETUPTOOLS' environment variable, so virtualenv
|
||||
can drive an installation that doesn't patch a global setuptools.
|
||||
* Reviewed unladen-swallow specific change from
|
||||
http://code.google.com/p/unladen-swallow/source/detail?spec=svn875&r=719
|
||||
and determined that it no longer applies. Distribute should work fine with
|
||||
Unladen Swallow 2009Q3.
|
||||
* `Issue 21`_: Allow PackageIndex.open_url to gracefully handle all cases of a
|
||||
httplib.HTTPException instead of just InvalidURL and BadStatusLine.
|
||||
* Removed virtual-python.py from this distribution and updated documentation
|
||||
to point to the actively maintained virtualenv instead.
|
||||
* `Issue 64`_: use_setuptools no longer rebuilds the distribute egg every
|
||||
time it is run
|
||||
* use_setuptools now properly respects the requested version
|
||||
* use_setuptools will no longer try to import a distribute egg for the
|
||||
wrong Python version
|
||||
* `Issue 74`_: no_fake should be True by default.
|
||||
* `Issue 72`_: avoid a bootstrapping issue with easy_install -U
|
||||
|
||||
-----
|
||||
0.6.6
|
||||
-----
|
||||
|
||||
* Unified the bootstrap file so it works on both py2.x and py3k without 2to3
|
||||
(patch by Holger Krekel)
|
||||
|
||||
-----
|
||||
0.6.5
|
||||
-----
|
||||
|
||||
* `Issue 65`_: cli.exe and gui.exe are now generated at build time,
|
||||
depending on the platform in use.
|
||||
|
||||
* `Issue 67`_: Fixed doc typo (PEP 381/382)
|
||||
|
||||
* Distribute no longer shadows setuptools if we require a 0.7-series
|
||||
setuptools. And an error is raised when installing a 0.7 setuptools with
|
||||
distribute.
|
||||
|
||||
* When run from within buildout, no attempt is made to modify an existing
|
||||
setuptools egg, whether in a shared egg directory or a system setuptools.
|
||||
|
||||
* Fixed a hole in sandboxing allowing builtin file to write outside of
|
||||
the sandbox.
|
||||
|
||||
-----
|
||||
0.6.4
|
||||
-----
|
||||
|
||||
* Added the generation of `distribute_setup_3k.py` during the release.
|
||||
This closes `issue #52`_.
|
||||
|
||||
* Added an upload_docs command to easily upload project documentation to
|
||||
PyPI's http://packages.python.org. This close `issue #56`_.
|
||||
|
||||
* Fixed a bootstrap bug on the use_setuptools() API.
|
||||
|
||||
-----
|
||||
0.6.3
|
||||
-----
|
||||
|
||||
setuptools
|
||||
==========
|
||||
|
||||
* Fixed a bunch of calls to file() that caused crashes on Python 3.
|
||||
|
||||
bootstrapping
|
||||
=============
|
||||
|
||||
* Fixed a bug in sorting that caused bootstrap to fail on Python 3.
|
||||
|
||||
-----
|
||||
0.6.2
|
||||
-----
|
||||
|
||||
setuptools
|
||||
==========
|
||||
|
||||
* Added Python 3 support; see docs/python3.txt.
|
||||
This closes http://bugs.python.org/setuptools/issue39.
|
||||
|
||||
* Added option to run 2to3 automatically when installing on Python 3.
|
||||
This closes `issue #31`_.
|
||||
|
||||
* Fixed invalid usage of requirement.parse, that broke develop -d.
|
||||
This closes http://bugs.python.org/setuptools/issue44.
|
||||
|
||||
* Fixed script launcher for 64-bit Windows.
|
||||
This closes http://bugs.python.org/setuptools/issue2.
|
||||
|
||||
* KeyError when compiling extensions.
|
||||
This closes http://bugs.python.org/setuptools/issue41.
|
||||
|
||||
bootstrapping
|
||||
=============
|
||||
|
||||
* Fixed bootstrap not working on Windows. This closes `issue #49`_.
|
||||
|
||||
* Fixed 2.6 dependencies. This closes `issue #50`_.
|
||||
|
||||
* Make sure setuptools is patched when running through easy_install
|
||||
This closes http://bugs.python.org/setuptools/issue40.
|
||||
|
||||
-----
|
||||
0.6.1
|
||||
-----
|
||||
|
||||
setuptools
|
||||
==========
|
||||
|
||||
* package_index.urlopen now catches BadStatusLine and malformed url errors.
|
||||
This closes `issue #16`_ and `issue #18`_.
|
||||
|
||||
* zip_ok is now False by default. This closes
|
||||
http://bugs.python.org/setuptools/issue33.
|
||||
|
||||
* Fixed invalid URL error catching. http://bugs.python.org/setuptools/issue20.
|
||||
|
||||
* Fixed invalid bootstraping with easy_install installation (`issue #40`_).
|
||||
Thanks to Florian Schulze for the help.
|
||||
|
||||
* Removed buildout/bootstrap.py. A new repository will create a specific
|
||||
bootstrap.py script.
|
||||
|
||||
|
||||
bootstrapping
|
||||
=============
|
||||
|
||||
* The boostrap process leave setuptools alone if detected in the system
|
||||
and --root or --prefix is provided, but is not in the same location.
|
||||
This closes `issue #10`_.
|
||||
|
||||
---
|
||||
0.6
|
||||
---
|
||||
|
||||
setuptools
|
||||
==========
|
||||
|
||||
* Packages required at build time where not fully present at install time.
|
||||
This closes `issue #12`_.
|
||||
|
||||
* Protected against failures in tarfile extraction. This closes `issue #10`_.
|
||||
|
||||
* Made Jython api_tests.txt doctest compatible. This closes `issue #7`_.
|
||||
|
||||
* sandbox.py replaced builtin type file with builtin function open. This
|
||||
closes `issue #6`_.
|
||||
|
||||
* Immediately close all file handles. This closes `issue #3`_.
|
||||
|
||||
* Added compatibility with Subversion 1.6. This references `issue #1`_.
|
||||
|
||||
pkg_resources
|
||||
=============
|
||||
|
||||
* Avoid a call to /usr/bin/sw_vers on OSX and use the official platform API
|
||||
instead. Based on a patch from ronaldoussoren. This closes `issue #5`_.
|
||||
|
||||
* Fixed a SandboxViolation for mkdir that could occur in certain cases.
|
||||
This closes `issue #13`_.
|
||||
|
||||
* Allow to find_on_path on systems with tight permissions to fail gracefully.
|
||||
This closes `issue #9`_.
|
||||
|
||||
* Corrected inconsistency between documentation and code of add_entry.
|
||||
This closes `issue #8`_.
|
||||
|
||||
* Immediately close all file handles. This closes `issue #3`_.
|
||||
|
||||
easy_install
|
||||
============
|
||||
|
||||
* Immediately close all file handles. This closes `issue #3`_.
|
||||
|
||||
|
||||
.. _`Issue #135`: http://bitbucket.org/tarek/distribute/issue/135
|
||||
.. _`Issue #183`: http://bitbucket.org/tarek/distribute/issue/183
|
||||
.. _`Issue #207`: http://bitbucket.org/tarek/distribute/issue/207
|
||||
.. _`Issue #208`: http://bitbucket.org/tarek/distribute/issue/208
|
||||
.. _`Issue #212`: http://bitbucket.org/tarek/distribute/issue/212
|
||||
.. _`Issue #213`: http://bitbucket.org/tarek/distribute/issue/213
|
||||
.. _`Issue #218`: http://bitbucket.org/tarek/distribute/issue/218
|
||||
.. _`Issue #225`: http://bitbucket.org/tarek/distribute/issue/225
|
||||
.. _`Issue #227`: http://bitbucket.org/tarek/distribute/issue/227
|
||||
.. _`Issue #231`: http://bitbucket.org/tarek/distribute/issue/231
|
||||
.. _`Issue #237`: http://bitbucket.org/tarek/distribute/issue/237
|
||||
.. _`Issue #238`: http://bitbucket.org/tarek/distribute/issue/238
|
||||
.. _`Issue #239`: http://bitbucket.org/tarek/distribute/issue/239
|
||||
.. _`Issue #240`: http://bitbucket.org/tarek/distribute/issue/240
|
||||
.. _`Issue #241`: http://bitbucket.org/tarek/distribute/issue/241
|
||||
.. _`Issue #243`: http://bitbucket.org/tarek/distribute/issue/243
|
||||
.. _`Issue #244`: http://bitbucket.org/tarek/distribute/issue/244
|
||||
.. _`Issue #249`: http://bitbucket.org/tarek/distribute/issue/249
|
||||
.. _`Issue #258`: http://bitbucket.org/tarek/distribute/issue/258
|
||||
.. _`Issue #260`: http://bitbucket.org/tarek/distribute/issue/260
|
||||
.. _`Issue #262`: http://bitbucket.org/tarek/distribute/issue/262
|
||||
.. _`Issue #269`: http://bitbucket.org/tarek/distribute/issue/269
|
||||
.. _`Issue #272`: http://bitbucket.org/tarek/distribute/issue/272
|
||||
.. _`Issue #273`: http://bitbucket.org/tarek/distribute/issue/273
|
||||
.. _`Issue #278`: http://bitbucket.org/tarek/distribute/issue/278
|
||||
.. _`Issue #283`: http://bitbucket.org/tarek/distribute/issue/283
|
||||
.. _`Issue #294`: http://bitbucket.org/tarek/distribute/issue/294
|
||||
.. _`Issue #299`: http://bitbucket.org/tarek/distribute/issue/299
|
||||
.. _`Issue #301`: http://bitbucket.org/tarek/distribute/issue/301
|
||||
.. _`Issue #303`: http://bitbucket.org/tarek/distribute/issue/303
|
||||
.. _`Issue #304`: http://bitbucket.org/tarek/distribute/issue/304
|
||||
.. _`Issue #305`: http://bitbucket.org/tarek/distribute/issue/305
|
||||
.. _`Issue #306`: http://bitbucket.org/tarek/distribute/issue/306
|
||||
.. _`Issue #307`: http://bitbucket.org/tarek/distribute/issue/307
|
||||
.. _`Issue #310`: http://bitbucket.org/tarek/distribute/issue/310
|
||||
.. _`Issue #311`: http://bitbucket.org/tarek/distribute/issue/311
|
||||
.. _`Issue #313`: http://bitbucket.org/tarek/distribute/issue/313
|
||||
.. _`Issue #314`: http://bitbucket.org/tarek/distribute/issue/314
|
||||
.. _`Issue #320`: http://bitbucket.org/tarek/distribute/issue/320
|
||||
.. _`Issue #323`: http://bitbucket.org/tarek/distribute/issue/323
|
||||
.. _`Issue #326`: http://bitbucket.org/tarek/distribute/issue/326
|
||||
.. _`Issue #327`: http://bitbucket.org/tarek/distribute/issue/327
|
||||
.. _`Issue #328`: http://bitbucket.org/tarek/distribute/issue/328
|
||||
.. _`Issue #329`: http://bitbucket.org/tarek/distribute/issue/329
|
||||
.. _`Issue #334`: http://bitbucket.org/tarek/distribute/issue/334
|
||||
.. _`Issue #335`: http://bitbucket.org/tarek/distribute/issue/335
|
||||
.. _`Issue #336`: http://bitbucket.org/tarek/distribute/issue/336
|
||||
.. _`Issue #341`: http://bitbucket.org/tarek/distribute/issue/341
|
||||
.. _`Issue 100`: http://bitbucket.org/tarek/distribute/issue/100
|
||||
.. _`Issue 101`: http://bitbucket.org/tarek/distribute/issue/101
|
||||
.. _`Issue 103`: http://bitbucket.org/tarek/distribute/issue/103
|
||||
.. _`Issue 104`: http://bitbucket.org/tarek/distribute/issue/104
|
||||
.. _`Issue 108`: http://bitbucket.org/tarek/distribute/issue/108
|
||||
.. _`Issue 11`: http://bitbucket.org/tarek/distribute/issue/11
|
||||
.. _`Issue 112`: http://bitbucket.org/tarek/distribute/issue/112
|
||||
.. _`Issue 121`: http://bitbucket.org/tarek/distribute/issue/121
|
||||
.. _`Issue 133`: http://bitbucket.org/tarek/distribute/issue/133
|
||||
.. _`Issue 134`: http://bitbucket.org/tarek/distribute/issue/134
|
||||
.. _`Issue 138`: http://bitbucket.org/tarek/distribute/issue/138
|
||||
.. _`Issue 143`: http://bitbucket.org/tarek/distribute/issue/143
|
||||
.. _`Issue 146`: http://bitbucket.org/tarek/distribute/issue/146
|
||||
.. _`Issue 147`: http://bitbucket.org/tarek/distribute/issue/147
|
||||
.. _`Issue 149`: http://bitbucket.org/tarek/distribute/issue/149
|
||||
.. _`Issue 15`: http://bitbucket.org/tarek/distribute/issue/15
|
||||
.. _`Issue 150`: http://bitbucket.org/tarek/distribute/issue/150
|
||||
.. _`Issue 160`: http://bitbucket.org/tarek/distribute/issue/160
|
||||
.. _`Issue 163`: http://bitbucket.org/tarek/distribute/issue/163
|
||||
.. _`Issue 170`: http://bitbucket.org/tarek/distribute/issue/170
|
||||
.. _`Issue 171`: http://bitbucket.org/tarek/distribute/issue/171
|
||||
.. _`Issue 174`: http://bitbucket.org/tarek/distribute/issue/174
|
||||
.. _`Issue 192`: http://bitbucket.org/tarek/distribute/issue/192
|
||||
.. _`Issue 193`: http://bitbucket.org/tarek/distribute/issue/193
|
||||
.. _`Issue 195`: http://bitbucket.org/tarek/distribute/issue/195
|
||||
.. _`Issue 196`: http://bitbucket.org/tarek/distribute/issue/196
|
||||
.. _`Issue 200`: http://bitbucket.org/tarek/distribute/issue/200
|
||||
.. _`Issue 204`: http://bitbucket.org/tarek/distribute/issue/204
|
||||
.. _`Issue 205`: http://bitbucket.org/tarek/distribute/issue/205
|
||||
.. _`Issue 206`: http://bitbucket.org/tarek/distribute/issue/206
|
||||
.. _`Issue 21`: http://bitbucket.org/tarek/distribute/issue/21
|
||||
.. _`Issue 210`: http://bitbucket.org/tarek/distribute/issue/210
|
||||
.. _`Issue 58`: http://bitbucket.org/tarek/distribute/issue/58
|
||||
.. _`Issue 64`: http://bitbucket.org/tarek/distribute/issue/64
|
||||
.. _`Issue 65`: http://bitbucket.org/tarek/distribute/issue/65
|
||||
.. _`Issue 67`: http://bitbucket.org/tarek/distribute/issue/67
|
||||
.. _`Issue 70`: http://bitbucket.org/tarek/distribute/issue/70
|
||||
.. _`Issue 72`: http://bitbucket.org/tarek/distribute/issue/72
|
||||
.. _`Issue 74`: http://bitbucket.org/tarek/distribute/issue/74
|
||||
.. _`Issue 80`: http://bitbucket.org/tarek/distribute/issue/80
|
||||
.. _`Issue 86`: http://bitbucket.org/tarek/distribute/issue/86
|
||||
.. _`Issue 87`: http://bitbucket.org/tarek/distribute/issue/87
|
||||
.. _`Issue 89`: http://bitbucket.org/tarek/distribute/issue/89
|
||||
.. _`Issue 90`: http://bitbucket.org/tarek/distribute/issue/90
|
||||
.. _`Issue 92`: http://bitbucket.org/tarek/distribute/issue/92
|
||||
.. _`Issue 93`: http://bitbucket.org/tarek/distribute/issue/93
|
||||
.. _`Issue 99`: http://bitbucket.org/tarek/distribute/issue/99
|
||||
.. _`issue
|
||||
449`: http://bitbucket.org/tarek/distribute/issue/449
|
||||
.. _`issue #1`: http://bitbucket.org/tarek/distribute/issue/1
|
||||
.. _`issue #10`: http://bitbucket.org/tarek/distribute/issue/10
|
||||
.. _`issue #12`: http://bitbucket.org/tarek/distribute/issue/12
|
||||
.. _`issue #13`: http://bitbucket.org/tarek/distribute/issue/13
|
||||
.. _`issue #16`: http://bitbucket.org/tarek/distribute/issue/16
|
||||
.. _`issue #18`: http://bitbucket.org/tarek/distribute/issue/18
|
||||
.. _`issue #3`: http://bitbucket.org/tarek/distribute/issue/3
|
||||
.. _`issue #31`: http://bitbucket.org/tarek/distribute/issue/31
|
||||
.. _`issue #40`: http://bitbucket.org/tarek/distribute/issue/40
|
||||
.. _`issue #49`: http://bitbucket.org/tarek/distribute/issue/49
|
||||
.. _`issue #5`: http://bitbucket.org/tarek/distribute/issue/5
|
||||
.. _`issue #50`: http://bitbucket.org/tarek/distribute/issue/50
|
||||
.. _`issue #52`: http://bitbucket.org/tarek/distribute/issue/52
|
||||
.. _`issue #56`: http://bitbucket.org/tarek/distribute/issue/56
|
||||
.. _`issue #6`: http://bitbucket.org/tarek/distribute/issue/6
|
||||
.. _`issue #7`: http://bitbucket.org/tarek/distribute/issue/7
|
||||
.. _`issue #8`: http://bitbucket.org/tarek/distribute/issue/8
|
||||
.. _`issue #9`: http://bitbucket.org/tarek/distribute/issue/9
|
||||
.. _`issue 64`: http://bitbucket.org/tarek/distribute/issue/64
|
||||
|
||||
|
||||
Keywords: CPAN PyPI distutils eggs package management
|
||||
Platform: UNKNOWN
|
||||
Classifier: Development Status :: 5 - Production/Stable
|
||||
Classifier: Intended Audience :: Developers
|
||||
Classifier: License :: OSI Approved :: Python Software Foundation License
|
||||
Classifier: License :: OSI Approved :: Zope Public License
|
||||
Classifier: Operating System :: OS Independent
|
||||
Classifier: Programming Language :: Python :: 2.4
|
||||
Classifier: Programming Language :: Python :: 2.5
|
||||
Classifier: Programming Language :: Python :: 2.6
|
||||
Classifier: Programming Language :: Python :: 2.7
|
||||
Classifier: Programming Language :: Python :: 3
|
||||
Classifier: Programming Language :: Python :: 3.1
|
||||
Classifier: Programming Language :: Python :: 3.2
|
||||
Classifier: Programming Language :: Python :: 3.3
|
||||
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
||||
Classifier: Topic :: System :: Archiving :: Packaging
|
||||
Classifier: Topic :: System :: Systems Administration
|
||||
Classifier: Topic :: Utilities
|
||||
Vendored
-228
@@ -1,228 +0,0 @@
|
||||
===============================
|
||||
Installing and Using Distribute
|
||||
===============================
|
||||
|
||||
.. contents:: **Table of Contents**
|
||||
|
||||
-----------
|
||||
Disclaimers
|
||||
-----------
|
||||
|
||||
About the fork
|
||||
==============
|
||||
|
||||
`Distribute` is a fork of the `Setuptools` project.
|
||||
|
||||
Distribute is intended to replace Setuptools as the standard method
|
||||
for working with Python module distributions.
|
||||
|
||||
The fork has two goals:
|
||||
|
||||
- Providing a backward compatible version to replace Setuptools
|
||||
and make all distributions that depend on Setuptools work as
|
||||
before, but with less bugs and behaviorial issues.
|
||||
|
||||
This work is done in the 0.6.x series.
|
||||
|
||||
Starting with version 0.6.2, Distribute supports Python 3.
|
||||
Installing and using distribute for Python 3 code works exactly
|
||||
the same as for Python 2 code, but Distribute also helps you to support
|
||||
Python 2 and Python 3 from the same source code by letting you run 2to3
|
||||
on the code as a part of the build process, by setting the keyword parameter
|
||||
``use_2to3`` to True. See http://packages.python.org/distribute for more
|
||||
information.
|
||||
|
||||
- Refactoring the code, and releasing it in several distributions.
|
||||
This work is being done in the 0.7.x series but not yet released.
|
||||
|
||||
The roadmap is still evolving, and the page that is up-to-date is
|
||||
located at : `http://packages.python.org/distribute/roadmap`.
|
||||
|
||||
If you install `Distribute` and want to switch back for any reason to
|
||||
`Setuptools`, get to the `Uninstallation instructions`_ section.
|
||||
|
||||
More documentation
|
||||
==================
|
||||
|
||||
You can get more information in the Sphinx-based documentation, located
|
||||
at http://packages.python.org/distribute. This documentation includes the old
|
||||
Setuptools documentation that is slowly replaced, and brand new content.
|
||||
|
||||
About the installation process
|
||||
==============================
|
||||
|
||||
The `Distribute` installer modifies your installation by de-activating an
|
||||
existing installation of `Setuptools` in a bootstrap process. This process
|
||||
has been tested in various installation schemes and contexts but in case of a
|
||||
bug during this process your Python installation might be left in a broken
|
||||
state. Since all modified files and directories are copied before the
|
||||
installation starts, you will be able to get back to a normal state by reading
|
||||
the instructions in the `Uninstallation instructions`_ section.
|
||||
|
||||
In any case, it is recommended to save you `site-packages` directory before
|
||||
you start the installation of `Distribute`.
|
||||
|
||||
-------------------------
|
||||
Installation Instructions
|
||||
-------------------------
|
||||
|
||||
Distribute is only released as a source distribution.
|
||||
|
||||
It can be installed using pip, and can be done so with the source tarball,
|
||||
or by using the ``distribute_setup.py`` script provided online.
|
||||
|
||||
``distribute_setup.py`` is the simplest and preferred way on all systems.
|
||||
|
||||
distribute_setup.py
|
||||
===================
|
||||
|
||||
Download
|
||||
`distribute_setup.py <http://python-distribute.org/distribute_setup.py>`_
|
||||
and execute it, using the Python interpreter of your choice.
|
||||
|
||||
If your shell has the ``curl`` program you can do::
|
||||
|
||||
$ curl -O http://python-distribute.org/distribute_setup.py
|
||||
$ python distribute_setup.py
|
||||
|
||||
Notice this file is also provided in the source release.
|
||||
|
||||
pip
|
||||
===
|
||||
|
||||
Run easy_install or pip::
|
||||
|
||||
$ pip install distribute
|
||||
|
||||
Source installation
|
||||
===================
|
||||
|
||||
Download the source tarball, uncompress it, then run the install command::
|
||||
|
||||
$ curl -O http://pypi.python.org/packages/source/d/distribute/distribute-0.6.36.tar.gz
|
||||
$ tar -xzvf distribute-0.6.36.tar.gz
|
||||
$ cd distribute-0.6.36
|
||||
$ python setup.py install
|
||||
|
||||
---------------------------
|
||||
Uninstallation Instructions
|
||||
---------------------------
|
||||
|
||||
Like other distutils-based distributions, Distribute doesn't provide an
|
||||
uninstaller yet. It's all done manually! We are all waiting for PEP 376
|
||||
support in Python.
|
||||
|
||||
Distribute is installed in three steps:
|
||||
|
||||
1. it gets out of the way an existing installation of Setuptools
|
||||
2. it installs a `fake` setuptools installation
|
||||
3. it installs distribute
|
||||
|
||||
Distribute can be removed like this:
|
||||
|
||||
- remove the ``distribute*.egg`` file located in your site-packages directory
|
||||
- remove the ``setuptools.pth`` file located in you site-packages directory
|
||||
- remove the easy_install script located in you ``sys.prefix/bin`` directory
|
||||
- remove the ``setuptools*.egg`` directory located in your site-packages directory,
|
||||
if any.
|
||||
|
||||
If you want to get back to setuptools:
|
||||
|
||||
- reinstall setuptools using its instruction.
|
||||
|
||||
Lastly:
|
||||
|
||||
- remove the *.OLD.* directory located in your site-packages directory if any,
|
||||
**once you have checked everything was working correctly again**.
|
||||
|
||||
-------------------------
|
||||
Quick help for developers
|
||||
-------------------------
|
||||
|
||||
To create an egg which is compatible with Distribute, use the same
|
||||
practice as with Setuptools, e.g.::
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
setup(...
|
||||
)
|
||||
|
||||
To use `pkg_resources` to access data files in the egg, you should
|
||||
require the Setuptools distribution explicitly::
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
setup(...
|
||||
install_requires=['setuptools']
|
||||
)
|
||||
|
||||
Only if you need Distribute-specific functionality should you depend
|
||||
on it explicitly. In this case, replace the Setuptools dependency::
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
setup(...
|
||||
install_requires=['distribute']
|
||||
)
|
||||
|
||||
-----------
|
||||
Install FAQ
|
||||
-----------
|
||||
|
||||
- **Why is Distribute wrapping my Setuptools installation?**
|
||||
|
||||
Since Distribute is a fork, and since it provides the same package
|
||||
and modules, it renames the existing Setuptools egg and inserts a
|
||||
new one which merely wraps the Distribute code. This way, full
|
||||
backwards compatibility is kept for packages which rely on the
|
||||
Setuptools modules.
|
||||
|
||||
At the same time, packages can meet their dependency on Setuptools
|
||||
without actually installing it (which would disable Distribute).
|
||||
|
||||
- **How does Distribute interact with virtualenv?**
|
||||
|
||||
Everytime you create a virtualenv it will install setuptools by default.
|
||||
You either need to re-install Distribute in it right after or pass the
|
||||
``--distribute`` option when creating it.
|
||||
|
||||
Once installed, your virtualenv will use Distribute transparently.
|
||||
|
||||
Although, if you have Setuptools installed in your system-wide Python,
|
||||
and if the virtualenv you are in was generated without the `--no-site-packages`
|
||||
option, the Distribute installation will stop.
|
||||
|
||||
You need in this case to build a virtualenv with the `--no-site-packages`
|
||||
option or to install `Distribute` globally.
|
||||
|
||||
- **How does Distribute interacts with zc.buildout?**
|
||||
|
||||
You can use Distribute in your zc.buildout, with the --distribute option,
|
||||
starting at zc.buildout 1.4.2::
|
||||
|
||||
$ python bootstrap.py --distribute
|
||||
|
||||
For previous zc.buildout versions, *the only thing* you need to do
|
||||
is use the bootstrap at `http://python-distribute.org/bootstrap.py`. Run
|
||||
that bootstrap and ``bin/buildout`` (and all other buildout-generated
|
||||
scripts) will transparently use distribute instead of setuptools. You do
|
||||
not need a specific buildout release.
|
||||
|
||||
A shared eggs directory is no problem (since 0.6.6): the setuptools egg is
|
||||
left in place unmodified. So other buildouts that do not yet use the new
|
||||
bootstrap continue to work just fine. And there is no need to list
|
||||
``distribute`` somewhere in your eggs: using the bootstrap is enough.
|
||||
|
||||
The source code for the bootstrap script is located at
|
||||
`http://bitbucket.org/tarek/buildout-distribute`.
|
||||
|
||||
|
||||
|
||||
-----------------------------
|
||||
Feedback and getting involved
|
||||
-----------------------------
|
||||
|
||||
- Mailing list: http://mail.python.org/mailman/listinfo/distutils-sig
|
||||
- Issue tracker: http://bitbucket.org/tarek/distribute/issues/
|
||||
- Code Repository: http://bitbucket.org/tarek/distribute
|
||||
|
||||
@@ -1,883 +0,0 @@
|
||||
Metadata-Version: 1.1
|
||||
Name: distribute
|
||||
Version: 0.6.36
|
||||
Summary: Easily download, build, install, upgrade, and uninstall Python packages
|
||||
Home-page: http://packages.python.org/distribute
|
||||
Author: The fellowship of the packaging
|
||||
Author-email: distutils-sig@python.org
|
||||
License: PSF or ZPL
|
||||
Description: ===============================
|
||||
Installing and Using Distribute
|
||||
===============================
|
||||
|
||||
.. contents:: **Table of Contents**
|
||||
|
||||
-----------
|
||||
Disclaimers
|
||||
-----------
|
||||
|
||||
About the fork
|
||||
==============
|
||||
|
||||
`Distribute` is a fork of the `Setuptools` project.
|
||||
|
||||
Distribute is intended to replace Setuptools as the standard method
|
||||
for working with Python module distributions.
|
||||
|
||||
The fork has two goals:
|
||||
|
||||
- Providing a backward compatible version to replace Setuptools
|
||||
and make all distributions that depend on Setuptools work as
|
||||
before, but with less bugs and behaviorial issues.
|
||||
|
||||
This work is done in the 0.6.x series.
|
||||
|
||||
Starting with version 0.6.2, Distribute supports Python 3.
|
||||
Installing and using distribute for Python 3 code works exactly
|
||||
the same as for Python 2 code, but Distribute also helps you to support
|
||||
Python 2 and Python 3 from the same source code by letting you run 2to3
|
||||
on the code as a part of the build process, by setting the keyword parameter
|
||||
``use_2to3`` to True. See http://packages.python.org/distribute for more
|
||||
information.
|
||||
|
||||
- Refactoring the code, and releasing it in several distributions.
|
||||
This work is being done in the 0.7.x series but not yet released.
|
||||
|
||||
The roadmap is still evolving, and the page that is up-to-date is
|
||||
located at : `http://packages.python.org/distribute/roadmap`.
|
||||
|
||||
If you install `Distribute` and want to switch back for any reason to
|
||||
`Setuptools`, get to the `Uninstallation instructions`_ section.
|
||||
|
||||
More documentation
|
||||
==================
|
||||
|
||||
You can get more information in the Sphinx-based documentation, located
|
||||
at http://packages.python.org/distribute. This documentation includes the old
|
||||
Setuptools documentation that is slowly replaced, and brand new content.
|
||||
|
||||
About the installation process
|
||||
==============================
|
||||
|
||||
The `Distribute` installer modifies your installation by de-activating an
|
||||
existing installation of `Setuptools` in a bootstrap process. This process
|
||||
has been tested in various installation schemes and contexts but in case of a
|
||||
bug during this process your Python installation might be left in a broken
|
||||
state. Since all modified files and directories are copied before the
|
||||
installation starts, you will be able to get back to a normal state by reading
|
||||
the instructions in the `Uninstallation instructions`_ section.
|
||||
|
||||
In any case, it is recommended to save you `site-packages` directory before
|
||||
you start the installation of `Distribute`.
|
||||
|
||||
-------------------------
|
||||
Installation Instructions
|
||||
-------------------------
|
||||
|
||||
Distribute is only released as a source distribution.
|
||||
|
||||
It can be installed using pip, and can be done so with the source tarball,
|
||||
or by using the ``distribute_setup.py`` script provided online.
|
||||
|
||||
``distribute_setup.py`` is the simplest and preferred way on all systems.
|
||||
|
||||
distribute_setup.py
|
||||
===================
|
||||
|
||||
Download
|
||||
`distribute_setup.py <http://python-distribute.org/distribute_setup.py>`_
|
||||
and execute it, using the Python interpreter of your choice.
|
||||
|
||||
If your shell has the ``curl`` program you can do::
|
||||
|
||||
$ curl -O http://python-distribute.org/distribute_setup.py
|
||||
$ python distribute_setup.py
|
||||
|
||||
Notice this file is also provided in the source release.
|
||||
|
||||
pip
|
||||
===
|
||||
|
||||
Run easy_install or pip::
|
||||
|
||||
$ pip install distribute
|
||||
|
||||
Source installation
|
||||
===================
|
||||
|
||||
Download the source tarball, uncompress it, then run the install command::
|
||||
|
||||
$ curl -O http://pypi.python.org/packages/source/d/distribute/distribute-0.6.36.tar.gz
|
||||
$ tar -xzvf distribute-0.6.36.tar.gz
|
||||
$ cd distribute-0.6.36
|
||||
$ python setup.py install
|
||||
|
||||
---------------------------
|
||||
Uninstallation Instructions
|
||||
---------------------------
|
||||
|
||||
Like other distutils-based distributions, Distribute doesn't provide an
|
||||
uninstaller yet. It's all done manually! We are all waiting for PEP 376
|
||||
support in Python.
|
||||
|
||||
Distribute is installed in three steps:
|
||||
|
||||
1. it gets out of the way an existing installation of Setuptools
|
||||
2. it installs a `fake` setuptools installation
|
||||
3. it installs distribute
|
||||
|
||||
Distribute can be removed like this:
|
||||
|
||||
- remove the ``distribute*.egg`` file located in your site-packages directory
|
||||
- remove the ``setuptools.pth`` file located in you site-packages directory
|
||||
- remove the easy_install script located in you ``sys.prefix/bin`` directory
|
||||
- remove the ``setuptools*.egg`` directory located in your site-packages directory,
|
||||
if any.
|
||||
|
||||
If you want to get back to setuptools:
|
||||
|
||||
- reinstall setuptools using its instruction.
|
||||
|
||||
Lastly:
|
||||
|
||||
- remove the *.OLD.* directory located in your site-packages directory if any,
|
||||
**once you have checked everything was working correctly again**.
|
||||
|
||||
-------------------------
|
||||
Quick help for developers
|
||||
-------------------------
|
||||
|
||||
To create an egg which is compatible with Distribute, use the same
|
||||
practice as with Setuptools, e.g.::
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
setup(...
|
||||
)
|
||||
|
||||
To use `pkg_resources` to access data files in the egg, you should
|
||||
require the Setuptools distribution explicitly::
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
setup(...
|
||||
install_requires=['setuptools']
|
||||
)
|
||||
|
||||
Only if you need Distribute-specific functionality should you depend
|
||||
on it explicitly. In this case, replace the Setuptools dependency::
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
setup(...
|
||||
install_requires=['distribute']
|
||||
)
|
||||
|
||||
-----------
|
||||
Install FAQ
|
||||
-----------
|
||||
|
||||
- **Why is Distribute wrapping my Setuptools installation?**
|
||||
|
||||
Since Distribute is a fork, and since it provides the same package
|
||||
and modules, it renames the existing Setuptools egg and inserts a
|
||||
new one which merely wraps the Distribute code. This way, full
|
||||
backwards compatibility is kept for packages which rely on the
|
||||
Setuptools modules.
|
||||
|
||||
At the same time, packages can meet their dependency on Setuptools
|
||||
without actually installing it (which would disable Distribute).
|
||||
|
||||
- **How does Distribute interact with virtualenv?**
|
||||
|
||||
Everytime you create a virtualenv it will install setuptools by default.
|
||||
You either need to re-install Distribute in it right after or pass the
|
||||
``--distribute`` option when creating it.
|
||||
|
||||
Once installed, your virtualenv will use Distribute transparently.
|
||||
|
||||
Although, if you have Setuptools installed in your system-wide Python,
|
||||
and if the virtualenv you are in was generated without the `--no-site-packages`
|
||||
option, the Distribute installation will stop.
|
||||
|
||||
You need in this case to build a virtualenv with the `--no-site-packages`
|
||||
option or to install `Distribute` globally.
|
||||
|
||||
- **How does Distribute interacts with zc.buildout?**
|
||||
|
||||
You can use Distribute in your zc.buildout, with the --distribute option,
|
||||
starting at zc.buildout 1.4.2::
|
||||
|
||||
$ python bootstrap.py --distribute
|
||||
|
||||
For previous zc.buildout versions, *the only thing* you need to do
|
||||
is use the bootstrap at `http://python-distribute.org/bootstrap.py`. Run
|
||||
that bootstrap and ``bin/buildout`` (and all other buildout-generated
|
||||
scripts) will transparently use distribute instead of setuptools. You do
|
||||
not need a specific buildout release.
|
||||
|
||||
A shared eggs directory is no problem (since 0.6.6): the setuptools egg is
|
||||
left in place unmodified. So other buildouts that do not yet use the new
|
||||
bootstrap continue to work just fine. And there is no need to list
|
||||
``distribute`` somewhere in your eggs: using the bootstrap is enough.
|
||||
|
||||
The source code for the bootstrap script is located at
|
||||
`http://bitbucket.org/tarek/buildout-distribute`.
|
||||
|
||||
|
||||
|
||||
-----------------------------
|
||||
Feedback and getting involved
|
||||
-----------------------------
|
||||
|
||||
- Mailing list: http://mail.python.org/mailman/listinfo/distutils-sig
|
||||
- Issue tracker: http://bitbucket.org/tarek/distribute/issues/
|
||||
- Code Repository: http://bitbucket.org/tarek/distribute
|
||||
|
||||
=======
|
||||
CHANGES
|
||||
=======
|
||||
|
||||
------
|
||||
0.6.36
|
||||
------
|
||||
|
||||
* Pull Request #35: In `Buildout `issue 64`_
|
||||
<https://github.com/buildout/buildout/issues/64>`_, it was reported that
|
||||
under Python 3, installation of distutils scripts could attempt to copy
|
||||
the ``__pycache__`` directory as a file, causing an error, apparently only
|
||||
under Windows. Easy_install now skips all directories when processing
|
||||
metadata scripts.
|
||||
|
||||
------
|
||||
0.6.35
|
||||
------
|
||||
|
||||
Note this release is backward-incompatible with distribute 0.6.23-0.6.34 in
|
||||
how it parses version numbers.
|
||||
|
||||
* `Issue #278`_: Restored compatibility with distribute 0.6.22 and setuptools
|
||||
0.6. Updated the documentation to match more closely with the version
|
||||
parsing as intended in setuptools 0.6.
|
||||
|
||||
------
|
||||
0.6.34
|
||||
------
|
||||
|
||||
* `Issue #341`_: 0.6.33 fails to build under Python 2.4.
|
||||
|
||||
------
|
||||
0.6.33
|
||||
------
|
||||
|
||||
* Fix 2 errors with Jython 2.5.
|
||||
* Fix 1 failure with Jython 2.5 and 2.7.
|
||||
* Disable workaround for Jython scripts on Linux systems.
|
||||
* `Issue #336`_: `setup.py` no longer masks failure exit code when tests fail.
|
||||
* Fix issue in pkg_resources where try/except around a platform-dependent
|
||||
import would trigger hook load failures on Mercurial. See pull request 32
|
||||
for details.
|
||||
* `Issue #341`_: Fix a ResourceWarning.
|
||||
|
||||
------
|
||||
0.6.32
|
||||
------
|
||||
|
||||
* Fix test suite with Python 2.6.
|
||||
* Fix some DeprecationWarnings and ResourceWarnings.
|
||||
* `Issue #335`_: Backed out `setup_requires` superceding installed requirements
|
||||
until regression can be addressed.
|
||||
|
||||
------
|
||||
0.6.31
|
||||
------
|
||||
|
||||
* `Issue #303`_: Make sure the manifest only ever contains UTF-8 in Python 3.
|
||||
* `Issue #329`_: Properly close files created by tests for compatibility with
|
||||
Jython.
|
||||
* Work around Jython bugs `#1980 <http://bugs.jython.org/issue1980>`_ and
|
||||
`#1981 <http://bugs.jython.org/issue1981>`_.
|
||||
* `Issue #334`_: Provide workaround for packages that reference `sys.__stdout__`
|
||||
such as numpy does. This change should address
|
||||
`virtualenv #359 <https://github.com/pypa/virtualenv/issues/359>`_ as long
|
||||
as the system encoding is UTF-8 or the IO encoding is specified in the
|
||||
environment, i.e.::
|
||||
|
||||
PYTHONIOENCODING=utf8 pip install numpy
|
||||
|
||||
* Fix for encoding issue when installing from Windows executable on Python 3.
|
||||
* `Issue #323`_: Allow `setup_requires` requirements to supercede installed
|
||||
requirements. Added some new keyword arguments to existing pkg_resources
|
||||
methods. Also had to updated how __path__ is handled for namespace packages
|
||||
to ensure that when a new egg distribution containing a namespace package is
|
||||
placed on sys.path, the entries in __path__ are found in the same order they
|
||||
would have been in had that egg been on the path when pkg_resources was
|
||||
first imported.
|
||||
|
||||
------
|
||||
0.6.30
|
||||
------
|
||||
|
||||
* `Issue #328`_: Clean up temporary directories in distribute_setup.py.
|
||||
* Fix fatal bug in distribute_setup.py.
|
||||
|
||||
------
|
||||
0.6.29
|
||||
------
|
||||
|
||||
* Pull Request #14: Honor file permissions in zip files.
|
||||
* `Issue #327`_: Merged pull request #24 to fix a dependency problem with pip.
|
||||
* Merged pull request #23 to fix https://github.com/pypa/virtualenv/issues/301.
|
||||
* If Sphinx is installed, the `upload_docs` command now runs `build_sphinx`
|
||||
to produce uploadable documentation.
|
||||
* `Issue #326`_: `upload_docs` provided mangled auth credentials under Python 3.
|
||||
* `Issue #320`_: Fix check for "createable" in distribute_setup.py.
|
||||
* `Issue #305`_: Remove a warning that was triggered during normal operations.
|
||||
* `Issue #311`_: Print metadata in UTF-8 independent of platform.
|
||||
* `Issue #303`_: Read manifest file with UTF-8 encoding under Python 3.
|
||||
* `Issue #301`_: Allow to run tests of namespace packages when using 2to3.
|
||||
* `Issue #304`_: Prevent import loop in site.py under Python 3.3.
|
||||
* `Issue #283`_: Reenable scanning of `*.pyc` / `*.pyo` files on Python 3.3.
|
||||
* `Issue #299`_: The develop command didn't work on Python 3, when using 2to3,
|
||||
as the egg link would go to the Python 2 source. Linking to the 2to3'd code
|
||||
in build/lib makes it work, although you will have to rebuild the module
|
||||
before testing it.
|
||||
* `Issue #306`_: Even if 2to3 is used, we build in-place under Python 2.
|
||||
* `Issue #307`_: Prints the full path when .svn/entries is broken.
|
||||
* `Issue #313`_: Support for sdist subcommands (Python 2.7)
|
||||
* `Issue #314`_: test_local_index() would fail an OS X.
|
||||
* `Issue #310`_: Non-ascii characters in a namespace __init__.py causes errors.
|
||||
* `Issue #218`_: Improved documentation on behavior of `package_data` and
|
||||
`include_package_data`. Files indicated by `package_data` are now included
|
||||
in the manifest.
|
||||
* `distribute_setup.py` now allows a `--download-base` argument for retrieving
|
||||
distribute from a specified location.
|
||||
|
||||
------
|
||||
0.6.28
|
||||
------
|
||||
|
||||
* `Issue #294`_: setup.py can now be invoked from any directory.
|
||||
* Scripts are now installed honoring the umask.
|
||||
* Added support for .dist-info directories.
|
||||
* `Issue #283`_: Fix and disable scanning of `*.pyc` / `*.pyo` files on
|
||||
Python 3.3.
|
||||
|
||||
------
|
||||
0.6.27
|
||||
------
|
||||
|
||||
* Support current snapshots of CPython 3.3.
|
||||
* Distribute now recognizes README.rst as a standard, default readme file.
|
||||
* Exclude 'encodings' modules when removing modules from sys.modules.
|
||||
Workaround for #285.
|
||||
* `Issue #231`_: Don't fiddle with system python when used with buildout
|
||||
(bootstrap.py)
|
||||
|
||||
------
|
||||
0.6.26
|
||||
------
|
||||
|
||||
* `Issue #183`_: Symlinked files are now extracted from source distributions.
|
||||
* `Issue #227`_: Easy_install fetch parameters are now passed during the
|
||||
installation of a source distribution; now fulfillment of setup_requires
|
||||
dependencies will honor the parameters passed to easy_install.
|
||||
|
||||
------
|
||||
0.6.25
|
||||
------
|
||||
|
||||
* `Issue #258`_: Workaround a cache issue
|
||||
* `Issue #260`_: distribute_setup.py now accepts the --user parameter for
|
||||
Python 2.6 and later.
|
||||
* `Issue #262`_: package_index.open_with_auth no longer throws LookupError
|
||||
on Python 3.
|
||||
* `Issue #269`_: AttributeError when an exception occurs reading Manifest.in
|
||||
on late releases of Python.
|
||||
* `Issue #272`_: Prevent TypeError when namespace package names are unicode
|
||||
and single-install-externally-managed is used. Also fixes PIP `issue
|
||||
449`_.
|
||||
* `Issue #273`_: Legacy script launchers now install with Python2/3 support.
|
||||
|
||||
------
|
||||
0.6.24
|
||||
------
|
||||
|
||||
* `Issue #249`_: Added options to exclude 2to3 fixers
|
||||
|
||||
------
|
||||
0.6.23
|
||||
------
|
||||
|
||||
* `Issue #244`_: Fixed a test
|
||||
* `Issue #243`_: Fixed a test
|
||||
* `Issue #239`_: Fixed a test
|
||||
* `Issue #240`_: Fixed a test
|
||||
* `Issue #241`_: Fixed a test
|
||||
* `Issue #237`_: Fixed a test
|
||||
* `Issue #238`_: easy_install now uses 64bit executable wrappers on 64bit Python
|
||||
* `Issue #208`_: Fixed parsed_versions, it now honors post-releases as noted in the documentation
|
||||
* `Issue #207`_: Windows cli and gui wrappers pass CTRL-C to child python process
|
||||
* `Issue #227`_: easy_install now passes its arguments to setup.py bdist_egg
|
||||
* `Issue #225`_: Fixed a NameError on Python 2.5, 2.4
|
||||
|
||||
------
|
||||
0.6.21
|
||||
------
|
||||
|
||||
* `Issue #225`_: FIxed a regression on py2.4
|
||||
|
||||
------
|
||||
0.6.20
|
||||
------
|
||||
|
||||
* `Issue #135`_: Include url in warning when processing URLs in package_index.
|
||||
* `Issue #212`_: Fix issue where easy_instal fails on Python 3 on windows installer.
|
||||
* `Issue #213`_: Fix typo in documentation.
|
||||
|
||||
------
|
||||
0.6.19
|
||||
------
|
||||
|
||||
* `Issue 206`_: AttributeError: 'HTTPMessage' object has no attribute 'getheaders'
|
||||
|
||||
------
|
||||
0.6.18
|
||||
------
|
||||
|
||||
* `Issue 210`_: Fixed a regression introduced by `Issue 204`_ fix.
|
||||
|
||||
------
|
||||
0.6.17
|
||||
------
|
||||
|
||||
* Support 'DISTRIBUTE_DISABLE_VERSIONED_EASY_INSTALL_SCRIPT' environment
|
||||
variable to allow to disable installation of easy_install-${version} script.
|
||||
* Support Python >=3.1.4 and >=3.2.1.
|
||||
* `Issue 204`_: Don't try to import the parent of a namespace package in
|
||||
declare_namespace
|
||||
* `Issue 196`_: Tolerate responses with multiple Content-Length headers
|
||||
* `Issue 205`_: Sandboxing doesn't preserve working_set. Leads to setup_requires
|
||||
problems.
|
||||
|
||||
------
|
||||
0.6.16
|
||||
------
|
||||
|
||||
* Builds sdist gztar even on Windows (avoiding `Issue 193`_).
|
||||
* `Issue 192`_: Fixed metadata omitted on Windows when package_dir
|
||||
specified with forward-slash.
|
||||
* `Issue 195`_: Cython build support.
|
||||
* `Issue 200`_: Issues with recognizing 64-bit packages on Windows.
|
||||
|
||||
------
|
||||
0.6.15
|
||||
------
|
||||
|
||||
* Fixed typo in bdist_egg
|
||||
* Several issues under Python 3 has been solved.
|
||||
* `Issue 146`_: Fixed missing DLL files after easy_install of windows exe package.
|
||||
|
||||
------
|
||||
0.6.14
|
||||
------
|
||||
|
||||
* `Issue 170`_: Fixed unittest failure. Thanks to Toshio.
|
||||
* `Issue 171`_: Fixed race condition in unittests cause deadlocks in test suite.
|
||||
* `Issue 143`_: Fixed a lookup issue with easy_install.
|
||||
Thanks to David and Zooko.
|
||||
* `Issue 174`_: Fixed the edit mode when its used with setuptools itself
|
||||
|
||||
------
|
||||
0.6.13
|
||||
------
|
||||
|
||||
* `Issue 160`_: 2.7 gives ValueError("Invalid IPv6 URL")
|
||||
* `Issue 150`_: Fixed using ~/.local even in a --no-site-packages virtualenv
|
||||
* `Issue 163`_: scan index links before external links, and don't use the md5 when
|
||||
comparing two distributions
|
||||
|
||||
------
|
||||
0.6.12
|
||||
------
|
||||
|
||||
* `Issue 149`_: Fixed various failures on 2.3/2.4
|
||||
|
||||
------
|
||||
0.6.11
|
||||
------
|
||||
|
||||
* Found another case of SandboxViolation - fixed
|
||||
* `Issue 15`_ and 48: Introduced a socket timeout of 15 seconds on url openings
|
||||
* Added indexsidebar.html into MANIFEST.in
|
||||
* `Issue 108`_: Fixed TypeError with Python3.1
|
||||
* `Issue 121`_: Fixed --help install command trying to actually install.
|
||||
* `Issue 112`_: Added an os.makedirs so that Tarek's solution will work.
|
||||
* `Issue 133`_: Added --no-find-links to easy_install
|
||||
* Added easy_install --user
|
||||
* `Issue 100`_: Fixed develop --user not taking '.' in PYTHONPATH into account
|
||||
* `Issue 134`_: removed spurious UserWarnings. Patch by VanLindberg
|
||||
* `Issue 138`_: cant_write_to_target error when setup_requires is used.
|
||||
* `Issue 147`_: respect the sys.dont_write_bytecode flag
|
||||
|
||||
------
|
||||
0.6.10
|
||||
------
|
||||
|
||||
* Reverted change made for the DistributionNotFound exception because
|
||||
zc.buildout uses the exception message to get the name of the
|
||||
distribution.
|
||||
|
||||
-----
|
||||
0.6.9
|
||||
-----
|
||||
|
||||
* `Issue 90`_: unknown setuptools version can be added in the working set
|
||||
* `Issue 87`_: setupt.py doesn't try to convert distribute_setup.py anymore
|
||||
Initial Patch by arfrever.
|
||||
* `Issue 89`_: added a side bar with a download link to the doc.
|
||||
* `Issue 86`_: fixed missing sentence in pkg_resources doc.
|
||||
* Added a nicer error message when a DistributionNotFound is raised.
|
||||
* `Issue 80`_: test_develop now works with Python 3.1
|
||||
* `Issue 93`_: upload_docs now works if there is an empty sub-directory.
|
||||
* `Issue 70`_: exec bit on non-exec files
|
||||
* `Issue 99`_: now the standalone easy_install command doesn't uses a
|
||||
"setup.cfg" if any exists in the working directory. It will use it
|
||||
only if triggered by ``install_requires`` from a setup.py call
|
||||
(install, develop, etc).
|
||||
* `Issue 101`_: Allowing ``os.devnull`` in Sandbox
|
||||
* `Issue 92`_: Fixed the "no eggs" found error with MacPort
|
||||
(platform.mac_ver() fails)
|
||||
* `Issue 103`_: test_get_script_header_jython_workaround not run
|
||||
anymore under py3 with C or POSIX local. Contributed by Arfrever.
|
||||
* `Issue 104`_: remvoved the assertion when the installation fails,
|
||||
with a nicer message for the end user.
|
||||
* `Issue 100`_: making sure there's no SandboxViolation when
|
||||
the setup script patches setuptools.
|
||||
|
||||
-----
|
||||
0.6.8
|
||||
-----
|
||||
|
||||
* Added "check_packages" in dist. (added in Setuptools 0.6c11)
|
||||
* Fixed the DONT_PATCH_SETUPTOOLS state.
|
||||
|
||||
-----
|
||||
0.6.7
|
||||
-----
|
||||
|
||||
* `Issue 58`_: Added --user support to the develop command
|
||||
* `Issue 11`_: Generated scripts now wrap their call to the script entry point
|
||||
in the standard "if name == 'main'"
|
||||
* Added the 'DONT_PATCH_SETUPTOOLS' environment variable, so virtualenv
|
||||
can drive an installation that doesn't patch a global setuptools.
|
||||
* Reviewed unladen-swallow specific change from
|
||||
http://code.google.com/p/unladen-swallow/source/detail?spec=svn875&r=719
|
||||
and determined that it no longer applies. Distribute should work fine with
|
||||
Unladen Swallow 2009Q3.
|
||||
* `Issue 21`_: Allow PackageIndex.open_url to gracefully handle all cases of a
|
||||
httplib.HTTPException instead of just InvalidURL and BadStatusLine.
|
||||
* Removed virtual-python.py from this distribution and updated documentation
|
||||
to point to the actively maintained virtualenv instead.
|
||||
* `Issue 64`_: use_setuptools no longer rebuilds the distribute egg every
|
||||
time it is run
|
||||
* use_setuptools now properly respects the requested version
|
||||
* use_setuptools will no longer try to import a distribute egg for the
|
||||
wrong Python version
|
||||
* `Issue 74`_: no_fake should be True by default.
|
||||
* `Issue 72`_: avoid a bootstrapping issue with easy_install -U
|
||||
|
||||
-----
|
||||
0.6.6
|
||||
-----
|
||||
|
||||
* Unified the bootstrap file so it works on both py2.x and py3k without 2to3
|
||||
(patch by Holger Krekel)
|
||||
|
||||
-----
|
||||
0.6.5
|
||||
-----
|
||||
|
||||
* `Issue 65`_: cli.exe and gui.exe are now generated at build time,
|
||||
depending on the platform in use.
|
||||
|
||||
* `Issue 67`_: Fixed doc typo (PEP 381/382)
|
||||
|
||||
* Distribute no longer shadows setuptools if we require a 0.7-series
|
||||
setuptools. And an error is raised when installing a 0.7 setuptools with
|
||||
distribute.
|
||||
|
||||
* When run from within buildout, no attempt is made to modify an existing
|
||||
setuptools egg, whether in a shared egg directory or a system setuptools.
|
||||
|
||||
* Fixed a hole in sandboxing allowing builtin file to write outside of
|
||||
the sandbox.
|
||||
|
||||
-----
|
||||
0.6.4
|
||||
-----
|
||||
|
||||
* Added the generation of `distribute_setup_3k.py` during the release.
|
||||
This closes `issue #52`_.
|
||||
|
||||
* Added an upload_docs command to easily upload project documentation to
|
||||
PyPI's http://packages.python.org. This close `issue #56`_.
|
||||
|
||||
* Fixed a bootstrap bug on the use_setuptools() API.
|
||||
|
||||
-----
|
||||
0.6.3
|
||||
-----
|
||||
|
||||
setuptools
|
||||
==========
|
||||
|
||||
* Fixed a bunch of calls to file() that caused crashes on Python 3.
|
||||
|
||||
bootstrapping
|
||||
=============
|
||||
|
||||
* Fixed a bug in sorting that caused bootstrap to fail on Python 3.
|
||||
|
||||
-----
|
||||
0.6.2
|
||||
-----
|
||||
|
||||
setuptools
|
||||
==========
|
||||
|
||||
* Added Python 3 support; see docs/python3.txt.
|
||||
This closes http://bugs.python.org/setuptools/issue39.
|
||||
|
||||
* Added option to run 2to3 automatically when installing on Python 3.
|
||||
This closes `issue #31`_.
|
||||
|
||||
* Fixed invalid usage of requirement.parse, that broke develop -d.
|
||||
This closes http://bugs.python.org/setuptools/issue44.
|
||||
|
||||
* Fixed script launcher for 64-bit Windows.
|
||||
This closes http://bugs.python.org/setuptools/issue2.
|
||||
|
||||
* KeyError when compiling extensions.
|
||||
This closes http://bugs.python.org/setuptools/issue41.
|
||||
|
||||
bootstrapping
|
||||
=============
|
||||
|
||||
* Fixed bootstrap not working on Windows. This closes `issue #49`_.
|
||||
|
||||
* Fixed 2.6 dependencies. This closes `issue #50`_.
|
||||
|
||||
* Make sure setuptools is patched when running through easy_install
|
||||
This closes http://bugs.python.org/setuptools/issue40.
|
||||
|
||||
-----
|
||||
0.6.1
|
||||
-----
|
||||
|
||||
setuptools
|
||||
==========
|
||||
|
||||
* package_index.urlopen now catches BadStatusLine and malformed url errors.
|
||||
This closes `issue #16`_ and `issue #18`_.
|
||||
|
||||
* zip_ok is now False by default. This closes
|
||||
http://bugs.python.org/setuptools/issue33.
|
||||
|
||||
* Fixed invalid URL error catching. http://bugs.python.org/setuptools/issue20.
|
||||
|
||||
* Fixed invalid bootstraping with easy_install installation (`issue #40`_).
|
||||
Thanks to Florian Schulze for the help.
|
||||
|
||||
* Removed buildout/bootstrap.py. A new repository will create a specific
|
||||
bootstrap.py script.
|
||||
|
||||
|
||||
bootstrapping
|
||||
=============
|
||||
|
||||
* The boostrap process leave setuptools alone if detected in the system
|
||||
and --root or --prefix is provided, but is not in the same location.
|
||||
This closes `issue #10`_.
|
||||
|
||||
---
|
||||
0.6
|
||||
---
|
||||
|
||||
setuptools
|
||||
==========
|
||||
|
||||
* Packages required at build time where not fully present at install time.
|
||||
This closes `issue #12`_.
|
||||
|
||||
* Protected against failures in tarfile extraction. This closes `issue #10`_.
|
||||
|
||||
* Made Jython api_tests.txt doctest compatible. This closes `issue #7`_.
|
||||
|
||||
* sandbox.py replaced builtin type file with builtin function open. This
|
||||
closes `issue #6`_.
|
||||
|
||||
* Immediately close all file handles. This closes `issue #3`_.
|
||||
|
||||
* Added compatibility with Subversion 1.6. This references `issue #1`_.
|
||||
|
||||
pkg_resources
|
||||
=============
|
||||
|
||||
* Avoid a call to /usr/bin/sw_vers on OSX and use the official platform API
|
||||
instead. Based on a patch from ronaldoussoren. This closes `issue #5`_.
|
||||
|
||||
* Fixed a SandboxViolation for mkdir that could occur in certain cases.
|
||||
This closes `issue #13`_.
|
||||
|
||||
* Allow to find_on_path on systems with tight permissions to fail gracefully.
|
||||
This closes `issue #9`_.
|
||||
|
||||
* Corrected inconsistency between documentation and code of add_entry.
|
||||
This closes `issue #8`_.
|
||||
|
||||
* Immediately close all file handles. This closes `issue #3`_.
|
||||
|
||||
easy_install
|
||||
============
|
||||
|
||||
* Immediately close all file handles. This closes `issue #3`_.
|
||||
|
||||
|
||||
.. _`Issue #135`: http://bitbucket.org/tarek/distribute/issue/135
|
||||
.. _`Issue #183`: http://bitbucket.org/tarek/distribute/issue/183
|
||||
.. _`Issue #207`: http://bitbucket.org/tarek/distribute/issue/207
|
||||
.. _`Issue #208`: http://bitbucket.org/tarek/distribute/issue/208
|
||||
.. _`Issue #212`: http://bitbucket.org/tarek/distribute/issue/212
|
||||
.. _`Issue #213`: http://bitbucket.org/tarek/distribute/issue/213
|
||||
.. _`Issue #218`: http://bitbucket.org/tarek/distribute/issue/218
|
||||
.. _`Issue #225`: http://bitbucket.org/tarek/distribute/issue/225
|
||||
.. _`Issue #227`: http://bitbucket.org/tarek/distribute/issue/227
|
||||
.. _`Issue #231`: http://bitbucket.org/tarek/distribute/issue/231
|
||||
.. _`Issue #237`: http://bitbucket.org/tarek/distribute/issue/237
|
||||
.. _`Issue #238`: http://bitbucket.org/tarek/distribute/issue/238
|
||||
.. _`Issue #239`: http://bitbucket.org/tarek/distribute/issue/239
|
||||
.. _`Issue #240`: http://bitbucket.org/tarek/distribute/issue/240
|
||||
.. _`Issue #241`: http://bitbucket.org/tarek/distribute/issue/241
|
||||
.. _`Issue #243`: http://bitbucket.org/tarek/distribute/issue/243
|
||||
.. _`Issue #244`: http://bitbucket.org/tarek/distribute/issue/244
|
||||
.. _`Issue #249`: http://bitbucket.org/tarek/distribute/issue/249
|
||||
.. _`Issue #258`: http://bitbucket.org/tarek/distribute/issue/258
|
||||
.. _`Issue #260`: http://bitbucket.org/tarek/distribute/issue/260
|
||||
.. _`Issue #262`: http://bitbucket.org/tarek/distribute/issue/262
|
||||
.. _`Issue #269`: http://bitbucket.org/tarek/distribute/issue/269
|
||||
.. _`Issue #272`: http://bitbucket.org/tarek/distribute/issue/272
|
||||
.. _`Issue #273`: http://bitbucket.org/tarek/distribute/issue/273
|
||||
.. _`Issue #278`: http://bitbucket.org/tarek/distribute/issue/278
|
||||
.. _`Issue #283`: http://bitbucket.org/tarek/distribute/issue/283
|
||||
.. _`Issue #294`: http://bitbucket.org/tarek/distribute/issue/294
|
||||
.. _`Issue #299`: http://bitbucket.org/tarek/distribute/issue/299
|
||||
.. _`Issue #301`: http://bitbucket.org/tarek/distribute/issue/301
|
||||
.. _`Issue #303`: http://bitbucket.org/tarek/distribute/issue/303
|
||||
.. _`Issue #304`: http://bitbucket.org/tarek/distribute/issue/304
|
||||
.. _`Issue #305`: http://bitbucket.org/tarek/distribute/issue/305
|
||||
.. _`Issue #306`: http://bitbucket.org/tarek/distribute/issue/306
|
||||
.. _`Issue #307`: http://bitbucket.org/tarek/distribute/issue/307
|
||||
.. _`Issue #310`: http://bitbucket.org/tarek/distribute/issue/310
|
||||
.. _`Issue #311`: http://bitbucket.org/tarek/distribute/issue/311
|
||||
.. _`Issue #313`: http://bitbucket.org/tarek/distribute/issue/313
|
||||
.. _`Issue #314`: http://bitbucket.org/tarek/distribute/issue/314
|
||||
.. _`Issue #320`: http://bitbucket.org/tarek/distribute/issue/320
|
||||
.. _`Issue #323`: http://bitbucket.org/tarek/distribute/issue/323
|
||||
.. _`Issue #326`: http://bitbucket.org/tarek/distribute/issue/326
|
||||
.. _`Issue #327`: http://bitbucket.org/tarek/distribute/issue/327
|
||||
.. _`Issue #328`: http://bitbucket.org/tarek/distribute/issue/328
|
||||
.. _`Issue #329`: http://bitbucket.org/tarek/distribute/issue/329
|
||||
.. _`Issue #334`: http://bitbucket.org/tarek/distribute/issue/334
|
||||
.. _`Issue #335`: http://bitbucket.org/tarek/distribute/issue/335
|
||||
.. _`Issue #336`: http://bitbucket.org/tarek/distribute/issue/336
|
||||
.. _`Issue #341`: http://bitbucket.org/tarek/distribute/issue/341
|
||||
.. _`Issue 100`: http://bitbucket.org/tarek/distribute/issue/100
|
||||
.. _`Issue 101`: http://bitbucket.org/tarek/distribute/issue/101
|
||||
.. _`Issue 103`: http://bitbucket.org/tarek/distribute/issue/103
|
||||
.. _`Issue 104`: http://bitbucket.org/tarek/distribute/issue/104
|
||||
.. _`Issue 108`: http://bitbucket.org/tarek/distribute/issue/108
|
||||
.. _`Issue 11`: http://bitbucket.org/tarek/distribute/issue/11
|
||||
.. _`Issue 112`: http://bitbucket.org/tarek/distribute/issue/112
|
||||
.. _`Issue 121`: http://bitbucket.org/tarek/distribute/issue/121
|
||||
.. _`Issue 133`: http://bitbucket.org/tarek/distribute/issue/133
|
||||
.. _`Issue 134`: http://bitbucket.org/tarek/distribute/issue/134
|
||||
.. _`Issue 138`: http://bitbucket.org/tarek/distribute/issue/138
|
||||
.. _`Issue 143`: http://bitbucket.org/tarek/distribute/issue/143
|
||||
.. _`Issue 146`: http://bitbucket.org/tarek/distribute/issue/146
|
||||
.. _`Issue 147`: http://bitbucket.org/tarek/distribute/issue/147
|
||||
.. _`Issue 149`: http://bitbucket.org/tarek/distribute/issue/149
|
||||
.. _`Issue 15`: http://bitbucket.org/tarek/distribute/issue/15
|
||||
.. _`Issue 150`: http://bitbucket.org/tarek/distribute/issue/150
|
||||
.. _`Issue 160`: http://bitbucket.org/tarek/distribute/issue/160
|
||||
.. _`Issue 163`: http://bitbucket.org/tarek/distribute/issue/163
|
||||
.. _`Issue 170`: http://bitbucket.org/tarek/distribute/issue/170
|
||||
.. _`Issue 171`: http://bitbucket.org/tarek/distribute/issue/171
|
||||
.. _`Issue 174`: http://bitbucket.org/tarek/distribute/issue/174
|
||||
.. _`Issue 192`: http://bitbucket.org/tarek/distribute/issue/192
|
||||
.. _`Issue 193`: http://bitbucket.org/tarek/distribute/issue/193
|
||||
.. _`Issue 195`: http://bitbucket.org/tarek/distribute/issue/195
|
||||
.. _`Issue 196`: http://bitbucket.org/tarek/distribute/issue/196
|
||||
.. _`Issue 200`: http://bitbucket.org/tarek/distribute/issue/200
|
||||
.. _`Issue 204`: http://bitbucket.org/tarek/distribute/issue/204
|
||||
.. _`Issue 205`: http://bitbucket.org/tarek/distribute/issue/205
|
||||
.. _`Issue 206`: http://bitbucket.org/tarek/distribute/issue/206
|
||||
.. _`Issue 21`: http://bitbucket.org/tarek/distribute/issue/21
|
||||
.. _`Issue 210`: http://bitbucket.org/tarek/distribute/issue/210
|
||||
.. _`Issue 58`: http://bitbucket.org/tarek/distribute/issue/58
|
||||
.. _`Issue 64`: http://bitbucket.org/tarek/distribute/issue/64
|
||||
.. _`Issue 65`: http://bitbucket.org/tarek/distribute/issue/65
|
||||
.. _`Issue 67`: http://bitbucket.org/tarek/distribute/issue/67
|
||||
.. _`Issue 70`: http://bitbucket.org/tarek/distribute/issue/70
|
||||
.. _`Issue 72`: http://bitbucket.org/tarek/distribute/issue/72
|
||||
.. _`Issue 74`: http://bitbucket.org/tarek/distribute/issue/74
|
||||
.. _`Issue 80`: http://bitbucket.org/tarek/distribute/issue/80
|
||||
.. _`Issue 86`: http://bitbucket.org/tarek/distribute/issue/86
|
||||
.. _`Issue 87`: http://bitbucket.org/tarek/distribute/issue/87
|
||||
.. _`Issue 89`: http://bitbucket.org/tarek/distribute/issue/89
|
||||
.. _`Issue 90`: http://bitbucket.org/tarek/distribute/issue/90
|
||||
.. _`Issue 92`: http://bitbucket.org/tarek/distribute/issue/92
|
||||
.. _`Issue 93`: http://bitbucket.org/tarek/distribute/issue/93
|
||||
.. _`Issue 99`: http://bitbucket.org/tarek/distribute/issue/99
|
||||
.. _`issue
|
||||
449`: http://bitbucket.org/tarek/distribute/issue/449
|
||||
.. _`issue #1`: http://bitbucket.org/tarek/distribute/issue/1
|
||||
.. _`issue #10`: http://bitbucket.org/tarek/distribute/issue/10
|
||||
.. _`issue #12`: http://bitbucket.org/tarek/distribute/issue/12
|
||||
.. _`issue #13`: http://bitbucket.org/tarek/distribute/issue/13
|
||||
.. _`issue #16`: http://bitbucket.org/tarek/distribute/issue/16
|
||||
.. _`issue #18`: http://bitbucket.org/tarek/distribute/issue/18
|
||||
.. _`issue #3`: http://bitbucket.org/tarek/distribute/issue/3
|
||||
.. _`issue #31`: http://bitbucket.org/tarek/distribute/issue/31
|
||||
.. _`issue #40`: http://bitbucket.org/tarek/distribute/issue/40
|
||||
.. _`issue #49`: http://bitbucket.org/tarek/distribute/issue/49
|
||||
.. _`issue #5`: http://bitbucket.org/tarek/distribute/issue/5
|
||||
.. _`issue #50`: http://bitbucket.org/tarek/distribute/issue/50
|
||||
.. _`issue #52`: http://bitbucket.org/tarek/distribute/issue/52
|
||||
.. _`issue #56`: http://bitbucket.org/tarek/distribute/issue/56
|
||||
.. _`issue #6`: http://bitbucket.org/tarek/distribute/issue/6
|
||||
.. _`issue #7`: http://bitbucket.org/tarek/distribute/issue/7
|
||||
.. _`issue #8`: http://bitbucket.org/tarek/distribute/issue/8
|
||||
.. _`issue #9`: http://bitbucket.org/tarek/distribute/issue/9
|
||||
.. _`issue 64`: http://bitbucket.org/tarek/distribute/issue/64
|
||||
|
||||
|
||||
Keywords: CPAN PyPI distutils eggs package management
|
||||
Platform: UNKNOWN
|
||||
Classifier: Development Status :: 5 - Production/Stable
|
||||
Classifier: Intended Audience :: Developers
|
||||
Classifier: License :: OSI Approved :: Python Software Foundation License
|
||||
Classifier: License :: OSI Approved :: Zope Public License
|
||||
Classifier: Operating System :: OS Independent
|
||||
Classifier: Programming Language :: Python :: 2.4
|
||||
Classifier: Programming Language :: Python :: 2.5
|
||||
Classifier: Programming Language :: Python :: 2.6
|
||||
Classifier: Programming Language :: Python :: 2.7
|
||||
Classifier: Programming Language :: Python :: 3
|
||||
Classifier: Programming Language :: Python :: 3.1
|
||||
Classifier: Programming Language :: Python :: 3.2
|
||||
Classifier: Programming Language :: Python :: 3.3
|
||||
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
||||
Classifier: Topic :: System :: Archiving :: Packaging
|
||||
Classifier: Topic :: System :: Systems Administration
|
||||
Classifier: Topic :: Utilities
|
||||
-546
@@ -1,546 +0,0 @@
|
||||
#!python
|
||||
"""Bootstrap distribute installation
|
||||
|
||||
If you want to use setuptools in your package's setup.py, just include this
|
||||
file in the same directory with it, and add this to the top of your setup.py::
|
||||
|
||||
from distribute_setup import use_setuptools
|
||||
use_setuptools()
|
||||
|
||||
If you want to require a specific version of setuptools, set a download
|
||||
mirror, or use an alternate download directory, you can do so by supplying
|
||||
the appropriate options to ``use_setuptools()``.
|
||||
|
||||
This file can also be run as a script to install or upgrade setuptools.
|
||||
"""
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import time
|
||||
import fnmatch
|
||||
import tempfile
|
||||
import tarfile
|
||||
import optparse
|
||||
|
||||
from distutils import log
|
||||
|
||||
try:
|
||||
from site import USER_SITE
|
||||
except ImportError:
|
||||
USER_SITE = None
|
||||
|
||||
try:
|
||||
import subprocess
|
||||
|
||||
def _python_cmd(*args):
|
||||
args = (sys.executable,) + args
|
||||
return subprocess.call(args) == 0
|
||||
|
||||
except ImportError:
|
||||
# will be used for python 2.3
|
||||
def _python_cmd(*args):
|
||||
args = (sys.executable,) + args
|
||||
# quoting arguments if windows
|
||||
if sys.platform == 'win32':
|
||||
def quote(arg):
|
||||
if ' ' in arg:
|
||||
return '"%s"' % arg
|
||||
return arg
|
||||
args = [quote(arg) for arg in args]
|
||||
return os.spawnl(os.P_WAIT, sys.executable, *args) == 0
|
||||
|
||||
DEFAULT_VERSION = "0.6.36"
|
||||
DEFAULT_URL = "http://pypi.python.org/packages/source/d/distribute/"
|
||||
SETUPTOOLS_FAKED_VERSION = "0.6c11"
|
||||
|
||||
SETUPTOOLS_PKG_INFO = """\
|
||||
Metadata-Version: 1.0
|
||||
Name: setuptools
|
||||
Version: %s
|
||||
Summary: xxxx
|
||||
Home-page: xxx
|
||||
Author: xxx
|
||||
Author-email: xxx
|
||||
License: xxx
|
||||
Description: xxx
|
||||
""" % SETUPTOOLS_FAKED_VERSION
|
||||
|
||||
|
||||
def _install(tarball, install_args=()):
|
||||
# extracting the tarball
|
||||
tmpdir = tempfile.mkdtemp()
|
||||
log.warn('Extracting in %s', tmpdir)
|
||||
old_wd = os.getcwd()
|
||||
try:
|
||||
os.chdir(tmpdir)
|
||||
tar = tarfile.open(tarball)
|
||||
_extractall(tar)
|
||||
tar.close()
|
||||
|
||||
# going in the directory
|
||||
subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0])
|
||||
os.chdir(subdir)
|
||||
log.warn('Now working in %s', subdir)
|
||||
|
||||
# installing
|
||||
log.warn('Installing Distribute')
|
||||
if not _python_cmd('setup.py', 'install', *install_args):
|
||||
log.warn('Something went wrong during the installation.')
|
||||
log.warn('See the error message above.')
|
||||
# exitcode will be 2
|
||||
return 2
|
||||
finally:
|
||||
os.chdir(old_wd)
|
||||
shutil.rmtree(tmpdir)
|
||||
|
||||
|
||||
def _build_egg(egg, tarball, to_dir):
|
||||
# extracting the tarball
|
||||
tmpdir = tempfile.mkdtemp()
|
||||
log.warn('Extracting in %s', tmpdir)
|
||||
old_wd = os.getcwd()
|
||||
try:
|
||||
os.chdir(tmpdir)
|
||||
tar = tarfile.open(tarball)
|
||||
_extractall(tar)
|
||||
tar.close()
|
||||
|
||||
# going in the directory
|
||||
subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0])
|
||||
os.chdir(subdir)
|
||||
log.warn('Now working in %s', subdir)
|
||||
|
||||
# building an egg
|
||||
log.warn('Building a Distribute egg in %s', to_dir)
|
||||
_python_cmd('setup.py', '-q', 'bdist_egg', '--dist-dir', to_dir)
|
||||
|
||||
finally:
|
||||
os.chdir(old_wd)
|
||||
shutil.rmtree(tmpdir)
|
||||
# returning the result
|
||||
log.warn(egg)
|
||||
if not os.path.exists(egg):
|
||||
raise IOError('Could not build the egg.')
|
||||
|
||||
|
||||
def _do_download(version, download_base, to_dir, download_delay):
|
||||
egg = os.path.join(to_dir, 'distribute-%s-py%d.%d.egg'
|
||||
% (version, sys.version_info[0], sys.version_info[1]))
|
||||
if not os.path.exists(egg):
|
||||
tarball = download_setuptools(version, download_base,
|
||||
to_dir, download_delay)
|
||||
_build_egg(egg, tarball, to_dir)
|
||||
sys.path.insert(0, egg)
|
||||
import setuptools
|
||||
setuptools.bootstrap_install_from = egg
|
||||
|
||||
|
||||
def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
|
||||
to_dir=os.curdir, download_delay=15, no_fake=True):
|
||||
# making sure we use the absolute path
|
||||
to_dir = os.path.abspath(to_dir)
|
||||
was_imported = 'pkg_resources' in sys.modules or \
|
||||
'setuptools' in sys.modules
|
||||
try:
|
||||
try:
|
||||
import pkg_resources
|
||||
if not hasattr(pkg_resources, '_distribute'):
|
||||
if not no_fake:
|
||||
_fake_setuptools()
|
||||
raise ImportError
|
||||
except ImportError:
|
||||
return _do_download(version, download_base, to_dir, download_delay)
|
||||
try:
|
||||
pkg_resources.require("distribute>=" + version)
|
||||
return
|
||||
except pkg_resources.VersionConflict:
|
||||
e = sys.exc_info()[1]
|
||||
if was_imported:
|
||||
sys.stderr.write(
|
||||
"The required version of distribute (>=%s) is not available,\n"
|
||||
"and can't be installed while this script is running. Please\n"
|
||||
"install a more recent version first, using\n"
|
||||
"'easy_install -U distribute'."
|
||||
"\n\n(Currently using %r)\n" % (version, e.args[0]))
|
||||
sys.exit(2)
|
||||
else:
|
||||
del pkg_resources, sys.modules['pkg_resources'] # reload ok
|
||||
return _do_download(version, download_base, to_dir,
|
||||
download_delay)
|
||||
except pkg_resources.DistributionNotFound:
|
||||
return _do_download(version, download_base, to_dir,
|
||||
download_delay)
|
||||
finally:
|
||||
if not no_fake:
|
||||
_create_fake_setuptools_pkg_info(to_dir)
|
||||
|
||||
|
||||
def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
|
||||
to_dir=os.curdir, delay=15):
|
||||
"""Download distribute from a specified location and return its filename
|
||||
|
||||
`version` should be a valid distribute version number that is available
|
||||
as an egg for download under the `download_base` URL (which should end
|
||||
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.
|
||||
"""
|
||||
# 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 = "distribute-%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()
|
||||
return os.path.realpath(saveto)
|
||||
|
||||
|
||||
def _no_sandbox(function):
|
||||
def __no_sandbox(*args, **kw):
|
||||
try:
|
||||
from setuptools.sandbox import DirectorySandbox
|
||||
if not hasattr(DirectorySandbox, '_old'):
|
||||
def violation(*args):
|
||||
pass
|
||||
DirectorySandbox._old = DirectorySandbox._violation
|
||||
DirectorySandbox._violation = violation
|
||||
patched = True
|
||||
else:
|
||||
patched = False
|
||||
except ImportError:
|
||||
patched = False
|
||||
|
||||
try:
|
||||
return function(*args, **kw)
|
||||
finally:
|
||||
if patched:
|
||||
DirectorySandbox._violation = DirectorySandbox._old
|
||||
del DirectorySandbox._old
|
||||
|
||||
return __no_sandbox
|
||||
|
||||
|
||||
def _patch_file(path, content):
|
||||
"""Will backup the file then patch it"""
|
||||
f = open(path)
|
||||
existing_content = f.read()
|
||||
f.close()
|
||||
if existing_content == content:
|
||||
# already patched
|
||||
log.warn('Already patched.')
|
||||
return False
|
||||
log.warn('Patching...')
|
||||
_rename_path(path)
|
||||
f = open(path, 'w')
|
||||
try:
|
||||
f.write(content)
|
||||
finally:
|
||||
f.close()
|
||||
return True
|
||||
|
||||
_patch_file = _no_sandbox(_patch_file)
|
||||
|
||||
|
||||
def _same_content(path, content):
|
||||
f = open(path)
|
||||
existing_content = f.read()
|
||||
f.close()
|
||||
return existing_content == content
|
||||
|
||||
|
||||
def _rename_path(path):
|
||||
new_name = path + '.OLD.%s' % time.time()
|
||||
log.warn('Renaming %s to %s', path, new_name)
|
||||
os.rename(path, new_name)
|
||||
return new_name
|
||||
|
||||
|
||||
def _remove_flat_installation(placeholder):
|
||||
if not os.path.isdir(placeholder):
|
||||
log.warn('Unkown installation at %s', placeholder)
|
||||
return False
|
||||
found = False
|
||||
for file in os.listdir(placeholder):
|
||||
if fnmatch.fnmatch(file, 'setuptools*.egg-info'):
|
||||
found = True
|
||||
break
|
||||
if not found:
|
||||
log.warn('Could not locate setuptools*.egg-info')
|
||||
return
|
||||
|
||||
log.warn('Moving elements out of the way...')
|
||||
pkg_info = os.path.join(placeholder, file)
|
||||
if os.path.isdir(pkg_info):
|
||||
patched = _patch_egg_dir(pkg_info)
|
||||
else:
|
||||
patched = _patch_file(pkg_info, SETUPTOOLS_PKG_INFO)
|
||||
|
||||
if not patched:
|
||||
log.warn('%s already patched.', pkg_info)
|
||||
return False
|
||||
# now let's move the files out of the way
|
||||
for element in ('setuptools', 'pkg_resources.py', 'site.py'):
|
||||
element = os.path.join(placeholder, element)
|
||||
if os.path.exists(element):
|
||||
_rename_path(element)
|
||||
else:
|
||||
log.warn('Could not find the %s element of the '
|
||||
'Setuptools distribution', element)
|
||||
return True
|
||||
|
||||
_remove_flat_installation = _no_sandbox(_remove_flat_installation)
|
||||
|
||||
|
||||
def _after_install(dist):
|
||||
log.warn('After install bootstrap.')
|
||||
placeholder = dist.get_command_obj('install').install_purelib
|
||||
_create_fake_setuptools_pkg_info(placeholder)
|
||||
|
||||
|
||||
def _create_fake_setuptools_pkg_info(placeholder):
|
||||
if not placeholder or not os.path.exists(placeholder):
|
||||
log.warn('Could not find the install location')
|
||||
return
|
||||
pyver = '%s.%s' % (sys.version_info[0], sys.version_info[1])
|
||||
setuptools_file = 'setuptools-%s-py%s.egg-info' % \
|
||||
(SETUPTOOLS_FAKED_VERSION, pyver)
|
||||
pkg_info = os.path.join(placeholder, setuptools_file)
|
||||
if os.path.exists(pkg_info):
|
||||
log.warn('%s already exists', pkg_info)
|
||||
return
|
||||
|
||||
log.warn('Creating %s', pkg_info)
|
||||
try:
|
||||
f = open(pkg_info, 'w')
|
||||
except EnvironmentError:
|
||||
log.warn("Don't have permissions to write %s, skipping", pkg_info)
|
||||
return
|
||||
try:
|
||||
f.write(SETUPTOOLS_PKG_INFO)
|
||||
finally:
|
||||
f.close()
|
||||
|
||||
pth_file = os.path.join(placeholder, 'setuptools.pth')
|
||||
log.warn('Creating %s', pth_file)
|
||||
f = open(pth_file, 'w')
|
||||
try:
|
||||
f.write(os.path.join(os.curdir, setuptools_file))
|
||||
finally:
|
||||
f.close()
|
||||
|
||||
_create_fake_setuptools_pkg_info = _no_sandbox(
|
||||
_create_fake_setuptools_pkg_info
|
||||
)
|
||||
|
||||
|
||||
def _patch_egg_dir(path):
|
||||
# let's check if it's already patched
|
||||
pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO')
|
||||
if os.path.exists(pkg_info):
|
||||
if _same_content(pkg_info, SETUPTOOLS_PKG_INFO):
|
||||
log.warn('%s already patched.', pkg_info)
|
||||
return False
|
||||
_rename_path(path)
|
||||
os.mkdir(path)
|
||||
os.mkdir(os.path.join(path, 'EGG-INFO'))
|
||||
pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO')
|
||||
f = open(pkg_info, 'w')
|
||||
try:
|
||||
f.write(SETUPTOOLS_PKG_INFO)
|
||||
finally:
|
||||
f.close()
|
||||
return True
|
||||
|
||||
_patch_egg_dir = _no_sandbox(_patch_egg_dir)
|
||||
|
||||
|
||||
def _before_install():
|
||||
log.warn('Before install bootstrap.')
|
||||
_fake_setuptools()
|
||||
|
||||
|
||||
def _under_prefix(location):
|
||||
if 'install' not in sys.argv:
|
||||
return True
|
||||
args = sys.argv[sys.argv.index('install') + 1:]
|
||||
for index, arg in enumerate(args):
|
||||
for option in ('--root', '--prefix'):
|
||||
if arg.startswith('%s=' % option):
|
||||
top_dir = arg.split('root=')[-1]
|
||||
return location.startswith(top_dir)
|
||||
elif arg == option:
|
||||
if len(args) > index:
|
||||
top_dir = args[index + 1]
|
||||
return location.startswith(top_dir)
|
||||
if arg == '--user' and USER_SITE is not None:
|
||||
return location.startswith(USER_SITE)
|
||||
return True
|
||||
|
||||
|
||||
def _fake_setuptools():
|
||||
log.warn('Scanning installed packages')
|
||||
try:
|
||||
import pkg_resources
|
||||
except ImportError:
|
||||
# we're cool
|
||||
log.warn('Setuptools or Distribute does not seem to be installed.')
|
||||
return
|
||||
ws = pkg_resources.working_set
|
||||
try:
|
||||
setuptools_dist = ws.find(
|
||||
pkg_resources.Requirement.parse('setuptools', replacement=False)
|
||||
)
|
||||
except TypeError:
|
||||
# old distribute API
|
||||
setuptools_dist = ws.find(
|
||||
pkg_resources.Requirement.parse('setuptools')
|
||||
)
|
||||
|
||||
if setuptools_dist is None:
|
||||
log.warn('No setuptools distribution found')
|
||||
return
|
||||
# detecting if it was already faked
|
||||
setuptools_location = setuptools_dist.location
|
||||
log.warn('Setuptools installation detected at %s', setuptools_location)
|
||||
|
||||
# if --root or --preix was provided, and if
|
||||
# setuptools is not located in them, we don't patch it
|
||||
if not _under_prefix(setuptools_location):
|
||||
log.warn('Not patching, --root or --prefix is installing Distribute'
|
||||
' in another location')
|
||||
return
|
||||
|
||||
# let's see if its an egg
|
||||
if not setuptools_location.endswith('.egg'):
|
||||
log.warn('Non-egg installation')
|
||||
res = _remove_flat_installation(setuptools_location)
|
||||
if not res:
|
||||
return
|
||||
else:
|
||||
log.warn('Egg installation')
|
||||
pkg_info = os.path.join(setuptools_location, 'EGG-INFO', 'PKG-INFO')
|
||||
if (os.path.exists(pkg_info) and
|
||||
_same_content(pkg_info, SETUPTOOLS_PKG_INFO)):
|
||||
log.warn('Already patched.')
|
||||
return
|
||||
log.warn('Patching...')
|
||||
# let's create a fake egg replacing setuptools one
|
||||
res = _patch_egg_dir(setuptools_location)
|
||||
if not res:
|
||||
return
|
||||
log.warn('Patching complete.')
|
||||
_relaunch()
|
||||
|
||||
|
||||
def _relaunch():
|
||||
log.warn('Relaunching...')
|
||||
# we have to relaunch the process
|
||||
# pip marker to avoid a relaunch bug
|
||||
_cmd1 = ['-c', 'install', '--single-version-externally-managed']
|
||||
_cmd2 = ['-c', 'install', '--record']
|
||||
if sys.argv[:3] == _cmd1 or sys.argv[:3] == _cmd2:
|
||||
sys.argv[0] = 'setup.py'
|
||||
args = [sys.executable] + sys.argv
|
||||
sys.exit(subprocess.call(args))
|
||||
|
||||
|
||||
def _extractall(self, path=".", members=None):
|
||||
"""Extract all members from the archive to the current working
|
||||
directory and set owner, modification time and permissions on
|
||||
directories afterwards. `path' specifies a different directory
|
||||
to extract to. `members' is optional and must be a subset of the
|
||||
list returned by getmembers().
|
||||
"""
|
||||
import copy
|
||||
import operator
|
||||
from tarfile import ExtractError
|
||||
directories = []
|
||||
|
||||
if members is None:
|
||||
members = self
|
||||
|
||||
for tarinfo in members:
|
||||
if tarinfo.isdir():
|
||||
# Extract directories with a safe mode.
|
||||
directories.append(tarinfo)
|
||||
tarinfo = copy.copy(tarinfo)
|
||||
tarinfo.mode = 448 # decimal for oct 0700
|
||||
self.extract(tarinfo, path)
|
||||
|
||||
# Reverse sort directories.
|
||||
if sys.version_info < (2, 4):
|
||||
def sorter(dir1, dir2):
|
||||
return cmp(dir1.name, dir2.name)
|
||||
directories.sort(sorter)
|
||||
directories.reverse()
|
||||
else:
|
||||
directories.sort(key=operator.attrgetter('name'), reverse=True)
|
||||
|
||||
# Set correct owner, mtime and filemode on directories.
|
||||
for tarinfo in directories:
|
||||
dirpath = os.path.join(path, tarinfo.name)
|
||||
try:
|
||||
self.chown(tarinfo, dirpath)
|
||||
self.utime(tarinfo, dirpath)
|
||||
self.chmod(tarinfo, dirpath)
|
||||
except ExtractError:
|
||||
e = sys.exc_info()[1]
|
||||
if self.errorlevel > 1:
|
||||
raise
|
||||
else:
|
||||
self._dbg(1, "tarfile: %s" % e)
|
||||
|
||||
|
||||
def _build_install_args(options):
|
||||
"""
|
||||
Build the arguments to 'python setup.py install' on the distribute package
|
||||
"""
|
||||
install_args = []
|
||||
if options.user_install:
|
||||
if sys.version_info < (2, 6):
|
||||
log.warn("--user requires Python 2.6 or later")
|
||||
raise SystemExit(1)
|
||||
install_args.append('--user')
|
||||
return install_args
|
||||
|
||||
def _parse_args():
|
||||
"""
|
||||
Parse the command line for options
|
||||
"""
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option(
|
||||
'--user', dest='user_install', action='store_true', default=False,
|
||||
help='install in user site package (requires Python 2.6 or later)')
|
||||
parser.add_option(
|
||||
'--download-base', dest='download_base', metavar="URL",
|
||||
default=DEFAULT_URL,
|
||||
help='alternative URL from where to download the distribute package')
|
||||
options, args = parser.parse_args()
|
||||
# positional arguments are ignored
|
||||
return options
|
||||
|
||||
def main(version=DEFAULT_VERSION):
|
||||
"""Install or upgrade setuptools and EasyInstall"""
|
||||
options = _parse_args()
|
||||
tarball = download_setuptools(download_base=options.download_base)
|
||||
return _install(tarball, _build_install_args(options))
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
@@ -1,8 +0,0 @@
|
||||
<h3>Download</h3>
|
||||
|
||||
<p>Current version: <b>{{ version }}</b></p>
|
||||
<p>Get Distribute from the <a href="http://pypi.python.org/pypi/distribute"> Python Package Index</a>
|
||||
|
||||
<h3>Questions? Suggestions? Contributions?</h3>
|
||||
|
||||
<p>Visit the <a href="http://bitbucket.org/tarek/distribute">Distribute project page</a> </p>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,36 +0,0 @@
|
||||
Welcome to Distribute's documentation!
|
||||
======================================
|
||||
|
||||
`Distribute` is a fork of the `Setuptools` project.
|
||||
|
||||
Distribute is intended to replace Setuptools as the standard method for
|
||||
working with Python module distributions.
|
||||
|
||||
For those who may wonder why they should switch to Distribute over Setuptools, it’s quite simple:
|
||||
|
||||
- Distribute is a drop-in replacement for Setuptools
|
||||
- The code is actively maintained, and has over 10 commiters
|
||||
- Distribute offers Python 3 support !
|
||||
|
||||
Documentation content:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
roadmap
|
||||
python3
|
||||
using
|
||||
setuptools
|
||||
easy_install
|
||||
pkg_resources
|
||||
|
||||
|
||||
.. image:: http://python-distribute.org/pip_distribute.png
|
||||
|
||||
Design done by Idan Gazit (http://pixane.com) - License: cc-by-3.0
|
||||
|
||||
Copy & paste::
|
||||
|
||||
curl -O http://python-distribute.org/distribute_setup.py
|
||||
python distribute_setup.py
|
||||
easy_install pip
|
||||
@@ -1,121 +0,0 @@
|
||||
=====================================================
|
||||
Supporting both Python 2 and Python 3 with Distribute
|
||||
=====================================================
|
||||
|
||||
Starting with version 0.6.2, Distribute supports Python 3. Installing and
|
||||
using distribute for Python 3 code works exactly the same as for Python 2
|
||||
code, but Distribute also helps you to support Python 2 and Python 3 from
|
||||
the same source code by letting you run 2to3 on the code as a part of the
|
||||
build process, by setting the keyword parameter ``use_2to3`` to True.
|
||||
|
||||
|
||||
Distribute as help during porting
|
||||
=================================
|
||||
|
||||
Distribute can make the porting process much easier by automatically running
|
||||
2to3 as a part of the test running. To do this you need to configure the
|
||||
setup.py so that you can run the unit tests with ``python setup.py test``.
|
||||
|
||||
See :ref:`test` for more information on this.
|
||||
|
||||
Once you have the tests running under Python 2, you can add the use_2to3
|
||||
keyword parameters to setup(), and start running the tests under Python 3.
|
||||
The test command will now first run the build command during which the code
|
||||
will be converted with 2to3, and the tests will then be run from the build
|
||||
directory, as opposed from the source directory as is normally done.
|
||||
|
||||
Distribute will convert all Python files, and also all doctests in Python
|
||||
files. However, if you have doctests located in separate text files, these
|
||||
will not automatically be converted. By adding them to the
|
||||
``convert_2to3_doctests`` keyword parameter Distrubute will convert them as
|
||||
well.
|
||||
|
||||
By default, the conversion uses all fixers in the ``lib2to3.fixers`` package.
|
||||
To use additional fixers, the parameter ``use_2to3_fixers`` can be set
|
||||
to a list of names of packages containing fixers. To exclude fixers, the
|
||||
parameter ``use_2to3_exclude_fixers`` can be set to fixer names to be
|
||||
skipped.
|
||||
|
||||
A typical setup.py can look something like this::
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
setup(
|
||||
name='your.module',
|
||||
version = '1.0',
|
||||
description='This is your awesome module',
|
||||
author='You',
|
||||
author_email='your@email',
|
||||
package_dir = {'': 'src'},
|
||||
packages = ['your', 'you.module'],
|
||||
test_suite = 'your.module.tests',
|
||||
use_2to3 = True,
|
||||
convert_2to3_doctests = ['src/your/module/README.txt'],
|
||||
use_2to3_fixers = ['your.fixers'],
|
||||
use_2to3_exclude_fixers = ['lib2to3.fixes.fix_import'],
|
||||
)
|
||||
|
||||
Differential conversion
|
||||
-----------------------
|
||||
|
||||
Note that a file will only be copied and converted during the build process
|
||||
if the source file has been changed. If you add a file to the doctests
|
||||
that should be converted, it will not be converted the next time you run
|
||||
the tests, since it hasn't been modified. You need to remove it from the
|
||||
build directory. Also if you run the build, install or test commands before
|
||||
adding the use_2to3 parameter, you will have to remove the build directory
|
||||
before you run the test command, as the files otherwise will seem updated,
|
||||
and no conversion will happen.
|
||||
|
||||
In general, if code doesn't seem to be converted, deleting the build directory
|
||||
and trying again is a good saferguard against the build directory getting
|
||||
"out of sync" with the source directory.
|
||||
|
||||
Distributing Python 3 modules
|
||||
=============================
|
||||
|
||||
You can distribute your modules with Python 3 support in different ways. A
|
||||
normal source distribution will work, but can be slow in installing, as the
|
||||
2to3 process will be run during the install. But you can also distribute
|
||||
the module in binary format, such as a binary egg. That egg will contain the
|
||||
already converted code, and hence no 2to3 conversion is needed during install.
|
||||
|
||||
Advanced features
|
||||
=================
|
||||
|
||||
If you don't want to run the 2to3 conversion on the doctests in Python files,
|
||||
you can turn that off by setting ``setuptools.use_2to3_on_doctests = False``.
|
||||
|
||||
Note on compatibility with setuptools
|
||||
=====================================
|
||||
|
||||
Setuptools do not know about the new keyword parameters to support Python 3.
|
||||
As a result it will warn about the unknown keyword parameters if you use
|
||||
setuptools instead of Distribute under Python 2. This is not an error, and
|
||||
install process will continue as normal, but if you want to get rid of that
|
||||
error this is easy. Simply conditionally add the new parameters into an extra
|
||||
dict and pass that dict into setup()::
|
||||
|
||||
from setuptools import setup
|
||||
import sys
|
||||
|
||||
extra = {}
|
||||
if sys.version_info >= (3,):
|
||||
extra['use_2to3'] = True
|
||||
extra['convert_2to3_doctests'] = ['src/your/module/README.txt']
|
||||
extra['use_2to3_fixers'] = ['your.fixers']
|
||||
|
||||
setup(
|
||||
name='your.module',
|
||||
version = '1.0',
|
||||
description='This is your awesome module',
|
||||
author='You',
|
||||
author_email='your@email',
|
||||
package_dir = {'': 'src'},
|
||||
packages = ['your', 'you.module'],
|
||||
test_suite = 'your.module.tests',
|
||||
**extra
|
||||
)
|
||||
|
||||
This way the parameters will only be used under Python 3, where you have to
|
||||
use Distribute.
|
||||
@@ -1,86 +0,0 @@
|
||||
=======
|
||||
Roadmap
|
||||
=======
|
||||
|
||||
Distribute has two branches:
|
||||
|
||||
- 0.6.x : provides a Setuptools-0.6cX compatible version
|
||||
- 0.7.x : will provide a refactoring
|
||||
|
||||
0.6.x
|
||||
=====
|
||||
|
||||
Not "much" is going to happen here, we want this branch to be helpful
|
||||
to the community *today* by addressing the 40-or-so bugs
|
||||
that were found in Setuptools and never fixed. This is eventually
|
||||
happen soon because its development is
|
||||
fast : there are up to 5 commiters that are working on it very often
|
||||
(and the number grows weekly.)
|
||||
|
||||
The biggest issue with this branch is that it is providing the same
|
||||
packages and modules setuptools does, and this
|
||||
requires some bootstrapping work where we make sure once Distribute is
|
||||
installed, all Distribution that requires Setuptools
|
||||
will continue to work. This is done by faking the metadata of
|
||||
Setuptools 0.6c9. That's the only way we found to do this.
|
||||
|
||||
There's one major thing though: thanks to the work of Lennart, Alex,
|
||||
Martin, this branch supports Python 3,
|
||||
which is great to have to speed up Py3 adoption.
|
||||
|
||||
The goal of the 0.6.x is to remove as much bugs as we can, and try if
|
||||
possible to remove the patches done
|
||||
on Distutils. We will support 0.6.x maintenance for years and we will
|
||||
promote its usage everywhere instead of
|
||||
Setuptools.
|
||||
|
||||
Some new commands are added there, when they are helpful and don't
|
||||
interact with the rest. I am thinking
|
||||
about "upload_docs" that let you upload documentation to PyPI. The
|
||||
goal is to move it to Distutils
|
||||
at some point, if the documentation feature of PyPI stays and starts to be used.
|
||||
|
||||
0.7.x
|
||||
=====
|
||||
|
||||
We've started to refactor Distribute with this roadmap in mind (and
|
||||
no, as someone said, it's not vaporware,
|
||||
we've done a lot already)
|
||||
|
||||
- 0.7.x can be installed and used with 0.6.x
|
||||
|
||||
- easy_install is going to be deprecated ! use Pip !
|
||||
|
||||
- the version system will be deprecated, in favor of the one in Distutils
|
||||
|
||||
- no more Distutils monkey-patch that happens once you use the code
|
||||
(things like 'from distutils import cmd; cmd.Command = CustomCommand')
|
||||
|
||||
- no more custom site.py (that is: if something misses in Python's
|
||||
site.py we'll add it there instead of patching it)
|
||||
|
||||
- no more namespaced packages system, if PEP 382 (namespaces package
|
||||
support) makes it to 2.7
|
||||
|
||||
- The code is splitted in many packages and might be distributed under
|
||||
several distributions.
|
||||
|
||||
- distribute.resources: that's the old pkg_resources, but
|
||||
reorganized in clean, pep-8 modules. This package will
|
||||
only contain the query APIs and will focus on being PEP 376
|
||||
compatible. We will promote its usage and see if Pip wants
|
||||
to use it as a basis.
|
||||
It will probably shrink a lot though, once the stdlib provides PEP 376 support.
|
||||
|
||||
- distribute.entrypoints: that's the old pkg_resources entry points
|
||||
system, but on its own. it uses distribute.resources
|
||||
|
||||
- distribute.index: that's package_index and a few other things.
|
||||
everything required to interact with PyPI. We will promote
|
||||
its usage and see if Pip wants to use it as a basis.
|
||||
|
||||
- distribute.core (might be renamed to main): that's everything
|
||||
else, and uses the other packages.
|
||||
|
||||
Goal: A first release before (or when) Python 2.7 / 3.2 is out.
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
================================
|
||||
Using Distribute in your project
|
||||
================================
|
||||
|
||||
To use Distribute in your project, the recommended way is to ship
|
||||
`distribute_setup.py` alongside your `setup.py` script and call
|
||||
it at the very begining of `setup.py` like this::
|
||||
|
||||
from distribute_setup import use_setuptools
|
||||
use_setuptools()
|
||||
|
||||
Another way is to add ``Distribute`` in the ``install_requires`` option::
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
setup(...
|
||||
install_requires=['distribute']
|
||||
)
|
||||
|
||||
|
||||
XXX to be finished
|
||||
@@ -1,540 +0,0 @@
|
||||
/*
|
||||
* basic.css
|
||||
* ~~~~~~~~~
|
||||
*
|
||||
* Sphinx stylesheet -- basic theme.
|
||||
*
|
||||
* :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
|
||||
* :license: BSD, see LICENSE for details.
|
||||
*
|
||||
*/
|
||||
|
||||
/* -- main layout ----------------------------------------------------------- */
|
||||
|
||||
div.clearer {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
/* -- relbar ---------------------------------------------------------------- */
|
||||
|
||||
div.related {
|
||||
width: 100%;
|
||||
font-size: 90%;
|
||||
}
|
||||
|
||||
div.related h3 {
|
||||
display: none;
|
||||
}
|
||||
|
||||
div.related ul {
|
||||
margin: 0;
|
||||
padding: 0 0 0 10px;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
div.related li {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
div.related li.right {
|
||||
float: right;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
/* -- sidebar --------------------------------------------------------------- */
|
||||
|
||||
div.sphinxsidebarwrapper {
|
||||
padding: 10px 5px 0 10px;
|
||||
}
|
||||
|
||||
div.sphinxsidebar {
|
||||
float: left;
|
||||
width: 230px;
|
||||
margin-left: -100%;
|
||||
font-size: 90%;
|
||||
}
|
||||
|
||||
div.sphinxsidebar ul {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
div.sphinxsidebar ul ul,
|
||||
div.sphinxsidebar ul.want-points {
|
||||
margin-left: 20px;
|
||||
list-style: square;
|
||||
}
|
||||
|
||||
div.sphinxsidebar ul ul {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
div.sphinxsidebar form {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
div.sphinxsidebar input {
|
||||
border: 1px solid #98dbcc;
|
||||
font-family: sans-serif;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
div.sphinxsidebar #searchbox input[type="text"] {
|
||||
width: 170px;
|
||||
}
|
||||
|
||||
div.sphinxsidebar #searchbox input[type="submit"] {
|
||||
width: 30px;
|
||||
}
|
||||
|
||||
img {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
/* -- search page ----------------------------------------------------------- */
|
||||
|
||||
ul.search {
|
||||
margin: 10px 0 0 20px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
ul.search li {
|
||||
padding: 5px 0 5px 20px;
|
||||
background-image: url(file.png);
|
||||
background-repeat: no-repeat;
|
||||
background-position: 0 7px;
|
||||
}
|
||||
|
||||
ul.search li a {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
ul.search li div.context {
|
||||
color: #888;
|
||||
margin: 2px 0 0 30px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
ul.keywordmatches li.goodmatch a {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* -- index page ------------------------------------------------------------ */
|
||||
|
||||
table.contentstable {
|
||||
width: 90%;
|
||||
}
|
||||
|
||||
table.contentstable p.biglink {
|
||||
line-height: 150%;
|
||||
}
|
||||
|
||||
a.biglink {
|
||||
font-size: 1.3em;
|
||||
}
|
||||
|
||||
span.linkdescr {
|
||||
font-style: italic;
|
||||
padding-top: 5px;
|
||||
font-size: 90%;
|
||||
}
|
||||
|
||||
/* -- general index --------------------------------------------------------- */
|
||||
|
||||
table.indextable {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
table.indextable td {
|
||||
text-align: left;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
table.indextable dl, table.indextable dd {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
table.indextable tr.pcap {
|
||||
height: 10px;
|
||||
}
|
||||
|
||||
table.indextable tr.cap {
|
||||
margin-top: 10px;
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
|
||||
img.toggler {
|
||||
margin-right: 3px;
|
||||
margin-top: 3px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
div.modindex-jumpbox {
|
||||
border-top: 1px solid #ddd;
|
||||
border-bottom: 1px solid #ddd;
|
||||
margin: 1em 0 1em 0;
|
||||
padding: 0.4em;
|
||||
}
|
||||
|
||||
div.genindex-jumpbox {
|
||||
border-top: 1px solid #ddd;
|
||||
border-bottom: 1px solid #ddd;
|
||||
margin: 1em 0 1em 0;
|
||||
padding: 0.4em;
|
||||
}
|
||||
|
||||
/* -- general body styles --------------------------------------------------- */
|
||||
|
||||
a.headerlink {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
h1:hover > a.headerlink,
|
||||
h2:hover > a.headerlink,
|
||||
h3:hover > a.headerlink,
|
||||
h4:hover > a.headerlink,
|
||||
h5:hover > a.headerlink,
|
||||
h6:hover > a.headerlink,
|
||||
dt:hover > a.headerlink {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
div.body p.caption {
|
||||
text-align: inherit;
|
||||
}
|
||||
|
||||
div.body td {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.field-list ul {
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
.first {
|
||||
margin-top: 0 !important;
|
||||
}
|
||||
|
||||
p.rubric {
|
||||
margin-top: 30px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
img.align-left, .figure.align-left, object.align-left {
|
||||
clear: left;
|
||||
float: left;
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
img.align-right, .figure.align-right, object.align-right {
|
||||
clear: right;
|
||||
float: right;
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
img.align-center, .figure.align-center, object.align-center {
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.align-left {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.align-center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.align-right {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
/* -- sidebars -------------------------------------------------------------- */
|
||||
|
||||
div.sidebar {
|
||||
margin: 0 0 0.5em 1em;
|
||||
border: 1px solid #ddb;
|
||||
padding: 7px 7px 0 7px;
|
||||
background-color: #ffe;
|
||||
width: 40%;
|
||||
float: right;
|
||||
}
|
||||
|
||||
p.sidebar-title {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* -- topics ---------------------------------------------------------------- */
|
||||
|
||||
div.topic {
|
||||
border: 1px solid #ccc;
|
||||
padding: 7px 7px 0 7px;
|
||||
margin: 10px 0 10px 0;
|
||||
}
|
||||
|
||||
p.topic-title {
|
||||
font-size: 1.1em;
|
||||
font-weight: bold;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
/* -- admonitions ----------------------------------------------------------- */
|
||||
|
||||
div.admonition {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
padding: 7px;
|
||||
}
|
||||
|
||||
div.admonition dt {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
div.admonition dl {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
p.admonition-title {
|
||||
margin: 0px 10px 5px 0px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
div.body p.centered {
|
||||
text-align: center;
|
||||
margin-top: 25px;
|
||||
}
|
||||
|
||||
/* -- tables ---------------------------------------------------------------- */
|
||||
|
||||
table.docutils {
|
||||
border: 0;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
table.docutils td, table.docutils th {
|
||||
padding: 1px 8px 1px 5px;
|
||||
border-top: 0;
|
||||
border-left: 0;
|
||||
border-right: 0;
|
||||
border-bottom: 1px solid #aaa;
|
||||
}
|
||||
|
||||
table.field-list td, table.field-list th {
|
||||
border: 0 !important;
|
||||
}
|
||||
|
||||
table.footnote td, table.footnote th {
|
||||
border: 0 !important;
|
||||
}
|
||||
|
||||
th {
|
||||
text-align: left;
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
table.citation {
|
||||
border-left: solid 1px gray;
|
||||
margin-left: 1px;
|
||||
}
|
||||
|
||||
table.citation td {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
/* -- other body styles ----------------------------------------------------- */
|
||||
|
||||
ol.arabic {
|
||||
list-style: decimal;
|
||||
}
|
||||
|
||||
ol.loweralpha {
|
||||
list-style: lower-alpha;
|
||||
}
|
||||
|
||||
ol.upperalpha {
|
||||
list-style: upper-alpha;
|
||||
}
|
||||
|
||||
ol.lowerroman {
|
||||
list-style: lower-roman;
|
||||
}
|
||||
|
||||
ol.upperroman {
|
||||
list-style: upper-roman;
|
||||
}
|
||||
|
||||
dl {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
dd p {
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
dd ul, dd table {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
dd {
|
||||
margin-top: 3px;
|
||||
margin-bottom: 10px;
|
||||
margin-left: 30px;
|
||||
}
|
||||
|
||||
dt:target, .highlighted {
|
||||
background-color: #fbe54e;
|
||||
}
|
||||
|
||||
dl.glossary dt {
|
||||
font-weight: bold;
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
||||
.field-list ul {
|
||||
margin: 0;
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
.field-list p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.refcount {
|
||||
color: #060;
|
||||
}
|
||||
|
||||
.optional {
|
||||
font-size: 1.3em;
|
||||
}
|
||||
|
||||
.versionmodified {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.system-message {
|
||||
background-color: #fda;
|
||||
padding: 5px;
|
||||
border: 3px solid red;
|
||||
}
|
||||
|
||||
.footnote:target {
|
||||
background-color: #ffa;
|
||||
}
|
||||
|
||||
.line-block {
|
||||
display: block;
|
||||
margin-top: 1em;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.line-block .line-block {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
margin-left: 1.5em;
|
||||
}
|
||||
|
||||
.guilabel, .menuselection {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
.accelerator {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.classifier {
|
||||
font-style: oblique;
|
||||
}
|
||||
|
||||
abbr, acronym {
|
||||
border-bottom: dotted 1px;
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
/* -- code displays --------------------------------------------------------- */
|
||||
|
||||
pre {
|
||||
overflow: auto;
|
||||
overflow-y: hidden; /* fixes display issues on Chrome browsers */
|
||||
}
|
||||
|
||||
td.linenos pre {
|
||||
padding: 5px 0px;
|
||||
border: 0;
|
||||
background-color: transparent;
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
table.highlighttable {
|
||||
margin-left: 0.5em;
|
||||
}
|
||||
|
||||
table.highlighttable td {
|
||||
padding: 0 0.5em 0 0.5em;
|
||||
}
|
||||
|
||||
tt.descname {
|
||||
background-color: transparent;
|
||||
font-weight: bold;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
tt.descclassname {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
tt.xref, a tt {
|
||||
background-color: transparent;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.viewcode-link {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.viewcode-back {
|
||||
float: right;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
div.viewcode-block:target {
|
||||
margin: -1px -10px;
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
/* -- math display ---------------------------------------------------------- */
|
||||
|
||||
img.math {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
div.body div.math p {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
span.eqno {
|
||||
float: right;
|
||||
}
|
||||
|
||||
/* -- printout stylesheet --------------------------------------------------- */
|
||||
|
||||
@media print {
|
||||
div.document,
|
||||
div.documentwrapper,
|
||||
div.bodywrapper {
|
||||
margin: 0 !important;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
div.sphinxsidebar,
|
||||
div.related,
|
||||
div.footer,
|
||||
#top-link {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@@ -1,236 +0,0 @@
|
||||
/**
|
||||
* Sphinx stylesheet -- default theme
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
*/
|
||||
|
||||
@import url("basic.css");
|
||||
|
||||
/* -- page layout ----------------------------------------------------------- */
|
||||
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
font-size: 100%;
|
||||
background-color: #111111;
|
||||
color: #555555;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
div.documentwrapper {
|
||||
float: left;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
div.bodywrapper {
|
||||
margin: 0 0 0 300px;
|
||||
}
|
||||
|
||||
hr{
|
||||
border: 1px solid #B1B4B6;
|
||||
}
|
||||
|
||||
div.document {
|
||||
background-color: #fafafa;
|
||||
}
|
||||
|
||||
div.body {
|
||||
background-color: #ffffff;
|
||||
color: #3E4349;
|
||||
padding: 1em 30px 30px 30px;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
div.footer {
|
||||
color: #555;
|
||||
width: 100%;
|
||||
padding: 13px 0;
|
||||
text-align: center;
|
||||
font-size: 75%;
|
||||
}
|
||||
|
||||
div.footer a {
|
||||
color: #444444;
|
||||
}
|
||||
|
||||
div.related {
|
||||
background-color: #6BA81E;
|
||||
line-height: 36px;
|
||||
color: #ffffff;
|
||||
text-shadow: 0px 1px 0 #444444;
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
||||
div.related a {
|
||||
color: #E2F3CC;
|
||||
}
|
||||
|
||||
div.related .right {
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
div.sphinxsidebar {
|
||||
font-size: 0.9em;
|
||||
line-height: 1.5em;
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
div.sphinxsidebarwrapper{
|
||||
padding: 20px 0;
|
||||
}
|
||||
|
||||
div.sphinxsidebar h3,
|
||||
div.sphinxsidebar h4 {
|
||||
font-family: Arial, sans-serif;
|
||||
color: #222222;
|
||||
font-size: 1.2em;
|
||||
font-weight: bold;
|
||||
margin: 0;
|
||||
padding: 5px 10px;
|
||||
text-shadow: 1px 1px 0 white
|
||||
}
|
||||
|
||||
div.sphinxsidebar h3 a {
|
||||
color: #444444;
|
||||
}
|
||||
|
||||
div.sphinxsidebar p {
|
||||
color: #888888;
|
||||
padding: 5px 20px;
|
||||
margin: 0.5em 0px;
|
||||
}
|
||||
|
||||
div.sphinxsidebar p.topless {
|
||||
}
|
||||
|
||||
div.sphinxsidebar ul {
|
||||
margin: 10px 10px 10px 20px;
|
||||
padding: 0;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
div.sphinxsidebar a {
|
||||
color: #444444;
|
||||
}
|
||||
|
||||
div.sphinxsidebar a:hover {
|
||||
color: #E32E00;
|
||||
}
|
||||
|
||||
div.sphinxsidebar input {
|
||||
border: 1px solid #cccccc;
|
||||
font-family: sans-serif;
|
||||
font-size: 1.1em;
|
||||
padding: 0.15em 0.3em;
|
||||
}
|
||||
|
||||
div.sphinxsidebar input[type=text]{
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
/* -- body styles ----------------------------------------------------------- */
|
||||
|
||||
a {
|
||||
color: #005B81;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #E32E00;
|
||||
}
|
||||
|
||||
div.body h1,
|
||||
div.body h2,
|
||||
div.body h3,
|
||||
div.body h4,
|
||||
div.body h5,
|
||||
div.body h6 {
|
||||
font-family: Arial, sans-serif;
|
||||
font-weight: normal;
|
||||
color: #212224;
|
||||
margin: 30px 0px 10px 0px;
|
||||
padding: 5px 0 5px 0px;
|
||||
text-shadow: 0px 1px 0 white;
|
||||
border-bottom: 1px solid #C8D5E3;
|
||||
}
|
||||
|
||||
div.body h1 { margin-top: 0; font-size: 200%; }
|
||||
div.body h2 { font-size: 150%; }
|
||||
div.body h3 { font-size: 120%; }
|
||||
div.body h4 { font-size: 110%; }
|
||||
div.body h5 { font-size: 100%; }
|
||||
div.body h6 { font-size: 100%; }
|
||||
|
||||
a.headerlink {
|
||||
color: #c60f0f;
|
||||
font-size: 0.8em;
|
||||
padding: 0 4px 0 4px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a.headerlink:hover {
|
||||
background-color: #c60f0f;
|
||||
color: white;
|
||||
}
|
||||
|
||||
div.body p, div.body dd, div.body li {
|
||||
line-height: 1.8em;
|
||||
}
|
||||
|
||||
div.admonition p.admonition-title + p {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
div.highlight{
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
div.note {
|
||||
background-color: #eeeeee;
|
||||
border: 1px solid #cccccc;
|
||||
}
|
||||
|
||||
div.seealso {
|
||||
background-color: #ffffcc;
|
||||
border: 1px solid #ffff66;
|
||||
}
|
||||
|
||||
div.topic {
|
||||
background-color: #fafafa;
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
div.warning {
|
||||
background-color: #ffe4e4;
|
||||
border: 1px solid #ff6666;
|
||||
}
|
||||
|
||||
p.admonition-title {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
p.admonition-title:after {
|
||||
content: ":";
|
||||
}
|
||||
|
||||
pre {
|
||||
padding: 10px;
|
||||
background-color: #fafafa;
|
||||
color: #222222;
|
||||
line-height: 1.5em;
|
||||
font-size: 1.1em;
|
||||
margin: 1.5em 0 1.5em 0;
|
||||
-webkit-box-shadow: 0px 0px 4px #d8d8d8;
|
||||
-moz-box-shadow: 0px 0px 4px #d8d8d8;
|
||||
box-shadow: 0px 0px 4px #d8d8d8;
|
||||
}
|
||||
|
||||
tt {
|
||||
color: #222222;
|
||||
padding: 1px 2px;
|
||||
font-size: 1.2em;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
#table-of-contents ul {
|
||||
padding-left: 2em;
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
.c { color: #999988; font-style: italic } /* Comment */
|
||||
.k { font-weight: bold } /* Keyword */
|
||||
.o { font-weight: bold } /* Operator */
|
||||
.cm { color: #999988; font-style: italic } /* Comment.Multiline */
|
||||
.cp { color: #999999; font-weight: bold } /* Comment.preproc */
|
||||
.c1 { color: #999988; font-style: italic } /* Comment.Single */
|
||||
.gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
|
||||
.ge { font-style: italic } /* Generic.Emph */
|
||||
.gr { color: #aa0000 } /* Generic.Error */
|
||||
.gh { color: #999999 } /* Generic.Heading */
|
||||
.gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
|
||||
.go { color: #111 } /* Generic.Output */
|
||||
.gp { color: #555555 } /* Generic.Prompt */
|
||||
.gs { font-weight: bold } /* Generic.Strong */
|
||||
.gu { color: #aaaaaa } /* Generic.Subheading */
|
||||
.gt { color: #aa0000 } /* Generic.Traceback */
|
||||
.kc { font-weight: bold } /* Keyword.Constant */
|
||||
.kd { font-weight: bold } /* Keyword.Declaration */
|
||||
.kp { font-weight: bold } /* Keyword.Pseudo */
|
||||
.kr { font-weight: bold } /* Keyword.Reserved */
|
||||
.kt { color: #445588; font-weight: bold } /* Keyword.Type */
|
||||
.m { color: #009999 } /* Literal.Number */
|
||||
.s { color: #bb8844 } /* Literal.String */
|
||||
.na { color: #008080 } /* Name.Attribute */
|
||||
.nb { color: #999999 } /* Name.Builtin */
|
||||
.nc { color: #445588; font-weight: bold } /* Name.Class */
|
||||
.no { color: #ff99ff } /* Name.Constant */
|
||||
.ni { color: #800080 } /* Name.Entity */
|
||||
.ne { color: #990000; font-weight: bold } /* Name.Exception */
|
||||
.nf { color: #990000; font-weight: bold } /* Name.Function */
|
||||
.nn { color: #555555 } /* Name.Namespace */
|
||||
.nt { color: #000080 } /* Name.Tag */
|
||||
.nv { color: purple } /* Name.Variable */
|
||||
.ow { font-weight: bold } /* Operator.Word */
|
||||
.mf { color: #009999 } /* Literal.Number.Float */
|
||||
.mh { color: #009999 } /* Literal.Number.Hex */
|
||||
.mi { color: #009999 } /* Literal.Number.Integer */
|
||||
.mo { color: #009999 } /* Literal.Number.Oct */
|
||||
.sb { color: #bb8844 } /* Literal.String.Backtick */
|
||||
.sc { color: #bb8844 } /* Literal.String.Char */
|
||||
.sd { color: #bb8844 } /* Literal.String.Doc */
|
||||
.s2 { color: #bb8844 } /* Literal.String.Double */
|
||||
.se { color: #bb8844 } /* Literal.String.Escape */
|
||||
.sh { color: #bb8844 } /* Literal.String.Heredoc */
|
||||
.si { color: #bb8844 } /* Literal.String.Interpol */
|
||||
.sx { color: #bb8844 } /* Literal.String.Other */
|
||||
.sr { color: #808000 } /* Literal.String.Regex */
|
||||
.s1 { color: #bb8844 } /* Literal.String.Single */
|
||||
.ss { color: #bb8844 } /* Literal.String.Symbol */
|
||||
.bp { color: #999999 } /* Name.Builtin.Pseudo */
|
||||
.vc { color: #ff99ff } /* Name.Variable.Class */
|
||||
.vg { color: #ff99ff } /* Name.Variable.Global */
|
||||
.vi { color: #ff99ff } /* Name.Variable.Instance */
|
||||
.il { color: #009999 } /* Literal.Number.Integer.Long */
|
||||
-36
@@ -1,36 +0,0 @@
|
||||
Welcome to Distribute's documentation!
|
||||
======================================
|
||||
|
||||
`Distribute` is a fork of the `Setuptools` project.
|
||||
|
||||
Distribute is intended to replace Setuptools as the standard method for
|
||||
working with Python module distributions.
|
||||
|
||||
For those who may wonder why they should switch to Distribute over Setuptools, it’s quite simple:
|
||||
|
||||
- Distribute is a drop-in replacement for Setuptools
|
||||
- The code is actively maintained, and has over 10 commiters
|
||||
- Distribute offers Python 3 support !
|
||||
|
||||
Documentation content:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
roadmap
|
||||
python3
|
||||
using
|
||||
setuptools
|
||||
easy_install
|
||||
pkg_resources
|
||||
|
||||
|
||||
.. image:: http://python-distribute.org/pip_distribute.png
|
||||
|
||||
Design done by Idan Gazit (http://pixane.com) - License: cc-by-3.0
|
||||
|
||||
Copy & paste::
|
||||
|
||||
curl -O http://python-distribute.org/distribute_setup.py
|
||||
python distribute_setup.py
|
||||
easy_install pip
|
||||
-1955
File diff suppressed because it is too large
Load Diff
-86
@@ -1,86 +0,0 @@
|
||||
=======
|
||||
Roadmap
|
||||
=======
|
||||
|
||||
Distribute has two branches:
|
||||
|
||||
- 0.6.x : provides a Setuptools-0.6cX compatible version
|
||||
- 0.7.x : will provide a refactoring
|
||||
|
||||
0.6.x
|
||||
=====
|
||||
|
||||
Not "much" is going to happen here, we want this branch to be helpful
|
||||
to the community *today* by addressing the 40-or-so bugs
|
||||
that were found in Setuptools and never fixed. This is eventually
|
||||
happen soon because its development is
|
||||
fast : there are up to 5 commiters that are working on it very often
|
||||
(and the number grows weekly.)
|
||||
|
||||
The biggest issue with this branch is that it is providing the same
|
||||
packages and modules setuptools does, and this
|
||||
requires some bootstrapping work where we make sure once Distribute is
|
||||
installed, all Distribution that requires Setuptools
|
||||
will continue to work. This is done by faking the metadata of
|
||||
Setuptools 0.6c9. That's the only way we found to do this.
|
||||
|
||||
There's one major thing though: thanks to the work of Lennart, Alex,
|
||||
Martin, this branch supports Python 3,
|
||||
which is great to have to speed up Py3 adoption.
|
||||
|
||||
The goal of the 0.6.x is to remove as much bugs as we can, and try if
|
||||
possible to remove the patches done
|
||||
on Distutils. We will support 0.6.x maintenance for years and we will
|
||||
promote its usage everywhere instead of
|
||||
Setuptools.
|
||||
|
||||
Some new commands are added there, when they are helpful and don't
|
||||
interact with the rest. I am thinking
|
||||
about "upload_docs" that let you upload documentation to PyPI. The
|
||||
goal is to move it to Distutils
|
||||
at some point, if the documentation feature of PyPI stays and starts to be used.
|
||||
|
||||
0.7.x
|
||||
=====
|
||||
|
||||
We've started to refactor Distribute with this roadmap in mind (and
|
||||
no, as someone said, it's not vaporware,
|
||||
we've done a lot already)
|
||||
|
||||
- 0.7.x can be installed and used with 0.6.x
|
||||
|
||||
- easy_install is going to be deprecated ! use Pip !
|
||||
|
||||
- the version system will be deprecated, in favor of the one in Distutils
|
||||
|
||||
- no more Distutils monkey-patch that happens once you use the code
|
||||
(things like 'from distutils import cmd; cmd.Command = CustomCommand')
|
||||
|
||||
- no more custom site.py (that is: if something misses in Python's
|
||||
site.py we'll add it there instead of patching it)
|
||||
|
||||
- no more namespaced packages system, if PEP 382 (namespaces package
|
||||
support) makes it to 2.7
|
||||
|
||||
- The code is splitted in many packages and might be distributed under
|
||||
several distributions.
|
||||
|
||||
- distribute.resources: that's the old pkg_resources, but
|
||||
reorganized in clean, pep-8 modules. This package will
|
||||
only contain the query APIs and will focus on being PEP 376
|
||||
compatible. We will promote its usage and see if Pip wants
|
||||
to use it as a basis.
|
||||
It will probably shrink a lot though, once the stdlib provides PEP 376 support.
|
||||
|
||||
- distribute.entrypoints: that's the old pkg_resources entry points
|
||||
system, but on its own. it uses distribute.resources
|
||||
|
||||
- distribute.index: that's package_index and a few other things.
|
||||
everything required to interact with PyPI. We will promote
|
||||
its usage and see if Pip wants to use it as a basis.
|
||||
|
||||
- distribute.core (might be renamed to main): that's everything
|
||||
else, and uses the other packages.
|
||||
|
||||
Goal: A first release before (or when) Python 2.7 / 3.2 is out.
|
||||
|
||||
-3230
File diff suppressed because it is too large
Load Diff
-21
@@ -1,21 +0,0 @@
|
||||
================================
|
||||
Using Distribute in your project
|
||||
================================
|
||||
|
||||
To use Distribute in your project, the recommended way is to ship
|
||||
`distribute_setup.py` alongside your `setup.py` script and call
|
||||
it at the very begining of `setup.py` like this::
|
||||
|
||||
from distribute_setup import use_setuptools
|
||||
use_setuptools()
|
||||
|
||||
Another way is to add ``Distribute`` in the ``install_requires`` option::
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
setup(...
|
||||
install_requires=['distribute']
|
||||
)
|
||||
|
||||
|
||||
XXX to be finished
|
||||
Vendored
-170
@@ -1,170 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
Script to fully automate the release process. Requires Python 2.6+
|
||||
with sphinx installed and the 'hg' command on the path.
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import subprocess
|
||||
import shutil
|
||||
import os
|
||||
import sys
|
||||
import urllib2
|
||||
import getpass
|
||||
import collections
|
||||
|
||||
try:
|
||||
import keyring
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
VERSION = '0.6.36'
|
||||
|
||||
def get_next_version():
|
||||
digits = map(int, VERSION.split('.'))
|
||||
digits[-1] += 1
|
||||
return '.'.join(map(str, digits))
|
||||
|
||||
NEXT_VERSION = get_next_version()
|
||||
|
||||
files_with_versions = ('docs/conf.py', 'setup.py', 'release.py',
|
||||
'README.txt', 'distribute_setup.py')
|
||||
|
||||
def get_repo_name():
|
||||
"""
|
||||
Get the repo name from the hgrc default path.
|
||||
"""
|
||||
default = subprocess.check_output('hg paths default').strip()
|
||||
parts = default.split('/')
|
||||
if parts[-1] == '':
|
||||
parts.pop()
|
||||
return '/'.join(parts[-2:])
|
||||
|
||||
def get_mercurial_creds(system='https://bitbucket.org', username=None):
|
||||
"""
|
||||
Return named tuple of username,password in much the same way that
|
||||
Mercurial would (from the keyring).
|
||||
"""
|
||||
# todo: consider getting this from .hgrc
|
||||
username = username or getpass.getuser()
|
||||
keyring_username = '@@'.join((username, system))
|
||||
system = 'Mercurial'
|
||||
password = (
|
||||
keyring.get_password(system, keyring_username)
|
||||
if 'keyring' in globals()
|
||||
else None
|
||||
)
|
||||
if not password:
|
||||
password = getpass.getpass()
|
||||
Credential = collections.namedtuple('Credential', 'username password')
|
||||
return Credential(username, password)
|
||||
|
||||
def add_milestone_and_version(version=NEXT_VERSION):
|
||||
auth = 'Basic ' + ':'.join(get_mercurial_creds()).encode('base64').strip()
|
||||
headers = {
|
||||
'Authorization': auth,
|
||||
}
|
||||
base = 'https://api.bitbucket.org'
|
||||
for type in 'milestones', 'versions':
|
||||
url = (base + '/1.0/repositories/{repo}/issues/{type}'
|
||||
.format(repo = get_repo_name(), type=type))
|
||||
req = urllib2.Request(url = url, headers = headers,
|
||||
data='name='+version)
|
||||
try:
|
||||
urllib2.urlopen(req)
|
||||
except urllib2.HTTPError as e:
|
||||
print(e.fp.read())
|
||||
|
||||
def bump_versions():
|
||||
list(map(bump_version, files_with_versions))
|
||||
|
||||
def bump_version(filename):
|
||||
with open(filename, 'rb') as f:
|
||||
lines = [line.replace(VERSION, NEXT_VERSION) for line in f]
|
||||
with open(filename, 'wb') as f:
|
||||
f.writelines(lines)
|
||||
|
||||
def do_release():
|
||||
assert all(map(os.path.exists, files_with_versions)), (
|
||||
"Expected file(s) missing")
|
||||
|
||||
assert has_sphinx(), "You must have Sphinx installed to release"
|
||||
|
||||
res = raw_input('Have you read through the SCM changelog and '
|
||||
'confirmed the changelog is current for releasing {VERSION}? '
|
||||
.format(**globals()))
|
||||
if not res.lower().startswith('y'):
|
||||
print("Please do that")
|
||||
raise SystemExit(1)
|
||||
|
||||
print("Travis-CI tests: http://travis-ci.org/#!/jaraco/distribute")
|
||||
res = raw_input('Have you or has someone verified that the tests '
|
||||
'pass on this revision? ')
|
||||
if not res.lower().startswith('y'):
|
||||
print("Please do that")
|
||||
raise SystemExit(2)
|
||||
|
||||
subprocess.check_call(['hg', 'tag', VERSION])
|
||||
|
||||
subprocess.check_call(['hg', 'update', VERSION])
|
||||
|
||||
has_docs = build_docs()
|
||||
if os.path.isdir('./dist'):
|
||||
shutil.rmtree('./dist')
|
||||
cmd = [sys.executable, 'setup.py', '-q', 'egg_info', '-RD', '-b', '',
|
||||
'sdist', 'register', 'upload']
|
||||
if has_docs:
|
||||
cmd.append('upload_docs')
|
||||
subprocess.check_call(cmd)
|
||||
upload_bootstrap_script()
|
||||
|
||||
# update to the tip for the next operation
|
||||
subprocess.check_call(['hg', 'update'])
|
||||
|
||||
# we just tagged the current version, bump for the next release.
|
||||
bump_versions()
|
||||
subprocess.check_call(['hg', 'ci', '-m',
|
||||
'Bumped to {NEXT_VERSION} in preparation for next '
|
||||
'release.'.format(**globals())])
|
||||
|
||||
# push the changes
|
||||
subprocess.check_call(['hg', 'push'])
|
||||
|
||||
add_milestone_and_version()
|
||||
|
||||
def has_sphinx():
|
||||
try:
|
||||
devnull = open(os.path.devnull, 'wb')
|
||||
subprocess.Popen(['sphinx-build', '--version'], stdout=devnull,
|
||||
stderr=subprocess.STDOUT).wait()
|
||||
except Exception:
|
||||
return False
|
||||
return True
|
||||
|
||||
def build_docs():
|
||||
if not os.path.isdir('docs'):
|
||||
return
|
||||
if os.path.isdir('docs/build'):
|
||||
shutil.rmtree('docs/build')
|
||||
subprocess.check_call([
|
||||
'sphinx-build',
|
||||
'-b', 'html',
|
||||
'-d', 'build/doctrees',
|
||||
'.',
|
||||
'build/html',
|
||||
],
|
||||
cwd='docs')
|
||||
return True
|
||||
|
||||
def upload_bootstrap_script():
|
||||
scp_command = 'pscp' if sys.platform.startswith('win') else 'scp'
|
||||
try:
|
||||
subprocess.check_call([scp_command, 'distribute_setup.py',
|
||||
'pypi@ziade.org:python-distribute.org/'])
|
||||
except:
|
||||
print("Unable to upload bootstrap script. Ask Tarek to do it.")
|
||||
|
||||
if __name__ == '__main__':
|
||||
do_release()
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -1,41 +0,0 @@
|
||||
from distutils.command.bdist_wininst import bdist_wininst as _bdist_wininst
|
||||
import os, sys
|
||||
|
||||
class bdist_wininst(_bdist_wininst):
|
||||
|
||||
def create_exe(self, arcname, fullname, bitmap=None):
|
||||
_bdist_wininst.create_exe(self, arcname, fullname, bitmap)
|
||||
dist_files = getattr(self.distribution, 'dist_files', [])
|
||||
|
||||
if self.target_version:
|
||||
installer_name = os.path.join(self.dist_dir,
|
||||
"%s.win32-py%s.exe" %
|
||||
(fullname, self.target_version))
|
||||
pyversion = self.target_version
|
||||
|
||||
# fix 2.5 bdist_wininst ignoring --target-version spec
|
||||
bad = ('bdist_wininst','any',installer_name)
|
||||
if bad in dist_files:
|
||||
dist_files.remove(bad)
|
||||
else:
|
||||
installer_name = os.path.join(self.dist_dir,
|
||||
"%s.win32.exe" % fullname)
|
||||
pyversion = 'any'
|
||||
good = ('bdist_wininst', pyversion, installer_name)
|
||||
if good not in dist_files:
|
||||
dist_files.append(good)
|
||||
|
||||
def reinitialize_command (self, command, reinit_subcommands=0):
|
||||
cmd = self.distribution.reinitialize_command(
|
||||
command, reinit_subcommands)
|
||||
if command in ('install', 'install_lib'):
|
||||
cmd.install_lib = None # work around distutils bug
|
||||
return cmd
|
||||
|
||||
def run(self):
|
||||
self._is_running = True
|
||||
try:
|
||||
_bdist_wininst.run(self)
|
||||
finally:
|
||||
self._is_running = False
|
||||
|
||||
@@ -1,185 +0,0 @@
|
||||
"""distutils.command.upload
|
||||
|
||||
Implements the Distutils 'upload' subcommand (upload package to PyPI)."""
|
||||
|
||||
from distutils.errors import *
|
||||
from distutils.core import Command
|
||||
from distutils.spawn import spawn
|
||||
from distutils import log
|
||||
try:
|
||||
from hashlib import md5
|
||||
except ImportError:
|
||||
from md5 import md5
|
||||
import os
|
||||
import socket
|
||||
import platform
|
||||
import ConfigParser
|
||||
import httplib
|
||||
import base64
|
||||
import urlparse
|
||||
import cStringIO as StringIO
|
||||
|
||||
class upload(Command):
|
||||
|
||||
description = "upload binary package to PyPI"
|
||||
|
||||
DEFAULT_REPOSITORY = 'http://pypi.python.org/pypi'
|
||||
|
||||
user_options = [
|
||||
('repository=', 'r',
|
||||
"url of repository [default: %s]" % DEFAULT_REPOSITORY),
|
||||
('show-response', None,
|
||||
'display full response text from server'),
|
||||
('sign', 's',
|
||||
'sign files to upload using gpg'),
|
||||
('identity=', 'i', 'GPG identity used to sign files'),
|
||||
]
|
||||
boolean_options = ['show-response', 'sign']
|
||||
|
||||
def initialize_options(self):
|
||||
self.username = ''
|
||||
self.password = ''
|
||||
self.repository = ''
|
||||
self.show_response = 0
|
||||
self.sign = False
|
||||
self.identity = None
|
||||
|
||||
def finalize_options(self):
|
||||
if self.identity and not self.sign:
|
||||
raise DistutilsOptionError(
|
||||
"Must use --sign for --identity to have meaning"
|
||||
)
|
||||
if os.environ.has_key('HOME'):
|
||||
rc = os.path.join(os.environ['HOME'], '.pypirc')
|
||||
if os.path.exists(rc):
|
||||
self.announce('Using PyPI login from %s' % rc)
|
||||
config = ConfigParser.ConfigParser({
|
||||
'username':'',
|
||||
'password':'',
|
||||
'repository':''})
|
||||
config.read(rc)
|
||||
if not self.repository:
|
||||
self.repository = config.get('server-login', 'repository')
|
||||
if not self.username:
|
||||
self.username = config.get('server-login', 'username')
|
||||
if not self.password:
|
||||
self.password = config.get('server-login', 'password')
|
||||
if not self.repository:
|
||||
self.repository = self.DEFAULT_REPOSITORY
|
||||
|
||||
def run(self):
|
||||
if not self.distribution.dist_files:
|
||||
raise DistutilsOptionError("No dist file created in earlier command")
|
||||
for command, pyversion, filename in self.distribution.dist_files:
|
||||
self.upload_file(command, pyversion, filename)
|
||||
|
||||
def upload_file(self, command, pyversion, filename):
|
||||
# Sign if requested
|
||||
if self.sign:
|
||||
gpg_args = ["gpg", "--detach-sign", "-a", filename]
|
||||
if self.identity:
|
||||
gpg_args[2:2] = ["--local-user", self.identity]
|
||||
spawn(gpg_args,
|
||||
dry_run=self.dry_run)
|
||||
|
||||
# Fill in the data
|
||||
f = open(filename,'rb')
|
||||
content = f.read()
|
||||
f.close()
|
||||
basename = os.path.basename(filename)
|
||||
comment = ''
|
||||
if command=='bdist_egg' and self.distribution.has_ext_modules():
|
||||
comment = "built on %s" % platform.platform(terse=1)
|
||||
data = {
|
||||
':action':'file_upload',
|
||||
'protocol_version':'1',
|
||||
'name':self.distribution.get_name(),
|
||||
'version':self.distribution.get_version(),
|
||||
'content':(basename,content),
|
||||
'filetype':command,
|
||||
'pyversion':pyversion,
|
||||
'md5_digest':md5(content).hexdigest(),
|
||||
}
|
||||
if command == 'bdist_rpm':
|
||||
dist, version, id = platform.dist()
|
||||
if dist:
|
||||
comment = 'built for %s %s' % (dist, version)
|
||||
elif command == 'bdist_dumb':
|
||||
comment = 'built for %s' % platform.platform(terse=1)
|
||||
data['comment'] = comment
|
||||
|
||||
if self.sign:
|
||||
asc_file = open(filename + ".asc")
|
||||
data['gpg_signature'] = (os.path.basename(filename) + ".asc", asc_file.read())
|
||||
asc_file.close()
|
||||
|
||||
# set up the authentication
|
||||
auth = "Basic " + base64.encodestring(self.username + ":" + self.password).strip()
|
||||
|
||||
# Build up the MIME payload for the POST data
|
||||
boundary = '--------------GHSKFJDLGDS7543FJKLFHRE75642756743254'
|
||||
sep_boundary = '\n--' + boundary
|
||||
end_boundary = sep_boundary + '--'
|
||||
body = StringIO.StringIO()
|
||||
for key, value in data.items():
|
||||
# handle multiple entries for the same name
|
||||
if type(value) != type([]):
|
||||
value = [value]
|
||||
for value in value:
|
||||
if type(value) is tuple:
|
||||
fn = ';filename="%s"' % value[0]
|
||||
value = value[1]
|
||||
else:
|
||||
fn = ""
|
||||
value = str(value)
|
||||
body.write(sep_boundary)
|
||||
body.write('\nContent-Disposition: form-data; name="%s"'%key)
|
||||
body.write(fn)
|
||||
body.write("\n\n")
|
||||
body.write(value)
|
||||
if value and value[-1] == '\r':
|
||||
body.write('\n') # write an extra newline (lurve Macs)
|
||||
body.write(end_boundary)
|
||||
body.write("\n")
|
||||
body = body.getvalue()
|
||||
|
||||
self.announce("Submitting %s to %s" % (filename, self.repository), log.INFO)
|
||||
|
||||
# build the Request
|
||||
# We can't use urllib2 since we need to send the Basic
|
||||
# auth right with the first request
|
||||
schema, netloc, url, params, query, fragments = \
|
||||
urlparse.urlparse(self.repository)
|
||||
assert not params and not query and not fragments
|
||||
if schema == 'http':
|
||||
http = httplib.HTTPConnection(netloc)
|
||||
elif schema == 'https':
|
||||
http = httplib.HTTPSConnection(netloc)
|
||||
else:
|
||||
raise AssertionError, "unsupported schema "+schema
|
||||
|
||||
data = ''
|
||||
loglevel = log.INFO
|
||||
try:
|
||||
http.connect()
|
||||
http.putrequest("POST", url)
|
||||
http.putheader('Content-type',
|
||||
'multipart/form-data; boundary=%s'%boundary)
|
||||
http.putheader('Content-length', str(len(body)))
|
||||
http.putheader('Authorization', auth)
|
||||
http.endheaders()
|
||||
http.send(body)
|
||||
except socket.error, e:
|
||||
self.announce(str(e), log.ERROR)
|
||||
return
|
||||
|
||||
r = http.getresponse()
|
||||
if r.status == 200:
|
||||
self.announce('Server response (%s): %s' % (r.status, r.reason),
|
||||
log.INFO)
|
||||
else:
|
||||
self.announce('Upload failed (%s): %s' % (r.status, r.reason),
|
||||
log.ERROR)
|
||||
if self.show_response:
|
||||
print '-'*75, r.read(), '-'*75
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
# EASY-INSTALL-DEV-SCRIPT: %(spec)r,%(script_name)r
|
||||
__requires__ = """%(spec)r"""
|
||||
from pkg_resources import require; require("""%(spec)r""")
|
||||
del require
|
||||
__file__ = """%(dev_path)r"""
|
||||
execfile(__file__)
|
||||
-75
@@ -1,75 +0,0 @@
|
||||
import urllib2
|
||||
import sys
|
||||
import os
|
||||
|
||||
if os.path.exists('distribute_setup.py'):
|
||||
print 'distribute_setup.py exists in the current dir, aborting'
|
||||
sys.exit(2)
|
||||
|
||||
print '**** Starting Test'
|
||||
print '\n\n'
|
||||
|
||||
is_jython = sys.platform.startswith('java')
|
||||
if is_jython:
|
||||
import subprocess
|
||||
|
||||
print 'Downloading bootstrap'
|
||||
file = urllib2.urlopen('http://nightly.ziade.org/distribute_setup.py')
|
||||
f = open('distribute_setup.py', 'w')
|
||||
f.write(file.read())
|
||||
f.close()
|
||||
|
||||
# running it
|
||||
args = [sys.executable] + ['distribute_setup.py']
|
||||
if is_jython:
|
||||
res = subprocess.call(args)
|
||||
else:
|
||||
res = os.spawnv(os.P_WAIT, sys.executable, args)
|
||||
|
||||
if res != 0:
|
||||
print '**** Test failed, please send me the output at tarek@ziade.org'
|
||||
os.remove('distribute_setup.py')
|
||||
sys.exit(2)
|
||||
|
||||
# now checking if Distribute is installed
|
||||
script = """\
|
||||
import sys
|
||||
try:
|
||||
import setuptools
|
||||
except ImportError:
|
||||
sys.exit(0)
|
||||
|
||||
sys.exit(hasattr(setuptools, "_distribute"))
|
||||
"""
|
||||
|
||||
root = 'script'
|
||||
seed = 0
|
||||
script_name = '%s%d.py' % (root, seed)
|
||||
|
||||
while os.path.exists(script_name):
|
||||
seed += 1
|
||||
script_name = '%s%d.py' % (root, seed)
|
||||
|
||||
f = open(script_name, 'w')
|
||||
try:
|
||||
f.write(script)
|
||||
finally:
|
||||
f.close()
|
||||
|
||||
try:
|
||||
args = [sys.executable] + [script_name]
|
||||
if is_jython:
|
||||
res = subprocess.call(args)
|
||||
else:
|
||||
res = os.spawnv(os.P_WAIT, sys.executable, args)
|
||||
|
||||
print '\n\n'
|
||||
if res:
|
||||
print '**** Test is OK'
|
||||
else:
|
||||
print '**** Test failed, please send me the output at tarek@ziade.org'
|
||||
finally:
|
||||
if os.path.exists(script_name):
|
||||
os.remove(script_name)
|
||||
os.remove('distribute_setup.py')
|
||||
|
||||
Vendored
-776
@@ -1,776 +0,0 @@
|
||||
Metadata-Version: 1.1
|
||||
Name: pip
|
||||
Version: 1.3.1
|
||||
Summary: A tool for installing and managing Python packages.
|
||||
Home-page: http://www.pip-installer.org
|
||||
Author: The pip developers
|
||||
Author-email: python-virtualenv@groups.google.com
|
||||
License: MIT
|
||||
Description:
|
||||
Project Info
|
||||
============
|
||||
|
||||
* Project Page: https://github.com/pypa/pip
|
||||
* Bug Tracking: https://github.com/pypa/pip/issues
|
||||
* Mailing list: http://groups.google.com/group/python-virtualenv
|
||||
* Docs: http://www.pip-installer.org
|
||||
* IRC: #pip.
|
||||
|
||||
|
||||
Quickstart
|
||||
==========
|
||||
|
||||
Install a package:
|
||||
|
||||
::
|
||||
|
||||
$ pip install SomePackage==1.0
|
||||
[...]
|
||||
Successfully installed SomePackage
|
||||
|
||||
Show what files were installed:
|
||||
|
||||
::
|
||||
|
||||
$ pip show --files SomePackage
|
||||
Name: SomePackage
|
||||
Version: 1.0
|
||||
Location: /my/env/lib/pythonx.x/site-packages
|
||||
Files:
|
||||
../somepackage/__init__.py
|
||||
[...]
|
||||
|
||||
List what packages are outdated:
|
||||
|
||||
::
|
||||
|
||||
$ pip list --outdated
|
||||
SomePackage (Current: 1.0 Latest: 2.0)
|
||||
|
||||
Upgrade a package:
|
||||
|
||||
::
|
||||
|
||||
$ pip install --upgrade SomePackage
|
||||
[...]
|
||||
Found existing installation: SomePackage 1.0
|
||||
Uninstalling SomePackage:
|
||||
Successfully uninstalled SomePackage
|
||||
Running setup.py install for SomePackage
|
||||
Successfully installed SomePackage
|
||||
|
||||
Uninstall a package:
|
||||
|
||||
::
|
||||
|
||||
$ pip uninstall SomePackage
|
||||
Uninstalling SomePackage:
|
||||
/my/env/lib/pythonx.x/site-packages/somepackage
|
||||
Proceed (y/n)? y
|
||||
Successfully uninstalled SomePackage
|
||||
|
||||
|
||||
Changelog
|
||||
=========
|
||||
|
||||
1.3.1 (2013-03-08)
|
||||
------------------
|
||||
|
||||
* Fixed a major backward incompatible change of parsing URLs to externally
|
||||
hosted packages that got accidentily included in 1.3.
|
||||
|
||||
1.3 (2013-03-07)
|
||||
----------------
|
||||
|
||||
* SSL Cert Verification; Make https the default for PyPI access.
|
||||
Thanks James Cleveland, Giovanni Bajo, Marcus Smith and many others (Pull #789).
|
||||
|
||||
* Added "pip list" for listing installed packages and the latest version
|
||||
available. Thanks Rafael Caricio, Miguel Araujo, Dmitry Gladkov (Pull #752)
|
||||
|
||||
* Fixed security issues with pip's use of temp build directories.
|
||||
Thanks David (d1b) and Thomas Guttler. (Pull #780)
|
||||
|
||||
* Improvements to sphinx docs and cli help. (Pull #773)
|
||||
|
||||
* Fixed issue #707, dealing with OS X temp dir handling, which was causing
|
||||
global NumPy installs to fail. (Pull #768)
|
||||
|
||||
* Split help output into general vs command-specific option groups.
|
||||
Thanks Georgi Valkov. (Pull #744; Pull #721 contains preceding refactor)
|
||||
|
||||
* Fixed dependency resolution when installing from archives with uppercase
|
||||
project names. (Pull #724)
|
||||
|
||||
* Fixed problem where re-installs always occurred when using file:// find-links.
|
||||
(Pulls #683/#702)
|
||||
|
||||
* "pip install -v" now shows the full download url, not just the archive name.
|
||||
Thanks Marc Abramowitz (Pull #687)
|
||||
|
||||
* Fix to prevent unnecessary PyPI redirects. Thanks Alex Gronholm (Pull #695)
|
||||
|
||||
* Fixed issue #670 - install failure under Python 3 when the same version
|
||||
of a package is found under 2 different URLs. Thanks Paul Moore (Pull #671)
|
||||
|
||||
* Fix git submodule recursive updates. Thanks Roey Berman. (Pulls #674)
|
||||
|
||||
* Explicitly ignore rel='download' links while looking for html pages.
|
||||
Thanks Maxime R. (Pull #677)
|
||||
|
||||
* --user/--upgrade install options now work together. Thanks 'eevee' for
|
||||
discovering the problem. (Pull #705)
|
||||
|
||||
* Added check in ``install --download`` to prevent re-downloading if the target
|
||||
file already exists. Thanks Andrey Bulgakov. (Pull #669)
|
||||
|
||||
* Added support for bare paths (including relative paths) as argument to
|
||||
`--find-links`. Thanks Paul Moore for draft patch.
|
||||
|
||||
* Added support for --no-index in requirements files.
|
||||
|
||||
* Added "pip show" command to get information about an installed package.
|
||||
Fixes #131. Thanks Kelsey Hightower and Rafael Caricio.
|
||||
|
||||
* Added `--root` option for "pip install" to specify root directory. Behaves
|
||||
like the same option in distutils but also plays nice with pip's egg-info.
|
||||
Thanks Przemek Wrzos. (Issue #253 / Pull #693)
|
||||
|
||||
1.2.1 (2012-09-06)
|
||||
------------------
|
||||
|
||||
* Fixed a regression introduced in 1.2 about raising an exception when
|
||||
not finding any files to uninstall in the current environment. Thanks for
|
||||
the fix, Marcus Smith.
|
||||
|
||||
1.2 (2012-09-01)
|
||||
----------------
|
||||
|
||||
* **Dropped support for Python 2.4** The minimum supported Python version is
|
||||
now Python 2.5.
|
||||
|
||||
* Fixed issue #605 - pypi mirror support broken on some DNS responses. Thanks
|
||||
philwhin.
|
||||
|
||||
* Fixed issue #355 - pip uninstall removes files it didn't install. Thanks
|
||||
pjdelport.
|
||||
|
||||
* Fixed issues #493, #494, #440, and #573 related to improving support for the
|
||||
user installation scheme. Thanks Marcus Smith.
|
||||
|
||||
* Write failure log to temp file if default location is not writable. Thanks
|
||||
andreigc.
|
||||
|
||||
* Pull in submodules for git editable checkouts. Fixes #289 and #421. Thanks
|
||||
Hsiaoming Yang and Markus Hametner.
|
||||
|
||||
* Use a temporary directory as the default build location outside of a
|
||||
virtualenv. Fixes issues #339 and #381. Thanks Ben Rosser.
|
||||
|
||||
* Added support for specifying extras with local editables. Thanks Nick
|
||||
Stenning.
|
||||
|
||||
* Added ``--egg`` flag to request egg-style rather than flat installation. Refs
|
||||
issue #3. Thanks Kamal Bin Mustafa.
|
||||
|
||||
* Fixed issue #510 - prevent e.g. ``gmpy2-2.0.tar.gz`` from matching a request
|
||||
to ``pip install gmpy``; sdist filename must begin with full project name
|
||||
followed by a dash. Thanks casevh for the report.
|
||||
|
||||
* Fixed issue #504 - allow package URLS to have querystrings. Thanks W.
|
||||
Trevor King.
|
||||
|
||||
* Fixed issue #58 - pip freeze now falls back to non-editable format rather
|
||||
than blowing up if it can't determine the origin repository of an editable.
|
||||
Thanks Rory McCann.
|
||||
|
||||
* Added a `__main__.py` file to enable `python -m pip` on Python versions
|
||||
that support it. Thanks Alexey Luchko.
|
||||
|
||||
* Fixed issue #487 - upgrade from VCS url of project that does exist on
|
||||
index. Thanks Andrew Knapp for the report.
|
||||
|
||||
* Fixed issue #486 - fix upgrade from VCS url of project with no distribution
|
||||
on index. Thanks Andrew Knapp for the report.
|
||||
|
||||
* Fixed issue #427 - clearer error message on a malformed VCS url. Thanks
|
||||
Thomas Fenzl.
|
||||
|
||||
* Added support for using any of the built in guaranteed algorithms in
|
||||
``hashlib`` as a checksum hash.
|
||||
|
||||
* Fixed issue #321 - Raise an exception if current working directory can't be
|
||||
found or accessed.
|
||||
|
||||
* Fixed issue #82 - Removed special casing of the user directory and use the
|
||||
Python default instead.
|
||||
|
||||
* Fixed #436 - Only warn about version conflicts if there is actually one.
|
||||
This re-enables using ``==dev`` in requirements files.
|
||||
|
||||
* Moved tests to be run on Travis CI: http://travis-ci.org/pypa/pip
|
||||
|
||||
* Added a better help formatter.
|
||||
|
||||
1.1 (2012-02-16)
|
||||
----------------
|
||||
|
||||
* Fixed issue #326 - don't crash when a package's setup.py emits UTF-8 and
|
||||
then fails. Thanks Marc Abramowitz.
|
||||
|
||||
* Added ``--target`` option for installing directly to arbitrary directory.
|
||||
Thanks Stavros Korokithakis.
|
||||
|
||||
* Added support for authentication with Subversion repositories. Thanks
|
||||
Qiangning Hong.
|
||||
|
||||
* Fixed issue #315 - ``--download`` now downloads dependencies as well.
|
||||
Thanks Qiangning Hong.
|
||||
|
||||
* Errors from subprocesses will display the current working directory.
|
||||
Thanks Antti Kaihola.
|
||||
|
||||
* Fixed issue #369 - compatibility with Subversion 1.7. Thanks Qiangning
|
||||
Hong. Note that setuptools remains incompatible with Subversion 1.7; to
|
||||
get the benefits of pip's support you must use Distribute rather than
|
||||
setuptools.
|
||||
|
||||
* Fixed issue #57 - ignore py2app-generated OS X mpkg zip files in finder.
|
||||
Thanks Rene Dudfield.
|
||||
|
||||
* Fixed issue #182 - log to ~/Library/Logs/ by default on OS X framework
|
||||
installs. Thanks Dan Callahan for report and patch.
|
||||
|
||||
* Fixed issue #310 - understand version tags without minor version ("py3")
|
||||
in sdist filenames. Thanks Stuart Andrews for report and Olivier Girardot for
|
||||
patch.
|
||||
|
||||
* Fixed issue #7 - Pip now supports optionally installing setuptools
|
||||
"extras" dependencies; e.g. "pip install Paste[openid]". Thanks Matt Maker
|
||||
and Olivier Girardot.
|
||||
|
||||
* Fixed issue #391 - freeze no longer borks on requirements files with
|
||||
--index-url or --find-links. Thanks Herbert Pfennig.
|
||||
|
||||
* Fixed issue #288 - handle symlinks properly. Thanks lebedov for the patch.
|
||||
|
||||
* Fixed issue #49 - pip install -U no longer reinstalls the same versions of
|
||||
packages. Thanks iguananaut for the pull request.
|
||||
|
||||
* Removed ``-E``/``--environment`` option and ``PIP_RESPECT_VIRTUALENV``;
|
||||
both use a restart-in-venv mechanism that's broken, and neither one is
|
||||
useful since every virtualenv now has pip inside it. Replace ``pip -E
|
||||
path/to/venv install Foo`` with ``virtualenv path/to/venv &&
|
||||
path/to/venv/pip install Foo``.
|
||||
|
||||
* Fixed issue #366 - pip throws IndexError when it calls `scraped_rel_links`
|
||||
|
||||
* Fixed issue #22 - pip search should set and return a userful shell status code
|
||||
|
||||
* Fixed issue #351 and #365 - added global ``--exists-action`` command line
|
||||
option to easier script file exists conflicts, e.g. from editable
|
||||
requirements from VCS that have a changed repo URL.
|
||||
|
||||
|
||||
1.0.2 (2011-07-16)
|
||||
------------------
|
||||
|
||||
* Fixed docs issues.
|
||||
* Fixed issue #295 - Reinstall a package when using the ``install -I`` option
|
||||
* Fixed issue #283 - Finds a Git tag pointing to same commit as origin/master
|
||||
* Fixed issue #279 - Use absolute path for path to docs in setup.py
|
||||
* Fixed issue #314 - Correctly handle exceptions on Python3.
|
||||
* Fixed issue #320 - Correctly parse ``--editable`` lines in requirements files
|
||||
|
||||
1.0.1 (2011-04-30)
|
||||
------------------
|
||||
|
||||
* Start to use git-flow.
|
||||
* Fixed issue #274 - `find_command` should not raise AttributeError
|
||||
* Fixed issue #273 - respect Content-Disposition header. Thanks Bradley Ayers.
|
||||
* Fixed issue #233 - pathext handling on Windows.
|
||||
* Fixed issue #252 - svn+svn protocol.
|
||||
* Fixed issue #44 - multiple CLI searches.
|
||||
* Fixed issue #266 - current working directory when running setup.py clean.
|
||||
|
||||
1.0 (2011-04-04)
|
||||
----------------
|
||||
|
||||
* Added Python 3 support! Huge thanks to Vinay Sajip, Vitaly Babiy, Kelsey
|
||||
Hightower, and Alex Gronholm, among others.
|
||||
|
||||
* Download progress only shown on a real TTY. Thanks Alex Morega.
|
||||
|
||||
* Fixed finding of VCS binaries to not be fooled by same-named directories.
|
||||
Thanks Alex Morega.
|
||||
|
||||
* Fixed uninstall of packages from system Python for users of Debian/Ubuntu
|
||||
python-setuptools package (workaround until fixed in Debian and Ubuntu).
|
||||
|
||||
* Added `get-pip.py <https://raw.github.com/pypa/pip/master/contrib/get-pip.py>`_
|
||||
installer. Simply download and execute it, using the Python interpreter of
|
||||
your choice::
|
||||
|
||||
$ curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
|
||||
$ python get-pip.py
|
||||
|
||||
This may have to be run as root.
|
||||
|
||||
.. note::
|
||||
|
||||
Make sure you have `distribute <http://pypi.python.org/pypi/distribute>`_
|
||||
installed before using the installer!
|
||||
|
||||
0.8.3
|
||||
-----
|
||||
|
||||
* Moved main repository to Github: https://github.com/pypa/pip
|
||||
|
||||
* Transferred primary maintenance from Ian to Jannis Leidel, Carl Meyer, Brian Rosner
|
||||
|
||||
* Fixed issue #14 - No uninstall-on-upgrade with URL package. Thanks Oliver Tonnhofer
|
||||
|
||||
* Fixed issue #163 - Egg name not properly resolved. Thanks Igor Sobreira
|
||||
|
||||
* Fixed issue #178 - Non-alphabetical installation of requirements. Thanks Igor Sobreira
|
||||
|
||||
* Fixed issue #199 - Documentation mentions --index instead of --index-url. Thanks Kelsey Hightower
|
||||
|
||||
* Fixed issue #204 - rmtree undefined in mercurial.py. Thanks Kelsey Hightower
|
||||
|
||||
* Fixed bug in Git vcs backend that would break during reinstallation.
|
||||
|
||||
* Fixed bug in Mercurial vcs backend related to pip freeze and branch/tag resolution.
|
||||
|
||||
* Fixed bug in version string parsing related to the suffix "-dev".
|
||||
|
||||
0.8.2
|
||||
-----
|
||||
|
||||
* Avoid redundant unpacking of bundles (from pwaller)
|
||||
|
||||
* Fixed issue #32, #150, #161 - Fixed checking out the correct
|
||||
tag/branch/commit when updating an editable Git requirement.
|
||||
|
||||
* Fixed issue #49 - Added ability to install version control requirements
|
||||
without making them editable, e.g.::
|
||||
|
||||
pip install git+https://github.com/pypa/pip/
|
||||
|
||||
* Fixed issue #175 - Correctly locate build and source directory on Mac OS X.
|
||||
|
||||
* Added ``git+https://`` scheme to Git VCS backend.
|
||||
|
||||
0.8.1
|
||||
-----
|
||||
|
||||
* Added global --user flag as shortcut for --install-option="--user". From
|
||||
Ronny Pfannschmidt.
|
||||
|
||||
* Added support for `PyPI mirrors <http://pypi.python.org/mirrors>`_ as
|
||||
defined in `PEP 381 <http://www.python.org/dev/peps/pep-0381/>`_, from
|
||||
Jannis Leidel.
|
||||
|
||||
* Fixed issue #138 - Git revisions ignored. Thanks John-Scott Atlakson.
|
||||
|
||||
* Fixed issue #95 - Initial editable install of github package from a tag fails. Thanks John-Scott Atlakson.
|
||||
|
||||
* Fixed issue #107 - Can't install if a directory in cwd has the same name as the package you're installing.
|
||||
|
||||
* Fixed issue #39 - --install-option="--prefix=~/.local" ignored with -e.
|
||||
Thanks Ronny Pfannschmidt and Wil Tan.
|
||||
|
||||
|
||||
|
||||
0.8
|
||||
---
|
||||
|
||||
* Track which ``build/`` directories pip creates, never remove directories
|
||||
it doesn't create. From Hugo Lopes Tavares.
|
||||
|
||||
* Pip now accepts file:// index URLs. Thanks Dave Abrahams.
|
||||
|
||||
* Various cleanup to make test-running more consistent and less fragile.
|
||||
Thanks Dave Abrahams.
|
||||
|
||||
* Real Windows support (with passing tests). Thanks Dave Abrahams.
|
||||
|
||||
* ``pip-2.7`` etc. scripts are created (Python-version specific scripts)
|
||||
|
||||
* ``contrib/build-standalone`` script creates a runnable ``.zip`` form of
|
||||
pip, from Jannis Leidel
|
||||
|
||||
* Editable git repos are updated when reinstalled
|
||||
|
||||
* Fix problem with ``--editable`` when multiple ``.egg-info/`` directories
|
||||
are found.
|
||||
|
||||
* A number of VCS-related fixes for ``pip freeze``, from Hugo Lopes Tavares.
|
||||
|
||||
* Significant test framework changes, from Hugo Lopes Tavares.
|
||||
|
||||
0.7.2
|
||||
-----
|
||||
|
||||
* Set zip_safe=False to avoid problems some people are encountering where
|
||||
pip is installed as a zip file.
|
||||
|
||||
0.7.1
|
||||
-----
|
||||
|
||||
* Fixed opening of logfile with no directory name. Thanks Alexandre Conrad.
|
||||
|
||||
* Temporary files are consistently cleaned up, especially after
|
||||
installing bundles, also from Alex Conrad.
|
||||
|
||||
* Tests now require at least ScriptTest 1.0.3.
|
||||
|
||||
0.7
|
||||
---
|
||||
|
||||
* Fixed uninstallation on Windows
|
||||
* Added ``pip search`` command.
|
||||
* Tab-complete names of installed distributions for ``pip uninstall``.
|
||||
* Support tab-completion when there is a global-option before the
|
||||
subcommand.
|
||||
* Install header files in standard (scheme-default) location when installing
|
||||
outside a virtualenv. Install them to a slightly more consistent
|
||||
non-standard location inside a virtualenv (since the standard location is
|
||||
a non-writable symlink to the global location).
|
||||
* pip now logs to a central location by default (instead of creating
|
||||
``pip-log.txt`` all over the place) and constantly overwrites the
|
||||
file in question. On Unix and Mac OS X this is ``'$HOME/.pip/pip.log'``
|
||||
and on Windows it's ``'%HOME%\\pip\\pip.log'``. You are still able to
|
||||
override this location with the ``$PIP_LOG_FILE`` environment variable.
|
||||
For a complete (appended) logfile use the separate ``'--log'`` command line
|
||||
option.
|
||||
* Fixed an issue with Git that left an editable packge as a checkout of a
|
||||
remote branch, even if the default behaviour would have been fine, too.
|
||||
* Fixed installing from a Git tag with older versions of Git.
|
||||
* Expand "~" in logfile and download cache paths.
|
||||
* Speed up installing from Mercurial repositories by cloning without
|
||||
updating the working copy multiple times.
|
||||
* Fixed installing directly from directories (e.g.
|
||||
``pip install path/to/dir/``).
|
||||
* Fixed installing editable packages with ``svn+ssh`` URLs.
|
||||
* Don't print unwanted debug information when running the freeze command.
|
||||
* Create log file directory automatically. Thanks Alexandre Conrad.
|
||||
* Make test suite easier to run successfully. Thanks Dave Abrahams.
|
||||
* Fixed "pip install ." and "pip install .."; better error for directory
|
||||
without setup.py. Thanks Alexandre Conrad.
|
||||
* Support Debian/Ubuntu "dist-packages" in zip command. Thanks duckx.
|
||||
* Fix relative --src folder. Thanks Simon Cross.
|
||||
* Handle missing VCS with an error message. Thanks Alexandre Conrad.
|
||||
* Added --no-download option to install; pairs with --no-install to separate
|
||||
download and installation into two steps. Thanks Simon Cross.
|
||||
* Fix uninstalling from requirements file containing -f, -i, or
|
||||
--extra-index-url.
|
||||
* Leftover build directories are now removed. Thanks Alexandre Conrad.
|
||||
|
||||
0.6.3
|
||||
-----
|
||||
|
||||
* Fixed import error on Windows with regard to the backwards compatibility
|
||||
package
|
||||
|
||||
0.6.2
|
||||
-----
|
||||
|
||||
* Fixed uninstall when /tmp is on a different filesystem.
|
||||
|
||||
* Fixed uninstallation of distributions with namespace packages.
|
||||
|
||||
0.6.1
|
||||
-----
|
||||
|
||||
* Added support for the ``https`` and ``http-static`` schemes to the
|
||||
Mercurial and ``ftp`` scheme to the Bazaar backend.
|
||||
|
||||
* Fixed uninstallation of scripts installed with easy_install.
|
||||
|
||||
* Fixed an issue in the package finder that could result in an
|
||||
infinite loop while looking for links.
|
||||
|
||||
* Fixed issue with ``pip bundle`` and local files (which weren't being
|
||||
copied into the bundle), from Whit Morriss.
|
||||
|
||||
0.6
|
||||
---
|
||||
|
||||
* Add ``pip uninstall`` and uninstall-before upgrade (from Carl
|
||||
Meyer).
|
||||
|
||||
* Extended configurability with config files and environment variables.
|
||||
|
||||
* Allow packages to be upgraded, e.g., ``pip install Package==0.1``
|
||||
then ``pip install Package==0.2``.
|
||||
|
||||
* Allow installing/upgrading to Package==dev (fix "Source version does not
|
||||
match target version" errors).
|
||||
|
||||
* Added command and option completion for bash and zsh.
|
||||
|
||||
* Extended integration with virtualenv by providing an option to
|
||||
automatically use an active virtualenv and an option to warn if no active
|
||||
virtualenv is found.
|
||||
|
||||
* Fixed a bug with pip install --download and editable packages, where
|
||||
directories were being set with 0000 permissions, now defaults to 755.
|
||||
|
||||
* Fixed uninstallation of easy_installed console_scripts.
|
||||
|
||||
* Fixed uninstallation on Mac OS X Framework layout installs
|
||||
|
||||
* Fixed bug preventing uninstall of editables with source outside venv.
|
||||
|
||||
* Creates download cache directory if not existing.
|
||||
|
||||
0.5.1
|
||||
-----
|
||||
|
||||
* Fixed a couple little bugs, with git and with extensions.
|
||||
|
||||
0.5
|
||||
---
|
||||
|
||||
* Added ability to override the default log file name (``pip-log.txt``)
|
||||
with the environmental variable ``$PIP_LOG_FILE``.
|
||||
|
||||
* Made the freeze command print installed packages to stdout instead of
|
||||
writing them to a file. Use simple redirection (e.g.
|
||||
``pip freeze > stable-req.txt``) to get a file with requirements.
|
||||
|
||||
* Fixed problem with freezing editable packages from a Git repository.
|
||||
|
||||
* Added support for base URLs using ``<base href='...'>`` when parsing
|
||||
HTML pages.
|
||||
|
||||
* Fixed installing of non-editable packages from version control systems.
|
||||
|
||||
* Fixed issue with Bazaar's bzr+ssh scheme.
|
||||
|
||||
* Added --download-dir option to the install command to retrieve package
|
||||
archives. If given an editable package it will create an archive of it.
|
||||
|
||||
* Added ability to pass local file and directory paths to ``--find-links``,
|
||||
e.g. ``--find-links=file:///path/to/my/private/archive``
|
||||
|
||||
* Reduced the amount of console log messages when fetching a page to find a
|
||||
distribution was problematic. The full messages can be found in pip-log.txt.
|
||||
|
||||
* Added ``--no-deps`` option to install ignore package dependencies
|
||||
|
||||
* Added ``--no-index`` option to ignore the package index (PyPI) temporarily
|
||||
|
||||
* Fixed installing editable packages from Git branches.
|
||||
|
||||
* Fixes freezing of editable packages from Mercurial repositories.
|
||||
|
||||
* Fixed handling read-only attributes of build files, e.g. of Subversion and
|
||||
Bazaar on Windows.
|
||||
|
||||
* When downloading a file from a redirect, use the redirected
|
||||
location's extension to guess the compression (happens specifically
|
||||
when redirecting to a bitbucket.org tip.gz file).
|
||||
|
||||
* Editable freeze URLs now always use revision hash/id rather than tip or
|
||||
branch names which could move.
|
||||
|
||||
* Fixed comparison of repo URLs so incidental differences such as
|
||||
presence/absence of final slashes or quoted/unquoted special
|
||||
characters don't trigger "ignore/switch/wipe/backup" choice.
|
||||
|
||||
* Fixed handling of attempt to checkout editable install to a
|
||||
non-empty, non-repo directory.
|
||||
|
||||
0.4
|
||||
---
|
||||
|
||||
* Make ``-e`` work better with local hg repositories
|
||||
|
||||
* Construct PyPI URLs the exact way easy_install constructs URLs (you
|
||||
might notice this if you use a custom index that is
|
||||
slash-sensitive).
|
||||
|
||||
* Improvements on Windows (from `Ionel Maries Cristian
|
||||
<http://ionelmc.wordpress.com/>`_).
|
||||
|
||||
* Fixed problem with not being able to install private git repositories.
|
||||
|
||||
* Make ``pip zip`` zip all its arguments, not just the first.
|
||||
|
||||
* Fix some filename issues on Windows.
|
||||
|
||||
* Allow the ``-i`` and ``--extra-index-url`` options in requirements
|
||||
files.
|
||||
|
||||
* Fix the way bundle components are unpacked and moved around, to make
|
||||
bundles work.
|
||||
|
||||
* Adds ``-s`` option to allow the access to the global site-packages if a
|
||||
virtualenv is to be created.
|
||||
|
||||
* Fixed support for Subversion 1.6.
|
||||
|
||||
0.3.1
|
||||
-----
|
||||
|
||||
* Improved virtualenv restart and various path/cleanup problems on win32.
|
||||
|
||||
* Fixed a regression with installing from svn repositories (when not
|
||||
using ``-e``).
|
||||
|
||||
* Fixes when installing editable packages that put their source in a
|
||||
subdirectory (like ``src/``).
|
||||
|
||||
* Improve ``pip -h``
|
||||
|
||||
0.3
|
||||
---
|
||||
|
||||
* Added support for editable packages created from Git, Mercurial and Bazaar
|
||||
repositories and ability to freeze them. Refactored support for version
|
||||
control systems.
|
||||
|
||||
* Do not use ``sys.exit()`` from inside the code, instead use a
|
||||
return. This will make it easier to invoke programmatically.
|
||||
|
||||
* Put the install record in ``Package.egg-info/installed-files.txt``
|
||||
(previously they went in
|
||||
``site-packages/install-record-Package.txt``).
|
||||
|
||||
* Fix a problem with ``pip freeze`` not including ``-e svn+`` when an
|
||||
svn structure is peculiar.
|
||||
|
||||
* Allow ``pip -E`` to work with a virtualenv that uses a different
|
||||
version of Python than the parent environment.
|
||||
|
||||
* Fixed Win32 virtualenv (``-E``) option.
|
||||
|
||||
* Search the links passed in with ``-f`` for packages.
|
||||
|
||||
* Detect zip files, even when the file doesn't have a ``.zip``
|
||||
extension and it is served with the wrong Content-Type.
|
||||
|
||||
* Installing editable from existing source now works, like ``pip
|
||||
install -e some/path/`` will install the package in ``some/path/``.
|
||||
Most importantly, anything that package requires will also be
|
||||
installed by pip.
|
||||
|
||||
* Add a ``--path`` option to ``pip un/zip``, so you can avoid zipping
|
||||
files that are outside of where you expect.
|
||||
|
||||
* Add ``--simulate`` option to ``pip zip``.
|
||||
|
||||
0.2.1
|
||||
-----
|
||||
|
||||
* Fixed small problem that prevented using ``pip.py`` without actually
|
||||
installing pip.
|
||||
|
||||
* Fixed ``--upgrade``, which would download and appear to install
|
||||
upgraded packages, but actually just reinstall the existing package.
|
||||
|
||||
* Fixed Windows problem with putting the install record in the right
|
||||
place, and generating the ``pip`` script with Setuptools.
|
||||
|
||||
* Download links that include embedded spaces or other unsafe
|
||||
characters (those characters get %-encoded).
|
||||
|
||||
* Fixed use of URLs in requirement files, and problems with some blank
|
||||
lines.
|
||||
|
||||
* Turn some tar file errors into warnings.
|
||||
|
||||
0.2
|
||||
---
|
||||
|
||||
* Renamed to ``pip``, and to install you now do ``pip install
|
||||
PACKAGE``
|
||||
|
||||
* Added command ``pip zip PACKAGE`` and ``pip unzip PACKAGE``. This
|
||||
is particularly intended for Google App Engine to manage libraries
|
||||
to stay under the 1000-file limit.
|
||||
|
||||
* Some fixes to bundles, especially editable packages and when
|
||||
creating a bundle using unnamed packages (like just an svn
|
||||
repository without ``#egg=Package``).
|
||||
|
||||
0.1.4
|
||||
-----
|
||||
|
||||
* Added an option ``--install-option`` to pass options to pass
|
||||
arguments to ``setup.py install``
|
||||
|
||||
* ``.svn/`` directories are no longer included in bundles, as these
|
||||
directories are specific to a version of svn -- if you build a
|
||||
bundle on a system with svn 1.5, you can't use the checkout on a
|
||||
system with svn 1.4. Instead a file ``svn-checkout.txt`` is
|
||||
included that notes the original location and revision, and the
|
||||
command you can use to turn it back into an svn checkout. (Probably
|
||||
unpacking the bundle should, maybe optionally, recreate this
|
||||
information -- but that is not currently implemented, and it would
|
||||
require network access.)
|
||||
|
||||
* Avoid ambiguities over project name case, where for instance
|
||||
MyPackage and mypackage would be considered different packages.
|
||||
This in particular caused problems on Macs, where ``MyPackage/`` and
|
||||
``mypackage/`` are the same directory.
|
||||
|
||||
* Added support for an environmental variable
|
||||
``$PIP_DOWNLOAD_CACHE`` which will cache package downloads, so
|
||||
future installations won't require large downloads. Network access
|
||||
is still required, but just some downloads will be avoided when
|
||||
using this.
|
||||
|
||||
0.1.3
|
||||
-----
|
||||
|
||||
* Always use ``svn checkout`` (not ``export``) so that
|
||||
``tag_svn_revision`` settings give the revision of the package.
|
||||
|
||||
* Don't update checkouts that came from ``.pybundle`` files.
|
||||
|
||||
0.1.2
|
||||
-----
|
||||
|
||||
* Improve error text when there are errors fetching HTML pages when
|
||||
seeking packages.
|
||||
|
||||
* Improve bundles: include empty directories, make them work with
|
||||
editable packages.
|
||||
|
||||
* If you use ``-E env`` and the environment ``env/`` doesn't exist, a
|
||||
new virtual environment will be created.
|
||||
|
||||
* Fix ``dependency_links`` for finding packages.
|
||||
|
||||
0.1.1
|
||||
-----
|
||||
|
||||
* Fixed a NameError exception when running pip outside of a
|
||||
virtualenv environment.
|
||||
|
||||
* Added HTTP proxy support (from Prabhu Ramachandran)
|
||||
|
||||
* Fixed use of ``hashlib.md5`` on python2.5+ (also from Prabhu
|
||||
Ramachandran)
|
||||
|
||||
0.1
|
||||
---
|
||||
|
||||
* Initial release
|
||||
|
||||
Keywords: easy_install distutils setuptools egg virtualenv
|
||||
Platform: UNKNOWN
|
||||
Classifier: Development Status :: 5 - Production/Stable
|
||||
Classifier: Intended Audience :: Developers
|
||||
Classifier: License :: OSI Approved :: MIT License
|
||||
Classifier: Topic :: Software Development :: Build Tools
|
||||
Classifier: Programming Language :: Python :: 2
|
||||
Classifier: Programming Language :: Python :: 2.5
|
||||
Classifier: Programming Language :: Python :: 2.6
|
||||
Classifier: Programming Language :: Python :: 2.7
|
||||
Classifier: Programming Language :: Python :: 3
|
||||
Classifier: Programming Language :: Python :: 3.1
|
||||
Classifier: Programming Language :: Python :: 3.2
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
Project Info
|
||||
============
|
||||
|
||||
* Project Page: https://github.com/pypa/pip
|
||||
* Bug Tracking: https://github.com/pypa/pip/issues
|
||||
* Mailing list: http://groups.google.com/group/python-virtualenv
|
||||
* Docs: http://www.pip-installer.org
|
||||
* IRC: #pip.
|
||||
Vendored
-131
@@ -1,131 +0,0 @@
|
||||
============
|
||||
Cookbook
|
||||
============
|
||||
|
||||
.. _`Requirements Files`:
|
||||
|
||||
Requirements Files
|
||||
******************
|
||||
|
||||
A key idea in pip is that package versions listed in requirement files (or as :ref:`pip install` arguments),
|
||||
have precedence over those that are located during the normal dependency resolution process that uses "install_requires" metadata.
|
||||
|
||||
This allows users to be in control of specifying an environment of packages that are known to work together.
|
||||
|
||||
Instead of running something like ``pip install MyApp`` and getting whatever libraries come along,
|
||||
you'd run ``pip install -r requirements.txt`` where "requirements.txt" contains something like::
|
||||
|
||||
MyApp
|
||||
Framework==0.9.4
|
||||
Library>=0.2
|
||||
|
||||
Regardless of what MyApp lists in ``setup.py``, you'll get a specific version
|
||||
of Framework (0.9.4) and at least the 0.2 version of
|
||||
Library. Additionally, you can add optional libraries and support tools that MyApp doesn't strictly
|
||||
require, giving people a set of recommended libraries.
|
||||
|
||||
Requirement files are intended to exhaust an environment and to be *flat*.
|
||||
Maybe ``MyApp`` requires ``Framework``, and ``Framework`` requires ``Library``.
|
||||
It is encouraged to still list all these in a single requirement file.
|
||||
It is the nature of Python programs that there are implicit bindings *directly*
|
||||
between MyApp and Library. For instance, Framework might expose one
|
||||
of Library's objects, and so if Library is updated it might directly
|
||||
break MyApp. If that happens you can update the requirements file to
|
||||
force an earlier version of Library, and you can do that without
|
||||
having to re-release MyApp at all.
|
||||
|
||||
To create a new requirements file from a known working environment, use::
|
||||
|
||||
$ pip freeze > stable-req.txt
|
||||
|
||||
This will write a listing of *all* installed libraries to ``stable-req.txt``
|
||||
with exact versions for every library.
|
||||
|
||||
For more information, see:
|
||||
|
||||
* :ref:`Requirements File Format`
|
||||
* :ref:`pip freeze`
|
||||
|
||||
|
||||
.. _`Downloading Archives`:
|
||||
|
||||
Downloading archives
|
||||
********************
|
||||
|
||||
pip allows you to *just* download the source archives for your requirements, without installing anything and without regard to what's already installed.
|
||||
|
||||
::
|
||||
|
||||
$ pip install --download <DIR> -r requirements.txt
|
||||
|
||||
or, for a specific package::
|
||||
|
||||
$ pip install --download <DIR> SomePackage
|
||||
|
||||
|
||||
Unpacking archives
|
||||
******************
|
||||
|
||||
pip allows you to *just* unpack archives to a build directory without installing them to site-packages. This can be useful to troubleshoot install errors or to inspect what is being installed.
|
||||
|
||||
::
|
||||
|
||||
$ pip install --no-install SomePackage
|
||||
|
||||
If you're in a virtualenv, the build dir is ``<virtualenv path>/build``. Otherwise, it's ``<OS temp dir>/pip-build-<username>``
|
||||
|
||||
Afterwards, to finish the job of installing unpacked archives, run::
|
||||
|
||||
$ pip install --no-download SomePackage
|
||||
|
||||
|
||||
|
||||
.. _`Fast & Local Installs`:
|
||||
|
||||
Fast & Local Installs
|
||||
*********************
|
||||
|
||||
Often, you will want a fast install from local archives, without probing PyPI.
|
||||
|
||||
First, :ref:`download the archives <Downloading Archives>` that fulfill your requirements::
|
||||
|
||||
$ pip install --download <DIR> -r requirements.txt
|
||||
|
||||
Then, install using :ref:`--find-links <--find-links>` and :ref:`--no-index <--no-index>`::
|
||||
|
||||
$ pip install --no-index --find-links=[file://]<DIR> -r requirements.txt
|
||||
|
||||
|
||||
|
||||
"Non-recursive" upgrades
|
||||
************************
|
||||
|
||||
``pip install ---upgrade`` is currently written to perform a "recursive upgrade".
|
||||
|
||||
E.g. supposing:
|
||||
|
||||
* `SomePackage-1.0` requires `AnotherPackage>=1.0`
|
||||
* `SomePackage-2.0` requires `AnotherPackage>=1.0` and `OneMorePoject==1.0`
|
||||
* `SomePackage-1.0` and `AnotherPackage-1.0` are currently installed
|
||||
* `SomePackage-2.0` and `AnotherPackage-2.0` are the latest versions available on PyPI.
|
||||
|
||||
Running ``pip install ---upgrade SomePackage`` would upgrade `SomePackage` *and* `AnotherPackage`
|
||||
despite `AnotherPackage` already being satisifed.
|
||||
|
||||
If you would like to perform a "non-recursive upgrade" perform these 2 steps::
|
||||
|
||||
pip install --upgrade --no-deps SomePackage
|
||||
pip install SomePackage
|
||||
|
||||
The first line will upgrade `SomePackage`, but not dependencies like `AnotherPackage`. The 2nd line will fill in new dependencies like `OneMorePackage`.
|
||||
|
||||
|
||||
Ensuring Repeatability
|
||||
**********************
|
||||
|
||||
Three things are required to fully guarantee a repeatable installation using requirements files.
|
||||
|
||||
1. The requirements file was generated by ``pip freeze`` or you're sure it only contains requirements that specify a specific version.
|
||||
2. The installation is performed using :ref:`--no-deps <install_--no-deps>`. This guarantees that only what is explicitly listed in the requirements file is installed.
|
||||
3. The installation is performed against an index or find-links location that is guaranteed to *not* allow archives to be changed and updated without a version increase.
|
||||
|
||||
-121
@@ -1,121 +0,0 @@
|
||||
===========
|
||||
Development
|
||||
===========
|
||||
|
||||
Pull Requests
|
||||
=============
|
||||
|
||||
Submit Pull Requests against the `develop` branch.
|
||||
|
||||
Provide a good description of what you're doing and why.
|
||||
|
||||
Provide tests that cover your changes and try to run the tests locally first.
|
||||
|
||||
Automated Testing
|
||||
=================
|
||||
|
||||
All pull requests and merges to 'develop' branch are tested in `Travis <https://travis-ci.org/>`_
|
||||
based on our `.travis.yml file <https://github.com/pypa/pip/blob/develop/.travis.yml>`_.
|
||||
|
||||
Usually, a link to your specific travis build appears in pull requests, but if not,
|
||||
you can find it on our `travis pull requests page <https://travis-ci.org/pypa/pip/pull_requests>`_
|
||||
|
||||
The only way to trigger Travis to run again for a pull request, is to submit another change to the pull branch.
|
||||
|
||||
We also have Jenkins CI that runs regularly for certain python versions on windows and centos.
|
||||
|
||||
Running tests
|
||||
=============
|
||||
|
||||
OS Requirements: subversion, bazaar, git, and mercurial.
|
||||
|
||||
Python Requirements: nose, virtualenv, scripttest, and mock
|
||||
|
||||
Ways to run the tests locally:
|
||||
|
||||
::
|
||||
|
||||
$ python setup.py test # Using the setuptools test plugin
|
||||
$ nosetests # Using nosetests directly
|
||||
$ tox # Using tox against pip's tox.ini
|
||||
|
||||
|
||||
Getting Involved
|
||||
================
|
||||
|
||||
The pip project welcomes help in the following ways:
|
||||
|
||||
- Making Pull Requests for code, tests, or docs.
|
||||
- Commenting on open issues and pull requests.
|
||||
- Helping to answer questions on the mailing list.
|
||||
|
||||
If you want to become an official maintainer, start by helping out.
|
||||
|
||||
Later, when you think you're ready, get in touch with one of the maintainers,
|
||||
and they will initiate a vote.
|
||||
|
||||
Release Process
|
||||
===============
|
||||
|
||||
This process includes virtualenv, since pip releases necessitate a virtualenv release.
|
||||
|
||||
:<oldp>/<newp>: refers to the old and new versions of pip.
|
||||
:<oldv>/<newv>: refers to the old and new versions of virtualenv.
|
||||
|
||||
1. Upgrade distribute, if needed:
|
||||
|
||||
#. Upgrade distribute in ``virtualenv:develop`` using the :ref:`Refresh virtualenv` process.
|
||||
#. Create a pull request against ``pip:develop`` with a modified ``.travis.yml`` file that installs virtualenv from ``virtualenv:develop``, to confirm the travis builds are still passing.
|
||||
|
||||
2. Create Release branches:
|
||||
|
||||
#. Create ``pip:<newp>`` branch.
|
||||
#. In ``pip:develop``, change ``pip.version`` to '<newp>.post1'.
|
||||
#. Create ``virtualenv:<newv>`` branch.
|
||||
#. In ``virtualenv:develop``, change ``virtualenv.version`` to '<newv>.post1'.
|
||||
|
||||
3. Prepare "rcX":
|
||||
|
||||
#. In ``pip:<newp>``, change ``pip.version`` to '<newp>rcX', and tag with '<newp>rcX'.
|
||||
#. Build a pip sdist from ``pip:<newp>``, and build it into ``virtualenv:<newv>`` using the :ref:`Refresh virtualenv` process.
|
||||
#. In ``virtualenv:<newv>``, change ``virtualenv.version`` to '<newv>rcX', and tag with '<newv>rcX'.
|
||||
|
||||
4. Announce ``pip-<newp>rcX`` and ``virtualenv-<newv>rcX`` with the :ref:`RC Install Instructions` and elicit feedback.
|
||||
|
||||
5. Apply fixes to 'rcX':
|
||||
|
||||
#. Apply fixes to ``pip:<newp>`` and ``virtualenv:<newv>``
|
||||
#. Periodically merge fixes to ``pip:develop`` and ``virtualenv:develop``
|
||||
|
||||
6. Repeat #4 thru #6 if needed.
|
||||
|
||||
7. Final Release:
|
||||
|
||||
#. In ``pip:<newp>``, change ``pip.version`` to '<newp>', and tag with '<newp>'.
|
||||
#. Merge ``pip:<newp>`` to ``pip:master``.
|
||||
#. Build a pip sdist from ``pip:<newp>``, and load it into ``virtualenv:<newv>`` using the :ref:`Refresh virtualenv` process.
|
||||
#. Merge ``vitualenv:<newv>`` to ``virtualenv:develop``.
|
||||
#. In ``virtualenv:<newv>``, change ``virtualenv.version`` to '<newv>', and tag with '<newv>'.
|
||||
#. Merge ``virtualenv:<newp>`` to ``virtualenv:master``
|
||||
#. Build and upload pip and virtualenv sdists to PyPI.
|
||||
|
||||
.. _`Refresh virtualenv`:
|
||||
|
||||
Refresh virtualenv
|
||||
++++++++++++++++++
|
||||
|
||||
#. Set the embedded versions of pip, distribute and setuptools in ``bin/refresh-support-files.py``
|
||||
#. Additionally, set the version of distribute in ``virtualenv_embedded/distribute_setup.py``, and setuptools in ``virtualenv_embedded/ez_setup.py``
|
||||
#. Run ``bin/refresh-support-files.py`` to download the latest versions.
|
||||
When specifying a beta of pip not on pypi, the last part of this script will fail. In this case, the pip sdist needs to be placed manually into ``virtualenv_support``.
|
||||
#. Run ``bin/rebuild-script.py`` to rebuild virtualenv based on the latest versions.
|
||||
|
||||
|
||||
.. _`RC Install Instructions`:
|
||||
|
||||
RC Install Instructions
|
||||
+++++++++++++++++++++++
|
||||
|
||||
#. Download and unpack ``https://github.com/pypa/virtualenv/archive/<newv>rcX.tar.gz``
|
||||
#. Run: ``python virtualenv-<newv>rcX/virtualenv.py myVE``
|
||||
#. ``myVE/bin/pip`` will be the <newp>rcX version of pip.
|
||||
Vendored
-25
@@ -1,25 +0,0 @@
|
||||
pip
|
||||
===
|
||||
|
||||
A tool for installing and managing Python packages.
|
||||
|
||||
`Mailing list <http://groups.google.com/group/python-virtualenv>`_ ``|``
|
||||
`Issues <https://github.com/pypa/pip/issues>`_ ``|``
|
||||
`Github <https://github.com/pypa/pip>`_ ``|``
|
||||
`PyPI <https://pypi.python.org/pypi/pip/>`_ ``|``
|
||||
irc:#pip
|
||||
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
quickstart
|
||||
installing
|
||||
usage
|
||||
cookbook
|
||||
logic
|
||||
configuration
|
||||
other-tools
|
||||
development
|
||||
news
|
||||
|
||||
Vendored
-93
@@ -1,93 +0,0 @@
|
||||
.. _`Installation`:
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
.. warning::
|
||||
|
||||
Prior to version 1.3, pip did not use SSL for downloading packages from PyPI, and thus left
|
||||
users more vulnerable to security threats. We advise installing at least version 1.3.
|
||||
If you're using `virtualenv <http://www.virtualenv.org>`_ to install pip, we advise installing
|
||||
at least version 1.9, which contains pip version 1.3.
|
||||
|
||||
|
||||
Python & OS Support
|
||||
-------------------
|
||||
|
||||
pip works with CPython versions 2.5, 2.6, 2.7, 3.1, 3.2, 3.3 and also pypy.
|
||||
|
||||
pip works on Unix/Linux, OS X, and Windows.
|
||||
|
||||
|
||||
Using virtualenv
|
||||
----------------
|
||||
|
||||
The easiest way to install and use pip is with `virtualenv
|
||||
<http://www.virtualenv.org>`_, since every virtualenv has pip (and it's dependencies) installed into it
|
||||
automatically.
|
||||
|
||||
This does not require root access or modify your system Python
|
||||
installation. For instance::
|
||||
|
||||
$ virtualenv my_env
|
||||
$ . my_env/bin/activate
|
||||
(my_env)$ pip install SomePackage
|
||||
|
||||
When used in this manner, pip will only affect the active virtual environment.
|
||||
|
||||
See the `virtualenv installation instructions <http://www.virtualenv.org/en/latest/#installation>`_.
|
||||
|
||||
Installing Globally
|
||||
-------------------
|
||||
|
||||
pip can be installed globally in order to manage global packages.
|
||||
Often this requires the installation to be performed as root.
|
||||
|
||||
.. warning::
|
||||
|
||||
We advise against using `easy_install <http://pythonhosted.org/distribute/easy_install.html>`_ to install pip, because easy_install
|
||||
does not download from PyPI over SSL, so the installation might be insecure.
|
||||
Since pip can then be used to install packages (which execute code on
|
||||
your computer), it is better to go through a trusted path.
|
||||
|
||||
|
||||
Requirements
|
||||
++++++++++++
|
||||
|
||||
pip requires either `setuptools <https://pypi.python.org/pypi/setuptools>`_
|
||||
or `distribute <https://pypi.python.org/pypi/distribute>`_.
|
||||
|
||||
See the `Distribute Install Instructions <https://pypi.python.org/pypi/distribute/>`_ or the
|
||||
`Setuptools Install Instructions <https://pypi.python.org/pypi/setuptools#installation-instructions>`_
|
||||
|
||||
If installing pip using a linux package manager, these requirements will be installed for you.
|
||||
|
||||
.. warning::
|
||||
|
||||
If you are using Python 3.X you **must** use distribute; setuptools doesn't
|
||||
support Python 3.X.
|
||||
|
||||
|
||||
Using get-pip
|
||||
+++++++++++++
|
||||
|
||||
After installing the requirements:
|
||||
|
||||
::
|
||||
|
||||
$ curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
|
||||
$ [sudo] python get-pip.py
|
||||
|
||||
|
||||
Installing from source
|
||||
++++++++++++++++++++++
|
||||
|
||||
After installing the requirements:
|
||||
|
||||
::
|
||||
|
||||
$ curl -O https://pypi.python.org/packages/source/p/pip/pip-X.X.tar.gz
|
||||
$ tar xvfz pip-X.X.tar.gz
|
||||
$ cd pip-X.X
|
||||
$ [sudo] python setup.py install
|
||||
|
||||
Vendored
-268
@@ -1,268 +0,0 @@
|
||||
.. _`pip logic`:
|
||||
|
||||
================
|
||||
Internal Details
|
||||
================
|
||||
|
||||
.. _`Requirements File Format`:
|
||||
|
||||
Requirements File Format
|
||||
========================
|
||||
|
||||
Each line of the requirements file indicates something to be installed,
|
||||
and like arguments to :ref:`pip install`, the following forms are supported::
|
||||
|
||||
<requirement specifier>
|
||||
<archive url/path>
|
||||
[-e] <local project path>
|
||||
[-e] <vcs project url>
|
||||
|
||||
See the :ref:`pip install Examples<pip install Examples>` for examples of all these forms.
|
||||
|
||||
A line beginning with ``#`` is treated as a comment and ignored.
|
||||
|
||||
Additionally, the following :ref:`Package Index Options <Package Index Options>` are supported
|
||||
|
||||
* :ref:`-i, --index-url <--index-url>`
|
||||
* :ref:`--extra-index-url <--extra-index-url>`
|
||||
* :ref:`--no-index <--no-index>`
|
||||
* :ref:`-f, --find-links <--find-links>`
|
||||
|
||||
For example, to specify :ref:`--no-index <--no-index>` and 2 :ref:`--find-links <--find-links>` locations:
|
||||
|
||||
::
|
||||
|
||||
--no-index
|
||||
--find-links /my/local/archives
|
||||
--find-links http://some.archives.com/archives
|
||||
|
||||
|
||||
Lastly, if you wish, you can refer to other requirements files, like this::
|
||||
|
||||
-r more_requirements.txt
|
||||
|
||||
.. _`Requirement Specifiers`:
|
||||
|
||||
Requirement Specifiers
|
||||
======================
|
||||
|
||||
pip supports installing from "requirement specifiers" as implemented in
|
||||
`pkg_resources Requirements <http://packages.python.org/distribute/pkg_resources.html#requirement-objects>`_
|
||||
|
||||
Some Examples::
|
||||
|
||||
FooProject >= 1.2
|
||||
Fizzy [foo, bar]
|
||||
PickyThing<1.6,>1.9,!=1.9.6,<2.0a0,==2.4c1
|
||||
SomethingWhoseVersionIDontCareAbout
|
||||
|
||||
|
||||
.. _`VCS Support`:
|
||||
|
||||
VCS Support
|
||||
===========
|
||||
|
||||
pip supports installing from Git, Mercurial, Subversion and Bazaar, and detects the type of VCS using url prefixes: "git+", "hg+", "bzr+", "svn+".
|
||||
|
||||
pip requires a working VCS command on your path: git, hg, svn, or bzr.
|
||||
|
||||
VCS projects can be installed in :ref:`editable mode <editable-installs>` (using the :ref:`--editable <install_--editable>` option) or not.
|
||||
|
||||
* For editable installs, the clone location by default is "<venv path>/src/SomeProject" in virtual environments, and "<cwd>/src/SomeProject" for global installs.
|
||||
The :ref:`--src <install_--src>` option can be used to modify this location.
|
||||
* For non-editable installs, the project is built locally in a temp dir and then installed normally.
|
||||
|
||||
The url suffix "egg=<project name>" is used by pip in it's dependency logic to identify the project prior to pip downloading and analyzing the metadata.
|
||||
|
||||
Git
|
||||
~~~
|
||||
|
||||
pip currently supports cloning over ``git``, ``git+http`` and ``git+ssh``::
|
||||
|
||||
git+git://git.myproject.org/MyProject#egg=MyProject
|
||||
git+http://git.myproject.org/MyProject#egg=MyProject
|
||||
git+ssh://git.myproject.org/MyProject#egg=MyProject
|
||||
|
||||
Passing branch names, a commit hash or a tag name is also possible::
|
||||
|
||||
git://git.myproject.org/MyProject.git@master#egg=MyProject
|
||||
git://git.myproject.org/MyProject.git@v1.0#egg=MyProject
|
||||
git://git.myproject.org/MyProject.git@da39a3ee5e6b4b0d3255bfef95601890afd80709#egg=MyProject
|
||||
|
||||
Mercurial
|
||||
~~~~~~~~~
|
||||
|
||||
The supported schemes are: ``hg+http``, ``hg+https``,
|
||||
``hg+static-http`` and ``hg+ssh``::
|
||||
|
||||
hg+http://hg.myproject.org/MyProject#egg=MyProject
|
||||
hg+https://hg.myproject.org/MyProject#egg=MyProject
|
||||
hg+ssh://hg.myproject.org/MyProject#egg=MyProject
|
||||
|
||||
You can also specify a revision number, a revision hash, a tag name or a local
|
||||
branch name::
|
||||
|
||||
hg+http://hg.myproject.org/MyProject@da39a3ee5e6b#egg=MyProject
|
||||
hg+http://hg.myproject.org/MyProject@2019#egg=MyProject
|
||||
hg+http://hg.myproject.org/MyProject@v1.0#egg=MyProject
|
||||
hg+http://hg.myproject.org/MyProject@special_feature#egg=MyProject
|
||||
|
||||
Subversion
|
||||
~~~~~~~~~~
|
||||
|
||||
pip supports the URL schemes ``svn``, ``svn+svn``, ``svn+http``, ``svn+https``, ``svn+ssh``.
|
||||
You can also give specific revisions to an SVN URL, like::
|
||||
|
||||
svn+svn://svn.myproject.org/svn/MyProject#egg=MyProject
|
||||
svn+http://svn.myproject.org/svn/MyProject/trunk@2019#egg=MyProject
|
||||
|
||||
which will check out revision 2019. ``@{20080101}`` would also check
|
||||
out the revision from 2008-01-01. You can only check out specific
|
||||
revisions using ``-e svn+...``.
|
||||
|
||||
Bazaar
|
||||
~~~~~~
|
||||
|
||||
pip supports Bazaar using the ``bzr+http``, ``bzr+https``, ``bzr+ssh``,
|
||||
``bzr+sftp``, ``bzr+ftp`` and ``bzr+lp`` schemes::
|
||||
|
||||
bzr+http://bzr.myproject.org/MyProject/trunk#egg=MyProject
|
||||
bzr+sftp://user@myproject.org/MyProject/trunk#egg=MyProject
|
||||
bzr+ssh://user@myproject.org/MyProject/trunk#egg=MyProject
|
||||
bzr+ftp://user@myproject.org/MyProject/trunk#egg=MyProject
|
||||
bzr+lp:MyProject#egg=MyProject
|
||||
|
||||
Tags or revisions can be installed like this::
|
||||
|
||||
bzr+https://bzr.myproject.org/MyProject/trunk@2019#egg=MyProject
|
||||
bzr+http://bzr.myproject.org/MyProject/trunk@v1.0#egg=MyProject
|
||||
|
||||
|
||||
Finding Packages
|
||||
================
|
||||
|
||||
pip searches for packages on `PyPI <http://pypi.python.org>`_ using the
|
||||
`http simple interface <http://pypi.python.org/simple>`_,
|
||||
which is documented `here <http://packages.python.org/distribute/easy_install.html#package-index-api>`_
|
||||
and `there <http://www.python.org/dev/peps/pep-0301/>`_
|
||||
|
||||
pip offers a set of :ref:`Package Index Options <Package Index Options>` for modifying how packages are found.
|
||||
|
||||
See the :ref:`pip install Examples<pip install Examples>`.
|
||||
|
||||
|
||||
.. _`SSL Certificate Verification`:
|
||||
|
||||
SSL Certificate Verification
|
||||
============================
|
||||
|
||||
Starting with v1.3, pip provides SSL certificate verification over https, for the purpose
|
||||
of providing secure, certified downloads from PyPI.
|
||||
|
||||
This is supported by default in all Python versions pip supports, except Python 2.5.
|
||||
|
||||
Python 2.5 users can :ref:`install an SSL backport <SSL Backport>`, which provides ssl support for older pythons.
|
||||
Pip does not try to install this automatically because it requires a compiler, which not all systems will have.
|
||||
|
||||
Although not recommended, Python 2.5 users who are unable to install ssl, can use the global option,
|
||||
``--insecure``, to allow access to PyPI w/o attempting SSL certificate verification. This option will only be visible
|
||||
when ssl is not importable. This is *not* a general option.
|
||||
|
||||
|
||||
.. _`SSL Backport`:
|
||||
|
||||
Installing the SSL Backport
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. warning::
|
||||
|
||||
We advise against using ``pip`` itself to install the ssl backport, because it won't be secure
|
||||
until *after* installing ssl. Likewise, `easy_install <http://pythonhosted.org/distribute/easy_install.html>`_ is not advised, because it
|
||||
does not currently support ssl.
|
||||
|
||||
|
||||
1. Download the ssl archive:
|
||||
|
||||
* Using a Browser:
|
||||
|
||||
1. Go to `this url <https://pypi.python.org/pypi/ssl/1.15>`_.
|
||||
2. Confirm the identity of the site is valid.
|
||||
Most browsers provide this information to the left of the URL bar in the form of padlock icon that you can click on to confirm the site is verified.
|
||||
3. Scroll down, and click to download ``ssl-1.15.tar.gz``.
|
||||
|
||||
* Using curl, which supports ssl certificate verification:
|
||||
::
|
||||
|
||||
$ curl -O https://pypi.python.org/packages/source/s/ssl/ssl-1.15.tar.gz
|
||||
|
||||
2. Confirm the md5sum:
|
||||
::
|
||||
$ md5sum ssl-1.15.tar.gz
|
||||
81ea8a1175e437b4c769ae65b3290e0c ssl-1.15.tar.gz
|
||||
|
||||
3. Unpack the archive, and change into the ``ssl-1.15`` directory.
|
||||
4. Run: ``python setup.py install``.
|
||||
|
||||
|
||||
Hash Verification
|
||||
=================
|
||||
|
||||
PyPI provides md5 hashes in the hash fragment of package download urls.
|
||||
|
||||
pip supports checking this, as well as any of the
|
||||
guaranteed hashlib algorithms (sha1, sha224, sha384, sha256, sha512, md5).
|
||||
|
||||
The hash fragment is case sensitive (i.e. sha1 not SHA1).
|
||||
|
||||
This check is only intended to provide basic download corruption protection.
|
||||
It is not intended to provide security against tampering. For that,
|
||||
see :ref:`SSL Certificate Verification`
|
||||
|
||||
|
||||
Download Cache
|
||||
==============
|
||||
|
||||
pip offers a :ref:`--download-cache <install_--download-cache>` option for installs to prevent redundant downloads of archives from PyPI.
|
||||
|
||||
The point of this cache is *not* to circumvent the index crawling process, but to *just* prevent redundant downloads.
|
||||
|
||||
Items are stored in this cache based on the url the archive was found at, not simply the archive name.
|
||||
|
||||
If you want a fast/local install solution that circumvents crawling PyPI, see the :ref:`Fast & Local Installs` Cookbook entry.
|
||||
|
||||
Like all options, :ref:`--download-cache <install_--download-cache>`, can also be set as an environment variable, or placed into the pip config file.
|
||||
See the :ref:`Configuration` section.
|
||||
|
||||
|
||||
.. _`editable-installs`:
|
||||
|
||||
"Editable" Installs
|
||||
===================
|
||||
|
||||
"Editable" installs are fundamentally `"setuptools develop mode" <http://packages.python.org/distribute/setuptools.html#development-mode>`_ installs.
|
||||
|
||||
You can install local projects or VCS projects in "editable" mode::
|
||||
|
||||
$ pip install -e path/to/SomeProject
|
||||
$ pip install -e git+http://repo/my_project.git#egg=SomeProject
|
||||
|
||||
For local projects, the "SomeProject.egg-info" directory is created relative to the project path.
|
||||
This is one advantage over just using ``setup.py develop``, which creates the "egg-info" directly relative the current working directory.
|
||||
|
||||
|
||||
setuptools & pkg_resources
|
||||
==========================
|
||||
|
||||
Internally, pip uses the `setuptools` package, and the `pkg_resources` module, which are available from the project, `Setuptools`_, or it's fork `Distribute`_.
|
||||
|
||||
pip can work with either `Setuptools`_ or `Distribute`_, although for Python 3, `Distribute`_ is required.
|
||||
|
||||
Here are some examples of how pip uses `setuptools` and `pkg_resources`:
|
||||
|
||||
* The core of pip's install process uses the `setuptools`'s "install" command.
|
||||
* Editable ("-e") installs use the `setuptools`'s "develop" command.
|
||||
* pip uses `pkg_resources` for version parsing, for detecting version conflicts, and to determine what projects are installed,
|
||||
|
||||
|
||||
.. _Setuptools: http://pypi.python.org/pypi/setuptools/0.6c11
|
||||
.. _Distribute: http://pypi.python.org/pypi/distribute/
|
||||
Vendored
-12
@@ -1,12 +0,0 @@
|
||||
========
|
||||
News
|
||||
========
|
||||
|
||||
Next Release
|
||||
============
|
||||
|
||||
Beta and final releases of 1.3 are planned for Feb 2013.
|
||||
|
||||
|
||||
.. include:: ../CHANGES.txt
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
"""
|
||||
patch for py25 socket to work with http://pypi.python.org/pypi/ssl/
|
||||
copy-paste from py2.6 stdlib socket.py
|
||||
https://gist.github.com/zed/1347055
|
||||
"""
|
||||
import socket
|
||||
import sys
|
||||
|
||||
_GLOBAL_DEFAULT_TIMEOUT = getattr(socket, '_GLOBAL_DEFAULT_TIMEOUT', object())
|
||||
def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT,
|
||||
source_address=None):
|
||||
"""Connect to *address* and return the socket object.
|
||||
|
||||
Convenience function. Connect to *address* (a 2-tuple ``(host,
|
||||
port)``) and return the socket object. Passing the optional
|
||||
*timeout* parameter will set the timeout on the socket instance
|
||||
before attempting to connect. If no *timeout* is supplied, the
|
||||
global default timeout setting returned by :func:`getdefaulttimeout`
|
||||
is used.
|
||||
"""
|
||||
|
||||
host, port = address
|
||||
err = None
|
||||
for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
|
||||
af, socktype, proto, canonname, sa = res
|
||||
sock = None
|
||||
try:
|
||||
sock = socket.socket(af, socktype, proto)
|
||||
if timeout is not _GLOBAL_DEFAULT_TIMEOUT:
|
||||
sock.settimeout(timeout)
|
||||
if source_address:
|
||||
sock.bind(source_address)
|
||||
sock.connect(sa)
|
||||
return sock
|
||||
|
||||
except socket.error:
|
||||
err = sys.exc_info()[1]
|
||||
if sock is not None:
|
||||
sock.close()
|
||||
|
||||
if err is not None:
|
||||
raise err
|
||||
else:
|
||||
raise socket.error("getaddrinfo returns an empty list")
|
||||
@@ -1,60 +0,0 @@
|
||||
"""The match_hostname() function from Python 3.2, essential when using SSL."""
|
||||
|
||||
import re
|
||||
|
||||
__version__ = '3.2a3'
|
||||
|
||||
class CertificateError(ValueError):
|
||||
pass
|
||||
|
||||
def _dnsname_to_pat(dn):
|
||||
pats = []
|
||||
for frag in dn.split(r'.'):
|
||||
if frag == '*':
|
||||
# When '*' is a fragment by itself, it matches a non-empty dotless
|
||||
# fragment.
|
||||
pats.append('[^.]+')
|
||||
else:
|
||||
# Otherwise, '*' matches any dotless fragment.
|
||||
frag = re.escape(frag)
|
||||
pats.append(frag.replace(r'\*', '[^.]*'))
|
||||
return re.compile(r'\A' + r'\.'.join(pats) + r'\Z', re.IGNORECASE)
|
||||
|
||||
def match_hostname(cert, hostname):
|
||||
"""Verify that *cert* (in decoded format as returned by
|
||||
SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 rules
|
||||
are mostly followed, but IP addresses are not accepted for *hostname*.
|
||||
|
||||
CertificateError is raised on failure. On success, the function
|
||||
returns nothing.
|
||||
"""
|
||||
if not cert:
|
||||
raise ValueError("empty or no certificate")
|
||||
dnsnames = []
|
||||
san = cert.get('subjectAltName', ())
|
||||
for key, value in san:
|
||||
if key == 'DNS':
|
||||
if _dnsname_to_pat(value).match(hostname):
|
||||
return
|
||||
dnsnames.append(value)
|
||||
if not san:
|
||||
# The subject is only checked when subjectAltName is empty
|
||||
for sub in cert.get('subject', ()):
|
||||
for key, value in sub:
|
||||
# XXX according to RFC 2818, the most specific Common Name
|
||||
# must be used.
|
||||
if key == 'commonName':
|
||||
if _dnsname_to_pat(value).match(hostname):
|
||||
return
|
||||
dnsnames.append(value)
|
||||
if len(dnsnames) > 1:
|
||||
raise CertificateError("hostname %r "
|
||||
"doesn't match either of %s"
|
||||
% (hostname, ', '.join(map(repr, dnsnames))))
|
||||
elif len(dnsnames) == 1:
|
||||
raise CertificateError("hostname %r "
|
||||
"doesn't match %r"
|
||||
% (hostname, dnsnames[0]))
|
||||
else:
|
||||
raise CertificateError("no appropriate commonName or "
|
||||
"subjectAltName fields were found")
|
||||
Vendored
-3895
File diff suppressed because it is too large
Load Diff
Vendored
-80
@@ -1,80 +0,0 @@
|
||||
"""shared options and groups"""
|
||||
from optparse import make_option, OptionGroup
|
||||
|
||||
|
||||
def make_option_group(group, parser):
|
||||
"""
|
||||
Return an OptionGroup object
|
||||
group -- assumed to be dict with 'name' and 'options' keys
|
||||
parser -- an optparse Parser
|
||||
"""
|
||||
option_group = OptionGroup(parser, group['name'])
|
||||
for option in group['options']:
|
||||
option_group.add_option(option)
|
||||
return option_group
|
||||
|
||||
###########
|
||||
# options #
|
||||
###########
|
||||
|
||||
index_url = make_option(
|
||||
'-i', '--index-url', '--pypi-url',
|
||||
dest='index_url',
|
||||
metavar='URL',
|
||||
default='https://pypi.python.org/simple/',
|
||||
help='Base URL of Python Package Index (default %default).')
|
||||
|
||||
extra_index_url = make_option(
|
||||
'--extra-index-url',
|
||||
dest='extra_index_urls',
|
||||
metavar='URL',
|
||||
action='append',
|
||||
default=[],
|
||||
help='Extra URLs of package indexes to use in addition to --index-url.')
|
||||
|
||||
no_index = make_option(
|
||||
'--no-index',
|
||||
dest='no_index',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='Ignore package index (only looking at --find-links URLs instead).')
|
||||
|
||||
find_links = make_option(
|
||||
'-f', '--find-links',
|
||||
dest='find_links',
|
||||
action='append',
|
||||
default=[],
|
||||
metavar='url',
|
||||
help="If a url or path to an html file, then parse for links to archives. If a local path or file:// url that's a directory, then look for archives in the directory listing.")
|
||||
|
||||
use_mirrors = make_option(
|
||||
'-M', '--use-mirrors',
|
||||
dest='use_mirrors',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='Use the PyPI mirrors as a fallback in case the main index is down.')
|
||||
|
||||
mirrors = make_option(
|
||||
'--mirrors',
|
||||
dest='mirrors',
|
||||
metavar='URL',
|
||||
action='append',
|
||||
default=[],
|
||||
help='Specific mirror URLs to query when --use-mirrors is used.')
|
||||
|
||||
|
||||
##########
|
||||
# groups #
|
||||
##########
|
||||
|
||||
index_group = {
|
||||
'name': 'Package Index Options',
|
||||
'options': [
|
||||
index_url,
|
||||
extra_index_url,
|
||||
no_index,
|
||||
find_links,
|
||||
use_mirrors,
|
||||
mirrors
|
||||
]
|
||||
}
|
||||
Vendored
-584
@@ -1,584 +0,0 @@
|
||||
import cgi
|
||||
import getpass
|
||||
import hashlib
|
||||
import mimetypes
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import socket
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
from pip.backwardcompat import (xmlrpclib, urllib, urllib2, httplib,
|
||||
urlparse, string_types, ssl)
|
||||
if ssl:
|
||||
from pip.backwardcompat import match_hostname, CertificateError
|
||||
from pip.exceptions import InstallationError, PipError, NoSSLError
|
||||
from pip.util import (splitext, rmtree, format_size, display_path,
|
||||
backup_dir, ask_path_exists, unpack_file,
|
||||
create_download_cache_folder, cache_download)
|
||||
from pip.vcs import vcs
|
||||
from pip.log import logger
|
||||
from pip.locations import default_cert_path
|
||||
|
||||
__all__ = ['xmlrpclib_transport', 'get_file_content', 'urlopen',
|
||||
'is_url', 'url_to_path', 'path_to_url', 'path_to_url2',
|
||||
'geturl', 'is_archive_file', 'unpack_vcs_link',
|
||||
'unpack_file_url', 'is_vcs_url', 'is_file_url', 'unpack_http_url']
|
||||
|
||||
|
||||
xmlrpclib_transport = xmlrpclib.Transport()
|
||||
|
||||
|
||||
def get_file_content(url, comes_from=None):
|
||||
"""Gets the content of a file; it may be a filename, file: URL, or
|
||||
http: URL. Returns (location, content)"""
|
||||
match = _scheme_re.search(url)
|
||||
if match:
|
||||
scheme = match.group(1).lower()
|
||||
if (scheme == 'file' and comes_from
|
||||
and comes_from.startswith('http')):
|
||||
raise InstallationError(
|
||||
'Requirements file %s references URL %s, which is local'
|
||||
% (comes_from, url))
|
||||
if scheme == 'file':
|
||||
path = url.split(':', 1)[1]
|
||||
path = path.replace('\\', '/')
|
||||
match = _url_slash_drive_re.match(path)
|
||||
if match:
|
||||
path = match.group(1) + ':' + path.split('|', 1)[1]
|
||||
path = urllib.unquote(path)
|
||||
if path.startswith('/'):
|
||||
path = '/' + path.lstrip('/')
|
||||
url = path
|
||||
else:
|
||||
## FIXME: catch some errors
|
||||
resp = urlopen(url)
|
||||
return geturl(resp), resp.read()
|
||||
try:
|
||||
f = open(url)
|
||||
content = f.read()
|
||||
except IOError:
|
||||
e = sys.exc_info()[1]
|
||||
raise InstallationError('Could not open requirements file: %s' % str(e))
|
||||
else:
|
||||
f.close()
|
||||
return url, content
|
||||
|
||||
|
||||
_scheme_re = re.compile(r'^(http|https|file):', re.I)
|
||||
_url_slash_drive_re = re.compile(r'/*([a-z])\|', re.I)
|
||||
|
||||
class VerifiedHTTPSConnection(httplib.HTTPSConnection):
|
||||
"""
|
||||
A connection that wraps connections with ssl certificate verification.
|
||||
"""
|
||||
def connect(self):
|
||||
|
||||
self.connection_kwargs = {}
|
||||
|
||||
#TODO: refactor compatibility logic into backwardcompat?
|
||||
|
||||
# for > py2.5
|
||||
if hasattr(self, 'timeout'):
|
||||
self.connection_kwargs.update(timeout = self.timeout)
|
||||
|
||||
# for >= py2.7
|
||||
if hasattr(self, 'source_address'):
|
||||
self.connection_kwargs.update(source_address = self.source_address)
|
||||
|
||||
sock = socket.create_connection((self.host, self.port), **self.connection_kwargs)
|
||||
|
||||
# for >= py2.7
|
||||
if getattr(self, '_tunnel_host', None):
|
||||
self.sock = sock
|
||||
self._tunnel()
|
||||
|
||||
# get alternate bundle or use our included bundle
|
||||
cert_path = os.environ.get('PIP_CERT', '') or default_cert_path
|
||||
|
||||
self.sock = ssl.wrap_socket(sock,
|
||||
self.key_file,
|
||||
self.cert_file,
|
||||
cert_reqs=ssl.CERT_REQUIRED,
|
||||
ca_certs=cert_path)
|
||||
|
||||
try:
|
||||
match_hostname(self.sock.getpeercert(), self.host)
|
||||
except CertificateError:
|
||||
self.sock.shutdown(socket.SHUT_RDWR)
|
||||
self.sock.close()
|
||||
raise
|
||||
|
||||
|
||||
|
||||
class VerifiedHTTPSHandler(urllib2.HTTPSHandler):
|
||||
"""
|
||||
A HTTPSHandler that uses our own VerifiedHTTPSConnection.
|
||||
"""
|
||||
def __init__(self, connection_class = VerifiedHTTPSConnection):
|
||||
self.specialized_conn_class = connection_class
|
||||
urllib2.HTTPSHandler.__init__(self)
|
||||
def https_open(self, req):
|
||||
return self.do_open(self.specialized_conn_class, req)
|
||||
|
||||
|
||||
class URLOpener(object):
|
||||
"""
|
||||
pip's own URL helper that adds HTTP auth and proxy support
|
||||
"""
|
||||
def __init__(self):
|
||||
self.passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
|
||||
|
||||
def __call__(self, url):
|
||||
"""
|
||||
If the given url contains auth info or if a normal request gets a 401
|
||||
response, an attempt is made to fetch the resource using basic HTTP
|
||||
auth.
|
||||
|
||||
"""
|
||||
url, username, password, scheme = self.extract_credentials(url)
|
||||
if username is None:
|
||||
try:
|
||||
response = self.get_opener(scheme=scheme).open(url)
|
||||
except urllib2.HTTPError:
|
||||
e = sys.exc_info()[1]
|
||||
if e.code != 401:
|
||||
raise
|
||||
response = self.get_response(url)
|
||||
else:
|
||||
response = self.get_response(url, username, password)
|
||||
return response
|
||||
|
||||
def get_request(self, url):
|
||||
"""
|
||||
Wraps the URL to retrieve to protects against "creative"
|
||||
interpretation of the RFC: http://bugs.python.org/issue8732
|
||||
"""
|
||||
if isinstance(url, string_types):
|
||||
url = urllib2.Request(url, headers={'Accept-encoding': 'identity'})
|
||||
return url
|
||||
|
||||
def get_response(self, url, username=None, password=None):
|
||||
"""
|
||||
does the dirty work of actually getting the rsponse object using urllib2
|
||||
and its HTTP auth builtins.
|
||||
"""
|
||||
scheme, netloc, path, query, frag = urlparse.urlsplit(url)
|
||||
req = self.get_request(url)
|
||||
|
||||
stored_username, stored_password = self.passman.find_user_password(None, netloc)
|
||||
# see if we have a password stored
|
||||
if stored_username is None:
|
||||
if username is None and self.prompting:
|
||||
username = urllib.quote(raw_input('User for %s: ' % netloc))
|
||||
password = urllib.quote(getpass.getpass('Password: '))
|
||||
if username and password:
|
||||
self.passman.add_password(None, netloc, username, password)
|
||||
stored_username, stored_password = self.passman.find_user_password(None, netloc)
|
||||
authhandler = urllib2.HTTPBasicAuthHandler(self.passman)
|
||||
opener = self.get_opener(authhandler, scheme=scheme)
|
||||
# FIXME: should catch a 401 and offer to let the user reenter credentials
|
||||
return opener.open(req)
|
||||
|
||||
def get_opener(self, *args, **kwargs):
|
||||
"""
|
||||
Build an OpenerDirector instance based on the scheme, whether ssl is
|
||||
importable and the --insecure parameter.
|
||||
"""
|
||||
if kwargs.get('scheme') == 'https':
|
||||
if ssl:
|
||||
https_handler = VerifiedHTTPSHandler()
|
||||
director = urllib2.build_opener(https_handler, *args)
|
||||
#strip out HTTPHandler to prevent MITM spoof
|
||||
for handler in director.handlers:
|
||||
if isinstance(handler, urllib2.HTTPHandler):
|
||||
director.handlers.remove(handler)
|
||||
return director
|
||||
elif os.environ.get('PIP_INSECURE', '') == '1':
|
||||
return urllib2.build_opener(*args)
|
||||
else:
|
||||
raise NoSSLError()
|
||||
else:
|
||||
return urllib2.build_opener(*args)
|
||||
|
||||
def setup(self, proxystr='', prompting=True):
|
||||
"""
|
||||
Sets the proxy handler given the option passed on the command
|
||||
line. If an empty string is passed it looks at the HTTP_PROXY
|
||||
environment variable.
|
||||
"""
|
||||
self.prompting = prompting
|
||||
proxy = self.get_proxy(proxystr)
|
||||
if proxy:
|
||||
proxy_support = urllib2.ProxyHandler({"http": proxy, "ftp": proxy, "https": proxy})
|
||||
opener = urllib2.build_opener(proxy_support, urllib2.CacheFTPHandler)
|
||||
urllib2.install_opener(opener)
|
||||
|
||||
def parse_credentials(self, netloc):
|
||||
if "@" in netloc:
|
||||
userinfo = netloc.rsplit("@", 1)[0]
|
||||
if ":" in userinfo:
|
||||
return userinfo.split(":", 1)
|
||||
return userinfo, None
|
||||
return None, None
|
||||
|
||||
def extract_credentials(self, url):
|
||||
"""
|
||||
Extracts user/password from a url.
|
||||
|
||||
Returns a tuple:
|
||||
(url-without-auth, username, password)
|
||||
"""
|
||||
if isinstance(url, urllib2.Request):
|
||||
result = urlparse.urlsplit(url.get_full_url())
|
||||
else:
|
||||
result = urlparse.urlsplit(url)
|
||||
scheme, netloc, path, query, frag = result
|
||||
|
||||
username, password = self.parse_credentials(netloc)
|
||||
if username is None:
|
||||
return url, None, None, scheme
|
||||
elif password is None and self.prompting:
|
||||
# remove the auth credentials from the url part
|
||||
netloc = netloc.replace('%s@' % username, '', 1)
|
||||
# prompt for the password
|
||||
prompt = 'Password for %s@%s: ' % (username, netloc)
|
||||
password = urllib.quote(getpass.getpass(prompt))
|
||||
else:
|
||||
# remove the auth credentials from the url part
|
||||
netloc = netloc.replace('%s:%s@' % (username, password), '', 1)
|
||||
|
||||
target_url = urlparse.urlunsplit((scheme, netloc, path, query, frag))
|
||||
return target_url, username, password, scheme
|
||||
|
||||
def get_proxy(self, proxystr=''):
|
||||
"""
|
||||
Get the proxy given the option passed on the command line.
|
||||
If an empty string is passed it looks at the HTTP_PROXY
|
||||
environment variable.
|
||||
"""
|
||||
if not proxystr:
|
||||
proxystr = os.environ.get('HTTP_PROXY', '')
|
||||
if proxystr:
|
||||
if '@' in proxystr:
|
||||
user_password, server_port = proxystr.split('@', 1)
|
||||
if ':' in user_password:
|
||||
user, password = user_password.split(':', 1)
|
||||
else:
|
||||
user = user_password
|
||||
prompt = 'Password for %s@%s: ' % (user, server_port)
|
||||
password = urllib.quote(getpass.getpass(prompt))
|
||||
return '%s:%s@%s' % (user, password, server_port)
|
||||
else:
|
||||
return proxystr
|
||||
else:
|
||||
return None
|
||||
|
||||
urlopen = URLOpener()
|
||||
|
||||
|
||||
def is_url(name):
|
||||
"""Returns true if the name looks like a URL"""
|
||||
if ':' not in name:
|
||||
return False
|
||||
scheme = name.split(':', 1)[0].lower()
|
||||
return scheme in ['http', 'https', 'file', 'ftp'] + vcs.all_schemes
|
||||
|
||||
|
||||
def url_to_path(url):
|
||||
"""
|
||||
Convert a file: URL to a path.
|
||||
"""
|
||||
assert url.startswith('file:'), (
|
||||
"You can only turn file: urls into filenames (not %r)" % url)
|
||||
path = url[len('file:'):].lstrip('/')
|
||||
path = urllib.unquote(path)
|
||||
if _url_drive_re.match(path):
|
||||
path = path[0] + ':' + path[2:]
|
||||
else:
|
||||
path = '/' + path
|
||||
return path
|
||||
|
||||
|
||||
_drive_re = re.compile('^([a-z]):', re.I)
|
||||
_url_drive_re = re.compile('^([a-z])[:|]', re.I)
|
||||
|
||||
|
||||
def path_to_url(path):
|
||||
"""
|
||||
Convert a path to a file: URL. The path will be made absolute.
|
||||
"""
|
||||
path = os.path.normcase(os.path.abspath(path))
|
||||
if _drive_re.match(path):
|
||||
path = path[0] + '|' + path[2:]
|
||||
url = urllib.quote(path)
|
||||
url = url.replace(os.path.sep, '/')
|
||||
url = url.lstrip('/')
|
||||
return 'file:///' + url
|
||||
|
||||
|
||||
def path_to_url2(path):
|
||||
"""
|
||||
Convert a path to a file: URL. The path will be made absolute and have
|
||||
quoted path parts.
|
||||
"""
|
||||
path = os.path.normpath(os.path.abspath(path))
|
||||
drive, path = os.path.splitdrive(path)
|
||||
filepath = path.split(os.path.sep)
|
||||
url = '/'.join([urllib.quote(part) for part in filepath])
|
||||
if not drive:
|
||||
url = url.lstrip('/')
|
||||
return 'file:///' + drive + url
|
||||
|
||||
|
||||
def geturl(urllib2_resp):
|
||||
"""
|
||||
Use instead of urllib.addinfourl.geturl(), which appears to have
|
||||
some issues with dropping the double slash for certain schemes
|
||||
(e.g. file://). This implementation is probably over-eager, as it
|
||||
always restores '://' if it is missing, and it appears some url
|
||||
schemata aren't always followed by '//' after the colon, but as
|
||||
far as I know pip doesn't need any of those.
|
||||
The URI RFC can be found at: http://tools.ietf.org/html/rfc1630
|
||||
|
||||
This function assumes that
|
||||
scheme:/foo/bar
|
||||
is the same as
|
||||
scheme:///foo/bar
|
||||
"""
|
||||
url = urllib2_resp.geturl()
|
||||
scheme, rest = url.split(':', 1)
|
||||
if rest.startswith('//'):
|
||||
return url
|
||||
else:
|
||||
# FIXME: write a good test to cover it
|
||||
return '%s://%s' % (scheme, rest)
|
||||
|
||||
|
||||
def is_archive_file(name):
|
||||
"""Return True if `name` is a considered as an archive file."""
|
||||
archives = ('.zip', '.tar.gz', '.tar.bz2', '.tgz', '.tar', '.pybundle')
|
||||
ext = splitext(name)[1].lower()
|
||||
if ext in archives:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def unpack_vcs_link(link, location, only_download=False):
|
||||
vcs_backend = _get_used_vcs_backend(link)
|
||||
if only_download:
|
||||
vcs_backend.export(location)
|
||||
else:
|
||||
vcs_backend.unpack(location)
|
||||
|
||||
|
||||
def unpack_file_url(link, location):
|
||||
source = url_to_path(link.url)
|
||||
content_type = mimetypes.guess_type(source)[0]
|
||||
if os.path.isdir(source):
|
||||
# delete the location since shutil will create it again :(
|
||||
if os.path.isdir(location):
|
||||
rmtree(location)
|
||||
shutil.copytree(source, location)
|
||||
else:
|
||||
unpack_file(source, location, content_type, link)
|
||||
|
||||
|
||||
def _get_used_vcs_backend(link):
|
||||
for backend in vcs.backends:
|
||||
if link.scheme in backend.schemes:
|
||||
vcs_backend = backend(link.url)
|
||||
return vcs_backend
|
||||
|
||||
|
||||
def is_vcs_url(link):
|
||||
return bool(_get_used_vcs_backend(link))
|
||||
|
||||
|
||||
def is_file_url(link):
|
||||
return link.url.lower().startswith('file:')
|
||||
|
||||
|
||||
def _check_hash(download_hash, link):
|
||||
if download_hash.digest_size != hashlib.new(link.hash_name).digest_size:
|
||||
logger.fatal("Hash digest size of the package %d (%s) doesn't match the expected hash name %s!"
|
||||
% (download_hash.digest_size, link, link.hash_name))
|
||||
raise InstallationError('Hash name mismatch for package %s' % link)
|
||||
if download_hash.hexdigest() != link.hash:
|
||||
logger.fatal("Hash of the package %s (%s) doesn't match the expected hash %s!"
|
||||
% (link, download_hash, link.hash))
|
||||
raise InstallationError('Bad %s hash for package %s' % (link.hash_name, link))
|
||||
|
||||
|
||||
def _get_hash_from_file(target_file, link):
|
||||
try:
|
||||
download_hash = hashlib.new(link.hash_name)
|
||||
except (ValueError, TypeError):
|
||||
logger.warn("Unsupported hash name %s for package %s" % (link.hash_name, link))
|
||||
return None
|
||||
|
||||
fp = open(target_file, 'rb')
|
||||
while True:
|
||||
chunk = fp.read(4096)
|
||||
if not chunk:
|
||||
break
|
||||
download_hash.update(chunk)
|
||||
fp.close()
|
||||
return download_hash
|
||||
|
||||
|
||||
def _download_url(resp, link, temp_location):
|
||||
fp = open(temp_location, 'wb')
|
||||
download_hash = None
|
||||
if link.hash and link.hash_name:
|
||||
try:
|
||||
download_hash = hashlib.new(link.hash_name)
|
||||
except ValueError:
|
||||
logger.warn("Unsupported hash name %s for package %s" % (link.hash_name, link))
|
||||
try:
|
||||
total_length = int(resp.info()['content-length'])
|
||||
except (ValueError, KeyError, TypeError):
|
||||
total_length = 0
|
||||
downloaded = 0
|
||||
show_progress = total_length > 40 * 1000 or not total_length
|
||||
show_url = link.show_url
|
||||
try:
|
||||
if show_progress:
|
||||
## FIXME: the URL can get really long in this message:
|
||||
if total_length:
|
||||
logger.start_progress('Downloading %s (%s): ' % (show_url, format_size(total_length)))
|
||||
else:
|
||||
logger.start_progress('Downloading %s (unknown size): ' % show_url)
|
||||
else:
|
||||
logger.notify('Downloading %s' % show_url)
|
||||
logger.info('Downloading from URL %s' % link)
|
||||
|
||||
while True:
|
||||
chunk = resp.read(4096)
|
||||
if not chunk:
|
||||
break
|
||||
downloaded += len(chunk)
|
||||
if show_progress:
|
||||
if not total_length:
|
||||
logger.show_progress('%s' % format_size(downloaded))
|
||||
else:
|
||||
logger.show_progress('%3i%% %s' % (100 * downloaded / total_length, format_size(downloaded)))
|
||||
if download_hash is not None:
|
||||
download_hash.update(chunk)
|
||||
fp.write(chunk)
|
||||
fp.close()
|
||||
finally:
|
||||
if show_progress:
|
||||
logger.end_progress('%s downloaded' % format_size(downloaded))
|
||||
return download_hash
|
||||
|
||||
|
||||
def _copy_file(filename, location, content_type, link):
|
||||
copy = True
|
||||
download_location = os.path.join(location, link.filename)
|
||||
if os.path.exists(download_location):
|
||||
response = ask_path_exists(
|
||||
'The file %s exists. (i)gnore, (w)ipe, (b)ackup ' %
|
||||
display_path(download_location), ('i', 'w', 'b'))
|
||||
if response == 'i':
|
||||
copy = False
|
||||
elif response == 'w':
|
||||
logger.warn('Deleting %s' % display_path(download_location))
|
||||
os.remove(download_location)
|
||||
elif response == 'b':
|
||||
dest_file = backup_dir(download_location)
|
||||
logger.warn('Backing up %s to %s'
|
||||
% (display_path(download_location), display_path(dest_file)))
|
||||
shutil.move(download_location, dest_file)
|
||||
if copy:
|
||||
shutil.copy(filename, download_location)
|
||||
logger.indent -= 2
|
||||
logger.notify('Saved %s' % display_path(download_location))
|
||||
|
||||
|
||||
def unpack_http_url(link, location, download_cache, download_dir=None):
|
||||
temp_dir = tempfile.mkdtemp('-unpack', 'pip-')
|
||||
target_url = link.url.split('#', 1)[0]
|
||||
target_file = None
|
||||
download_hash = None
|
||||
if download_cache:
|
||||
target_file = os.path.join(download_cache,
|
||||
urllib.quote(target_url, ''))
|
||||
if not os.path.isdir(download_cache):
|
||||
create_download_cache_folder(download_cache)
|
||||
|
||||
already_downloaded = None
|
||||
if download_dir:
|
||||
already_downloaded = os.path.join(download_dir, link.filename)
|
||||
if not os.path.exists(already_downloaded):
|
||||
already_downloaded = None
|
||||
|
||||
if (target_file
|
||||
and os.path.exists(target_file)
|
||||
and os.path.exists(target_file + '.content-type')):
|
||||
fp = open(target_file+'.content-type')
|
||||
content_type = fp.read().strip()
|
||||
fp.close()
|
||||
if link.hash and link.hash_name:
|
||||
download_hash = _get_hash_from_file(target_file, link)
|
||||
temp_location = target_file
|
||||
logger.notify('Using download cache from %s' % target_file)
|
||||
elif already_downloaded:
|
||||
temp_location = already_downloaded
|
||||
content_type = mimetypes.guess_type(already_downloaded)
|
||||
if link.hash:
|
||||
download_hash = _get_hash_from_file(temp_location, link)
|
||||
logger.notify('File was already downloaded %s' % already_downloaded)
|
||||
else:
|
||||
resp = _get_response_from_url(target_url, link)
|
||||
content_type = resp.info()['content-type']
|
||||
filename = link.filename # fallback
|
||||
# Have a look at the Content-Disposition header for a better guess
|
||||
content_disposition = resp.info().get('content-disposition')
|
||||
if content_disposition:
|
||||
type, params = cgi.parse_header(content_disposition)
|
||||
# We use ``or`` here because we don't want to use an "empty" value
|
||||
# from the filename param.
|
||||
filename = params.get('filename') or filename
|
||||
ext = splitext(filename)[1]
|
||||
if not ext:
|
||||
ext = mimetypes.guess_extension(content_type)
|
||||
if ext:
|
||||
filename += ext
|
||||
if not ext and link.url != geturl(resp):
|
||||
ext = os.path.splitext(geturl(resp))[1]
|
||||
if ext:
|
||||
filename += ext
|
||||
temp_location = os.path.join(temp_dir, filename)
|
||||
download_hash = _download_url(resp, link, temp_location)
|
||||
if link.hash and link.hash_name:
|
||||
_check_hash(download_hash, link)
|
||||
if download_dir and not already_downloaded:
|
||||
_copy_file(temp_location, download_dir, content_type, link)
|
||||
unpack_file(temp_location, location, content_type, link)
|
||||
if target_file and target_file != temp_location:
|
||||
cache_download(target_file, temp_location, content_type)
|
||||
if target_file is None and not already_downloaded:
|
||||
os.unlink(temp_location)
|
||||
os.rmdir(temp_dir)
|
||||
|
||||
|
||||
def _get_response_from_url(target_url, link):
|
||||
try:
|
||||
resp = urlopen(target_url)
|
||||
except urllib2.HTTPError:
|
||||
e = sys.exc_info()[1]
|
||||
logger.fatal("HTTP error %s while getting %s" % (e.code, link))
|
||||
raise
|
||||
except IOError:
|
||||
e = sys.exc_info()[1]
|
||||
# Typically an FTP error
|
||||
logger.fatal("Error %s while getting %s" % (e, link))
|
||||
raise
|
||||
return resp
|
||||
|
||||
|
||||
class Urllib2HeadRequest(urllib2.Request):
|
||||
def get_method(self):
|
||||
return "HEAD"
|
||||
Vendored
-56
@@ -1,56 +0,0 @@
|
||||
"""Exceptions used throughout package"""
|
||||
|
||||
import textwrap
|
||||
|
||||
class PipError(Exception):
|
||||
"""Base pip exception"""
|
||||
|
||||
|
||||
class InstallationError(PipError):
|
||||
"""General exception during installation"""
|
||||
|
||||
|
||||
class UninstallationError(PipError):
|
||||
"""General exception during uninstallation"""
|
||||
|
||||
|
||||
class DistributionNotFound(InstallationError):
|
||||
"""Raised when a distribution cannot be found to satisfy a requirement"""
|
||||
|
||||
|
||||
class BestVersionAlreadyInstalled(PipError):
|
||||
"""Raised when the most up-to-date version of a package is already
|
||||
installed. """
|
||||
|
||||
|
||||
class BadCommand(PipError):
|
||||
"""Raised when virtualenv or a command is not found"""
|
||||
|
||||
|
||||
class CommandError(PipError):
|
||||
"""Raised when there is an error in command-line arguments"""
|
||||
|
||||
|
||||
class NoSSLError(PipError):
|
||||
"""Raised when there's no ssl and not using '--insecure'"""
|
||||
|
||||
def __str__(self):
|
||||
return textwrap.dedent("""
|
||||
###################################################################
|
||||
## You don't have an importable ssl module. You are most ##
|
||||
## likely using Python 2.5, which did not include ssl ##
|
||||
## support by default. In this state, we can not provide ##
|
||||
## ssl certified downloads from PyPI. ##
|
||||
## ##
|
||||
## You can do one of 2 things: ##
|
||||
## 1) Install this: https://pypi.python.org/pypi/ssl/ ##
|
||||
## (It provides ssl support for older Pythons ) ##
|
||||
## 2) Use the --insecure option to allow this insecurity ##
|
||||
## ##
|
||||
## For more details, go to the "SSL Certificate Verification" ##
|
||||
## section located here: ##
|
||||
## http://www.pip-installer.org/en/latest/logic.html ##
|
||||
## ##
|
||||
###################################################################
|
||||
""")
|
||||
|
||||
Vendored
-757
@@ -1,757 +0,0 @@
|
||||
"""Routines related to PyPI, indexes"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
import gzip
|
||||
import mimetypes
|
||||
import posixpath
|
||||
import pkg_resources
|
||||
import random
|
||||
import socket
|
||||
import string
|
||||
import zlib
|
||||
|
||||
try:
|
||||
import threading
|
||||
except ImportError:
|
||||
import dummy_threading as threading
|
||||
|
||||
from pip.log import logger
|
||||
from pip.util import Inf, normalize_name, splitext
|
||||
from pip.exceptions import DistributionNotFound, BestVersionAlreadyInstalled
|
||||
from pip.backwardcompat import (WindowsError, BytesIO,
|
||||
Queue, urlparse,
|
||||
URLError, HTTPError, u,
|
||||
product, url2pathname, ssl,
|
||||
Empty as QueueEmpty)
|
||||
if ssl:
|
||||
from pip.backwardcompat import CertificateError
|
||||
from pip.download import urlopen, path_to_url2, url_to_path, geturl, Urllib2HeadRequest
|
||||
|
||||
__all__ = ['PackageFinder']
|
||||
|
||||
|
||||
DEFAULT_MIRROR_HOSTNAME = "last.pypi.python.org"
|
||||
|
||||
|
||||
class PackageFinder(object):
|
||||
"""This finds packages.
|
||||
|
||||
This is meant to match easy_install's technique for looking for
|
||||
packages, by reading pages and looking for appropriate links
|
||||
"""
|
||||
|
||||
def __init__(self, find_links, index_urls,
|
||||
use_mirrors=False, mirrors=None, main_mirror_url=None):
|
||||
self.find_links = find_links
|
||||
self.index_urls = index_urls
|
||||
self.dependency_links = []
|
||||
self.cache = PageCache()
|
||||
# These are boring links that have already been logged somehow:
|
||||
self.logged_links = set()
|
||||
if use_mirrors:
|
||||
self.mirror_urls = self._get_mirror_urls(mirrors, main_mirror_url)
|
||||
logger.info('Using PyPI mirrors: %s' % ', '.join(self.mirror_urls))
|
||||
else:
|
||||
self.mirror_urls = []
|
||||
|
||||
def add_dependency_links(self, links):
|
||||
## FIXME: this shouldn't be global list this, it should only
|
||||
## apply to requirements of the package that specifies the
|
||||
## dependency_links value
|
||||
## FIXME: also, we should track comes_from (i.e., use Link)
|
||||
self.dependency_links.extend(links)
|
||||
|
||||
def _sort_locations(self, locations):
|
||||
"""
|
||||
Sort locations into "files" (archives) and "urls", and return
|
||||
a pair of lists (files,urls)
|
||||
"""
|
||||
files = []
|
||||
urls = []
|
||||
|
||||
# puts the url for the given file path into the appropriate list
|
||||
def sort_path(path):
|
||||
url = path_to_url2(path)
|
||||
if mimetypes.guess_type(url, strict=False)[0] == 'text/html':
|
||||
urls.append(url)
|
||||
else:
|
||||
files.append(url)
|
||||
|
||||
for url in locations:
|
||||
|
||||
is_local_path = os.path.exists(url)
|
||||
is_file_url = url.startswith('file:')
|
||||
is_find_link = url in self.find_links
|
||||
|
||||
if is_local_path or is_file_url:
|
||||
if is_local_path:
|
||||
path = url
|
||||
else:
|
||||
path = url_to_path(url)
|
||||
if is_find_link and os.path.isdir(path):
|
||||
path = os.path.realpath(path)
|
||||
for item in os.listdir(path):
|
||||
sort_path(os.path.join(path, item))
|
||||
elif is_file_url and os.path.isdir(path):
|
||||
urls.append(url)
|
||||
elif os.path.isfile(path):
|
||||
sort_path(path)
|
||||
else:
|
||||
urls.append(url)
|
||||
|
||||
return files, urls
|
||||
|
||||
def find_requirement(self, req, upgrade):
|
||||
|
||||
def mkurl_pypi_url(url):
|
||||
loc = posixpath.join(url, url_name)
|
||||
# For maximum compatibility with easy_install, ensure the path
|
||||
# ends in a trailing slash. Although this isn't in the spec
|
||||
# (and PyPI can handle it without the slash) some other index
|
||||
# implementations might break if they relied on easy_install's behavior.
|
||||
if not loc.endswith('/'):
|
||||
loc = loc + '/'
|
||||
return loc
|
||||
|
||||
url_name = req.url_name
|
||||
# Only check main index if index URL is given:
|
||||
main_index_url = None
|
||||
if self.index_urls:
|
||||
# Check that we have the url_name correctly spelled:
|
||||
main_index_url = Link(mkurl_pypi_url(self.index_urls[0]))
|
||||
# This will also cache the page, so it's okay that we get it again later:
|
||||
page = self._get_page(main_index_url, req)
|
||||
if page is None:
|
||||
url_name = self._find_url_name(Link(self.index_urls[0]), url_name, req) or req.url_name
|
||||
|
||||
# Combine index URLs with mirror URLs here to allow
|
||||
# adding more index URLs from requirements files
|
||||
all_index_urls = self.index_urls + self.mirror_urls
|
||||
|
||||
if url_name is not None:
|
||||
locations = [
|
||||
mkurl_pypi_url(url)
|
||||
for url in all_index_urls] + self.find_links
|
||||
else:
|
||||
locations = list(self.find_links)
|
||||
locations.extend(self.dependency_links)
|
||||
for version in req.absolute_versions:
|
||||
if url_name is not None and main_index_url is not None:
|
||||
locations = [
|
||||
posixpath.join(main_index_url.url, version)] + locations
|
||||
|
||||
file_locations, url_locations = self._sort_locations(locations)
|
||||
|
||||
locations = [Link(url) for url in url_locations]
|
||||
logger.debug('URLs to search for versions for %s:' % req)
|
||||
for location in locations:
|
||||
logger.debug('* %s' % location)
|
||||
found_versions = []
|
||||
found_versions.extend(
|
||||
self._package_versions(
|
||||
[Link(url, '-f') for url in self.find_links], req.name.lower()))
|
||||
page_versions = []
|
||||
for page in self._get_pages(locations, req):
|
||||
logger.debug('Analyzing links from page %s' % page.url)
|
||||
logger.indent += 2
|
||||
try:
|
||||
page_versions.extend(self._package_versions(page.links, req.name.lower()))
|
||||
finally:
|
||||
logger.indent -= 2
|
||||
dependency_versions = list(self._package_versions(
|
||||
[Link(url) for url in self.dependency_links], req.name.lower()))
|
||||
if dependency_versions:
|
||||
logger.info('dependency_links found: %s' % ', '.join([link.url for parsed, link, version in dependency_versions]))
|
||||
file_versions = list(self._package_versions(
|
||||
[Link(url) for url in file_locations], req.name.lower()))
|
||||
if not found_versions and not page_versions and not dependency_versions and not file_versions:
|
||||
logger.fatal('Could not find any downloads that satisfy the requirement %s' % req)
|
||||
raise DistributionNotFound('No distributions at all found for %s' % req)
|
||||
installed_version = []
|
||||
if req.satisfied_by is not None:
|
||||
installed_version = [(req.satisfied_by.parsed_version, InfLink, req.satisfied_by.version)]
|
||||
if file_versions:
|
||||
file_versions.sort(reverse=True)
|
||||
logger.info('Local files found: %s' % ', '.join([url_to_path(link.url) for parsed, link, version in file_versions]))
|
||||
#this is an intentional priority ordering
|
||||
all_versions = installed_version + file_versions + found_versions + page_versions + dependency_versions
|
||||
applicable_versions = []
|
||||
for (parsed_version, link, version) in all_versions:
|
||||
if version not in req.req:
|
||||
logger.info("Ignoring link %s, version %s doesn't match %s"
|
||||
% (link, version, ','.join([''.join(s) for s in req.req.specs])))
|
||||
continue
|
||||
applicable_versions.append((parsed_version, link, version))
|
||||
#bring the latest version to the front, but maintains the priority ordering as secondary
|
||||
applicable_versions = sorted(applicable_versions, key=lambda v: v[0], reverse=True)
|
||||
existing_applicable = bool([link for parsed_version, link, version in applicable_versions if link is InfLink])
|
||||
if not upgrade and existing_applicable:
|
||||
if applicable_versions[0][1] is InfLink:
|
||||
logger.info('Existing installed version (%s) is most up-to-date and satisfies requirement'
|
||||
% req.satisfied_by.version)
|
||||
else:
|
||||
logger.info('Existing installed version (%s) satisfies requirement (most up-to-date version is %s)'
|
||||
% (req.satisfied_by.version, applicable_versions[0][2]))
|
||||
return None
|
||||
if not applicable_versions:
|
||||
logger.fatal('Could not find a version that satisfies the requirement %s (from versions: %s)'
|
||||
% (req, ', '.join([version for parsed_version, link, version in all_versions])))
|
||||
raise DistributionNotFound('No distributions matching the version for %s' % req)
|
||||
if applicable_versions[0][1] is InfLink:
|
||||
# We have an existing version, and its the best version
|
||||
logger.info('Installed version (%s) is most up-to-date (past versions: %s)'
|
||||
% (req.satisfied_by.version, ', '.join([version for parsed_version, link, version in applicable_versions[1:]]) or 'none'))
|
||||
raise BestVersionAlreadyInstalled
|
||||
if len(applicable_versions) > 1:
|
||||
logger.info('Using version %s (newest of versions: %s)' %
|
||||
(applicable_versions[0][2], ', '.join([version for parsed_version, link, version in applicable_versions])))
|
||||
return applicable_versions[0][1]
|
||||
|
||||
|
||||
def _find_url_name(self, index_url, url_name, req):
|
||||
"""Finds the true URL name of a package, when the given name isn't quite correct.
|
||||
This is usually used to implement case-insensitivity."""
|
||||
if not index_url.url.endswith('/'):
|
||||
# Vaguely part of the PyPI API... weird but true.
|
||||
## FIXME: bad to modify this?
|
||||
index_url.url += '/'
|
||||
page = self._get_page(index_url, req)
|
||||
if page is None:
|
||||
logger.fatal('Cannot fetch index base URL %s' % index_url)
|
||||
return
|
||||
norm_name = normalize_name(req.url_name)
|
||||
for link in page.links:
|
||||
base = posixpath.basename(link.path.rstrip('/'))
|
||||
if norm_name == normalize_name(base):
|
||||
logger.notify('Real name of requirement %s is %s' % (url_name, base))
|
||||
return base
|
||||
return None
|
||||
|
||||
def _get_pages(self, locations, req):
|
||||
"""Yields (page, page_url) from the given locations, skipping
|
||||
locations that have errors, and adding download/homepage links"""
|
||||
pending_queue = Queue()
|
||||
for location in locations:
|
||||
pending_queue.put(location)
|
||||
done = []
|
||||
seen = set()
|
||||
threads = []
|
||||
for i in range(min(10, len(locations))):
|
||||
t = threading.Thread(target=self._get_queued_page, args=(req, pending_queue, done, seen))
|
||||
t.setDaemon(True)
|
||||
threads.append(t)
|
||||
t.start()
|
||||
for t in threads:
|
||||
t.join()
|
||||
return done
|
||||
|
||||
_log_lock = threading.Lock()
|
||||
|
||||
def _get_queued_page(self, req, pending_queue, done, seen):
|
||||
while 1:
|
||||
try:
|
||||
location = pending_queue.get(False)
|
||||
except QueueEmpty:
|
||||
return
|
||||
if location in seen:
|
||||
continue
|
||||
seen.add(location)
|
||||
page = self._get_page(location, req)
|
||||
if page is None:
|
||||
continue
|
||||
done.append(page)
|
||||
for link in page.rel_links():
|
||||
pending_queue.put(link)
|
||||
|
||||
_egg_fragment_re = re.compile(r'#egg=([^&]*)')
|
||||
_egg_info_re = re.compile(r'([a-z0-9_.]+)-([a-z0-9_.-]+)', re.I)
|
||||
_py_version_re = re.compile(r'-py([123]\.?[0-9]?)$')
|
||||
|
||||
def _sort_links(self, links):
|
||||
"Returns elements of links in order, non-egg links first, egg links second, while eliminating duplicates"
|
||||
eggs, no_eggs = [], []
|
||||
seen = set()
|
||||
for link in links:
|
||||
if link not in seen:
|
||||
seen.add(link)
|
||||
if link.egg_fragment:
|
||||
eggs.append(link)
|
||||
else:
|
||||
no_eggs.append(link)
|
||||
return no_eggs + eggs
|
||||
|
||||
def _package_versions(self, links, search_name):
|
||||
for link in self._sort_links(links):
|
||||
for v in self._link_package_versions(link, search_name):
|
||||
yield v
|
||||
|
||||
def _link_package_versions(self, link, search_name):
|
||||
"""
|
||||
Return an iterable of triples (pkg_resources_version_key,
|
||||
link, python_version) that can be extracted from the given
|
||||
link.
|
||||
|
||||
Meant to be overridden by subclasses, not called by clients.
|
||||
"""
|
||||
if link.egg_fragment:
|
||||
egg_info = link.egg_fragment
|
||||
else:
|
||||
egg_info, ext = link.splitext()
|
||||
if not ext:
|
||||
if link not in self.logged_links:
|
||||
logger.debug('Skipping link %s; not a file' % link)
|
||||
self.logged_links.add(link)
|
||||
return []
|
||||
if egg_info.endswith('.tar'):
|
||||
# Special double-extension case:
|
||||
egg_info = egg_info[:-4]
|
||||
ext = '.tar' + ext
|
||||
if ext not in ('.tar.gz', '.tar.bz2', '.tar', '.tgz', '.zip'):
|
||||
if link not in self.logged_links:
|
||||
logger.debug('Skipping link %s; unknown archive format: %s' % (link, ext))
|
||||
self.logged_links.add(link)
|
||||
return []
|
||||
if "macosx10" in link.path and ext == '.zip':
|
||||
if link not in self.logged_links:
|
||||
logger.debug('Skipping link %s; macosx10 one' % (link))
|
||||
self.logged_links.add(link)
|
||||
return []
|
||||
version = self._egg_info_matches(egg_info, search_name, link)
|
||||
if version is None:
|
||||
logger.debug('Skipping link %s; wrong project name (not %s)' % (link, search_name))
|
||||
return []
|
||||
match = self._py_version_re.search(version)
|
||||
if match:
|
||||
version = version[:match.start()]
|
||||
py_version = match.group(1)
|
||||
if py_version != sys.version[:3]:
|
||||
logger.debug('Skipping %s because Python version is incorrect' % link)
|
||||
return []
|
||||
logger.debug('Found link %s, version: %s' % (link, version))
|
||||
return [(pkg_resources.parse_version(version),
|
||||
link,
|
||||
version)]
|
||||
|
||||
def _egg_info_matches(self, egg_info, search_name, link):
|
||||
match = self._egg_info_re.search(egg_info)
|
||||
if not match:
|
||||
logger.debug('Could not parse version from link: %s' % link)
|
||||
return None
|
||||
name = match.group(0).lower()
|
||||
# To match the "safe" name that pkg_resources creates:
|
||||
name = name.replace('_', '-')
|
||||
# project name and version must be separated by a dash
|
||||
look_for = search_name.lower() + "-"
|
||||
if name.startswith(look_for):
|
||||
return match.group(0)[len(look_for):]
|
||||
else:
|
||||
return None
|
||||
|
||||
def _get_page(self, link, req):
|
||||
return HTMLPage.get_page(link, req, cache=self.cache)
|
||||
|
||||
def _get_mirror_urls(self, mirrors=None, main_mirror_url=None):
|
||||
"""Retrieves a list of URLs from the main mirror DNS entry
|
||||
unless a list of mirror URLs are passed.
|
||||
"""
|
||||
if not mirrors:
|
||||
mirrors = get_mirrors(main_mirror_url)
|
||||
# Should this be made "less random"? E.g. netselect like?
|
||||
random.shuffle(mirrors)
|
||||
|
||||
mirror_urls = set()
|
||||
for mirror_url in mirrors:
|
||||
mirror_url = mirror_url.rstrip('/')
|
||||
# Make sure we have a valid URL
|
||||
if not any([mirror_url.startswith(scheme) for scheme in ["http://", "https://", "file://"]]):
|
||||
mirror_url = "http://%s" % mirror_url
|
||||
if not mirror_url.endswith("/simple"):
|
||||
mirror_url = "%s/simple" % mirror_url
|
||||
mirror_urls.add(mirror_url + '/')
|
||||
|
||||
return list(mirror_urls)
|
||||
|
||||
|
||||
class PageCache(object):
|
||||
"""Cache of HTML pages"""
|
||||
|
||||
failure_limit = 3
|
||||
|
||||
def __init__(self):
|
||||
self._failures = {}
|
||||
self._pages = {}
|
||||
self._archives = {}
|
||||
|
||||
def too_many_failures(self, url):
|
||||
return self._failures.get(url, 0) >= self.failure_limit
|
||||
|
||||
def get_page(self, url):
|
||||
return self._pages.get(url)
|
||||
|
||||
def is_archive(self, url):
|
||||
return self._archives.get(url, False)
|
||||
|
||||
def set_is_archive(self, url, value=True):
|
||||
self._archives[url] = value
|
||||
|
||||
def add_page_failure(self, url, level):
|
||||
self._failures[url] = self._failures.get(url, 0)+level
|
||||
|
||||
def add_page(self, urls, page):
|
||||
for url in urls:
|
||||
self._pages[url] = page
|
||||
|
||||
|
||||
class HTMLPage(object):
|
||||
"""Represents one page, along with its URL"""
|
||||
|
||||
## FIXME: these regexes are horrible hacks:
|
||||
_homepage_re = re.compile(r'<th>\s*home\s*page', re.I)
|
||||
_download_re = re.compile(r'<th>\s*download\s+url', re.I)
|
||||
## These aren't so aweful:
|
||||
_rel_re = re.compile("""<[^>]*\srel\s*=\s*['"]?([^'">]+)[^>]*>""", re.I)
|
||||
_href_re = re.compile('href=(?:"([^"]*)"|\'([^\']*)\'|([^>\\s\\n]*))', re.I|re.S)
|
||||
_base_re = re.compile(r"""<base\s+href\s*=\s*['"]?([^'">]+)""", re.I)
|
||||
|
||||
def __init__(self, content, url, headers=None):
|
||||
self.content = content
|
||||
self.url = url
|
||||
self.headers = headers
|
||||
|
||||
def __str__(self):
|
||||
return self.url
|
||||
|
||||
@classmethod
|
||||
def get_page(cls, link, req, cache=None, skip_archives=True):
|
||||
url = link.url
|
||||
url = url.split('#', 1)[0]
|
||||
if cache.too_many_failures(url):
|
||||
return None
|
||||
|
||||
# Check for VCS schemes that do not support lookup as web pages.
|
||||
from pip.vcs import VcsSupport
|
||||
for scheme in VcsSupport.schemes:
|
||||
if url.lower().startswith(scheme) and url[len(scheme)] in '+:':
|
||||
logger.debug('Cannot look at %(scheme)s URL %(link)s' % locals())
|
||||
return None
|
||||
|
||||
if cache is not None:
|
||||
inst = cache.get_page(url)
|
||||
if inst is not None:
|
||||
return inst
|
||||
try:
|
||||
if skip_archives:
|
||||
if cache is not None:
|
||||
if cache.is_archive(url):
|
||||
return None
|
||||
filename = link.filename
|
||||
for bad_ext in ['.tar', '.tar.gz', '.tar.bz2', '.tgz', '.zip']:
|
||||
if filename.endswith(bad_ext):
|
||||
content_type = cls._get_content_type(url)
|
||||
if content_type.lower().startswith('text/html'):
|
||||
break
|
||||
else:
|
||||
logger.debug('Skipping page %s because of Content-Type: %s' % (link, content_type))
|
||||
if cache is not None:
|
||||
cache.set_is_archive(url)
|
||||
return None
|
||||
logger.debug('Getting page %s' % url)
|
||||
|
||||
# Tack index.html onto file:// URLs that point to directories
|
||||
(scheme, netloc, path, params, query, fragment) = urlparse.urlparse(url)
|
||||
if scheme == 'file' and os.path.isdir(url2pathname(path)):
|
||||
# add trailing slash if not present so urljoin doesn't trim final segment
|
||||
if not url.endswith('/'):
|
||||
url += '/'
|
||||
url = urlparse.urljoin(url, 'index.html')
|
||||
logger.debug(' file: URL is directory, getting %s' % url)
|
||||
|
||||
resp = urlopen(url)
|
||||
|
||||
real_url = geturl(resp)
|
||||
headers = resp.info()
|
||||
contents = resp.read()
|
||||
encoding = headers.get('Content-Encoding', None)
|
||||
#XXX need to handle exceptions and add testing for this
|
||||
if encoding is not None:
|
||||
if encoding == 'gzip':
|
||||
contents = gzip.GzipFile(fileobj=BytesIO(contents)).read()
|
||||
if encoding == 'deflate':
|
||||
contents = zlib.decompress(contents)
|
||||
inst = cls(u(contents), real_url, headers)
|
||||
except (HTTPError, URLError, socket.timeout, socket.error, OSError, WindowsError):
|
||||
e = sys.exc_info()[1]
|
||||
desc = str(e)
|
||||
if isinstance(e, socket.timeout):
|
||||
log_meth = logger.info
|
||||
level =1
|
||||
desc = 'timed out'
|
||||
elif isinstance(e, URLError):
|
||||
#ssl/certificate error
|
||||
if ssl and hasattr(e, 'reason') and (isinstance(e.reason, ssl.SSLError) or isinstance(e.reason, CertificateError)):
|
||||
desc = 'There was a problem confirming the ssl certificate: %s' % e
|
||||
log_meth = logger.notify
|
||||
else:
|
||||
log_meth = logger.info
|
||||
if hasattr(e, 'reason') and isinstance(e.reason, socket.timeout):
|
||||
desc = 'timed out'
|
||||
level = 1
|
||||
else:
|
||||
level = 2
|
||||
elif isinstance(e, HTTPError) and e.code == 404:
|
||||
## FIXME: notify?
|
||||
log_meth = logger.info
|
||||
level = 2
|
||||
else:
|
||||
log_meth = logger.info
|
||||
level = 1
|
||||
log_meth('Could not fetch URL %s: %s' % (link, desc))
|
||||
log_meth('Will skip URL %s when looking for download links for %s' % (link.url, req))
|
||||
if cache is not None:
|
||||
cache.add_page_failure(url, level)
|
||||
return None
|
||||
if cache is not None:
|
||||
cache.add_page([url, real_url], inst)
|
||||
return inst
|
||||
|
||||
@staticmethod
|
||||
def _get_content_type(url):
|
||||
"""Get the Content-Type of the given url, using a HEAD request"""
|
||||
scheme, netloc, path, query, fragment = urlparse.urlsplit(url)
|
||||
if not scheme in ('http', 'https', 'ftp', 'ftps'):
|
||||
## FIXME: some warning or something?
|
||||
## assertion error?
|
||||
return ''
|
||||
req = Urllib2HeadRequest(url, headers={'Host': netloc})
|
||||
resp = urlopen(req)
|
||||
try:
|
||||
if hasattr(resp, 'code') and resp.code != 200 and scheme not in ('ftp', 'ftps'):
|
||||
## FIXME: doesn't handle redirects
|
||||
return ''
|
||||
return resp.info().get('content-type', '')
|
||||
finally:
|
||||
resp.close()
|
||||
|
||||
@property
|
||||
def base_url(self):
|
||||
if not hasattr(self, "_base_url"):
|
||||
match = self._base_re.search(self.content)
|
||||
if match:
|
||||
self._base_url = match.group(1)
|
||||
else:
|
||||
self._base_url = self.url
|
||||
return self._base_url
|
||||
|
||||
@property
|
||||
def links(self):
|
||||
"""Yields all links in the page"""
|
||||
for match in self._href_re.finditer(self.content):
|
||||
url = match.group(1) or match.group(2) or match.group(3)
|
||||
url = self.clean_link(urlparse.urljoin(self.base_url, url))
|
||||
yield Link(url, self)
|
||||
|
||||
def rel_links(self):
|
||||
for url in self.explicit_rel_links():
|
||||
yield url
|
||||
for url in self.scraped_rel_links():
|
||||
yield url
|
||||
|
||||
def explicit_rel_links(self, rels=('homepage', 'download')):
|
||||
"""Yields all links with the given relations"""
|
||||
for match in self._rel_re.finditer(self.content):
|
||||
found_rels = match.group(1).lower().split()
|
||||
for rel in rels:
|
||||
if rel in found_rels:
|
||||
break
|
||||
else:
|
||||
continue
|
||||
match = self._href_re.search(match.group(0))
|
||||
if not match:
|
||||
continue
|
||||
url = match.group(1) or match.group(2) or match.group(3)
|
||||
url = self.clean_link(urlparse.urljoin(self.base_url, url))
|
||||
yield Link(url, self)
|
||||
|
||||
def scraped_rel_links(self):
|
||||
for regex in (self._homepage_re, self._download_re):
|
||||
match = regex.search(self.content)
|
||||
if not match:
|
||||
continue
|
||||
href_match = self._href_re.search(self.content, pos=match.end())
|
||||
if not href_match:
|
||||
continue
|
||||
url = href_match.group(1) or href_match.group(2) or href_match.group(3)
|
||||
if not url:
|
||||
continue
|
||||
url = self.clean_link(urlparse.urljoin(self.base_url, url))
|
||||
yield Link(url, self)
|
||||
|
||||
_clean_re = re.compile(r'[^a-z0-9$&+,/:;=?@.#%_\\|-]', re.I)
|
||||
|
||||
def clean_link(self, url):
|
||||
"""Makes sure a link is fully encoded. That is, if a ' ' shows up in
|
||||
the link, it will be rewritten to %20 (while not over-quoting
|
||||
% or other characters)."""
|
||||
return self._clean_re.sub(
|
||||
lambda match: '%%%2x' % ord(match.group(0)), url)
|
||||
|
||||
|
||||
class Link(object):
|
||||
|
||||
def __init__(self, url, comes_from=None):
|
||||
self.url = url
|
||||
self.comes_from = comes_from
|
||||
|
||||
def __str__(self):
|
||||
if self.comes_from:
|
||||
return '%s (from %s)' % (self.url, self.comes_from)
|
||||
else:
|
||||
return str(self.url)
|
||||
|
||||
def __repr__(self):
|
||||
return '<Link %s>' % self
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.url == other.url
|
||||
|
||||
def __ne__(self, other):
|
||||
return self.url != other.url
|
||||
|
||||
def __lt__(self, other):
|
||||
return self.url < other.url
|
||||
|
||||
def __le__(self, other):
|
||||
return self.url <= other.url
|
||||
|
||||
def __gt__(self, other):
|
||||
return self.url > other.url
|
||||
|
||||
def __ge__(self, other):
|
||||
return self.url >= other.url
|
||||
|
||||
def __hash__(self):
|
||||
return hash(self.url)
|
||||
|
||||
@property
|
||||
def filename(self):
|
||||
_, netloc, path, _, _ = urlparse.urlsplit(self.url)
|
||||
name = posixpath.basename(path.rstrip('/')) or netloc
|
||||
assert name, ('URL %r produced no filename' % self.url)
|
||||
return name
|
||||
|
||||
@property
|
||||
def scheme(self):
|
||||
return urlparse.urlsplit(self.url)[0]
|
||||
|
||||
@property
|
||||
def path(self):
|
||||
return urlparse.urlsplit(self.url)[2]
|
||||
|
||||
def splitext(self):
|
||||
return splitext(posixpath.basename(self.path.rstrip('/')))
|
||||
|
||||
@property
|
||||
def url_without_fragment(self):
|
||||
scheme, netloc, path, query, fragment = urlparse.urlsplit(self.url)
|
||||
return urlparse.urlunsplit((scheme, netloc, path, query, None))
|
||||
|
||||
_egg_fragment_re = re.compile(r'#egg=([^&]*)')
|
||||
|
||||
@property
|
||||
def egg_fragment(self):
|
||||
match = self._egg_fragment_re.search(self.url)
|
||||
if not match:
|
||||
return None
|
||||
return match.group(1)
|
||||
|
||||
_hash_re = re.compile(r'(sha1|sha224|sha384|sha256|sha512|md5)=([a-f0-9]+)')
|
||||
|
||||
@property
|
||||
def hash(self):
|
||||
match = self._hash_re.search(self.url)
|
||||
if match:
|
||||
return match.group(2)
|
||||
return None
|
||||
|
||||
@property
|
||||
def hash_name(self):
|
||||
match = self._hash_re.search(self.url)
|
||||
if match:
|
||||
return match.group(1)
|
||||
return None
|
||||
|
||||
@property
|
||||
def show_url(self):
|
||||
return posixpath.basename(self.url.split('#', 1)[0].split('?', 1)[0])
|
||||
|
||||
#An "Infinite Link" that compares greater than other links
|
||||
InfLink = Link(Inf) #this object is not currently used as a sortable
|
||||
|
||||
|
||||
def get_requirement_from_url(url):
|
||||
"""Get a requirement from the URL, if possible. This looks for #egg
|
||||
in the URL"""
|
||||
link = Link(url)
|
||||
egg_info = link.egg_fragment
|
||||
if not egg_info:
|
||||
egg_info = splitext(link.filename)[0]
|
||||
return package_to_requirement(egg_info)
|
||||
|
||||
|
||||
def package_to_requirement(package_name):
|
||||
"""Translate a name like Foo-1.2 to Foo==1.3"""
|
||||
match = re.search(r'^(.*?)-(dev|\d.*)', package_name)
|
||||
if match:
|
||||
name = match.group(1)
|
||||
version = match.group(2)
|
||||
else:
|
||||
name = package_name
|
||||
version = ''
|
||||
if version:
|
||||
return '%s==%s' % (name, version)
|
||||
else:
|
||||
return name
|
||||
|
||||
|
||||
def get_mirrors(hostname=None):
|
||||
"""Return the list of mirrors from the last record found on the DNS
|
||||
entry::
|
||||
|
||||
>>> from pip.index import get_mirrors
|
||||
>>> get_mirrors()
|
||||
['a.pypi.python.org', 'b.pypi.python.org', 'c.pypi.python.org',
|
||||
'd.pypi.python.org']
|
||||
|
||||
Originally written for the distutils2 project by Alexis Metaireau.
|
||||
"""
|
||||
if hostname is None:
|
||||
hostname = DEFAULT_MIRROR_HOSTNAME
|
||||
|
||||
# return the last mirror registered on PyPI.
|
||||
last_mirror_hostname = None
|
||||
try:
|
||||
last_mirror_hostname = socket.gethostbyname_ex(hostname)[0]
|
||||
except socket.gaierror:
|
||||
return []
|
||||
if not last_mirror_hostname or last_mirror_hostname == DEFAULT_MIRROR_HOSTNAME:
|
||||
last_mirror_hostname = "z.pypi.python.org"
|
||||
end_letter = last_mirror_hostname.split(".", 1)
|
||||
|
||||
# determine the list from the last one.
|
||||
return ["%s.%s" % (s, end_letter[1]) for s in string_range(end_letter[0])]
|
||||
|
||||
|
||||
def string_range(last):
|
||||
"""Compute the range of string between "a" and last.
|
||||
|
||||
This works for simple "a to z" lists, but also for "a to zz" lists.
|
||||
"""
|
||||
for k in range(len(last)):
|
||||
for x in product(string.ascii_lowercase, repeat=k+1):
|
||||
result = ''.join(x)
|
||||
yield result
|
||||
if result == last:
|
||||
return
|
||||
|
||||
Vendored
-100
@@ -1,100 +0,0 @@
|
||||
"""Locations where we look for configs, install stuff, etc"""
|
||||
|
||||
import sys
|
||||
import site
|
||||
import os
|
||||
import tempfile
|
||||
import getpass
|
||||
from pip.backwardcompat import get_python_lib
|
||||
import pip.exceptions
|
||||
|
||||
default_cert_path = os.path.join(os.path.dirname(__file__), 'cacert.pem')
|
||||
|
||||
def running_under_virtualenv():
|
||||
"""
|
||||
Return True if we're running inside a virtualenv, False otherwise.
|
||||
|
||||
"""
|
||||
return hasattr(sys, 'real_prefix')
|
||||
|
||||
|
||||
def virtualenv_no_global():
|
||||
"""
|
||||
Return True if in a venv and no system site packages.
|
||||
"""
|
||||
#this mirrors the logic in virtualenv.py for locating the no-global-site-packages.txt file
|
||||
site_mod_dir = os.path.dirname(os.path.abspath(site.__file__))
|
||||
no_global_file = os.path.join(site_mod_dir, 'no-global-site-packages.txt')
|
||||
if running_under_virtualenv() and os.path.isfile(no_global_file):
|
||||
return True
|
||||
|
||||
def _get_build_prefix():
|
||||
""" Returns a safe build_prefix """
|
||||
path = os.path.join(tempfile.gettempdir(), 'pip-build-%s' % \
|
||||
getpass.getuser())
|
||||
if sys.platform == 'win32':
|
||||
""" on windows(tested on 7) temp dirs are isolated """
|
||||
return path
|
||||
try:
|
||||
os.mkdir(path)
|
||||
except OSError:
|
||||
file_uid = None
|
||||
try:
|
||||
fd = os.open(path, os.O_RDONLY | os.O_NOFOLLOW)
|
||||
file_uid = os.fstat(fd).st_uid
|
||||
os.close(fd)
|
||||
except OSError:
|
||||
file_uid = None
|
||||
if file_uid != os.getuid():
|
||||
msg = "The temporary folder for building (%s) is not owned by your user!" \
|
||||
% path
|
||||
print (msg)
|
||||
print("pip will not work until the temporary folder is " + \
|
||||
"either deleted or owned by your user account.")
|
||||
raise pip.exceptions.InstallationError(msg)
|
||||
return path
|
||||
|
||||
if running_under_virtualenv():
|
||||
build_prefix = os.path.join(sys.prefix, 'build')
|
||||
src_prefix = os.path.join(sys.prefix, 'src')
|
||||
else:
|
||||
# Use tempfile to create a temporary folder for build
|
||||
# Note: we are NOT using mkdtemp so we can have a consistent build dir
|
||||
# Note: using realpath due to tmp dirs on OSX being symlinks
|
||||
build_prefix = _get_build_prefix()
|
||||
|
||||
## FIXME: keep src in cwd for now (it is not a temporary folder)
|
||||
try:
|
||||
src_prefix = os.path.join(os.getcwd(), 'src')
|
||||
except OSError:
|
||||
# In case the current working directory has been renamed or deleted
|
||||
sys.exit("The folder you are executing pip from can no longer be found.")
|
||||
|
||||
# under Mac OS X + virtualenv sys.prefix is not properly resolved
|
||||
# it is something like /path/to/python/bin/..
|
||||
build_prefix = os.path.abspath(os.path.realpath(build_prefix))
|
||||
src_prefix = os.path.abspath(src_prefix)
|
||||
|
||||
# FIXME doesn't account for venv linked to global site-packages
|
||||
|
||||
site_packages = get_python_lib()
|
||||
user_dir = os.path.expanduser('~')
|
||||
if sys.platform == 'win32':
|
||||
bin_py = os.path.join(sys.prefix, 'Scripts')
|
||||
# buildout uses 'bin' on Windows too?
|
||||
if not os.path.exists(bin_py):
|
||||
bin_py = os.path.join(sys.prefix, 'bin')
|
||||
default_storage_dir = os.path.join(user_dir, 'pip')
|
||||
default_config_file = os.path.join(default_storage_dir, 'pip.ini')
|
||||
default_log_file = os.path.join(default_storage_dir, 'pip.log')
|
||||
else:
|
||||
bin_py = os.path.join(sys.prefix, 'bin')
|
||||
default_storage_dir = os.path.join(user_dir, '.pip')
|
||||
default_config_file = os.path.join(default_storage_dir, 'pip.conf')
|
||||
default_log_file = os.path.join(default_storage_dir, 'pip.log')
|
||||
|
||||
# Forcing to use /usr/local/bin for standard Mac OS X framework installs
|
||||
# Also log to ~/Library/Logs/ for use with the Console.app log viewer
|
||||
if sys.platform[:6] == 'darwin' and sys.prefix[:16] == '/System/Library/':
|
||||
bin_py = '/usr/local/bin'
|
||||
default_log_file = os.path.join(user_dir, 'Library/Logs/pip.log')
|
||||
Vendored
-11
@@ -1,11 +0,0 @@
|
||||
[nosetests]
|
||||
where = tests
|
||||
|
||||
[aliases]
|
||||
dev = develop easy_install pip[testing]
|
||||
|
||||
[egg_info]
|
||||
tag_build =
|
||||
tag_date = 0
|
||||
tag_svn_revision = 0
|
||||
|
||||
Vendored
-61
@@ -1,61 +0,0 @@
|
||||
import codecs
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import textwrap
|
||||
from setuptools import setup
|
||||
|
||||
here = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
def read(*parts):
|
||||
# intentionally *not* adding an encoding option to open
|
||||
# see here: https://github.com/pypa/virtualenv/issues/201#issuecomment-3145690
|
||||
return codecs.open(os.path.join(here, *parts), 'r').read()
|
||||
|
||||
def find_version(*file_paths):
|
||||
version_file = read(*file_paths)
|
||||
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
|
||||
version_file, re.M)
|
||||
if version_match:
|
||||
return version_match.group(1)
|
||||
raise RuntimeError("Unable to find version string.")
|
||||
|
||||
long_description = "\n" + "\n".join([
|
||||
read('PROJECT.txt'),
|
||||
read('docs', 'quickstart.txt'),
|
||||
read('CHANGES.txt')])
|
||||
|
||||
tests_require = ['nose', 'virtualenv>=1.7', 'scripttest>=1.1.1', 'mock']
|
||||
|
||||
setup(name="pip",
|
||||
version=find_version('pip', '__init__.py'),
|
||||
description="A tool for installing and managing Python packages.",
|
||||
long_description=long_description,
|
||||
classifiers=[
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
'Intended Audience :: Developers',
|
||||
'License :: OSI Approved :: MIT License',
|
||||
'Topic :: Software Development :: Build Tools',
|
||||
'Programming Language :: Python :: 2',
|
||||
'Programming Language :: Python :: 2.5',
|
||||
'Programming Language :: Python :: 2.6',
|
||||
'Programming Language :: Python :: 2.7',
|
||||
'Programming Language :: Python :: 3',
|
||||
'Programming Language :: Python :: 3.1',
|
||||
'Programming Language :: Python :: 3.2',
|
||||
],
|
||||
keywords='easy_install distutils setuptools egg virtualenv',
|
||||
author='The pip developers',
|
||||
author_email='python-virtualenv@groups.google.com',
|
||||
url='http://www.pip-installer.org',
|
||||
license='MIT',
|
||||
packages=['pip', 'pip.commands', 'pip.vcs', 'pip.backwardcompat'],
|
||||
package_data={'pip': ['*.pem']},
|
||||
entry_points=dict(console_scripts=['pip=pip:main', 'pip-%s=pip:main' % sys.version[:3]]),
|
||||
test_suite='nose.collector',
|
||||
tests_require=tests_require,
|
||||
zip_safe=False,
|
||||
extras_require = {
|
||||
'testing':tests_require,
|
||||
},
|
||||
)
|
||||
+49
-3
@@ -1,61 +1,99 @@
|
||||
Alex Gaynor
|
||||
Alex Grönholm
|
||||
Alex Morega
|
||||
Alexandre Conrad
|
||||
Andrey Bulgakov
|
||||
Anrs Hu
|
||||
Anton Patrushev
|
||||
Antti Kaihola
|
||||
Armin Ronacher
|
||||
Aziz Köksal
|
||||
Ben Rosser
|
||||
Bernardo B. Marques
|
||||
Bradley Ayers
|
||||
Brian Rosner
|
||||
Carl Meyer
|
||||
Chris McDonough
|
||||
Christian Oudard
|
||||
Clay McClure
|
||||
Cody Soyland
|
||||
Craig Kerstiens
|
||||
Cristian Sorinel
|
||||
Dan Sully
|
||||
Daniel Holth
|
||||
Dave Abrahams
|
||||
David (d1b)
|
||||
David Aguilar
|
||||
David Evans
|
||||
David Pursehouse
|
||||
dengzhp
|
||||
Dmitry Gladkov
|
||||
Donald Stufft
|
||||
Endoh Takanao
|
||||
enoch
|
||||
Erik M. Bray
|
||||
Francesco
|
||||
Gabriel de Perthuis
|
||||
Garry Polley
|
||||
Geoffrey Lehée
|
||||
George Song
|
||||
Georgi Valkov
|
||||
Herbert Pfennig
|
||||
hetmankp
|
||||
Hugo Lopes Tavares
|
||||
Hynek Schlawack
|
||||
Ian Bicking
|
||||
Igor Sobreira
|
||||
Ionel Maries Cristian
|
||||
Jakub Vysoky
|
||||
James Cleveland
|
||||
Jannis Leidel
|
||||
Jakub Stasiak
|
||||
Jay Graves
|
||||
Jeff Dairiki
|
||||
John-Scott Atlakson
|
||||
Jon Parise
|
||||
Jonas Nockert
|
||||
Jon Parise
|
||||
Jorge Niedbalski
|
||||
Josh Bronson
|
||||
Josh Hansen
|
||||
Kamal Bin Mustafa
|
||||
Kelsey Hightower
|
||||
Kenneth Belitzky
|
||||
Kenneth Reitz
|
||||
Kevin Frommelt
|
||||
Kumar McMillan
|
||||
Lev Givon
|
||||
Lincoln de Sousa
|
||||
Luke Macken
|
||||
Masklinn
|
||||
Marc Abramowitz
|
||||
Marc Tamlyn
|
||||
Marcus Smith
|
||||
Markus Hametner
|
||||
Matt Maker
|
||||
Maxime R.
|
||||
Miguel Araujo
|
||||
Maxime Rouyrre
|
||||
Michael Williamson
|
||||
Miguel Araujo Perez
|
||||
Monty Taylor
|
||||
Nick Stenning
|
||||
Nowell Strite
|
||||
Oliver Tonnhofer
|
||||
Olivier Girardot
|
||||
Ollie Rutherfurd
|
||||
Oren Held
|
||||
Patrick Jenkins
|
||||
Patrick Dubroy
|
||||
Paul Moore
|
||||
Paul Nasrat
|
||||
Paul Oswald
|
||||
Paul van der Linden
|
||||
Peter Waller
|
||||
Phil Freo
|
||||
Phil Whelan
|
||||
Piet Delport
|
||||
Preston Holmes
|
||||
Przemek Wrzos
|
||||
Qiangning Hong
|
||||
Rafael Caricio
|
||||
@@ -63,12 +101,20 @@ Rene Dudfield
|
||||
Roey Berman
|
||||
Ronny Pfannschmidt
|
||||
Rory McCann
|
||||
Ross Brattain
|
||||
Sergey Vasilyev
|
||||
Seth Woodworth
|
||||
Simon Cross
|
||||
Stavros Korokithakis
|
||||
Stéphane Klein
|
||||
Steven Myint
|
||||
Takayuki SHIMIZUKAWA
|
||||
Thomas Fenzl
|
||||
Thomas Johansson
|
||||
Toshio Kuratomi
|
||||
Travis Swicegood
|
||||
Vinay Sajip
|
||||
Vitaly Babiy
|
||||
W Trevor King
|
||||
W. Trevor King
|
||||
Wil Tan
|
||||
Hsiaoming Yang
|
||||
+175
-2
@@ -1,6 +1,179 @@
|
||||
Changelog
|
||||
=========
|
||||
|
||||
1.5.2 (2014-01-26)
|
||||
------------------
|
||||
|
||||
* Upgraded the vendored ``pkg_resources`` and ``_markerlib`` to setuptools 2.1.
|
||||
|
||||
* Fixed an error that prevented accessing PyPI when pyopenssl, ndg-httpsclient,
|
||||
and pyasn1 are installed
|
||||
|
||||
* Fixed an issue that caused trailing comments to be incorrectly included as
|
||||
part of the URL in a requirements file
|
||||
|
||||
|
||||
1.5.1 (2014-01-20)
|
||||
------------------
|
||||
|
||||
* pip now only requires setuptools (any setuptools, not a certain version) when
|
||||
installing distributions from src (i.e. not from wheel). (Pull #1434).
|
||||
|
||||
* `get-pip.py` now installs setuptools, when it's not already installed (Pull
|
||||
#1475)
|
||||
|
||||
* Don't decode downloaded files that have a ``Content-Encoding`` header. (Pull
|
||||
#1435)
|
||||
|
||||
* Fix to correctly parse wheel filenames with single digit versions. (Pull
|
||||
#1445)
|
||||
|
||||
* If `--allow-unverified` is used assume it also means `--allow-external`. (Pull
|
||||
#1457)
|
||||
|
||||
|
||||
|
||||
1.5 (2014-01-01)
|
||||
----------------
|
||||
|
||||
* **BACKWARD INCOMPATIBLE** pip no longer supports the ``--use-mirrors``,
|
||||
``-M``, and ``--mirrors`` flags. The mirroring support has been removed. In
|
||||
order to use a mirror specify it as the primary index with ``-i`` or
|
||||
``--index-url``, or as an additional index with ``--extra-index-url``. (Pull #1098, CVE-2013-5123)
|
||||
|
||||
* **BACKWARD INCOMPATIBLE** pip no longer will scrape insecure external urls by
|
||||
default nor will it install externally hosted files by default. Users may opt
|
||||
into installing externally hosted or insecure files or urls using
|
||||
``--allow-external PROJECT`` and ``--allow-unverified PROJECT``. (Pull #1055)
|
||||
|
||||
* **BACKWARD INCOMPATIBLE** pip no longer respects dependency links by default.
|
||||
Users may opt into respecting them again using ``--process-dependency-links``.
|
||||
|
||||
* **DEPRECATION** ``pip install --no-install`` and ``pip install
|
||||
--no-download`` are now formally deprecated. See Issue #906 for discussion on
|
||||
possible alternatives, or lack thereof, in future releases.
|
||||
|
||||
* **DEPRECATION** ``pip zip`` and ``pip unzip`` are now formally deprecated.
|
||||
|
||||
* pip will now install Mac OSX platform wheels from PyPI. (Pull #1278)
|
||||
|
||||
* pip now generates the appropriate platform-specific console scripts when
|
||||
installing wheels. (Pull #1251)
|
||||
|
||||
* Pip now confirms a wheel is supported when installing directly from a path or
|
||||
url. (Pull #1315)
|
||||
|
||||
* Fixed #1097, ``--ignore-installed`` now behaves again as designed, after it was
|
||||
unintentionally broke in v0.8.3 when fixing Issue #14 (Pull #1352).
|
||||
|
||||
* Fixed a bug where global scripts were being removed when uninstalling --user
|
||||
installed packages (Pull #1353).
|
||||
|
||||
* Fixed #1163, --user wasn't being respected when installing scripts from wheels (Pull #1176).
|
||||
|
||||
* Fixed #1150, we now assume '_' means '-' in versions from wheel filenames (Pull #1158).
|
||||
|
||||
* Fixed #219, error when using --log with a failed install (Pull #1205).
|
||||
|
||||
* Fixed #1131, logging was buffered and choppy in Python 3.
|
||||
|
||||
* Fixed #70, --timeout was being ignored (Pull #1202).
|
||||
|
||||
* Fixed #772, error when setting PIP_EXISTS_ACTION (Pull #1201).
|
||||
|
||||
* Added colors to the logging output in order to draw attention to important
|
||||
warnings and errors. (Pull #1109)
|
||||
|
||||
* Added warnings when using an insecure index, find-link, or dependency link. (Pull #1121)
|
||||
|
||||
* Added support for installing packages from a subdirectory using the ``subdirectory``
|
||||
editable option. ( Pull #1082 )
|
||||
|
||||
* Fixed #1192. "TypeError: bad operand type for unary" in some cases when
|
||||
installing wheels using --find-links (Pull #1218).
|
||||
|
||||
* Fixed #1133 and #317. Archive contents are now written based on system
|
||||
defaults and umask (i.e. permissions are not preserved), except that regular
|
||||
files with any execute permissions have the equivalent of "chmod +x" applied
|
||||
after being written (Pull #1146).
|
||||
|
||||
* PreviousBuildDirError now returns a non-zero exit code and prevents the
|
||||
previous build dir from being cleaned in all cases (Pull #1162).
|
||||
|
||||
* Renamed --allow-insecure to --allow-unverified, however the old name will
|
||||
continue to work for a period of time (Pull #1257).
|
||||
|
||||
* Fixed #1006, error when installing local projects with symlinks in
|
||||
Python 3. (Pull #1311)
|
||||
|
||||
* The previously hidden ``--log-file`` otion, is now shown as a general option.
|
||||
(Pull #1316)
|
||||
|
||||
|
||||
|
||||
|
||||
1.4.1 (2013-08-07)
|
||||
------------------
|
||||
|
||||
* **New Signing Key** Release 1.4.1 is using a different key than normal with
|
||||
fingerprint: 7C6B 7C5D 5E2B 6356 A926 F04F 6E3C BCE9 3372 DCFA
|
||||
* Fixed issues with installing from pybundle files (Pull #1116).
|
||||
* Fixed error when sysconfig module throws an exception (Pull #1095).
|
||||
* Don't ignore already installed pre-releases (Pull #1076).
|
||||
* Fixes related to upgrading setuptools (Pull #1092).
|
||||
* Fixes so that --download works with wheel archives (Pull #1113).
|
||||
* Fixes related to recognizing and cleaning global build dirs (Pull #1080).
|
||||
|
||||
|
||||
1.4 (2013-07-23)
|
||||
----------------
|
||||
|
||||
* **BACKWARD INCOMPATIBLE** pip now only installs stable versions by default,
|
||||
and offers a new ``--pre`` option to also find pre-release and development
|
||||
versions. (Pull #834)
|
||||
|
||||
* **BACKWARD INCOMPATIBLE** Dropped support for Python 2.5. The minimum
|
||||
supported Python version for pip 1.4 is Python 2.6.
|
||||
|
||||
* Added support for installing and building wheel archives.
|
||||
Thanks Daniel Holth, Marcus Smith, Paul Moore, and Michele Lacchia
|
||||
(Pull #845)
|
||||
|
||||
* Applied security patch to pip's ssl support related to certificate DNS
|
||||
wildcard matching (http://bugs.python.org/issue17980).
|
||||
|
||||
* To satisfy pip's setuptools requirement, pip now recommends setuptools>=0.8,
|
||||
not distribute. setuptools and distribute are now merged into one project
|
||||
called 'setuptools'. (Pull #1003)
|
||||
|
||||
* pip will now warn when installing a file that is either hosted externally to
|
||||
the index or cannot be verified with a hash. In the future pip will default
|
||||
to not installing them and will require the flags --allow-external NAME, and
|
||||
--allow-insecure NAME respectively. (Pull #985)
|
||||
|
||||
* If an already-downloaded or cached file has a bad hash, re-download it rather
|
||||
than erroring out. (Issue #963).
|
||||
|
||||
* ``pip bundle`` and support for installing from pybundle files is now
|
||||
considered deprecated and will be removed in pip v1.5.
|
||||
|
||||
* Fixed a number of issues (#413, #709, #634, #602, and #939) related to
|
||||
cleaning up and not reusing build directories. (Pull #865, #948)
|
||||
|
||||
* Added a User Agent so that pip is identifiable in logs. (Pull #901)
|
||||
|
||||
* Added ssl and --user support to get-pip.py. Thanks Gabriel de Perthuis.
|
||||
(Pull #895)
|
||||
|
||||
* Fixed the proxy support, which was broken in pip 1.3.x (Pull #840)
|
||||
|
||||
* Fixed issue #32 - pip fails when server does not send content-type header.
|
||||
Thanks Hugo Lopes Tavares and Kelsey Hightower (Pull #872).
|
||||
|
||||
* "Vendorized" distlib as pip.vendor.distlib (https://distlib.readthedocs.org/).
|
||||
|
||||
* Fixed git VCS backend with git 1.8.3. (Pull #967)
|
||||
|
||||
1.3.1 (2013-03-08)
|
||||
------------------
|
||||
|
||||
@@ -11,13 +184,13 @@ Changelog
|
||||
----------------
|
||||
|
||||
* SSL Cert Verification; Make https the default for PyPI access.
|
||||
Thanks James Cleveland, Giovanni Bajo, Marcus Smith and many others (Pull #789).
|
||||
Thanks James Cleveland, Giovanni Bajo, Marcus Smith and many others (Pull #791, CVE-2013-1629).
|
||||
|
||||
* Added "pip list" for listing installed packages and the latest version
|
||||
available. Thanks Rafael Caricio, Miguel Araujo, Dmitry Gladkov (Pull #752)
|
||||
|
||||
* Fixed security issues with pip's use of temp build directories.
|
||||
Thanks David (d1b) and Thomas Guttler. (Pull #780)
|
||||
Thanks David (d1b) and Thomas Guttler. (Pull #780, CVE-2013-1888)
|
||||
|
||||
* Improvements to sphinx docs and cli help. (Pull #773)
|
||||
|
||||
+1
-20
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2008-2013 The pip developers (see AUTHORS.txt file)
|
||||
Copyright (c) 2008-2014 The pip developers (see AUTHORS.txt file)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
@@ -18,22 +18,3 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
License for Bundle of CA Root Certificates (pip/cacert.pem)
|
||||
===========================================================
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
02110-1301
|
||||
@@ -3,7 +3,7 @@ include LICENSE.txt
|
||||
include CHANGES.txt
|
||||
include PROJECT.txt
|
||||
include pip/cacert.pem
|
||||
recursive-include docs *.txt
|
||||
recursive-include docs *.rst
|
||||
recursive-include docs *.html
|
||||
recursive-exclude docs/_build *.txt
|
||||
recursive-exclude docs/_build *.rst
|
||||
prune docs/_build/_sources
|
||||
Vendored
+86
@@ -0,0 +1,86 @@
|
||||
Metadata-Version: 1.1
|
||||
Name: pip
|
||||
Version: 1.5.2
|
||||
Summary: A tool for installing and managing Python packages.
|
||||
Home-page: http://www.pip-installer.org
|
||||
Author: The pip developers
|
||||
Author-email: python-virtualenv@groups.google.com
|
||||
License: MIT
|
||||
Description:
|
||||
Project Info
|
||||
============
|
||||
|
||||
* Project Page: https://github.com/pypa/pip
|
||||
* Install howto: http://www.pip-installer.org/en/latest/installing.html
|
||||
* Changelog: http://www.pip-installer.org/en/latest/news.html
|
||||
* Bug Tracking: https://github.com/pypa/pip/issues
|
||||
* Mailing list: http://groups.google.com/group/python-virtualenv
|
||||
* Docs: http://www.pip-installer.org/
|
||||
* IRC: #pip on Freenode.
|
||||
|
||||
Quickstart
|
||||
==========
|
||||
|
||||
Install a package:
|
||||
|
||||
::
|
||||
|
||||
$ pip install SomePackage==1.0
|
||||
[...]
|
||||
Successfully installed SomePackage
|
||||
|
||||
Show what files were installed:
|
||||
|
||||
::
|
||||
|
||||
$ pip show --files SomePackage
|
||||
Name: SomePackage
|
||||
Version: 1.0
|
||||
Location: /my/env/lib/pythonx.x/site-packages
|
||||
Files:
|
||||
../somepackage/__init__.py
|
||||
[...]
|
||||
|
||||
List what packages are outdated:
|
||||
|
||||
::
|
||||
|
||||
$ pip list --outdated
|
||||
SomePackage (Current: 1.0 Latest: 2.0)
|
||||
|
||||
Upgrade a package:
|
||||
|
||||
::
|
||||
|
||||
$ pip install --upgrade SomePackage
|
||||
[...]
|
||||
Found existing installation: SomePackage 1.0
|
||||
Uninstalling SomePackage:
|
||||
Successfully uninstalled SomePackage
|
||||
Running setup.py install for SomePackage
|
||||
Successfully installed SomePackage
|
||||
|
||||
Uninstall a package:
|
||||
|
||||
::
|
||||
|
||||
$ pip uninstall SomePackage
|
||||
Uninstalling SomePackage:
|
||||
/my/env/lib/pythonx.x/site-packages/somepackage
|
||||
Proceed (y/n)? y
|
||||
Successfully uninstalled SomePackage
|
||||
|
||||
|
||||
Keywords: easy_install distutils setuptools egg virtualenv
|
||||
Platform: UNKNOWN
|
||||
Classifier: Development Status :: 5 - Production/Stable
|
||||
Classifier: Intended Audience :: Developers
|
||||
Classifier: License :: OSI Approved :: MIT License
|
||||
Classifier: Topic :: Software Development :: Build Tools
|
||||
Classifier: Programming Language :: Python :: 2
|
||||
Classifier: Programming Language :: Python :: 2.6
|
||||
Classifier: Programming Language :: Python :: 2.7
|
||||
Classifier: Programming Language :: Python :: 3
|
||||
Classifier: Programming Language :: Python :: 3.1
|
||||
Classifier: Programming Language :: Python :: 3.2
|
||||
Classifier: Programming Language :: Python :: 3.3
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
Project Info
|
||||
============
|
||||
|
||||
* Project Page: https://github.com/pypa/pip
|
||||
* Install howto: http://www.pip-installer.org/en/latest/installing.html
|
||||
* Changelog: http://www.pip-installer.org/en/latest/news.html
|
||||
* Bug Tracking: https://github.com/pypa/pip/issues
|
||||
* Mailing list: http://groups.google.com/group/python-virtualenv
|
||||
* Docs: http://www.pip-installer.org/
|
||||
* IRC: #pip on Freenode.
|
||||
@@ -1,6 +1,9 @@
|
||||
pip
|
||||
===
|
||||
|
||||
.. image:: https://pypip.in/v/pip/badge.png
|
||||
:target: https://crate.io/packages/pip
|
||||
|
||||
.. image:: https://secure.travis-ci.org/pypa/pip.png?branch=develop
|
||||
:target: http://travis-ci.org/pypa/pip
|
||||
|
||||
+2
@@ -3,6 +3,8 @@
|
||||
Configuration
|
||||
=================
|
||||
|
||||
.. _config-file:
|
||||
|
||||
Config file
|
||||
------------
|
||||
|
||||
Vendored
+453
@@ -0,0 +1,453 @@
|
||||
============
|
||||
Cookbook
|
||||
============
|
||||
|
||||
.. _`Requirements Files`:
|
||||
|
||||
Requirements Files
|
||||
******************
|
||||
|
||||
"Requirements files" are files containing a list of items to be
|
||||
installed using :ref:`pip install -r <install_--requirement>` like so:
|
||||
|
||||
::
|
||||
|
||||
pip install -r requirements.txt
|
||||
|
||||
|
||||
Details on the format of the files are here: :ref:`Requirements File Format`.
|
||||
|
||||
|
||||
There are 3 common use cases for requirements files:
|
||||
|
||||
1. When installing many things, it's easier to use a requirements file,
|
||||
than specifying them all on the command line.
|
||||
|
||||
2. Requirements files are often used to hold the result from :ref:`pip freeze`
|
||||
for the purpose of achieving :ref:`repeatable installations <Repeatability>`.
|
||||
In this case, your requirement file contains a pinned version of everything
|
||||
that was installed when `pip freeze` was run.
|
||||
|
||||
::
|
||||
|
||||
pip freeze > requirements.txt
|
||||
pip install -r requirements.txt
|
||||
|
||||
3. Requirements files can be used to force pip to properly resolve dependencies.
|
||||
As it is now, pip `doesn't have true dependency resolution
|
||||
<https://github.com/pypa/pip/issues/988>`_, but instead simply uses the first
|
||||
specification it finds for a project. E.g if `pkg1` requires `pkg3>=1.0` and
|
||||
`pkg2` requires `pkg3>=1.0,<=2.0`, and if `pkg1` is resolved first, pip will
|
||||
only use `pkg3>=1.0`, and could easily end up installing a version of `pkg3`
|
||||
that conflicts with the needs of `pkg2`. To solve this problem, you can
|
||||
place `pkg3>=1.0,<=2.0` (i.e. the correct specification) into your
|
||||
requirements file directly along with the other top level requirements. Like
|
||||
so:
|
||||
|
||||
::
|
||||
|
||||
pkg1
|
||||
pkg2
|
||||
pkg3>=1.0,<=2.0
|
||||
|
||||
|
||||
It's important to be clear that pip determines package dependencies using `install_requires metadata
|
||||
<http://pythonhosted.org/setuptools/setuptools.html#declaring-dependencies>`_, not by discovering `requirements.txt`
|
||||
files embedded in projects.
|
||||
|
||||
For a good discussion on the conceptual differences between setup.py and
|
||||
requirements, see `"setup.py vs requirements.txt" (an article by Donald Stufft)
|
||||
<https://caremad.io/blog/setup-vs-requirement/>`_
|
||||
|
||||
See also:
|
||||
|
||||
* :ref:`Requirements File Format`
|
||||
* :ref:`pip freeze`
|
||||
|
||||
|
||||
.. _`Fast & Local Installs`:
|
||||
|
||||
Fast & Local Installs
|
||||
*********************
|
||||
|
||||
Often, you will want a fast install from local archives, without probing PyPI.
|
||||
|
||||
First, :ref:`download the archives <Downloading Archives>` that fulfill your requirements::
|
||||
|
||||
$ pip install --download <DIR> -r requirements.txt
|
||||
|
||||
Then, install using :ref:`--find-links <--find-links>` and :ref:`--no-index <--no-index>`::
|
||||
|
||||
$ pip install --no-index --find-links=[file://]<DIR> -r requirements.txt
|
||||
|
||||
|
||||
.. _`Building and Installing Wheels`:
|
||||
|
||||
Building and Installing Wheels
|
||||
******************************
|
||||
|
||||
"Wheel" is a built, archive format that can greatly speed installation compared
|
||||
to building and installing from source archives. For more information, see the
|
||||
`Wheel docs <http://wheel.readthedocs.org>`_ ,
|
||||
`PEP427 <http://www.python.org/dev/peps/pep-0427>`_, and
|
||||
`PEP425 <http://www.python.org/dev/peps/pep-0425>`_
|
||||
|
||||
Pip prefers Wheels where they are available, to disable this use the
|
||||
:ref:`--no-use-wheel <install_--no-use-wheel>` flag for :ref:`pip install`.
|
||||
|
||||
If no satisfactory wheels are found, pip will default to finding source archives.
|
||||
|
||||
.. note::
|
||||
|
||||
pip currently disallows platform-specific wheels (except for Windows and Mac)
|
||||
from being downloaded from PyPI. See :ref:`Should you upload wheels to PyPI`.
|
||||
|
||||
|
||||
To install directly from a wheel archive:
|
||||
|
||||
::
|
||||
|
||||
pip install SomePackage-1.0-py2.py3-none-any.whl
|
||||
|
||||
|
||||
pip additionally offers :ref:`pip wheel` as a convenience, to build wheels for
|
||||
your requirements and dependencies.
|
||||
|
||||
:ref:`pip wheel` requires the `wheel package <https://pypi.python.org/pypi/wheel>`_ to be installed,
|
||||
which provides the "bdist_wheel" setuptools extension that it uses.
|
||||
|
||||
To build wheels for your requirements and all their dependencies to a local directory:
|
||||
|
||||
::
|
||||
|
||||
pip install wheel
|
||||
pip wheel --wheel-dir=/local/wheels -r requirements.txt
|
||||
|
||||
|
||||
.. warning::
|
||||
|
||||
Currently, when ``pip wheel`` finds a wheel for one of your requirements
|
||||
already on PyPI, it does not rebuild, and it does not place the file in your
|
||||
wheelhouse dir. There is an issue open to change this
|
||||
(https://github.com/pypa/pip/issues/1310)
|
||||
|
||||
|
||||
|
||||
And *then* to install those requirements just using your local directory of wheels (and not from PyPI):
|
||||
|
||||
::
|
||||
|
||||
pip install --no-index --find-links=/local/wheels -r requirements.txt
|
||||
|
||||
|
||||
.. _`Should you upload wheels to PyPI`:
|
||||
|
||||
Should you upload wheels to PyPI?
|
||||
---------------------------------
|
||||
|
||||
The wheel format can eliminate a lot of redundant compilation but, alas,
|
||||
it's not generally advisable to upload your pre-compiled linux-x86-64
|
||||
library binding to pypi. Wheel's tags are only designed to express
|
||||
the most important *Python*-specific compatibility concerns (Python
|
||||
version, ABI, and architecture) but do not represent other important
|
||||
binary compatibility factors such as the OS release, patch level, and
|
||||
the versions of all the shared library dependencies of any extensions
|
||||
inside the package.
|
||||
|
||||
Rather than representing all possible compatibility information in the
|
||||
wheel itself, the wheel design suggests distribution-specific build
|
||||
services (e.g. a separate index for Fedora Linux binary wheels, compiled
|
||||
by the index maintainer). This is the same solution taken by Linux
|
||||
distributions which all re-compile their own packages instead of installing
|
||||
each other's binary packages.
|
||||
|
||||
Some kinds of precompiled C extension modules can make sense on PyPI, even
|
||||
for Linux. Good examples include things that can be sensibly statically
|
||||
linked (a cryptographic hash function; an accelerator module that is
|
||||
not a binding for an external library); the best example of something
|
||||
that shouldn't be statically linked is a library like openssl that needs
|
||||
to be constantly kept up-to-date for security. Regardless of whether a
|
||||
compatible pre-build package is available, many Linux users will prefer
|
||||
to always compile their own anyway.
|
||||
|
||||
On Windows and Mac, the case for binary wheels on pypi is stronger due to the
|
||||
systems being much more uniform than Linux and because it's harder for the end
|
||||
user to compile their own. Windows and Mac wheels uploaded to pypi should be
|
||||
compatible with the Python distributions downloaded from http://python.org/. If
|
||||
you already upload other binary formats to pypi, upload wheels as well. Unlike
|
||||
the older formats, wheels are compatible with virtual environments.
|
||||
|
||||
|
||||
.. _`Downloading Archives`:
|
||||
|
||||
Downloading archives
|
||||
********************
|
||||
|
||||
pip allows you to *just* download the source archives for your requirements, without installing anything and without regard to what's already installed.
|
||||
|
||||
::
|
||||
|
||||
$ pip install --download <DIR> -r requirements.txt
|
||||
|
||||
or, for a specific package::
|
||||
|
||||
$ pip install --download <DIR> SomePackage
|
||||
|
||||
|
||||
Unpacking archives
|
||||
******************
|
||||
|
||||
pip allows you to *just* unpack archives to a build directory without installing them to site-packages. This can be useful to troubleshoot install errors or to inspect what is being installed.
|
||||
|
||||
::
|
||||
|
||||
$ pip install --no-install SomePackage
|
||||
|
||||
If you're in a virtualenv, the build dir is ``<virtualenv path>/build``. Otherwise, it's ``<OS temp dir>/pip-build-<username>``
|
||||
|
||||
Afterwards, to finish the job of installing unpacked archives, run::
|
||||
|
||||
$ pip install --no-download SomePackage
|
||||
|
||||
|
||||
|
||||
Non-recursive upgrades
|
||||
************************
|
||||
|
||||
``pip install --upgrade`` is currently written to perform a recursive upgrade.
|
||||
|
||||
E.g. supposing:
|
||||
|
||||
* `SomePackage-1.0` requires `AnotherPackage>=1.0`
|
||||
* `SomePackage-2.0` requires `AnotherPackage>=1.0` and `OneMorePoject==1.0`
|
||||
* `SomePackage-1.0` and `AnotherPackage-1.0` are currently installed
|
||||
* `SomePackage-2.0` and `AnotherPackage-2.0` are the latest versions available on PyPI.
|
||||
|
||||
Running ``pip install --upgrade SomePackage`` would upgrade `SomePackage` *and* `AnotherPackage`
|
||||
despite `AnotherPackage` already being satisifed.
|
||||
|
||||
If you would like to perform a non-recursive upgrade perform these 2 steps::
|
||||
|
||||
pip install --upgrade --no-deps SomePackage
|
||||
pip install SomePackage
|
||||
|
||||
The first line will upgrade `SomePackage`, but not dependencies like `AnotherPackage`. The 2nd line will fill in new dependencies like `OneMorePackage`.
|
||||
|
||||
|
||||
.. _`Repeatability`:
|
||||
|
||||
Ensuring Repeatability
|
||||
**********************
|
||||
|
||||
Three things are required to fully guarantee a repeatable installation using requirements files.
|
||||
|
||||
1. The requirements file was generated by ``pip freeze`` or you're sure it only
|
||||
contains requirements that specify a specific version.
|
||||
2. The installation is performed using :ref:`--no-deps <install_--no-deps>`.
|
||||
This guarantees that only what is explicitly listed in the requirements file is
|
||||
installed.
|
||||
3. The installation is performed against an index or find-links location that is
|
||||
guaranteed to *not* allow archives to be changed and updated without a
|
||||
version increase. Unfortunately, this is *not* true on PyPI. It is possible
|
||||
for the same pypi distribution to have a different hash over time. Project
|
||||
authors are allowed to delete a distribution, and then upload a new one with
|
||||
the same name and version, but a different hash. See `Issue #1175
|
||||
<https://github.com/pypa/pip/issues/1175>`_ for plans to add hash
|
||||
confirmation to pip, or a new "lock file" notion, but for now, know that the `peep
|
||||
project <https://pypi.python.org/pypi/peep>`_ offers this feature on top of pip
|
||||
using requirements file comments.
|
||||
|
||||
User Installs
|
||||
*************
|
||||
|
||||
With Python 2.6 came the `"user scheme" for installation
|
||||
<http://docs.python.org/install/index.html#alternate-installation-the-user-scheme>`_, which means that all
|
||||
Python distributions support an alternative install location that is specific to a user.
|
||||
The default location for each OS is explained in the python documentation
|
||||
for the `site.USER_BASE <http://docs.python.org/library/site.html#site.USER_BASE>`_ variable.
|
||||
This mode of installation can be turned on by
|
||||
specifying the :ref:`--user <install_--user>` option to ``pip install``.
|
||||
|
||||
Moreover, the "user scheme" can be customized by setting the
|
||||
``PYTHONUSERBASE`` environment variable, which updates the value of ``site.USER_BASE``.
|
||||
|
||||
To install "SomePackage" into an environment with site.USER_BASE customized to '/myappenv', do the following::
|
||||
|
||||
export PYTHONUSERBASE=/myappenv
|
||||
pip install --user SomePackage
|
||||
|
||||
|
||||
``pip install --user`` follows four rules:
|
||||
|
||||
#. When globally installed packages are on the python path, and they *conflict*
|
||||
with the installation requirements, they are ignored, and *not*
|
||||
uninstalled.
|
||||
#. When globally installed packages are on the python path, and they *satisfy*
|
||||
the installation requirements, pip does nothing, and reports that
|
||||
requirement is satisfied (similar to how global packages can satisfy
|
||||
requirements when installing packages in a ``--system-site-packages``
|
||||
virtualenv).
|
||||
#. pip will not perform a ``--user`` install in a ``--no-site-packages``
|
||||
virtualenv (i.e. the default kind of virtualenv), due to the user site not
|
||||
being on the python path. The installation would be pointless.
|
||||
#. In a ``--system-site-packages`` virtualenv, pip will not install a package
|
||||
that conflicts with a package in the virtualenv site-packages. The --user
|
||||
installation would lack sys.path precedence and be pointless.
|
||||
|
||||
|
||||
To make the rules clearer, here are some examples:
|
||||
|
||||
|
||||
From within a ``--no-site-packages`` virtualenv (i.e. the default kind)::
|
||||
|
||||
$ pip install --user SomePackage
|
||||
Can not perform a '--user' install. User site-packages are not visible in this virtualenv.
|
||||
|
||||
|
||||
From within a ``--system-site-packages`` virtualenv where ``SomePackage==0.3`` is already installed in the virtualenv::
|
||||
|
||||
$ pip install --user SomePackage==0.4
|
||||
Will not install to the user site because it will lack sys.path precedence
|
||||
|
||||
|
||||
From within a real python, where ``SomePackage`` is *not* installed globally::
|
||||
|
||||
$ pip install --user SomePackage
|
||||
[...]
|
||||
Successfully installed SomePackage
|
||||
|
||||
|
||||
From within a real python, where ``SomePackage`` *is* installed globally, but is *not* the latest version::
|
||||
|
||||
$ pip install --user SomePackage
|
||||
[...]
|
||||
Requirement already satisfied (use --upgrade to upgrade)
|
||||
|
||||
$ pip install --user --upgrade SomePackage
|
||||
[...]
|
||||
Successfully installed SomePackage
|
||||
|
||||
|
||||
From within a real python, where ``SomePackage`` *is* installed globally, and is the latest version::
|
||||
|
||||
$ pip install --user SomePackage
|
||||
[...]
|
||||
Requirement already satisfied (use --upgrade to upgrade)
|
||||
|
||||
$ pip install --user --upgrade SomePackage
|
||||
[...]
|
||||
Requirement already up-to-date: SomePackage
|
||||
|
||||
# force the install
|
||||
$ pip install --user --ignore-installed SomePackage
|
||||
[...]
|
||||
Successfully installed SomePackage
|
||||
|
||||
|
||||
|
||||
Controlling setup_requires
|
||||
**************************
|
||||
|
||||
Setuptools offers the ``setup_requires``
|
||||
`setup() keyword <http://pythonhosted.org/setuptools/setuptools.html#new-and-changed-setup-keywords>`_
|
||||
for specifying dependencies that need to be present in order for the `setup.py` script to run.
|
||||
Internally, Setuptools uses ``easy_install`` to fulfill these dependencies.
|
||||
|
||||
pip has no way to control how these dependencies are located.
|
||||
None of the :ref:`Package Index Options <Package Index Options>` have an effect.
|
||||
|
||||
The solution is to configure a "system" or "personal"
|
||||
`Distutils configuration file <http://docs.python.org/2/install/index.html#distutils-configuration-files>`_
|
||||
to manage the fulfillment.
|
||||
|
||||
For example, to have the dependency located at an alternate index, add this:
|
||||
|
||||
::
|
||||
|
||||
[easy_install]
|
||||
index_url = https://my.index-mirror.com
|
||||
|
||||
To have the dependency located from a local directory and not crawl PyPI, add this:
|
||||
|
||||
::
|
||||
|
||||
[easy_install]
|
||||
allow_hosts = ''
|
||||
find_links = file:///path/to/local/archives
|
||||
|
||||
|
||||
Upgrading from distribute to setuptools
|
||||
***************************************
|
||||
|
||||
`distribute`_ has now been merged into `setuptools`_, and it is recommended to upgrade to setuptools when possible.
|
||||
|
||||
To upgrade from `distribute`_ to `setuptools`_ using pip, run::
|
||||
|
||||
pip install --upgrade setuptools
|
||||
|
||||
"ImportError: No module named setuptools"
|
||||
-----------------------------------------
|
||||
|
||||
Although using the upgrade command above works in isolation, it's possible to get
|
||||
"ImportError: No module named setuptools" when using pip<1.4 to upgrade a
|
||||
package that depends on setuptools or distribute.
|
||||
|
||||
e.g. when running a command like this: `pip install --upgrade pyramid`
|
||||
|
||||
Solution
|
||||
~~~~~~~~
|
||||
|
||||
To prevent the problem in *new* environments (that aren't broken yet):
|
||||
|
||||
* Option 1:
|
||||
|
||||
* *First* run `pip install -U setuptools`,
|
||||
* *Then* run the command to upgrade your package (e.g. `pip install --upgrade pyramid`)
|
||||
|
||||
* Option 2:
|
||||
|
||||
* Upgrade pip using :ref:`get-pip <get-pip>`
|
||||
* *Then* run the command to upgrade your package (e.g. `pip install --upgrade pyramid`)
|
||||
|
||||
To fix the problem once it's occurred, you'll need to manually install the new
|
||||
setuptools, then rerun the upgrade that failed.
|
||||
|
||||
1. Download `ez_setup.py` (https://bitbucket.org/pypa/setuptools/downloads/ez_setup.py)
|
||||
2. Run `python ez_setup.py`
|
||||
3. Then rerun your upgrade (e.g. `pip install --upgrade pyramid`)
|
||||
|
||||
|
||||
Cause
|
||||
~~~~~
|
||||
|
||||
distribute-0.7.3 is just an empty wrapper that only serves to require the new
|
||||
setuptools (setuptools>=0.7) so that it will be installed. (If you don't know
|
||||
yet, the "new setuptools" is a merge of distribute and setuptools back into one
|
||||
project).
|
||||
|
||||
distribute-0.7.3 does its job well, when the upgrade is done in isolation.
|
||||
E.g. if you're currently on distribute-0.6.X, then running `pip install -U
|
||||
setuptools` works fine to upgrade you to setuptools>=0.7.
|
||||
|
||||
The problem occurs when:
|
||||
|
||||
1. you are currently using an older distribute (i.e. 0.6.X)
|
||||
2. and you try to use pip to upgrade a package that *depends* on setuptools or
|
||||
distribute.
|
||||
|
||||
As part of the upgrade process, pip builds an install list that ends up
|
||||
including distribute-0.7.3 and setuptools>=0.7 , but they can end up being
|
||||
separated by other dependencies in the list, so what can happen is this:
|
||||
|
||||
1. pip uninstalls the existing distribute
|
||||
2. pip installs distribute-0.7.3 (which has no importable setuptools, that pip
|
||||
*needs* internally to function)
|
||||
3. pip moves on to install another dependency (before setuptools>=0.7) and is
|
||||
unable to proceed without the setuptools package
|
||||
|
||||
Note that pip v1.4 has fixes to prevent this. distribute-0.7.3 (or
|
||||
setuptools>=0.7) by themselves cannot prevent this kind of problem.
|
||||
|
||||
.. _setuptools: https://pypi.python.org/pypi/setuptools
|
||||
.. _distribute: https://pypi.python.org/pypi/distribute
|
||||
.. _PyPI: https://pypi.python.org
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
===========
|
||||
Development
|
||||
===========
|
||||
|
||||
Pull Requests
|
||||
=============
|
||||
|
||||
Submit Pull Requests against the `develop` branch.
|
||||
|
||||
Provide a good description of what you're doing and why.
|
||||
|
||||
Provide tests that cover your changes and try to run the tests locally first.
|
||||
|
||||
Automated Testing
|
||||
=================
|
||||
|
||||
All pull requests and merges to 'develop' branch are tested in `Travis <https://travis-ci.org/>`_
|
||||
based on our `.travis.yml file <https://github.com/pypa/pip/blob/develop/.travis.yml>`_.
|
||||
|
||||
Usually, a link to your specific travis build appears in pull requests, but if not,
|
||||
you can find it on our `travis pull requests page <https://travis-ci.org/pypa/pip/pull_requests>`_
|
||||
|
||||
The only way to trigger Travis to run again for a pull request, is to submit another change to the pull branch.
|
||||
|
||||
We also have Jenkins CI that runs regularly for certain python versions on windows and centos.
|
||||
|
||||
Running tests
|
||||
=============
|
||||
|
||||
OS Requirements: subversion, bazaar, git, and mercurial.
|
||||
|
||||
Python Requirements: tox or pytest, virtualenv, scripttest, and mock
|
||||
|
||||
Ways to run the tests locally:
|
||||
|
||||
::
|
||||
|
||||
$ tox -e py33 # The preferred way to run the tests, can use pyNN to
|
||||
# run for a particular version or leave off the -e to
|
||||
# run for all versions.
|
||||
$ python setup.py test # Using the setuptools test plugin
|
||||
$ py.test # Using py.test directly
|
||||
$ tox # Using tox against pip's tox.ini
|
||||
|
||||
|
||||
Getting Involved
|
||||
================
|
||||
|
||||
The pip project welcomes help in the following ways:
|
||||
|
||||
- Making Pull Requests for code, tests, or docs.
|
||||
- Commenting on open issues and pull requests.
|
||||
- Helping to answer questions on the mailing list.
|
||||
|
||||
If you want to become an official maintainer, start by helping out.
|
||||
|
||||
Later, when you think you're ready, get in touch with one of the maintainers,
|
||||
and they will initiate a vote.
|
||||
|
||||
Release Process
|
||||
===============
|
||||
|
||||
This process includes virtualenv, since pip releases necessitate a virtualenv release.
|
||||
|
||||
As an example, the instructions assume we're releasing pip-1.4, and virtualenv-1.10.
|
||||
|
||||
1. Upgrade setuptools, if needed:
|
||||
|
||||
#. Upgrade setuptools in ``virtualenv/develop`` using the :ref:`Refresh virtualenv` process.
|
||||
#. Create a pull request against ``pip/develop`` with a modified ``.travis.yml`` file that installs virtualenv from ``virtualenv/develop``, to confirm the travis builds are still passing.
|
||||
|
||||
2. Create Release branches:
|
||||
|
||||
#. Create ``pip/release-1.4`` branch.
|
||||
#. In ``pip/develop``, change ``pip.version`` to '1.5.dev1'.
|
||||
#. Create ``virtualenv/release-1.10`` branch.
|
||||
#. In ``virtualenv/develop``, change ``virtualenv.version`` to '1.11.dev1'.
|
||||
|
||||
3. Prepare "rcX":
|
||||
|
||||
#. In ``pip/release-1.4``, change ``pip.version`` to '1.4rcX', and tag with '1.4rcX'.
|
||||
#. Build a pip sdist from ``pip/release-1.4``, and build it into ``virtualenv/release-1.10`` using the :ref:`Refresh virtualenv` process.
|
||||
#. In ``virtualenv/release-1.10``, change ``virtualenv.version`` to '1.10rcX', and tag with '1.10rcX'.
|
||||
|
||||
4. Announce ``pip-1.4rcX`` and ``virtualenv-1.10rcX`` with the :ref:`RC Install Instructions` and elicit feedback.
|
||||
|
||||
5. Apply fixes to 'rcX':
|
||||
|
||||
#. Apply fixes to ``pip/release-1.4`` and ``virtualenv/release-1.10``
|
||||
#. Periodically merge fixes to ``pip/develop`` and ``virtualenv/develop``
|
||||
|
||||
6. Repeat #4 thru #6 if needed.
|
||||
|
||||
7. Final Release:
|
||||
|
||||
#. In ``pip/release-1.4``, change ``pip.version`` to '1.4', and tag with '1.4'.
|
||||
#. Merge ``pip/release-1.4`` to ``pip/master``.
|
||||
#. Build a pip sdist from ``pip/release-1.4``, and load it into ``virtualenv/release-1.10`` using the :ref:`Refresh virtualenv` process.
|
||||
#. Merge ``vitualenv/release-1.10`` to ``virtualenv/develop``.
|
||||
#. In ``virtualenv/release-1.10``, change ``virtualenv.version`` to '1.10', and tag with '1.10'.
|
||||
#. Merge ``virtualenv/release-1.10`` to ``virtualenv/master``
|
||||
#. Build and upload pip and virtualenv sdists to PyPI.
|
||||
|
||||
.. _`Refresh virtualenv`:
|
||||
|
||||
Refresh virtualenv
|
||||
++++++++++++++++++
|
||||
|
||||
#. Update the embedded versions of pip and setuptools in ``virtualenv_support``.
|
||||
#. Run ``bin/rebuild-script.py`` to rebuild virtualenv based on the latest versions.
|
||||
|
||||
|
||||
.. _`RC Install Instructions`:
|
||||
|
||||
RC Install Instructions
|
||||
+++++++++++++++++++++++
|
||||
|
||||
::
|
||||
|
||||
$ curl -L -O https://github.com/pypa/virtualenv/archive/1.10rc1.tar.gz
|
||||
$ echo "<md5sum value> 1.10rc1.tar.gz" | md5sum -c
|
||||
1.10rc1.tar.gz: OK
|
||||
$ tar zxf 1.10rc1.tar.gz
|
||||
$ python virtualenv-1.10rc1/virtualenv.py myVE
|
||||
$ myVE/bin/pip install SomePackage
|
||||
|
||||
Vendored
+26
@@ -0,0 +1,26 @@
|
||||
pip
|
||||
===
|
||||
|
||||
A tool for installing and managing Python packages.
|
||||
|
||||
`User list <http://groups.google.com/group/python-virtualenv>`_ |
|
||||
`Dev list <http://groups.google.com/group/pypa-dev>`_ |
|
||||
`Issues <https://github.com/pypa/pip/issues>`_ |
|
||||
`Github <https://github.com/pypa/pip>`_ |
|
||||
`PyPI <https://pypi.python.org/pypi/pip/>`_ |
|
||||
irc:#pip
|
||||
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
quickstart
|
||||
installing
|
||||
usage
|
||||
cookbook
|
||||
logic
|
||||
configuration
|
||||
other-tools
|
||||
development
|
||||
news
|
||||
|
||||
Vendored
+60
@@ -0,0 +1,60 @@
|
||||
.. _`Installation`:
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
Python & OS Support
|
||||
-------------------
|
||||
|
||||
pip works with CPython versions 2.6, 2.7, 3.1, 3.2, 3.3, 3.4 and also pypy.
|
||||
|
||||
pip works on Unix/Linux, OS X, and Windows.
|
||||
|
||||
.. note::
|
||||
|
||||
Python 2.5 was supported through v1.3.1, and Python 2.4 was supported through v1.1.
|
||||
|
||||
|
||||
.. _`get-pip`:
|
||||
|
||||
Install or Upgrade pip
|
||||
----------------------
|
||||
|
||||
To install or upgrade pip, securely download `get-pip.py
|
||||
<https://raw.github.com/pypa/pip/master/contrib/get-pip.py>`_. [1]_
|
||||
|
||||
Then run the following (which may require administrator access)::
|
||||
|
||||
$ python get-pip.py
|
||||
|
||||
.. note::
|
||||
|
||||
Beginning with v1.5.1, pip does not require `setuptools`_ prior to running
|
||||
`get-pip.py`. Additionally, if `setuptools`_ (or `distribute`_) is not
|
||||
already installed, `get-pip.py` will install `setuptools`_ for you.
|
||||
|
||||
|
||||
Using Package Managers
|
||||
----------------------
|
||||
|
||||
On Linux, pip will generally be available for the system install of python using
|
||||
the system package manager, although often the latest version will be
|
||||
unavailable.
|
||||
|
||||
On Debian and Ubuntu::
|
||||
|
||||
$ sudo apt-get install python-pip
|
||||
|
||||
On Fedora::
|
||||
|
||||
$ sudo yum install python-pip
|
||||
|
||||
|
||||
.. [1] "Secure" in this context means using a modern browser or a
|
||||
tool like `curl` that verifies SSL certificates when downloading from
|
||||
https URLs.
|
||||
|
||||
.. _setuptools: https://pypi.python.org/pypi/setuptools
|
||||
.. _distribute: https://pypi.python.org/pypi/distribute
|
||||
|
||||
|
||||
Vendored
+345
@@ -0,0 +1,345 @@
|
||||
.. _`pip logic`:
|
||||
|
||||
================
|
||||
Internal Details
|
||||
================
|
||||
|
||||
.. _`Requirements File Format`:
|
||||
|
||||
Requirements File Format
|
||||
========================
|
||||
|
||||
Each line of the requirements file indicates something to be installed,
|
||||
and like arguments to :ref:`pip install`, the following forms are supported::
|
||||
|
||||
<requirement specifier>
|
||||
<archive url/path>
|
||||
[-e] <local project path>
|
||||
[-e] <vcs project url>
|
||||
|
||||
See the :ref:`pip install Examples<pip install Examples>` for examples of all these forms.
|
||||
|
||||
A line beginning with ``#`` is treated as a comment and ignored.
|
||||
|
||||
Additionally, the following :ref:`Package Index Options <Package Index Options>` are supported
|
||||
|
||||
* :ref:`-i, --index-url <--index-url>`
|
||||
* :ref:`--extra-index-url <--extra-index-url>`
|
||||
* :ref:`--no-index <--no-index>`
|
||||
* :ref:`-f, --find-links <--find-links>`
|
||||
* :ref:`--allow-external <--allow-external>`
|
||||
* :ref:`--allow-all-external <--allow-external>`
|
||||
* :ref:`--allow-unverified <--allow-unverified>`
|
||||
|
||||
For example, to specify :ref:`--no-index <--no-index>` and 2 :ref:`--find-links <--find-links>` locations:
|
||||
|
||||
::
|
||||
|
||||
--no-index
|
||||
--find-links /my/local/archives
|
||||
--find-links http://some.archives.com/archives
|
||||
|
||||
|
||||
Lastly, if you wish, you can refer to other requirements files, like this::
|
||||
|
||||
-r more_requirements.txt
|
||||
|
||||
.. _`Requirement Specifiers`:
|
||||
|
||||
Requirement Specifiers
|
||||
======================
|
||||
|
||||
pip supports installing from "requirement specifiers" as implemented in
|
||||
`pkg_resources Requirements <http://packages.python.org/setuptools/pkg_resources.html#requirement-objects>`_
|
||||
|
||||
Some Examples:
|
||||
|
||||
::
|
||||
|
||||
'FooProject >= 1.2'
|
||||
Fizzy [foo, bar]
|
||||
'PickyThing<1.6,>1.9,!=1.9.6,<2.0a0,==2.4c1'
|
||||
SomethingWhoseVersionIDontCareAbout
|
||||
|
||||
.. note::
|
||||
|
||||
Use single or double quotes around specifiers to avoid ``>`` and ``<`` being interpreted as shell redirects. e.g. ``pip install 'FooProject>=1.2'``.
|
||||
|
||||
|
||||
.. _`Logging`:
|
||||
|
||||
Logging
|
||||
=======
|
||||
|
||||
Console logging
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
pip offers :ref:`-v, --verbose <--verbose>` and :ref:`-q, --quiet <--quiet>`
|
||||
to control the console log level. Each option can be used multiple times and
|
||||
used together. One ``-v`` increases the verbosity by one, whereas one ``-q`` decreases it by
|
||||
one.
|
||||
|
||||
The series of log levels, in order, are as follows::
|
||||
|
||||
VERBOSE_DEBUG, DEBUG, INFO, NOTIFY, WARN, ERROR, FATAL
|
||||
|
||||
``NOTIFY`` is the default level.
|
||||
|
||||
A few examples on how the parameters work to affect the level:
|
||||
|
||||
* specifying nothing results in ``NOTIFY``
|
||||
* ``-v`` results in ``INFO``
|
||||
* ``-vv`` results in ``DEBUG``
|
||||
* ``-q`` results in ``WARN``
|
||||
* ``-vq`` results in ``NOTIFY``
|
||||
|
||||
The most practical use case for users is either ``-v`` or ``-vv`` to see
|
||||
additional logging to help troubleshoot an issue.
|
||||
|
||||
|
||||
.. _`FileLogging`:
|
||||
|
||||
File logging
|
||||
~~~~~~~~~~~~
|
||||
|
||||
pip offers the :ref:`--log <--log>` option for specifying a file where a maximum
|
||||
verbosity log will be kept. This option is empty by default. This log appends
|
||||
to previous logging.
|
||||
|
||||
Additionally, when commands fail (i.e. return a non-zero exit code), pip writes
|
||||
a "failure log" for the failed command. This log overwrites previous
|
||||
logging. The default location is as follows:
|
||||
|
||||
* On Unix and Mac OS X: :file:`$HOME/.pip/pip.log`
|
||||
* On Windows, the configuration file is: :file:`%HOME%\\pip\\pip.log`
|
||||
|
||||
The option for the failure log, is :ref:`--log-file <--log-file>`.
|
||||
|
||||
Both logs add a line per execution to specify the date and what pip executable wrote the log.
|
||||
|
||||
Like all pip options, ``--log`` and ``log-file``, can also be set as an environment
|
||||
variable, or placed into the pip config file. See the :ref:`Configuration`
|
||||
section.
|
||||
|
||||
|
||||
.. _`Pre Release Versions`:
|
||||
|
||||
Pre-release Versions
|
||||
====================
|
||||
|
||||
Starting with v1.4, pip will only install stable versions as specified by `PEP426`_ by default. If
|
||||
a version cannot be parsed as a compliant `PEP426`_ version then it is assumed
|
||||
to be a pre-release.
|
||||
|
||||
If a Requirement specifier includes a pre-release or development version (e.g. ``>=0.0.dev0``) then
|
||||
pip will allow pre-release and development versions for that requirement. This does not include
|
||||
the != flag.
|
||||
|
||||
The ``pip install`` command also supports a :ref:`--pre <install_--pre>` flag that will enable
|
||||
installing pre-releases and development releases.
|
||||
|
||||
|
||||
.. _PEP426: http://www.python.org/dev/peps/pep-0426
|
||||
|
||||
.. _`Externally Hosted Files`:
|
||||
|
||||
Externally Hosted Files
|
||||
=======================
|
||||
|
||||
Starting with v1.4, pip will warn about installing any file that does not come
|
||||
from the primary index. As of version 1.5, pip defaults to ignoring these files
|
||||
unless asked to consider them.
|
||||
|
||||
The ``pip install`` command supports a
|
||||
:ref:`--allow-external PROJECT <--allow-external>` option that will enable
|
||||
installing links that are linked directly from the simple index but to an
|
||||
external host that also have a supported hash fragment. Externally hosted
|
||||
files for all projects may be enabled using the
|
||||
:ref:`--allow-all-external <--allow-all-external>` flag to the ``pip install``
|
||||
command.
|
||||
|
||||
The ``pip install`` command also supports a
|
||||
:ref:`--allow-unverified PROJECT <--allow-unverified>` option that will enable
|
||||
installing insecurely linked files. These are either directly linked (as above)
|
||||
files without a hash, or files that are linked from either the home page or the
|
||||
download url of a package.
|
||||
|
||||
These options can be used in a requirements file. Assuming some fictional
|
||||
`ExternalPackage` that is hosted external and unverified, then your requirements
|
||||
file would be like so::
|
||||
|
||||
--allow-external ExternalPackage
|
||||
--allow-unverified ExternalPackage
|
||||
ExternalPackage
|
||||
|
||||
|
||||
.. _`VCS Support`:
|
||||
|
||||
VCS Support
|
||||
===========
|
||||
|
||||
pip supports installing from Git, Mercurial, Subversion and Bazaar, and detects the type of VCS using url prefixes: "git+", "hg+", "bzr+", "svn+".
|
||||
|
||||
pip requires a working VCS command on your path: git, hg, svn, or bzr.
|
||||
|
||||
VCS projects can be installed in :ref:`editable mode <editable-installs>` (using the :ref:`--editable <install_--editable>` option) or not.
|
||||
|
||||
* For editable installs, the clone location by default is "<venv path>/src/SomeProject" in virtual environments, and "<cwd>/src/SomeProject" for global installs.
|
||||
The :ref:`--src <install_--src>` option can be used to modify this location.
|
||||
* For non-editable installs, the project is built locally in a temp dir and then installed normally.
|
||||
|
||||
The url suffix "egg=<project name>" is used by pip in it's dependency logic to identify the project prior to pip downloading and analyzing the metadata.
|
||||
|
||||
Git
|
||||
~~~
|
||||
|
||||
pip currently supports cloning over ``git``, ``git+https`` and ``git+ssh``:
|
||||
|
||||
Here are the supported forms::
|
||||
|
||||
[-e] git+git://git.myproject.org/MyProject#egg=MyProject
|
||||
[-e] git+https://git.myproject.org/MyProject#egg=MyProject
|
||||
[-e] git+ssh://git.myproject.org/MyProject#egg=MyProject
|
||||
-e git+git@git.myproject.org:MyProject#egg=MyProject
|
||||
|
||||
Passing branch names, a commit hash or a tag name is possible like so::
|
||||
|
||||
[-e] git://git.myproject.org/MyProject.git@master#egg=MyProject
|
||||
[-e] git://git.myproject.org/MyProject.git@v1.0#egg=MyProject
|
||||
[-e] git://git.myproject.org/MyProject.git@da39a3ee5e6b4b0d3255bfef95601890afd80709#egg=MyProject
|
||||
|
||||
Mercurial
|
||||
~~~~~~~~~
|
||||
|
||||
The supported schemes are: ``hg+http``, ``hg+https``,
|
||||
``hg+static-http`` and ``hg+ssh``.
|
||||
|
||||
Here are the supported forms::
|
||||
|
||||
[-e] hg+http://hg.myproject.org/MyProject#egg=MyProject
|
||||
[-e] hg+https://hg.myproject.org/MyProject#egg=MyProject
|
||||
[-e] hg+ssh://hg.myproject.org/MyProject#egg=MyProject
|
||||
|
||||
You can also specify a revision number, a revision hash, a tag name or a local
|
||||
branch name like so::
|
||||
|
||||
[-e] hg+http://hg.myproject.org/MyProject@da39a3ee5e6b#egg=MyProject
|
||||
[-e] hg+http://hg.myproject.org/MyProject@2019#egg=MyProject
|
||||
[-e] hg+http://hg.myproject.org/MyProject@v1.0#egg=MyProject
|
||||
[-e] hg+http://hg.myproject.org/MyProject@special_feature#egg=MyProject
|
||||
|
||||
Subversion
|
||||
~~~~~~~~~~
|
||||
|
||||
pip supports the URL schemes ``svn``, ``svn+svn``, ``svn+http``, ``svn+https``, ``svn+ssh``.
|
||||
|
||||
You can also give specific revisions to an SVN URL, like so::
|
||||
|
||||
[-e] svn+svn://svn.myproject.org/svn/MyProject#egg=MyProject
|
||||
[-e] svn+http://svn.myproject.org/svn/MyProject/trunk@2019#egg=MyProject
|
||||
|
||||
which will check out revision 2019. ``@{20080101}`` would also check
|
||||
out the revision from 2008-01-01. You can only check out specific
|
||||
revisions using ``-e svn+...``.
|
||||
|
||||
Bazaar
|
||||
~~~~~~
|
||||
|
||||
pip supports Bazaar using the ``bzr+http``, ``bzr+https``, ``bzr+ssh``,
|
||||
``bzr+sftp``, ``bzr+ftp`` and ``bzr+lp`` schemes.
|
||||
|
||||
Here are the supported forms::
|
||||
|
||||
[-e] bzr+http://bzr.myproject.org/MyProject/trunk#egg=MyProject
|
||||
[-e] bzr+sftp://user@myproject.org/MyProject/trunk#egg=MyProject
|
||||
[-e] bzr+ssh://user@myproject.org/MyProject/trunk#egg=MyProject
|
||||
[-e] bzr+ftp://user@myproject.org/MyProject/trunk#egg=MyProject
|
||||
[-e] bzr+lp:MyProject#egg=MyProject
|
||||
|
||||
Tags or revisions can be installed like so::
|
||||
|
||||
[-e] bzr+https://bzr.myproject.org/MyProject/trunk@2019#egg=MyProject
|
||||
[-e] bzr+http://bzr.myproject.org/MyProject/trunk@v1.0#egg=MyProject
|
||||
|
||||
|
||||
Finding Packages
|
||||
================
|
||||
|
||||
pip searches for packages on `PyPI <http://pypi.python.org>`_ using the
|
||||
`http simple interface <http://pypi.python.org/simple>`_,
|
||||
which is documented `here <http://packages.python.org/setuptools/easy_install.html#package-index-api>`_
|
||||
and `there <http://www.python.org/dev/peps/pep-0301/>`_
|
||||
|
||||
pip offers a set of :ref:`Package Index Options <Package Index Options>` for modifying how packages are found.
|
||||
|
||||
See the :ref:`pip install Examples<pip install Examples>`.
|
||||
|
||||
|
||||
.. _`SSL Certificate Verification`:
|
||||
|
||||
SSL Certificate Verification
|
||||
============================
|
||||
|
||||
Starting with v1.3, pip provides SSL certificate verification over https, for the purpose
|
||||
of providing secure, certified downloads from PyPI.
|
||||
|
||||
|
||||
Hash Verification
|
||||
=================
|
||||
|
||||
PyPI provides md5 hashes in the hash fragment of package download urls.
|
||||
|
||||
pip supports checking this, as well as any of the
|
||||
guaranteed hashlib algorithms (sha1, sha224, sha384, sha256, sha512, md5).
|
||||
|
||||
The hash fragment is case sensitive (i.e. sha1 not SHA1).
|
||||
|
||||
This check is only intended to provide basic download corruption protection.
|
||||
It is not intended to provide security against tampering. For that,
|
||||
see :ref:`SSL Certificate Verification`
|
||||
|
||||
|
||||
Download Cache
|
||||
==============
|
||||
|
||||
pip offers a :ref:`--download-cache <install_--download-cache>` option for installs to prevent redundant downloads of archives from PyPI.
|
||||
|
||||
The point of this cache is *not* to circumvent the index crawling process, but to *just* prevent redundant downloads.
|
||||
|
||||
Items are stored in this cache based on the url the archive was found at, not simply the archive name.
|
||||
|
||||
If you want a fast/local install solution that circumvents crawling PyPI, see the :ref:`Fast & Local Installs` Cookbook entry.
|
||||
|
||||
Like all options, :ref:`--download-cache <install_--download-cache>`, can also be set as an environment variable, or placed into the pip config file.
|
||||
See the :ref:`Configuration` section.
|
||||
|
||||
|
||||
.. _`editable-installs`:
|
||||
|
||||
"Editable" Installs
|
||||
===================
|
||||
|
||||
"Editable" installs are fundamentally `"setuptools develop mode" <http://packages.python.org/setuptools/setuptools.html#development-mode>`_ installs.
|
||||
|
||||
You can install local projects or VCS projects in "editable" mode::
|
||||
|
||||
$ pip install -e path/to/SomeProject
|
||||
$ pip install -e git+http://repo/my_project.git#egg=SomeProject
|
||||
|
||||
For local projects, the "SomeProject.egg-info" directory is created relative to the project path.
|
||||
This is one advantage over just using ``setup.py develop``, which creates the "egg-info" directly relative the current working directory.
|
||||
|
||||
|
||||
setuptools & pkg_resources
|
||||
==========================
|
||||
|
||||
Internally, pip uses the `setuptools` package, and the `pkg_resources` module, which are available from the project, `Setuptools`_.
|
||||
|
||||
Here are some examples of how pip uses `setuptools` and `pkg_resources`:
|
||||
|
||||
* The core of pip's install process uses the `setuptools`'s "install" command.
|
||||
* Editable ("-e") installs use the `setuptools`'s "develop" command.
|
||||
* pip uses `pkg_resources` for version parsing, for detecting version conflicts, and to determine what projects are installed,
|
||||
|
||||
|
||||
.. _Setuptools: http://pypi.python.org/pypi/setuptools/
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
====
|
||||
News
|
||||
====
|
||||
|
||||
.. include:: ../CHANGES.txt
|
||||
+6
-7
@@ -1,6 +1,6 @@
|
||||
===================
|
||||
===========
|
||||
Other tools
|
||||
===================
|
||||
===========
|
||||
|
||||
virtualenv
|
||||
----------
|
||||
@@ -17,11 +17,10 @@ and to bail if not, use::
|
||||
|
||||
export PIP_REQUIRE_VIRTUALENV=true
|
||||
|
||||
|
||||
easy_install
|
||||
------------
|
||||
|
||||
pip was originally written to improve on `easy_install <http://pythonhosted.org/distribute/easy_install.html>`_ in the following ways:
|
||||
pip was originally written to improve on `easy_install <http://pythonhosted.org/setuptools/easy_install.html>`_ in the following ways:
|
||||
|
||||
* All packages are downloaded before installation. Partially-completed
|
||||
installation doesn't occur as a result.
|
||||
@@ -48,9 +47,9 @@ pip was originally written to improve on `easy_install <http://pythonhosted.org/
|
||||
|
||||
pip doesn't do everything that easy_install does. Specifically:
|
||||
|
||||
* It cannot install from eggs. It only installs from source. (In the
|
||||
future it would be good if it could install binaries from Windows ``.exe``
|
||||
or ``.msi`` -- binary install on other platforms is not a priority.)
|
||||
* It cannot install from eggs. That’s not a problem anymore though because pip
|
||||
supports the superior binary `wheel format
|
||||
<https://wheel.readthedocs.org/en/latest/>`_ since the 1.4 release.
|
||||
|
||||
* It is incompatible with some packages that extensively customize distutils
|
||||
or setuptools in their ``setup.py`` files.
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
Quickstart
|
||||
==========
|
||||
|
||||
@@ -2,6 +2,20 @@
|
||||
Usage
|
||||
==========
|
||||
|
||||
pip
|
||||
---
|
||||
|
||||
Usage
|
||||
*****
|
||||
|
||||
::
|
||||
|
||||
pip <command> [options]
|
||||
|
||||
|
||||
Options
|
||||
*******
|
||||
|
||||
.. _`General Options`:
|
||||
|
||||
**General Options:**
|
||||
@@ -55,7 +69,7 @@ Examples
|
||||
|
||||
$ pip install SomePackage # latest version
|
||||
$ pip install SomePackage==1.0.4 # specific version
|
||||
$ pip install SomePackage>=1.0.4 # minimum version
|
||||
$ pip install 'SomePackage>=1.0.4' # minimum version
|
||||
|
||||
|
||||
2) Install a list of requirements specified in a file. See the :ref:`Cookbook entry on Requirements files <Requirements Files>`.
|
||||
@@ -88,7 +102,7 @@ Examples
|
||||
$ pip install -e hg+https://hg.repo/some_pkg.git#egg=SomePackage # from mercurial
|
||||
$ pip install -e svn+svn://svn.repo/some_pkg/trunk/#egg=SomePackage # from svn
|
||||
$ pip install -e git+https://git.repo/some_pkg.git@feature#egg=SomePackage # from 'feature' branch
|
||||
|
||||
$ pip install -e git+https://git.repo/some_repo.git@egg=subdir&subdirectory=subdir_path # install a python package from a repo subdirectory
|
||||
|
||||
6) Install a package with `setuptools extras`_.
|
||||
|
||||
@@ -119,13 +133,21 @@ Examples
|
||||
|
||||
Install from a local flat directory containing archives (and don't scan indexes)::
|
||||
|
||||
$ pip install --no-index --find-links:file:///local/dir/ SomePackage
|
||||
$ pip install --no-index --find-links:/local/dir/ SomePackage
|
||||
$ pip install --no-index --find-links:relative/dir/ SomePackage
|
||||
$ pip install --no-index --find-links=file:///local/dir/ SomePackage
|
||||
$ pip install --no-index --find-links=/local/dir/ SomePackage
|
||||
$ pip install --no-index --find-links=relative/dir/ SomePackage
|
||||
|
||||
|
||||
9) Find pre-release and development versions, in addition to stable versions. By default, pip only finds stable versions.
|
||||
|
||||
::
|
||||
|
||||
$ pip install --pre SomePackage
|
||||
|
||||
|
||||
|
||||
.. _PyPI: http://pypi.python.org/pypi
|
||||
.. _setuptools extras: http://packages.python.org/distribute/setuptools.html#declaring-extras-optional-features-with-their-own-dependencies
|
||||
.. _setuptools extras: http://packages.python.org/setuptools/setuptools.html#declaring-extras-optional-features-with-their-own-dependencies
|
||||
|
||||
|
||||
pip uninstall
|
||||
@@ -212,6 +234,15 @@ Examples
|
||||
docutils==0.9.1
|
||||
|
||||
|
||||
2) Generate a requirements file and then install from it in another environment.
|
||||
|
||||
::
|
||||
|
||||
$ env1/bin/pip freeze > requirements.txt
|
||||
$ env2/bin/pip install -r requirements.txt
|
||||
|
||||
|
||||
|
||||
pip list
|
||||
---------
|
||||
|
||||
@@ -316,7 +347,7 @@ Description
|
||||
Options
|
||||
*******
|
||||
|
||||
**Seach Options:**
|
||||
**Search Options:**
|
||||
|
||||
.. pip-command-options:: search
|
||||
|
||||
@@ -335,6 +366,52 @@ Examples
|
||||
pepperedform - Helpers for using peppercorn with formprocess.
|
||||
peppercorn - A library for converting a token stream into [...]
|
||||
|
||||
.. _`pip wheel`:
|
||||
|
||||
pip wheel
|
||||
---------
|
||||
|
||||
Usage
|
||||
*****
|
||||
|
||||
.. pip-command-usage:: wheel
|
||||
|
||||
|
||||
Description
|
||||
***********
|
||||
|
||||
.. pip-command-description:: wheel
|
||||
|
||||
.. warning::
|
||||
|
||||
Currently, when ``pip wheel`` finds a wheel for one of your requirements
|
||||
already on PyPI, it does not rebuild, and it does not place the file in your
|
||||
wheelhouse dir. There is an issue open to change this
|
||||
(https://github.com/pypa/pip/issues/1310)
|
||||
|
||||
|
||||
Options
|
||||
*******
|
||||
|
||||
**Wheel Options:**
|
||||
|
||||
.. pip-command-options:: wheel
|
||||
|
||||
**Other Options:**
|
||||
|
||||
* :ref:`Package Index Options <Package Index Options>`
|
||||
* :ref:`General Options <General Options>`
|
||||
|
||||
Examples
|
||||
********
|
||||
|
||||
1. Build wheels for a requirement (and all its dependencies), and then install
|
||||
|
||||
::
|
||||
|
||||
$ pip wheel --wheel-dir=/tmp/wheelhouse SomePackage
|
||||
$ pip install --no-index --find-links=/tmp/wheelhouse SomePackage
|
||||
|
||||
|
||||
pip zip
|
||||
-------
|
||||
@@ -359,4 +436,3 @@ Options
|
||||
**Other Options:**
|
||||
|
||||
* :ref:`General Options <General Options>`
|
||||
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
Metadata-Version: 1.1
|
||||
Name: pip
|
||||
Version: 1.5.2
|
||||
Summary: A tool for installing and managing Python packages.
|
||||
Home-page: http://www.pip-installer.org
|
||||
Author: The pip developers
|
||||
Author-email: python-virtualenv@groups.google.com
|
||||
License: MIT
|
||||
Description:
|
||||
Project Info
|
||||
============
|
||||
|
||||
* Project Page: https://github.com/pypa/pip
|
||||
* Install howto: http://www.pip-installer.org/en/latest/installing.html
|
||||
* Changelog: http://www.pip-installer.org/en/latest/news.html
|
||||
* Bug Tracking: https://github.com/pypa/pip/issues
|
||||
* Mailing list: http://groups.google.com/group/python-virtualenv
|
||||
* Docs: http://www.pip-installer.org/
|
||||
* IRC: #pip on Freenode.
|
||||
|
||||
Quickstart
|
||||
==========
|
||||
|
||||
Install a package:
|
||||
|
||||
::
|
||||
|
||||
$ pip install SomePackage==1.0
|
||||
[...]
|
||||
Successfully installed SomePackage
|
||||
|
||||
Show what files were installed:
|
||||
|
||||
::
|
||||
|
||||
$ pip show --files SomePackage
|
||||
Name: SomePackage
|
||||
Version: 1.0
|
||||
Location: /my/env/lib/pythonx.x/site-packages
|
||||
Files:
|
||||
../somepackage/__init__.py
|
||||
[...]
|
||||
|
||||
List what packages are outdated:
|
||||
|
||||
::
|
||||
|
||||
$ pip list --outdated
|
||||
SomePackage (Current: 1.0 Latest: 2.0)
|
||||
|
||||
Upgrade a package:
|
||||
|
||||
::
|
||||
|
||||
$ pip install --upgrade SomePackage
|
||||
[...]
|
||||
Found existing installation: SomePackage 1.0
|
||||
Uninstalling SomePackage:
|
||||
Successfully uninstalled SomePackage
|
||||
Running setup.py install for SomePackage
|
||||
Successfully installed SomePackage
|
||||
|
||||
Uninstall a package:
|
||||
|
||||
::
|
||||
|
||||
$ pip uninstall SomePackage
|
||||
Uninstalling SomePackage:
|
||||
/my/env/lib/pythonx.x/site-packages/somepackage
|
||||
Proceed (y/n)? y
|
||||
Successfully uninstalled SomePackage
|
||||
|
||||
|
||||
Keywords: easy_install distutils setuptools egg virtualenv
|
||||
Platform: UNKNOWN
|
||||
Classifier: Development Status :: 5 - Production/Stable
|
||||
Classifier: Intended Audience :: Developers
|
||||
Classifier: License :: OSI Approved :: MIT License
|
||||
Classifier: Topic :: Software Development :: Build Tools
|
||||
Classifier: Programming Language :: Python :: 2
|
||||
Classifier: Programming Language :: Python :: 2.6
|
||||
Classifier: Programming Language :: Python :: 2.7
|
||||
Classifier: Programming Language :: Python :: 3
|
||||
Classifier: Programming Language :: Python :: 3.1
|
||||
Classifier: Programming Language :: Python :: 3.2
|
||||
Classifier: Programming Language :: Python :: 3.3
|
||||
+240
@@ -0,0 +1,240 @@
|
||||
AUTHORS.txt
|
||||
CHANGES.txt
|
||||
LICENSE.txt
|
||||
MANIFEST.in
|
||||
PROJECT.txt
|
||||
README.rst
|
||||
setup.cfg
|
||||
setup.py
|
||||
docs/configuration.rst
|
||||
docs/cookbook.rst
|
||||
docs/development.rst
|
||||
docs/index.rst
|
||||
docs/installing.rst
|
||||
docs/logic.rst
|
||||
docs/news.rst
|
||||
docs/other-tools.rst
|
||||
docs/quickstart.rst
|
||||
docs/usage.rst
|
||||
pip/__init__.py
|
||||
pip/__main__.py
|
||||
pip/basecommand.py
|
||||
pip/baseparser.py
|
||||
pip/cmdoptions.py
|
||||
pip/download.py
|
||||
pip/exceptions.py
|
||||
pip/index.py
|
||||
pip/locations.py
|
||||
pip/log.py
|
||||
pip/pep425tags.py
|
||||
pip/req.py
|
||||
pip/runner.py
|
||||
pip/status_codes.py
|
||||
pip/util.py
|
||||
pip/wheel.py
|
||||
pip.egg-info/PKG-INFO
|
||||
pip.egg-info/SOURCES.txt
|
||||
pip.egg-info/dependency_links.txt
|
||||
pip.egg-info/entry_points.txt
|
||||
pip.egg-info/not-zip-safe
|
||||
pip.egg-info/requires.txt
|
||||
pip.egg-info/top_level.txt
|
||||
pip/_vendor/__init__.py
|
||||
pip/_vendor/pkg_resources.py
|
||||
pip/_vendor/re-vendor.py
|
||||
pip/_vendor/six.py
|
||||
pip/_vendor/_markerlib/__init__.py
|
||||
pip/_vendor/_markerlib/markers.py
|
||||
pip/_vendor/colorama/__init__.py
|
||||
pip/_vendor/colorama/ansi.py
|
||||
pip/_vendor/colorama/ansitowin32.py
|
||||
pip/_vendor/colorama/initialise.py
|
||||
pip/_vendor/colorama/win32.py
|
||||
pip/_vendor/colorama/winterm.py
|
||||
pip/_vendor/distlib/__init__.py
|
||||
pip/_vendor/distlib/compat.py
|
||||
pip/_vendor/distlib/database.py
|
||||
pip/_vendor/distlib/index.py
|
||||
pip/_vendor/distlib/locators.py
|
||||
pip/_vendor/distlib/manifest.py
|
||||
pip/_vendor/distlib/markers.py
|
||||
pip/_vendor/distlib/metadata.py
|
||||
pip/_vendor/distlib/resources.py
|
||||
pip/_vendor/distlib/scripts.py
|
||||
pip/_vendor/distlib/t32.exe
|
||||
pip/_vendor/distlib/t64.exe
|
||||
pip/_vendor/distlib/util.py
|
||||
pip/_vendor/distlib/version.py
|
||||
pip/_vendor/distlib/w32.exe
|
||||
pip/_vendor/distlib/w64.exe
|
||||
pip/_vendor/distlib/wheel.py
|
||||
pip/_vendor/distlib/_backport/__init__.py
|
||||
pip/_vendor/distlib/_backport/misc.py
|
||||
pip/_vendor/distlib/_backport/shutil.py
|
||||
pip/_vendor/distlib/_backport/sysconfig.cfg
|
||||
pip/_vendor/distlib/_backport/sysconfig.py
|
||||
pip/_vendor/distlib/_backport/tarfile.py
|
||||
pip/_vendor/html5lib/__init__.py
|
||||
pip/_vendor/html5lib/constants.py
|
||||
pip/_vendor/html5lib/html5parser.py
|
||||
pip/_vendor/html5lib/ihatexml.py
|
||||
pip/_vendor/html5lib/inputstream.py
|
||||
pip/_vendor/html5lib/sanitizer.py
|
||||
pip/_vendor/html5lib/tokenizer.py
|
||||
pip/_vendor/html5lib/utils.py
|
||||
pip/_vendor/html5lib/filters/__init__.py
|
||||
pip/_vendor/html5lib/filters/_base.py
|
||||
pip/_vendor/html5lib/filters/alphabeticalattributes.py
|
||||
pip/_vendor/html5lib/filters/inject_meta_charset.py
|
||||
pip/_vendor/html5lib/filters/lint.py
|
||||
pip/_vendor/html5lib/filters/optionaltags.py
|
||||
pip/_vendor/html5lib/filters/sanitizer.py
|
||||
pip/_vendor/html5lib/filters/whitespace.py
|
||||
pip/_vendor/html5lib/serializer/__init__.py
|
||||
pip/_vendor/html5lib/serializer/htmlserializer.py
|
||||
pip/_vendor/html5lib/treebuilders/__init__.py
|
||||
pip/_vendor/html5lib/treebuilders/_base.py
|
||||
pip/_vendor/html5lib/treebuilders/dom.py
|
||||
pip/_vendor/html5lib/treebuilders/etree.py
|
||||
pip/_vendor/html5lib/treebuilders/etree_lxml.py
|
||||
pip/_vendor/html5lib/treewalkers/__init__.py
|
||||
pip/_vendor/html5lib/treewalkers/_base.py
|
||||
pip/_vendor/html5lib/treewalkers/dom.py
|
||||
pip/_vendor/html5lib/treewalkers/etree.py
|
||||
pip/_vendor/html5lib/treewalkers/genshistream.py
|
||||
pip/_vendor/html5lib/treewalkers/lxmletree.py
|
||||
pip/_vendor/html5lib/treewalkers/pulldom.py
|
||||
pip/_vendor/html5lib/trie/__init__.py
|
||||
pip/_vendor/html5lib/trie/_base.py
|
||||
pip/_vendor/html5lib/trie/datrie.py
|
||||
pip/_vendor/html5lib/trie/py.py
|
||||
pip/_vendor/requests/__init__.py
|
||||
pip/_vendor/requests/adapters.py
|
||||
pip/_vendor/requests/api.py
|
||||
pip/_vendor/requests/auth.py
|
||||
pip/_vendor/requests/cacert.pem
|
||||
pip/_vendor/requests/certs.py
|
||||
pip/_vendor/requests/compat.py
|
||||
pip/_vendor/requests/cookies.py
|
||||
pip/_vendor/requests/exceptions.py
|
||||
pip/_vendor/requests/hooks.py
|
||||
pip/_vendor/requests/models.py
|
||||
pip/_vendor/requests/sessions.py
|
||||
pip/_vendor/requests/status_codes.py
|
||||
pip/_vendor/requests/structures.py
|
||||
pip/_vendor/requests/utils.py
|
||||
pip/_vendor/requests/packages/__init__.py
|
||||
pip/_vendor/requests/packages/charade/__init__.py
|
||||
pip/_vendor/requests/packages/charade/__main__.py
|
||||
pip/_vendor/requests/packages/charade/big5freq.py
|
||||
pip/_vendor/requests/packages/charade/big5prober.py
|
||||
pip/_vendor/requests/packages/charade/chardistribution.py
|
||||
pip/_vendor/requests/packages/charade/charsetgroupprober.py
|
||||
pip/_vendor/requests/packages/charade/charsetprober.py
|
||||
pip/_vendor/requests/packages/charade/codingstatemachine.py
|
||||
pip/_vendor/requests/packages/charade/compat.py
|
||||
pip/_vendor/requests/packages/charade/constants.py
|
||||
pip/_vendor/requests/packages/charade/cp949prober.py
|
||||
pip/_vendor/requests/packages/charade/escprober.py
|
||||
pip/_vendor/requests/packages/charade/escsm.py
|
||||
pip/_vendor/requests/packages/charade/eucjpprober.py
|
||||
pip/_vendor/requests/packages/charade/euckrfreq.py
|
||||
pip/_vendor/requests/packages/charade/euckrprober.py
|
||||
pip/_vendor/requests/packages/charade/euctwfreq.py
|
||||
pip/_vendor/requests/packages/charade/euctwprober.py
|
||||
pip/_vendor/requests/packages/charade/gb2312freq.py
|
||||
pip/_vendor/requests/packages/charade/gb2312prober.py
|
||||
pip/_vendor/requests/packages/charade/hebrewprober.py
|
||||
pip/_vendor/requests/packages/charade/jisfreq.py
|
||||
pip/_vendor/requests/packages/charade/jpcntx.py
|
||||
pip/_vendor/requests/packages/charade/langbulgarianmodel.py
|
||||
pip/_vendor/requests/packages/charade/langcyrillicmodel.py
|
||||
pip/_vendor/requests/packages/charade/langgreekmodel.py
|
||||
pip/_vendor/requests/packages/charade/langhebrewmodel.py
|
||||
pip/_vendor/requests/packages/charade/langhungarianmodel.py
|
||||
pip/_vendor/requests/packages/charade/langthaimodel.py
|
||||
pip/_vendor/requests/packages/charade/latin1prober.py
|
||||
pip/_vendor/requests/packages/charade/mbcharsetprober.py
|
||||
pip/_vendor/requests/packages/charade/mbcsgroupprober.py
|
||||
pip/_vendor/requests/packages/charade/mbcssm.py
|
||||
pip/_vendor/requests/packages/charade/sbcharsetprober.py
|
||||
pip/_vendor/requests/packages/charade/sbcsgroupprober.py
|
||||
pip/_vendor/requests/packages/charade/sjisprober.py
|
||||
pip/_vendor/requests/packages/charade/universaldetector.py
|
||||
pip/_vendor/requests/packages/charade/utf8prober.py
|
||||
pip/_vendor/requests/packages/chardet/__init__.py
|
||||
pip/_vendor/requests/packages/chardet/big5freq.py
|
||||
pip/_vendor/requests/packages/chardet/big5prober.py
|
||||
pip/_vendor/requests/packages/chardet/chardetect.py
|
||||
pip/_vendor/requests/packages/chardet/chardistribution.py
|
||||
pip/_vendor/requests/packages/chardet/charsetgroupprober.py
|
||||
pip/_vendor/requests/packages/chardet/charsetprober.py
|
||||
pip/_vendor/requests/packages/chardet/codingstatemachine.py
|
||||
pip/_vendor/requests/packages/chardet/compat.py
|
||||
pip/_vendor/requests/packages/chardet/constants.py
|
||||
pip/_vendor/requests/packages/chardet/cp949prober.py
|
||||
pip/_vendor/requests/packages/chardet/escprober.py
|
||||
pip/_vendor/requests/packages/chardet/escsm.py
|
||||
pip/_vendor/requests/packages/chardet/eucjpprober.py
|
||||
pip/_vendor/requests/packages/chardet/euckrfreq.py
|
||||
pip/_vendor/requests/packages/chardet/euckrprober.py
|
||||
pip/_vendor/requests/packages/chardet/euctwfreq.py
|
||||
pip/_vendor/requests/packages/chardet/euctwprober.py
|
||||
pip/_vendor/requests/packages/chardet/gb2312freq.py
|
||||
pip/_vendor/requests/packages/chardet/gb2312prober.py
|
||||
pip/_vendor/requests/packages/chardet/hebrewprober.py
|
||||
pip/_vendor/requests/packages/chardet/jisfreq.py
|
||||
pip/_vendor/requests/packages/chardet/jpcntx.py
|
||||
pip/_vendor/requests/packages/chardet/langbulgarianmodel.py
|
||||
pip/_vendor/requests/packages/chardet/langcyrillicmodel.py
|
||||
pip/_vendor/requests/packages/chardet/langgreekmodel.py
|
||||
pip/_vendor/requests/packages/chardet/langhebrewmodel.py
|
||||
pip/_vendor/requests/packages/chardet/langhungarianmodel.py
|
||||
pip/_vendor/requests/packages/chardet/langthaimodel.py
|
||||
pip/_vendor/requests/packages/chardet/latin1prober.py
|
||||
pip/_vendor/requests/packages/chardet/mbcharsetprober.py
|
||||
pip/_vendor/requests/packages/chardet/mbcsgroupprober.py
|
||||
pip/_vendor/requests/packages/chardet/mbcssm.py
|
||||
pip/_vendor/requests/packages/chardet/sbcharsetprober.py
|
||||
pip/_vendor/requests/packages/chardet/sbcsgroupprober.py
|
||||
pip/_vendor/requests/packages/chardet/sjisprober.py
|
||||
pip/_vendor/requests/packages/chardet/universaldetector.py
|
||||
pip/_vendor/requests/packages/chardet/utf8prober.py
|
||||
pip/_vendor/requests/packages/urllib3/__init__.py
|
||||
pip/_vendor/requests/packages/urllib3/_collections.py
|
||||
pip/_vendor/requests/packages/urllib3/connection.py
|
||||
pip/_vendor/requests/packages/urllib3/connectionpool.py
|
||||
pip/_vendor/requests/packages/urllib3/exceptions.py
|
||||
pip/_vendor/requests/packages/urllib3/fields.py
|
||||
pip/_vendor/requests/packages/urllib3/filepost.py
|
||||
pip/_vendor/requests/packages/urllib3/poolmanager.py
|
||||
pip/_vendor/requests/packages/urllib3/request.py
|
||||
pip/_vendor/requests/packages/urllib3/response.py
|
||||
pip/_vendor/requests/packages/urllib3/util.py
|
||||
pip/_vendor/requests/packages/urllib3/contrib/__init__.py
|
||||
pip/_vendor/requests/packages/urllib3/contrib/ntlmpool.py
|
||||
pip/_vendor/requests/packages/urllib3/contrib/pyopenssl.py
|
||||
pip/_vendor/requests/packages/urllib3/packages/__init__.py
|
||||
pip/_vendor/requests/packages/urllib3/packages/ordered_dict.py
|
||||
pip/_vendor/requests/packages/urllib3/packages/six.py
|
||||
pip/_vendor/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py
|
||||
pip/_vendor/requests/packages/urllib3/packages/ssl_match_hostname/_implementation.py
|
||||
pip/backwardcompat/__init__.py
|
||||
pip/commands/__init__.py
|
||||
pip/commands/bundle.py
|
||||
pip/commands/completion.py
|
||||
pip/commands/freeze.py
|
||||
pip/commands/help.py
|
||||
pip/commands/install.py
|
||||
pip/commands/list.py
|
||||
pip/commands/search.py
|
||||
pip/commands/show.py
|
||||
pip/commands/uninstall.py
|
||||
pip/commands/unzip.py
|
||||
pip/commands/wheel.py
|
||||
pip/commands/zip.py
|
||||
pip/vcs/__init__.py
|
||||
pip/vcs/bazaar.py
|
||||
pip/vcs/git.py
|
||||
pip/vcs/mercurial.py
|
||||
pip/vcs/subversion.py
|
||||
@@ -0,0 +1,5 @@
|
||||
[console_scripts]
|
||||
pip = pip:main
|
||||
pip2.7 = pip:main
|
||||
pip2 = pip:main
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
|
||||
|
||||
[testing]
|
||||
pytest
|
||||
virtualenv>=1.10
|
||||
scripttest>=1.3
|
||||
mock
|
||||
+1
@@ -0,0 +1 @@
|
||||
pip
|
||||
@@ -9,12 +9,17 @@ from pip.exceptions import InstallationError, CommandError, PipError
|
||||
from pip.log import logger
|
||||
from pip.util import get_installed_distributions, get_prog
|
||||
from pip.vcs import git, mercurial, subversion, bazaar # noqa
|
||||
from pip.baseparser import create_main_parser
|
||||
from pip.commands import commands, get_similar_commands, get_summaries
|
||||
from pip.baseparser import ConfigOptionParser, UpdatingDefaultsHelpFormatter
|
||||
from pip.commands import commands, get_summaries, get_similar_commands
|
||||
|
||||
# This fixes a peculiarity when importing via __import__ - as we are
|
||||
# initialising the pip module, "from pip import cmdoptions" is recursive
|
||||
# and appears not to work properly in that situation.
|
||||
import pip.cmdoptions
|
||||
cmdoptions = pip.cmdoptions
|
||||
|
||||
# The version as used in the setup.py and the docs conf.py
|
||||
__version__ = "1.3.1"
|
||||
__version__ = "1.5.2"
|
||||
|
||||
|
||||
def autocomplete():
|
||||
@@ -60,7 +65,7 @@ def autocomplete():
|
||||
print(dist)
|
||||
sys.exit(1)
|
||||
|
||||
subcommand = commands[subcommand_name](parser)
|
||||
subcommand = commands[subcommand_name]()
|
||||
options += [(opt.get_opt_string(), opt.nargs)
|
||||
for opt in subcommand.parser.option_list_all
|
||||
if opt.help != optparse.SUPPRESS_HELP]
|
||||
@@ -90,45 +95,76 @@ def autocomplete():
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def parseopts(args):
|
||||
parser = create_main_parser()
|
||||
def create_main_parser():
|
||||
parser_kw = {
|
||||
'usage': '\n%prog <command> [options]',
|
||||
'add_help_option': False,
|
||||
'formatter': UpdatingDefaultsHelpFormatter(),
|
||||
'name': 'global',
|
||||
'prog': get_prog(),
|
||||
}
|
||||
|
||||
parser = ConfigOptionParser(**parser_kw)
|
||||
parser.disable_interspersed_args()
|
||||
|
||||
pip_pkg_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
parser.version = 'pip %s from %s (python %s)' % (
|
||||
__version__, pip_pkg_dir, sys.version[:3])
|
||||
|
||||
# add the general options
|
||||
gen_opts = cmdoptions.make_option_group(cmdoptions.general_group, parser)
|
||||
parser.add_option_group(gen_opts)
|
||||
|
||||
parser.main = True # so the help formatter knows
|
||||
|
||||
# create command listing
|
||||
# create command listing for description
|
||||
command_summaries = get_summaries()
|
||||
|
||||
description = [''] + ['%-27s %s' % (i, j) for i, j in command_summaries]
|
||||
parser.description = '\n'.join(description)
|
||||
|
||||
options, args = parser.parse_args(args)
|
||||
return parser
|
||||
|
||||
if options.version:
|
||||
|
||||
def parseopts(args):
|
||||
parser = create_main_parser()
|
||||
|
||||
# Note: parser calls disable_interspersed_args(), so the result of this call
|
||||
# is to split the initial args into the general options before the
|
||||
# subcommand and everything else.
|
||||
# For example:
|
||||
# args: ['--timeout=5', 'install', '--user', 'INITools']
|
||||
# general_options: ['--timeout==5']
|
||||
# args_else: ['install', '--user', 'INITools']
|
||||
general_options, args_else = parser.parse_args(args)
|
||||
|
||||
# --version
|
||||
if general_options.version:
|
||||
sys.stdout.write(parser.version)
|
||||
sys.stdout.write(os.linesep)
|
||||
sys.exit()
|
||||
|
||||
# pip || pip help || pip --help -> print_help()
|
||||
if not args or (args[0] == 'help' and len(args) == 1):
|
||||
# pip || pip help -> print_help()
|
||||
if not args_else or (args_else[0] == 'help' and len(args_else) == 1):
|
||||
parser.print_help()
|
||||
sys.exit()
|
||||
|
||||
if not args:
|
||||
msg = ('You must give a command '
|
||||
'(use "pip --help" to see a list of commands)')
|
||||
raise CommandError(msg)
|
||||
# the subcommand name
|
||||
cmd_name = args_else[0].lower()
|
||||
|
||||
command = args[0].lower()
|
||||
#all the args without the subcommand
|
||||
cmd_args = args[:]
|
||||
cmd_args.remove(args_else[0].lower())
|
||||
|
||||
if command not in commands:
|
||||
guess = get_similar_commands(command)
|
||||
if cmd_name not in commands:
|
||||
guess = get_similar_commands(cmd_name)
|
||||
|
||||
msg = ['unknown command "%s"' % command]
|
||||
msg = ['unknown command "%s"' % cmd_name]
|
||||
if guess:
|
||||
msg.append('maybe you meant "%s"' % guess)
|
||||
|
||||
raise CommandError(' - '.join(msg))
|
||||
|
||||
return command, options, args, parser
|
||||
return cmd_name, cmd_args
|
||||
|
||||
|
||||
def main(initial_args=None):
|
||||
@@ -138,22 +174,27 @@ def main(initial_args=None):
|
||||
autocomplete()
|
||||
|
||||
try:
|
||||
cmd_name, options, args, parser = parseopts(initial_args)
|
||||
cmd_name, cmd_args = parseopts(initial_args)
|
||||
except PipError:
|
||||
e = sys.exc_info()[1]
|
||||
sys.stderr.write("ERROR: %s" % e)
|
||||
sys.stderr.write(os.linesep)
|
||||
sys.exit(1)
|
||||
|
||||
command = commands[cmd_name](parser) # see baseparser.Command
|
||||
return command.main(args[1:], options)
|
||||
command = commands[cmd_name]()
|
||||
return command.main(cmd_args)
|
||||
|
||||
|
||||
def bootstrap():
|
||||
"""
|
||||
Bootstrapping function to be called from install-pip.py script.
|
||||
"""
|
||||
return main(['install', '--upgrade', 'pip'])
|
||||
pkgs = ['pip']
|
||||
try:
|
||||
import setuptools
|
||||
except ImportError:
|
||||
pkgs.append('setuptools')
|
||||
return main(['install', '--upgrade'] + pkgs + sys.argv[1:])
|
||||
|
||||
############################################################
|
||||
## Writing freeze files
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
"""
|
||||
pip._vendor is for vendoring dependencies of pip to prevent needing pip to
|
||||
depend on something external.
|
||||
|
||||
Files inside of pip._vendor should be considered immutable and should only be
|
||||
updated to versions from upstream.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
@@ -0,0 +1,16 @@
|
||||
try:
|
||||
import ast
|
||||
from pip._vendor._markerlib.markers import default_environment, compile, interpret
|
||||
except ImportError:
|
||||
if 'ast' in globals():
|
||||
raise
|
||||
def default_environment():
|
||||
return {}
|
||||
def compile(marker):
|
||||
def marker_fn(environment=None, override=None):
|
||||
# 'empty markers are True' heuristic won't install extra deps.
|
||||
return not marker.strip()
|
||||
marker_fn.__doc__ = marker
|
||||
return marker_fn
|
||||
def interpret(marker, environment=None, override=None):
|
||||
return compile(marker)()
|
||||
Vendored
+4
@@ -49,6 +49,10 @@ _VARS = {'sys.platform': sys.platform,
|
||||
'extra': None # wheel extension
|
||||
}
|
||||
|
||||
for var in list(_VARS.keys()):
|
||||
if '.' in var:
|
||||
_VARS[var.replace('.', '_')] = _VARS[var]
|
||||
|
||||
def default_environment():
|
||||
"""Return copy of default PEP 385 globals dictionary."""
|
||||
return dict(_VARS)
|
||||
@@ -0,0 +1,7 @@
|
||||
# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
|
||||
from .initialise import init, deinit, reinit
|
||||
from .ansi import Fore, Back, Style
|
||||
from .ansitowin32 import AnsiToWin32
|
||||
|
||||
VERSION = '0.2.7'
|
||||
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
|
||||
'''
|
||||
This module generates ANSI character codes to printing colors to terminals.
|
||||
See: http://en.wikipedia.org/wiki/ANSI_escape_code
|
||||
'''
|
||||
|
||||
CSI = '\033['
|
||||
|
||||
def code_to_chars(code):
|
||||
return CSI + str(code) + 'm'
|
||||
|
||||
class AnsiCodes(object):
|
||||
def __init__(self, codes):
|
||||
for name in dir(codes):
|
||||
if not name.startswith('_'):
|
||||
value = getattr(codes, name)
|
||||
setattr(self, name, code_to_chars(value))
|
||||
|
||||
class AnsiFore:
|
||||
BLACK = 30
|
||||
RED = 31
|
||||
GREEN = 32
|
||||
YELLOW = 33
|
||||
BLUE = 34
|
||||
MAGENTA = 35
|
||||
CYAN = 36
|
||||
WHITE = 37
|
||||
RESET = 39
|
||||
|
||||
class AnsiBack:
|
||||
BLACK = 40
|
||||
RED = 41
|
||||
GREEN = 42
|
||||
YELLOW = 43
|
||||
BLUE = 44
|
||||
MAGENTA = 45
|
||||
CYAN = 46
|
||||
WHITE = 47
|
||||
RESET = 49
|
||||
|
||||
class AnsiStyle:
|
||||
BRIGHT = 1
|
||||
DIM = 2
|
||||
NORMAL = 22
|
||||
RESET_ALL = 0
|
||||
|
||||
Fore = AnsiCodes( AnsiFore )
|
||||
Back = AnsiCodes( AnsiBack )
|
||||
Style = AnsiCodes( AnsiStyle )
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
|
||||
import re
|
||||
import sys
|
||||
|
||||
from .ansi import AnsiFore, AnsiBack, AnsiStyle, Style
|
||||
from .winterm import WinTerm, WinColor, WinStyle
|
||||
from .win32 import windll
|
||||
|
||||
|
||||
if windll is not None:
|
||||
winterm = WinTerm()
|
||||
|
||||
|
||||
def is_a_tty(stream):
|
||||
return hasattr(stream, 'isatty') and stream.isatty()
|
||||
|
||||
|
||||
class StreamWrapper(object):
|
||||
'''
|
||||
Wraps a stream (such as stdout), acting as a transparent proxy for all
|
||||
attribute access apart from method 'write()', which is delegated to our
|
||||
Converter instance.
|
||||
'''
|
||||
def __init__(self, wrapped, converter):
|
||||
# double-underscore everything to prevent clashes with names of
|
||||
# attributes on the wrapped stream object.
|
||||
self.__wrapped = wrapped
|
||||
self.__convertor = converter
|
||||
|
||||
def __getattr__(self, name):
|
||||
return getattr(self.__wrapped, name)
|
||||
|
||||
def write(self, text):
|
||||
self.__convertor.write(text)
|
||||
|
||||
|
||||
class AnsiToWin32(object):
|
||||
'''
|
||||
Implements a 'write()' method which, on Windows, will strip ANSI character
|
||||
sequences from the text, and if outputting to a tty, will convert them into
|
||||
win32 function calls.
|
||||
'''
|
||||
ANSI_RE = re.compile('\033\[((?:\d|;)*)([a-zA-Z])')
|
||||
|
||||
def __init__(self, wrapped, convert=None, strip=None, autoreset=False):
|
||||
# The wrapped stream (normally sys.stdout or sys.stderr)
|
||||
self.wrapped = wrapped
|
||||
|
||||
# should we reset colors to defaults after every .write()
|
||||
self.autoreset = autoreset
|
||||
|
||||
# create the proxy wrapping our output stream
|
||||
self.stream = StreamWrapper(wrapped, self)
|
||||
|
||||
on_windows = sys.platform.startswith('win')
|
||||
|
||||
# should we strip ANSI sequences from our output?
|
||||
if strip is None:
|
||||
strip = on_windows
|
||||
self.strip = strip
|
||||
|
||||
# should we should convert ANSI sequences into win32 calls?
|
||||
if convert is None:
|
||||
convert = on_windows and is_a_tty(wrapped)
|
||||
self.convert = convert
|
||||
|
||||
# dict of ansi codes to win32 functions and parameters
|
||||
self.win32_calls = self.get_win32_calls()
|
||||
|
||||
# are we wrapping stderr?
|
||||
self.on_stderr = self.wrapped is sys.stderr
|
||||
|
||||
|
||||
def should_wrap(self):
|
||||
'''
|
||||
True if this class is actually needed. If false, then the output
|
||||
stream will not be affected, nor will win32 calls be issued, so
|
||||
wrapping stdout is not actually required. This will generally be
|
||||
False on non-Windows platforms, unless optional functionality like
|
||||
autoreset has been requested using kwargs to init()
|
||||
'''
|
||||
return self.convert or self.strip or self.autoreset
|
||||
|
||||
|
||||
def get_win32_calls(self):
|
||||
if self.convert and winterm:
|
||||
return {
|
||||
AnsiStyle.RESET_ALL: (winterm.reset_all, ),
|
||||
AnsiStyle.BRIGHT: (winterm.style, WinStyle.BRIGHT),
|
||||
AnsiStyle.DIM: (winterm.style, WinStyle.NORMAL),
|
||||
AnsiStyle.NORMAL: (winterm.style, WinStyle.NORMAL),
|
||||
AnsiFore.BLACK: (winterm.fore, WinColor.BLACK),
|
||||
AnsiFore.RED: (winterm.fore, WinColor.RED),
|
||||
AnsiFore.GREEN: (winterm.fore, WinColor.GREEN),
|
||||
AnsiFore.YELLOW: (winterm.fore, WinColor.YELLOW),
|
||||
AnsiFore.BLUE: (winterm.fore, WinColor.BLUE),
|
||||
AnsiFore.MAGENTA: (winterm.fore, WinColor.MAGENTA),
|
||||
AnsiFore.CYAN: (winterm.fore, WinColor.CYAN),
|
||||
AnsiFore.WHITE: (winterm.fore, WinColor.GREY),
|
||||
AnsiFore.RESET: (winterm.fore, ),
|
||||
AnsiBack.BLACK: (winterm.back, WinColor.BLACK),
|
||||
AnsiBack.RED: (winterm.back, WinColor.RED),
|
||||
AnsiBack.GREEN: (winterm.back, WinColor.GREEN),
|
||||
AnsiBack.YELLOW: (winterm.back, WinColor.YELLOW),
|
||||
AnsiBack.BLUE: (winterm.back, WinColor.BLUE),
|
||||
AnsiBack.MAGENTA: (winterm.back, WinColor.MAGENTA),
|
||||
AnsiBack.CYAN: (winterm.back, WinColor.CYAN),
|
||||
AnsiBack.WHITE: (winterm.back, WinColor.GREY),
|
||||
AnsiBack.RESET: (winterm.back, ),
|
||||
}
|
||||
|
||||
|
||||
def write(self, text):
|
||||
if self.strip or self.convert:
|
||||
self.write_and_convert(text)
|
||||
else:
|
||||
self.wrapped.write(text)
|
||||
self.wrapped.flush()
|
||||
if self.autoreset:
|
||||
self.reset_all()
|
||||
|
||||
|
||||
def reset_all(self):
|
||||
if self.convert:
|
||||
self.call_win32('m', (0,))
|
||||
elif is_a_tty(self.wrapped):
|
||||
self.wrapped.write(Style.RESET_ALL)
|
||||
|
||||
|
||||
def write_and_convert(self, text):
|
||||
'''
|
||||
Write the given text to our wrapped stream, stripping any ANSI
|
||||
sequences from the text, and optionally converting them into win32
|
||||
calls.
|
||||
'''
|
||||
cursor = 0
|
||||
for match in self.ANSI_RE.finditer(text):
|
||||
start, end = match.span()
|
||||
self.write_plain_text(text, cursor, start)
|
||||
self.convert_ansi(*match.groups())
|
||||
cursor = end
|
||||
self.write_plain_text(text, cursor, len(text))
|
||||
|
||||
|
||||
def write_plain_text(self, text, start, end):
|
||||
if start < end:
|
||||
self.wrapped.write(text[start:end])
|
||||
self.wrapped.flush()
|
||||
|
||||
|
||||
def convert_ansi(self, paramstring, command):
|
||||
if self.convert:
|
||||
params = self.extract_params(paramstring)
|
||||
self.call_win32(command, params)
|
||||
|
||||
|
||||
def extract_params(self, paramstring):
|
||||
def split(paramstring):
|
||||
for p in paramstring.split(';'):
|
||||
if p != '':
|
||||
yield int(p)
|
||||
return tuple(split(paramstring))
|
||||
|
||||
|
||||
def call_win32(self, command, params):
|
||||
if params == []:
|
||||
params = [0]
|
||||
if command == 'm':
|
||||
for param in params:
|
||||
if param in self.win32_calls:
|
||||
func_args = self.win32_calls[param]
|
||||
func = func_args[0]
|
||||
args = func_args[1:]
|
||||
kwargs = dict(on_stderr=self.on_stderr)
|
||||
func(*args, **kwargs)
|
||||
elif command in ('H', 'f'): # set cursor position
|
||||
func = winterm.set_cursor_position
|
||||
func(params, on_stderr=self.on_stderr)
|
||||
elif command in ('J'):
|
||||
func = winterm.erase_data
|
||||
func(params, on_stderr=self.on_stderr)
|
||||
elif command == 'A':
|
||||
if params == () or params == None:
|
||||
num_rows = 1
|
||||
else:
|
||||
num_rows = params[0]
|
||||
func = winterm.cursor_up
|
||||
func(num_rows, on_stderr=self.on_stderr)
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
|
||||
import atexit
|
||||
import sys
|
||||
|
||||
from .ansitowin32 import AnsiToWin32
|
||||
|
||||
|
||||
orig_stdout = sys.stdout
|
||||
orig_stderr = sys.stderr
|
||||
|
||||
wrapped_stdout = sys.stdout
|
||||
wrapped_stderr = sys.stderr
|
||||
|
||||
atexit_done = False
|
||||
|
||||
|
||||
def reset_all():
|
||||
AnsiToWin32(orig_stdout).reset_all()
|
||||
|
||||
|
||||
def init(autoreset=False, convert=None, strip=None, wrap=True):
|
||||
|
||||
if not wrap and any([autoreset, convert, strip]):
|
||||
raise ValueError('wrap=False conflicts with any other arg=True')
|
||||
|
||||
global wrapped_stdout, wrapped_stderr
|
||||
sys.stdout = wrapped_stdout = \
|
||||
wrap_stream(orig_stdout, convert, strip, autoreset, wrap)
|
||||
sys.stderr = wrapped_stderr = \
|
||||
wrap_stream(orig_stderr, convert, strip, autoreset, wrap)
|
||||
|
||||
global atexit_done
|
||||
if not atexit_done:
|
||||
atexit.register(reset_all)
|
||||
atexit_done = True
|
||||
|
||||
|
||||
def deinit():
|
||||
sys.stdout = orig_stdout
|
||||
sys.stderr = orig_stderr
|
||||
|
||||
|
||||
def reinit():
|
||||
sys.stdout = wrapped_stdout
|
||||
sys.stderr = wrapped_stdout
|
||||
|
||||
|
||||
def wrap_stream(stream, convert, strip, autoreset, wrap):
|
||||
if wrap:
|
||||
wrapper = AnsiToWin32(stream,
|
||||
convert=convert, strip=strip, autoreset=autoreset)
|
||||
if wrapper.should_wrap():
|
||||
stream = wrapper.stream
|
||||
return stream
|
||||
|
||||
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
|
||||
|
||||
# from winbase.h
|
||||
STDOUT = -11
|
||||
STDERR = -12
|
||||
|
||||
try:
|
||||
from ctypes import windll
|
||||
from ctypes import wintypes
|
||||
except ImportError:
|
||||
windll = None
|
||||
SetConsoleTextAttribute = lambda *_: None
|
||||
else:
|
||||
from ctypes import (
|
||||
byref, Structure, c_char, c_short, c_uint32, c_ushort, POINTER
|
||||
)
|
||||
|
||||
class CONSOLE_SCREEN_BUFFER_INFO(Structure):
|
||||
"""struct in wincon.h."""
|
||||
_fields_ = [
|
||||
("dwSize", wintypes._COORD),
|
||||
("dwCursorPosition", wintypes._COORD),
|
||||
("wAttributes", wintypes.WORD),
|
||||
("srWindow", wintypes.SMALL_RECT),
|
||||
("dwMaximumWindowSize", wintypes._COORD),
|
||||
]
|
||||
def __str__(self):
|
||||
return '(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)' % (
|
||||
self.dwSize.Y, self.dwSize.X
|
||||
, self.dwCursorPosition.Y, self.dwCursorPosition.X
|
||||
, self.wAttributes
|
||||
, self.srWindow.Top, self.srWindow.Left, self.srWindow.Bottom, self.srWindow.Right
|
||||
, self.dwMaximumWindowSize.Y, self.dwMaximumWindowSize.X
|
||||
)
|
||||
|
||||
_GetStdHandle = windll.kernel32.GetStdHandle
|
||||
_GetStdHandle.argtypes = [
|
||||
wintypes.DWORD,
|
||||
]
|
||||
_GetStdHandle.restype = wintypes.HANDLE
|
||||
|
||||
_GetConsoleScreenBufferInfo = windll.kernel32.GetConsoleScreenBufferInfo
|
||||
_GetConsoleScreenBufferInfo.argtypes = [
|
||||
wintypes.HANDLE,
|
||||
POINTER(CONSOLE_SCREEN_BUFFER_INFO),
|
||||
]
|
||||
_GetConsoleScreenBufferInfo.restype = wintypes.BOOL
|
||||
|
||||
_SetConsoleTextAttribute = windll.kernel32.SetConsoleTextAttribute
|
||||
_SetConsoleTextAttribute.argtypes = [
|
||||
wintypes.HANDLE,
|
||||
wintypes.WORD,
|
||||
]
|
||||
_SetConsoleTextAttribute.restype = wintypes.BOOL
|
||||
|
||||
_SetConsoleCursorPosition = windll.kernel32.SetConsoleCursorPosition
|
||||
_SetConsoleCursorPosition.argtypes = [
|
||||
wintypes.HANDLE,
|
||||
wintypes._COORD,
|
||||
]
|
||||
_SetConsoleCursorPosition.restype = wintypes.BOOL
|
||||
|
||||
_FillConsoleOutputCharacterA = windll.kernel32.FillConsoleOutputCharacterA
|
||||
_FillConsoleOutputCharacterA.argtypes = [
|
||||
wintypes.HANDLE,
|
||||
c_char,
|
||||
wintypes.DWORD,
|
||||
wintypes._COORD,
|
||||
POINTER(wintypes.DWORD),
|
||||
]
|
||||
_FillConsoleOutputCharacterA.restype = wintypes.BOOL
|
||||
|
||||
_FillConsoleOutputAttribute = windll.kernel32.FillConsoleOutputAttribute
|
||||
_FillConsoleOutputAttribute.argtypes = [
|
||||
wintypes.HANDLE,
|
||||
wintypes.WORD,
|
||||
wintypes.DWORD,
|
||||
wintypes._COORD,
|
||||
POINTER(wintypes.DWORD),
|
||||
]
|
||||
_FillConsoleOutputAttribute.restype = wintypes.BOOL
|
||||
|
||||
handles = {
|
||||
STDOUT: _GetStdHandle(STDOUT),
|
||||
STDERR: _GetStdHandle(STDERR),
|
||||
}
|
||||
|
||||
def GetConsoleScreenBufferInfo(stream_id=STDOUT):
|
||||
handle = handles[stream_id]
|
||||
csbi = CONSOLE_SCREEN_BUFFER_INFO()
|
||||
success = _GetConsoleScreenBufferInfo(
|
||||
handle, byref(csbi))
|
||||
return csbi
|
||||
|
||||
def SetConsoleTextAttribute(stream_id, attrs):
|
||||
handle = handles[stream_id]
|
||||
return _SetConsoleTextAttribute(handle, attrs)
|
||||
|
||||
def SetConsoleCursorPosition(stream_id, position):
|
||||
position = wintypes._COORD(*position)
|
||||
# If the position is out of range, do nothing.
|
||||
if position.Y <= 0 or position.X <= 0:
|
||||
return
|
||||
# Adjust for Windows' SetConsoleCursorPosition:
|
||||
# 1. being 0-based, while ANSI is 1-based.
|
||||
# 2. expecting (x,y), while ANSI uses (y,x).
|
||||
adjusted_position = wintypes._COORD(position.Y - 1, position.X - 1)
|
||||
# Adjust for viewport's scroll position
|
||||
sr = GetConsoleScreenBufferInfo(STDOUT).srWindow
|
||||
adjusted_position.Y += sr.Top
|
||||
adjusted_position.X += sr.Left
|
||||
# Resume normal processing
|
||||
handle = handles[stream_id]
|
||||
return _SetConsoleCursorPosition(handle, adjusted_position)
|
||||
|
||||
def FillConsoleOutputCharacter(stream_id, char, length, start):
|
||||
handle = handles[stream_id]
|
||||
char = c_char(char)
|
||||
length = wintypes.DWORD(length)
|
||||
num_written = wintypes.DWORD(0)
|
||||
# Note that this is hard-coded for ANSI (vs wide) bytes.
|
||||
success = _FillConsoleOutputCharacterA(
|
||||
handle, char, length, start, byref(num_written))
|
||||
return num_written.value
|
||||
|
||||
def FillConsoleOutputAttribute(stream_id, attr, length, start):
|
||||
''' FillConsoleOutputAttribute( hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten )'''
|
||||
handle = handles[stream_id]
|
||||
attribute = wintypes.WORD(attr)
|
||||
length = wintypes.DWORD(length)
|
||||
num_written = wintypes.DWORD(0)
|
||||
# Note that this is hard-coded for ANSI (vs wide) bytes.
|
||||
return _FillConsoleOutputAttribute(
|
||||
handle, attribute, length, start, byref(num_written))
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
|
||||
from . import win32
|
||||
|
||||
|
||||
# from wincon.h
|
||||
class WinColor(object):
|
||||
BLACK = 0
|
||||
BLUE = 1
|
||||
GREEN = 2
|
||||
CYAN = 3
|
||||
RED = 4
|
||||
MAGENTA = 5
|
||||
YELLOW = 6
|
||||
GREY = 7
|
||||
|
||||
# from wincon.h
|
||||
class WinStyle(object):
|
||||
NORMAL = 0x00 # dim text, dim background
|
||||
BRIGHT = 0x08 # bright text, dim background
|
||||
|
||||
|
||||
class WinTerm(object):
|
||||
|
||||
def __init__(self):
|
||||
self._default = win32.GetConsoleScreenBufferInfo(win32.STDOUT).wAttributes
|
||||
self.set_attrs(self._default)
|
||||
self._default_fore = self._fore
|
||||
self._default_back = self._back
|
||||
self._default_style = self._style
|
||||
|
||||
def get_attrs(self):
|
||||
return self._fore + self._back * 16 + self._style
|
||||
|
||||
def set_attrs(self, value):
|
||||
self._fore = value & 7
|
||||
self._back = (value >> 4) & 7
|
||||
self._style = value & WinStyle.BRIGHT
|
||||
|
||||
def reset_all(self, on_stderr=None):
|
||||
self.set_attrs(self._default)
|
||||
self.set_console(attrs=self._default)
|
||||
|
||||
def fore(self, fore=None, on_stderr=False):
|
||||
if fore is None:
|
||||
fore = self._default_fore
|
||||
self._fore = fore
|
||||
self.set_console(on_stderr=on_stderr)
|
||||
|
||||
def back(self, back=None, on_stderr=False):
|
||||
if back is None:
|
||||
back = self._default_back
|
||||
self._back = back
|
||||
self.set_console(on_stderr=on_stderr)
|
||||
|
||||
def style(self, style=None, on_stderr=False):
|
||||
if style is None:
|
||||
style = self._default_style
|
||||
self._style = style
|
||||
self.set_console(on_stderr=on_stderr)
|
||||
|
||||
def set_console(self, attrs=None, on_stderr=False):
|
||||
if attrs is None:
|
||||
attrs = self.get_attrs()
|
||||
handle = win32.STDOUT
|
||||
if on_stderr:
|
||||
handle = win32.STDERR
|
||||
win32.SetConsoleTextAttribute(handle, attrs)
|
||||
|
||||
def get_position(self, handle):
|
||||
position = win32.GetConsoleScreenBufferInfo(handle).dwCursorPosition
|
||||
# Because Windows coordinates are 0-based,
|
||||
# and win32.SetConsoleCursorPosition expects 1-based.
|
||||
position.X += 1
|
||||
position.Y += 1
|
||||
return position
|
||||
|
||||
def set_cursor_position(self, position=None, on_stderr=False):
|
||||
if position is None:
|
||||
#I'm not currently tracking the position, so there is no default.
|
||||
#position = self.get_position()
|
||||
return
|
||||
handle = win32.STDOUT
|
||||
if on_stderr:
|
||||
handle = win32.STDERR
|
||||
win32.SetConsoleCursorPosition(handle, position)
|
||||
|
||||
def cursor_up(self, num_rows=0, on_stderr=False):
|
||||
if num_rows == 0:
|
||||
return
|
||||
handle = win32.STDOUT
|
||||
if on_stderr:
|
||||
handle = win32.STDERR
|
||||
position = self.get_position(handle)
|
||||
adjusted_position = (position.Y - num_rows, position.X)
|
||||
self.set_cursor_position(adjusted_position, on_stderr)
|
||||
|
||||
def erase_data(self, mode=0, on_stderr=False):
|
||||
# 0 (or None) should clear from the cursor to the end of the screen.
|
||||
# 1 should clear from the cursor to the beginning of the screen.
|
||||
# 2 should clear the entire screen. (And maybe move cursor to (1,1)?)
|
||||
#
|
||||
# At the moment, I only support mode 2. From looking at the API, it
|
||||
# should be possible to calculate a different number of bytes to clear,
|
||||
# and to do so relative to the cursor position.
|
||||
if mode[0] not in (2,):
|
||||
return
|
||||
handle = win32.STDOUT
|
||||
if on_stderr:
|
||||
handle = win32.STDERR
|
||||
# here's where we'll home the cursor
|
||||
coord_screen = win32.COORD(0,0)
|
||||
csbi = win32.GetConsoleScreenBufferInfo(handle)
|
||||
# get the number of character cells in the current buffer
|
||||
dw_con_size = csbi.dwSize.X * csbi.dwSize.Y
|
||||
# fill the entire screen with blanks
|
||||
win32.FillConsoleOutputCharacter(handle, ' ', dw_con_size, coord_screen)
|
||||
# now set the buffer's attributes accordingly
|
||||
win32.FillConsoleOutputAttribute(handle, self.get_attrs(), dw_con_size, coord_screen );
|
||||
# put the cursor at (0, 0)
|
||||
win32.SetConsoleCursorPosition(handle, (coord_screen.X, coord_screen.Y))
|
||||
@@ -0,0 +1,22 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2012-2013 Vinay Sajip.
|
||||
# Licensed to the Python Software Foundation under a contributor agreement.
|
||||
# See LICENSE.txt and CONTRIBUTORS.txt.
|
||||
#
|
||||
import logging
|
||||
|
||||
__version__ = '0.1.7'
|
||||
|
||||
class DistlibException(Exception):
|
||||
pass
|
||||
|
||||
try:
|
||||
from logging import NullHandler
|
||||
except ImportError: # pragma: no cover
|
||||
class NullHandler(logging.Handler):
|
||||
def handle(self, record): pass
|
||||
def emit(self, record): pass
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.addHandler(NullHandler())
|
||||
@@ -0,0 +1,6 @@
|
||||
"""Modules copied from Python 3 standard libraries, for internal use only.
|
||||
|
||||
Individual classes and functions are found in d2._backport.misc. Intended
|
||||
usage is to always import things missing from 3.1 from that module: the
|
||||
built-in/stdlib objects will be used if found.
|
||||
"""
|
||||
@@ -0,0 +1,41 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2012 The Python Software Foundation.
|
||||
# See LICENSE.txt and CONTRIBUTORS.txt.
|
||||
#
|
||||
"""Backports for individual classes and functions."""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
__all__ = ['cache_from_source', 'callable', 'fsencode']
|
||||
|
||||
|
||||
try:
|
||||
from imp import cache_from_source
|
||||
except ImportError:
|
||||
def cache_from_source(py_file, debug=__debug__):
|
||||
ext = debug and 'c' or 'o'
|
||||
return py_file + ext
|
||||
|
||||
|
||||
try:
|
||||
callable = callable
|
||||
except NameError:
|
||||
from collections import Callable
|
||||
|
||||
def callable(obj):
|
||||
return isinstance(obj, Callable)
|
||||
|
||||
|
||||
try:
|
||||
fsencode = os.fsencode
|
||||
except AttributeError:
|
||||
def fsencode(filename):
|
||||
if isinstance(filename, bytes):
|
||||
return filename
|
||||
elif isinstance(filename, str):
|
||||
return filename.encode(sys.getfilesystemencoding())
|
||||
else:
|
||||
raise TypeError("expect bytes or str, not %s" %
|
||||
type(filename).__name__)
|
||||
@@ -0,0 +1,761 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2012 The Python Software Foundation.
|
||||
# See LICENSE.txt and CONTRIBUTORS.txt.
|
||||
#
|
||||
"""Utility functions for copying and archiving files and directory trees.
|
||||
|
||||
XXX The functions here don't copy the resource fork or other metadata on Mac.
|
||||
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import stat
|
||||
from os.path import abspath
|
||||
import fnmatch
|
||||
import collections
|
||||
import errno
|
||||
from . import tarfile
|
||||
|
||||
try:
|
||||
import bz2
|
||||
_BZ2_SUPPORTED = True
|
||||
except ImportError:
|
||||
_BZ2_SUPPORTED = False
|
||||
|
||||
try:
|
||||
from pwd import getpwnam
|
||||
except ImportError:
|
||||
getpwnam = None
|
||||
|
||||
try:
|
||||
from grp import getgrnam
|
||||
except ImportError:
|
||||
getgrnam = None
|
||||
|
||||
__all__ = ["copyfileobj", "copyfile", "copymode", "copystat", "copy", "copy2",
|
||||
"copytree", "move", "rmtree", "Error", "SpecialFileError",
|
||||
"ExecError", "make_archive", "get_archive_formats",
|
||||
"register_archive_format", "unregister_archive_format",
|
||||
"get_unpack_formats", "register_unpack_format",
|
||||
"unregister_unpack_format", "unpack_archive", "ignore_patterns"]
|
||||
|
||||
class Error(EnvironmentError):
|
||||
pass
|
||||
|
||||
class SpecialFileError(EnvironmentError):
|
||||
"""Raised when trying to do a kind of operation (e.g. copying) which is
|
||||
not supported on a special file (e.g. a named pipe)"""
|
||||
|
||||
class ExecError(EnvironmentError):
|
||||
"""Raised when a command could not be executed"""
|
||||
|
||||
class ReadError(EnvironmentError):
|
||||
"""Raised when an archive cannot be read"""
|
||||
|
||||
class RegistryError(Exception):
|
||||
"""Raised when a registery operation with the archiving
|
||||
and unpacking registeries fails"""
|
||||
|
||||
|
||||
try:
|
||||
WindowsError
|
||||
except NameError:
|
||||
WindowsError = None
|
||||
|
||||
def copyfileobj(fsrc, fdst, length=16*1024):
|
||||
"""copy data from file-like object fsrc to file-like object fdst"""
|
||||
while 1:
|
||||
buf = fsrc.read(length)
|
||||
if not buf:
|
||||
break
|
||||
fdst.write(buf)
|
||||
|
||||
def _samefile(src, dst):
|
||||
# Macintosh, Unix.
|
||||
if hasattr(os.path, 'samefile'):
|
||||
try:
|
||||
return os.path.samefile(src, dst)
|
||||
except OSError:
|
||||
return False
|
||||
|
||||
# All other platforms: check for same pathname.
|
||||
return (os.path.normcase(os.path.abspath(src)) ==
|
||||
os.path.normcase(os.path.abspath(dst)))
|
||||
|
||||
def copyfile(src, dst):
|
||||
"""Copy data from src to dst"""
|
||||
if _samefile(src, dst):
|
||||
raise Error("`%s` and `%s` are the same file" % (src, dst))
|
||||
|
||||
for fn in [src, dst]:
|
||||
try:
|
||||
st = os.stat(fn)
|
||||
except OSError:
|
||||
# File most likely does not exist
|
||||
pass
|
||||
else:
|
||||
# XXX What about other special files? (sockets, devices...)
|
||||
if stat.S_ISFIFO(st.st_mode):
|
||||
raise SpecialFileError("`%s` is a named pipe" % fn)
|
||||
|
||||
with open(src, 'rb') as fsrc:
|
||||
with open(dst, 'wb') as fdst:
|
||||
copyfileobj(fsrc, fdst)
|
||||
|
||||
def copymode(src, dst):
|
||||
"""Copy mode bits from src to dst"""
|
||||
if hasattr(os, 'chmod'):
|
||||
st = os.stat(src)
|
||||
mode = stat.S_IMODE(st.st_mode)
|
||||
os.chmod(dst, mode)
|
||||
|
||||
def copystat(src, dst):
|
||||
"""Copy all stat info (mode bits, atime, mtime, flags) from src to dst"""
|
||||
st = os.stat(src)
|
||||
mode = stat.S_IMODE(st.st_mode)
|
||||
if hasattr(os, 'utime'):
|
||||
os.utime(dst, (st.st_atime, st.st_mtime))
|
||||
if hasattr(os, 'chmod'):
|
||||
os.chmod(dst, mode)
|
||||
if hasattr(os, 'chflags') and hasattr(st, 'st_flags'):
|
||||
try:
|
||||
os.chflags(dst, st.st_flags)
|
||||
except OSError as why:
|
||||
if (not hasattr(errno, 'EOPNOTSUPP') or
|
||||
why.errno != errno.EOPNOTSUPP):
|
||||
raise
|
||||
|
||||
def copy(src, dst):
|
||||
"""Copy data and mode bits ("cp src dst").
|
||||
|
||||
The destination may be a directory.
|
||||
|
||||
"""
|
||||
if os.path.isdir(dst):
|
||||
dst = os.path.join(dst, os.path.basename(src))
|
||||
copyfile(src, dst)
|
||||
copymode(src, dst)
|
||||
|
||||
def copy2(src, dst):
|
||||
"""Copy data and all stat info ("cp -p src dst").
|
||||
|
||||
The destination may be a directory.
|
||||
|
||||
"""
|
||||
if os.path.isdir(dst):
|
||||
dst = os.path.join(dst, os.path.basename(src))
|
||||
copyfile(src, dst)
|
||||
copystat(src, dst)
|
||||
|
||||
def ignore_patterns(*patterns):
|
||||
"""Function that can be used as copytree() ignore parameter.
|
||||
|
||||
Patterns is a sequence of glob-style patterns
|
||||
that are used to exclude files"""
|
||||
def _ignore_patterns(path, names):
|
||||
ignored_names = []
|
||||
for pattern in patterns:
|
||||
ignored_names.extend(fnmatch.filter(names, pattern))
|
||||
return set(ignored_names)
|
||||
return _ignore_patterns
|
||||
|
||||
def copytree(src, dst, symlinks=False, ignore=None, copy_function=copy2,
|
||||
ignore_dangling_symlinks=False):
|
||||
"""Recursively copy a directory tree.
|
||||
|
||||
The destination directory must not already exist.
|
||||
If exception(s) occur, an Error is raised with a list of reasons.
|
||||
|
||||
If the optional symlinks flag is true, symbolic links in the
|
||||
source tree result in symbolic links in the destination tree; if
|
||||
it is false, the contents of the files pointed to by symbolic
|
||||
links are copied. If the file pointed by the symlink doesn't
|
||||
exist, an exception will be added in the list of errors raised in
|
||||
an Error exception at the end of the copy process.
|
||||
|
||||
You can set the optional ignore_dangling_symlinks flag to true if you
|
||||
want to silence this exception. Notice that this has no effect on
|
||||
platforms that don't support os.symlink.
|
||||
|
||||
The optional ignore argument is a callable. If given, it
|
||||
is called with the `src` parameter, which is the directory
|
||||
being visited by copytree(), and `names` which is the list of
|
||||
`src` contents, as returned by os.listdir():
|
||||
|
||||
callable(src, names) -> ignored_names
|
||||
|
||||
Since copytree() is called recursively, the callable will be
|
||||
called once for each directory that is copied. It returns a
|
||||
list of names relative to the `src` directory that should
|
||||
not be copied.
|
||||
|
||||
The optional copy_function argument is a callable that will be used
|
||||
to copy each file. It will be called with the source path and the
|
||||
destination path as arguments. By default, copy2() is used, but any
|
||||
function that supports the same signature (like copy()) can be used.
|
||||
|
||||
"""
|
||||
names = os.listdir(src)
|
||||
if ignore is not None:
|
||||
ignored_names = ignore(src, names)
|
||||
else:
|
||||
ignored_names = set()
|
||||
|
||||
os.makedirs(dst)
|
||||
errors = []
|
||||
for name in names:
|
||||
if name in ignored_names:
|
||||
continue
|
||||
srcname = os.path.join(src, name)
|
||||
dstname = os.path.join(dst, name)
|
||||
try:
|
||||
if os.path.islink(srcname):
|
||||
linkto = os.readlink(srcname)
|
||||
if symlinks:
|
||||
os.symlink(linkto, dstname)
|
||||
else:
|
||||
# ignore dangling symlink if the flag is on
|
||||
if not os.path.exists(linkto) and ignore_dangling_symlinks:
|
||||
continue
|
||||
# otherwise let the copy occurs. copy2 will raise an error
|
||||
copy_function(srcname, dstname)
|
||||
elif os.path.isdir(srcname):
|
||||
copytree(srcname, dstname, symlinks, ignore, copy_function)
|
||||
else:
|
||||
# Will raise a SpecialFileError for unsupported file types
|
||||
copy_function(srcname, dstname)
|
||||
# catch the Error from the recursive copytree so that we can
|
||||
# continue with other files
|
||||
except Error as err:
|
||||
errors.extend(err.args[0])
|
||||
except EnvironmentError as why:
|
||||
errors.append((srcname, dstname, str(why)))
|
||||
try:
|
||||
copystat(src, dst)
|
||||
except OSError as why:
|
||||
if WindowsError is not None and isinstance(why, WindowsError):
|
||||
# Copying file access times may fail on Windows
|
||||
pass
|
||||
else:
|
||||
errors.extend((src, dst, str(why)))
|
||||
if errors:
|
||||
raise Error(errors)
|
||||
|
||||
def rmtree(path, ignore_errors=False, onerror=None):
|
||||
"""Recursively delete a directory tree.
|
||||
|
||||
If ignore_errors is set, errors are ignored; otherwise, if onerror
|
||||
is set, it is called to handle the error with arguments (func,
|
||||
path, exc_info) where func is os.listdir, os.remove, or os.rmdir;
|
||||
path is the argument to that function that caused it to fail; and
|
||||
exc_info is a tuple returned by sys.exc_info(). If ignore_errors
|
||||
is false and onerror is None, an exception is raised.
|
||||
|
||||
"""
|
||||
if ignore_errors:
|
||||
def onerror(*args):
|
||||
pass
|
||||
elif onerror is None:
|
||||
def onerror(*args):
|
||||
raise
|
||||
try:
|
||||
if os.path.islink(path):
|
||||
# symlinks to directories are forbidden, see bug #1669
|
||||
raise OSError("Cannot call rmtree on a symbolic link")
|
||||
except OSError:
|
||||
onerror(os.path.islink, path, sys.exc_info())
|
||||
# can't continue even if onerror hook returns
|
||||
return
|
||||
names = []
|
||||
try:
|
||||
names = os.listdir(path)
|
||||
except os.error:
|
||||
onerror(os.listdir, path, sys.exc_info())
|
||||
for name in names:
|
||||
fullname = os.path.join(path, name)
|
||||
try:
|
||||
mode = os.lstat(fullname).st_mode
|
||||
except os.error:
|
||||
mode = 0
|
||||
if stat.S_ISDIR(mode):
|
||||
rmtree(fullname, ignore_errors, onerror)
|
||||
else:
|
||||
try:
|
||||
os.remove(fullname)
|
||||
except os.error:
|
||||
onerror(os.remove, fullname, sys.exc_info())
|
||||
try:
|
||||
os.rmdir(path)
|
||||
except os.error:
|
||||
onerror(os.rmdir, path, sys.exc_info())
|
||||
|
||||
|
||||
def _basename(path):
|
||||
# A basename() variant which first strips the trailing slash, if present.
|
||||
# Thus we always get the last component of the path, even for directories.
|
||||
return os.path.basename(path.rstrip(os.path.sep))
|
||||
|
||||
def move(src, dst):
|
||||
"""Recursively move a file or directory to another location. This is
|
||||
similar to the Unix "mv" command.
|
||||
|
||||
If the destination is a directory or a symlink to a directory, the source
|
||||
is moved inside the directory. The destination path must not already
|
||||
exist.
|
||||
|
||||
If the destination already exists but is not a directory, it may be
|
||||
overwritten depending on os.rename() semantics.
|
||||
|
||||
If the destination is on our current filesystem, then rename() is used.
|
||||
Otherwise, src is copied to the destination and then removed.
|
||||
A lot more could be done here... A look at a mv.c shows a lot of
|
||||
the issues this implementation glosses over.
|
||||
|
||||
"""
|
||||
real_dst = dst
|
||||
if os.path.isdir(dst):
|
||||
if _samefile(src, dst):
|
||||
# We might be on a case insensitive filesystem,
|
||||
# perform the rename anyway.
|
||||
os.rename(src, dst)
|
||||
return
|
||||
|
||||
real_dst = os.path.join(dst, _basename(src))
|
||||
if os.path.exists(real_dst):
|
||||
raise Error("Destination path '%s' already exists" % real_dst)
|
||||
try:
|
||||
os.rename(src, real_dst)
|
||||
except OSError:
|
||||
if os.path.isdir(src):
|
||||
if _destinsrc(src, dst):
|
||||
raise Error("Cannot move a directory '%s' into itself '%s'." % (src, dst))
|
||||
copytree(src, real_dst, symlinks=True)
|
||||
rmtree(src)
|
||||
else:
|
||||
copy2(src, real_dst)
|
||||
os.unlink(src)
|
||||
|
||||
def _destinsrc(src, dst):
|
||||
src = abspath(src)
|
||||
dst = abspath(dst)
|
||||
if not src.endswith(os.path.sep):
|
||||
src += os.path.sep
|
||||
if not dst.endswith(os.path.sep):
|
||||
dst += os.path.sep
|
||||
return dst.startswith(src)
|
||||
|
||||
def _get_gid(name):
|
||||
"""Returns a gid, given a group name."""
|
||||
if getgrnam is None or name is None:
|
||||
return None
|
||||
try:
|
||||
result = getgrnam(name)
|
||||
except KeyError:
|
||||
result = None
|
||||
if result is not None:
|
||||
return result[2]
|
||||
return None
|
||||
|
||||
def _get_uid(name):
|
||||
"""Returns an uid, given a user name."""
|
||||
if getpwnam is None or name is None:
|
||||
return None
|
||||
try:
|
||||
result = getpwnam(name)
|
||||
except KeyError:
|
||||
result = None
|
||||
if result is not None:
|
||||
return result[2]
|
||||
return None
|
||||
|
||||
def _make_tarball(base_name, base_dir, compress="gzip", verbose=0, dry_run=0,
|
||||
owner=None, group=None, logger=None):
|
||||
"""Create a (possibly compressed) tar file from all the files under
|
||||
'base_dir'.
|
||||
|
||||
'compress' must be "gzip" (the default), "bzip2", or None.
|
||||
|
||||
'owner' and 'group' can be used to define an owner and a group for the
|
||||
archive that is being built. If not provided, the current owner and group
|
||||
will be used.
|
||||
|
||||
The output tar file will be named 'base_name' + ".tar", possibly plus
|
||||
the appropriate compression extension (".gz", or ".bz2").
|
||||
|
||||
Returns the output filename.
|
||||
"""
|
||||
tar_compression = {'gzip': 'gz', None: ''}
|
||||
compress_ext = {'gzip': '.gz'}
|
||||
|
||||
if _BZ2_SUPPORTED:
|
||||
tar_compression['bzip2'] = 'bz2'
|
||||
compress_ext['bzip2'] = '.bz2'
|
||||
|
||||
# flags for compression program, each element of list will be an argument
|
||||
if compress is not None and compress not in compress_ext:
|
||||
raise ValueError("bad value for 'compress', or compression format not "
|
||||
"supported : {0}".format(compress))
|
||||
|
||||
archive_name = base_name + '.tar' + compress_ext.get(compress, '')
|
||||
archive_dir = os.path.dirname(archive_name)
|
||||
|
||||
if not os.path.exists(archive_dir):
|
||||
if logger is not None:
|
||||
logger.info("creating %s", archive_dir)
|
||||
if not dry_run:
|
||||
os.makedirs(archive_dir)
|
||||
|
||||
# creating the tarball
|
||||
if logger is not None:
|
||||
logger.info('Creating tar archive')
|
||||
|
||||
uid = _get_uid(owner)
|
||||
gid = _get_gid(group)
|
||||
|
||||
def _set_uid_gid(tarinfo):
|
||||
if gid is not None:
|
||||
tarinfo.gid = gid
|
||||
tarinfo.gname = group
|
||||
if uid is not None:
|
||||
tarinfo.uid = uid
|
||||
tarinfo.uname = owner
|
||||
return tarinfo
|
||||
|
||||
if not dry_run:
|
||||
tar = tarfile.open(archive_name, 'w|%s' % tar_compression[compress])
|
||||
try:
|
||||
tar.add(base_dir, filter=_set_uid_gid)
|
||||
finally:
|
||||
tar.close()
|
||||
|
||||
return archive_name
|
||||
|
||||
def _call_external_zip(base_dir, zip_filename, verbose=False, dry_run=False):
|
||||
# XXX see if we want to keep an external call here
|
||||
if verbose:
|
||||
zipoptions = "-r"
|
||||
else:
|
||||
zipoptions = "-rq"
|
||||
from distutils.errors import DistutilsExecError
|
||||
from distutils.spawn import spawn
|
||||
try:
|
||||
spawn(["zip", zipoptions, zip_filename, base_dir], dry_run=dry_run)
|
||||
except DistutilsExecError:
|
||||
# XXX really should distinguish between "couldn't find
|
||||
# external 'zip' command" and "zip failed".
|
||||
raise ExecError("unable to create zip file '%s': "
|
||||
"could neither import the 'zipfile' module nor "
|
||||
"find a standalone zip utility") % zip_filename
|
||||
|
||||
def _make_zipfile(base_name, base_dir, verbose=0, dry_run=0, logger=None):
|
||||
"""Create a zip file from all the files under 'base_dir'.
|
||||
|
||||
The output zip file will be named 'base_name' + ".zip". Uses either the
|
||||
"zipfile" Python module (if available) or the InfoZIP "zip" utility
|
||||
(if installed and found on the default search path). If neither tool is
|
||||
available, raises ExecError. Returns the name of the output zip
|
||||
file.
|
||||
"""
|
||||
zip_filename = base_name + ".zip"
|
||||
archive_dir = os.path.dirname(base_name)
|
||||
|
||||
if not os.path.exists(archive_dir):
|
||||
if logger is not None:
|
||||
logger.info("creating %s", archive_dir)
|
||||
if not dry_run:
|
||||
os.makedirs(archive_dir)
|
||||
|
||||
# If zipfile module is not available, try spawning an external 'zip'
|
||||
# command.
|
||||
try:
|
||||
import zipfile
|
||||
except ImportError:
|
||||
zipfile = None
|
||||
|
||||
if zipfile is None:
|
||||
_call_external_zip(base_dir, zip_filename, verbose, dry_run)
|
||||
else:
|
||||
if logger is not None:
|
||||
logger.info("creating '%s' and adding '%s' to it",
|
||||
zip_filename, base_dir)
|
||||
|
||||
if not dry_run:
|
||||
zip = zipfile.ZipFile(zip_filename, "w",
|
||||
compression=zipfile.ZIP_DEFLATED)
|
||||
|
||||
for dirpath, dirnames, filenames in os.walk(base_dir):
|
||||
for name in filenames:
|
||||
path = os.path.normpath(os.path.join(dirpath, name))
|
||||
if os.path.isfile(path):
|
||||
zip.write(path, path)
|
||||
if logger is not None:
|
||||
logger.info("adding '%s'", path)
|
||||
zip.close()
|
||||
|
||||
return zip_filename
|
||||
|
||||
_ARCHIVE_FORMATS = {
|
||||
'gztar': (_make_tarball, [('compress', 'gzip')], "gzip'ed tar-file"),
|
||||
'bztar': (_make_tarball, [('compress', 'bzip2')], "bzip2'ed tar-file"),
|
||||
'tar': (_make_tarball, [('compress', None)], "uncompressed tar file"),
|
||||
'zip': (_make_zipfile, [], "ZIP file"),
|
||||
}
|
||||
|
||||
if _BZ2_SUPPORTED:
|
||||
_ARCHIVE_FORMATS['bztar'] = (_make_tarball, [('compress', 'bzip2')],
|
||||
"bzip2'ed tar-file")
|
||||
|
||||
def get_archive_formats():
|
||||
"""Returns a list of supported formats for archiving and unarchiving.
|
||||
|
||||
Each element of the returned sequence is a tuple (name, description)
|
||||
"""
|
||||
formats = [(name, registry[2]) for name, registry in
|
||||
_ARCHIVE_FORMATS.items()]
|
||||
formats.sort()
|
||||
return formats
|
||||
|
||||
def register_archive_format(name, function, extra_args=None, description=''):
|
||||
"""Registers an archive format.
|
||||
|
||||
name is the name of the format. function is the callable that will be
|
||||
used to create archives. If provided, extra_args is a sequence of
|
||||
(name, value) tuples that will be passed as arguments to the callable.
|
||||
description can be provided to describe the format, and will be returned
|
||||
by the get_archive_formats() function.
|
||||
"""
|
||||
if extra_args is None:
|
||||
extra_args = []
|
||||
if not isinstance(function, collections.Callable):
|
||||
raise TypeError('The %s object is not callable' % function)
|
||||
if not isinstance(extra_args, (tuple, list)):
|
||||
raise TypeError('extra_args needs to be a sequence')
|
||||
for element in extra_args:
|
||||
if not isinstance(element, (tuple, list)) or len(element) !=2:
|
||||
raise TypeError('extra_args elements are : (arg_name, value)')
|
||||
|
||||
_ARCHIVE_FORMATS[name] = (function, extra_args, description)
|
||||
|
||||
def unregister_archive_format(name):
|
||||
del _ARCHIVE_FORMATS[name]
|
||||
|
||||
def make_archive(base_name, format, root_dir=None, base_dir=None, verbose=0,
|
||||
dry_run=0, owner=None, group=None, logger=None):
|
||||
"""Create an archive file (eg. zip or tar).
|
||||
|
||||
'base_name' is the name of the file to create, minus any format-specific
|
||||
extension; 'format' is the archive format: one of "zip", "tar", "bztar"
|
||||
or "gztar".
|
||||
|
||||
'root_dir' is a directory that will be the root directory of the
|
||||
archive; ie. we typically chdir into 'root_dir' before creating the
|
||||
archive. 'base_dir' is the directory where we start archiving from;
|
||||
ie. 'base_dir' will be the common prefix of all files and
|
||||
directories in the archive. 'root_dir' and 'base_dir' both default
|
||||
to the current directory. Returns the name of the archive file.
|
||||
|
||||
'owner' and 'group' are used when creating a tar archive. By default,
|
||||
uses the current owner and group.
|
||||
"""
|
||||
save_cwd = os.getcwd()
|
||||
if root_dir is not None:
|
||||
if logger is not None:
|
||||
logger.debug("changing into '%s'", root_dir)
|
||||
base_name = os.path.abspath(base_name)
|
||||
if not dry_run:
|
||||
os.chdir(root_dir)
|
||||
|
||||
if base_dir is None:
|
||||
base_dir = os.curdir
|
||||
|
||||
kwargs = {'dry_run': dry_run, 'logger': logger}
|
||||
|
||||
try:
|
||||
format_info = _ARCHIVE_FORMATS[format]
|
||||
except KeyError:
|
||||
raise ValueError("unknown archive format '%s'" % format)
|
||||
|
||||
func = format_info[0]
|
||||
for arg, val in format_info[1]:
|
||||
kwargs[arg] = val
|
||||
|
||||
if format != 'zip':
|
||||
kwargs['owner'] = owner
|
||||
kwargs['group'] = group
|
||||
|
||||
try:
|
||||
filename = func(base_name, base_dir, **kwargs)
|
||||
finally:
|
||||
if root_dir is not None:
|
||||
if logger is not None:
|
||||
logger.debug("changing back to '%s'", save_cwd)
|
||||
os.chdir(save_cwd)
|
||||
|
||||
return filename
|
||||
|
||||
|
||||
def get_unpack_formats():
|
||||
"""Returns a list of supported formats for unpacking.
|
||||
|
||||
Each element of the returned sequence is a tuple
|
||||
(name, extensions, description)
|
||||
"""
|
||||
formats = [(name, info[0], info[3]) for name, info in
|
||||
_UNPACK_FORMATS.items()]
|
||||
formats.sort()
|
||||
return formats
|
||||
|
||||
def _check_unpack_options(extensions, function, extra_args):
|
||||
"""Checks what gets registered as an unpacker."""
|
||||
# first make sure no other unpacker is registered for this extension
|
||||
existing_extensions = {}
|
||||
for name, info in _UNPACK_FORMATS.items():
|
||||
for ext in info[0]:
|
||||
existing_extensions[ext] = name
|
||||
|
||||
for extension in extensions:
|
||||
if extension in existing_extensions:
|
||||
msg = '%s is already registered for "%s"'
|
||||
raise RegistryError(msg % (extension,
|
||||
existing_extensions[extension]))
|
||||
|
||||
if not isinstance(function, collections.Callable):
|
||||
raise TypeError('The registered function must be a callable')
|
||||
|
||||
|
||||
def register_unpack_format(name, extensions, function, extra_args=None,
|
||||
description=''):
|
||||
"""Registers an unpack format.
|
||||
|
||||
`name` is the name of the format. `extensions` is a list of extensions
|
||||
corresponding to the format.
|
||||
|
||||
`function` is the callable that will be
|
||||
used to unpack archives. The callable will receive archives to unpack.
|
||||
If it's unable to handle an archive, it needs to raise a ReadError
|
||||
exception.
|
||||
|
||||
If provided, `extra_args` is a sequence of
|
||||
(name, value) tuples that will be passed as arguments to the callable.
|
||||
description can be provided to describe the format, and will be returned
|
||||
by the get_unpack_formats() function.
|
||||
"""
|
||||
if extra_args is None:
|
||||
extra_args = []
|
||||
_check_unpack_options(extensions, function, extra_args)
|
||||
_UNPACK_FORMATS[name] = extensions, function, extra_args, description
|
||||
|
||||
def unregister_unpack_format(name):
|
||||
"""Removes the pack format from the registery."""
|
||||
del _UNPACK_FORMATS[name]
|
||||
|
||||
def _ensure_directory(path):
|
||||
"""Ensure that the parent directory of `path` exists"""
|
||||
dirname = os.path.dirname(path)
|
||||
if not os.path.isdir(dirname):
|
||||
os.makedirs(dirname)
|
||||
|
||||
def _unpack_zipfile(filename, extract_dir):
|
||||
"""Unpack zip `filename` to `extract_dir`
|
||||
"""
|
||||
try:
|
||||
import zipfile
|
||||
except ImportError:
|
||||
raise ReadError('zlib not supported, cannot unpack this archive.')
|
||||
|
||||
if not zipfile.is_zipfile(filename):
|
||||
raise ReadError("%s is not a zip file" % filename)
|
||||
|
||||
zip = zipfile.ZipFile(filename)
|
||||
try:
|
||||
for info in zip.infolist():
|
||||
name = info.filename
|
||||
|
||||
# don't extract absolute paths or ones with .. in them
|
||||
if name.startswith('/') or '..' in name:
|
||||
continue
|
||||
|
||||
target = os.path.join(extract_dir, *name.split('/'))
|
||||
if not target:
|
||||
continue
|
||||
|
||||
_ensure_directory(target)
|
||||
if not name.endswith('/'):
|
||||
# file
|
||||
data = zip.read(info.filename)
|
||||
f = open(target, 'wb')
|
||||
try:
|
||||
f.write(data)
|
||||
finally:
|
||||
f.close()
|
||||
del data
|
||||
finally:
|
||||
zip.close()
|
||||
|
||||
def _unpack_tarfile(filename, extract_dir):
|
||||
"""Unpack tar/tar.gz/tar.bz2 `filename` to `extract_dir`
|
||||
"""
|
||||
try:
|
||||
tarobj = tarfile.open(filename)
|
||||
except tarfile.TarError:
|
||||
raise ReadError(
|
||||
"%s is not a compressed or uncompressed tar file" % filename)
|
||||
try:
|
||||
tarobj.extractall(extract_dir)
|
||||
finally:
|
||||
tarobj.close()
|
||||
|
||||
_UNPACK_FORMATS = {
|
||||
'gztar': (['.tar.gz', '.tgz'], _unpack_tarfile, [], "gzip'ed tar-file"),
|
||||
'tar': (['.tar'], _unpack_tarfile, [], "uncompressed tar file"),
|
||||
'zip': (['.zip'], _unpack_zipfile, [], "ZIP file")
|
||||
}
|
||||
|
||||
if _BZ2_SUPPORTED:
|
||||
_UNPACK_FORMATS['bztar'] = (['.bz2'], _unpack_tarfile, [],
|
||||
"bzip2'ed tar-file")
|
||||
|
||||
def _find_unpack_format(filename):
|
||||
for name, info in _UNPACK_FORMATS.items():
|
||||
for extension in info[0]:
|
||||
if filename.endswith(extension):
|
||||
return name
|
||||
return None
|
||||
|
||||
def unpack_archive(filename, extract_dir=None, format=None):
|
||||
"""Unpack an archive.
|
||||
|
||||
`filename` is the name of the archive.
|
||||
|
||||
`extract_dir` is the name of the target directory, where the archive
|
||||
is unpacked. If not provided, the current working directory is used.
|
||||
|
||||
`format` is the archive format: one of "zip", "tar", or "gztar". Or any
|
||||
other registered format. If not provided, unpack_archive will use the
|
||||
filename extension and see if an unpacker was registered for that
|
||||
extension.
|
||||
|
||||
In case none is found, a ValueError is raised.
|
||||
"""
|
||||
if extract_dir is None:
|
||||
extract_dir = os.getcwd()
|
||||
|
||||
if format is not None:
|
||||
try:
|
||||
format_info = _UNPACK_FORMATS[format]
|
||||
except KeyError:
|
||||
raise ValueError("Unknown unpack format '{0}'".format(format))
|
||||
|
||||
func = format_info[1]
|
||||
func(filename, extract_dir, **dict(format_info[2]))
|
||||
else:
|
||||
# we need to look at the registered unpackers supported extensions
|
||||
format = _find_unpack_format(filename)
|
||||
if format is None:
|
||||
raise ReadError("Unknown archive format '{0}'".format(filename))
|
||||
|
||||
func = _UNPACK_FORMATS[format][1]
|
||||
kwargs = dict(_UNPACK_FORMATS[format][2])
|
||||
func(filename, extract_dir, **kwargs)
|
||||
@@ -0,0 +1,84 @@
|
||||
[posix_prefix]
|
||||
# Configuration directories. Some of these come straight out of the
|
||||
# configure script. They are for implementing the other variables, not to
|
||||
# be used directly in [resource_locations].
|
||||
confdir = /etc
|
||||
datadir = /usr/share
|
||||
libdir = /usr/lib
|
||||
statedir = /var
|
||||
# User resource directory
|
||||
local = ~/.local/{distribution.name}
|
||||
|
||||
stdlib = {base}/lib/python{py_version_short}
|
||||
platstdlib = {platbase}/lib/python{py_version_short}
|
||||
purelib = {base}/lib/python{py_version_short}/site-packages
|
||||
platlib = {platbase}/lib/python{py_version_short}/site-packages
|
||||
include = {base}/include/python{py_version_short}{abiflags}
|
||||
platinclude = {platbase}/include/python{py_version_short}{abiflags}
|
||||
data = {base}
|
||||
|
||||
[posix_home]
|
||||
stdlib = {base}/lib/python
|
||||
platstdlib = {base}/lib/python
|
||||
purelib = {base}/lib/python
|
||||
platlib = {base}/lib/python
|
||||
include = {base}/include/python
|
||||
platinclude = {base}/include/python
|
||||
scripts = {base}/bin
|
||||
data = {base}
|
||||
|
||||
[nt]
|
||||
stdlib = {base}/Lib
|
||||
platstdlib = {base}/Lib
|
||||
purelib = {base}/Lib/site-packages
|
||||
platlib = {base}/Lib/site-packages
|
||||
include = {base}/Include
|
||||
platinclude = {base}/Include
|
||||
scripts = {base}/Scripts
|
||||
data = {base}
|
||||
|
||||
[os2]
|
||||
stdlib = {base}/Lib
|
||||
platstdlib = {base}/Lib
|
||||
purelib = {base}/Lib/site-packages
|
||||
platlib = {base}/Lib/site-packages
|
||||
include = {base}/Include
|
||||
platinclude = {base}/Include
|
||||
scripts = {base}/Scripts
|
||||
data = {base}
|
||||
|
||||
[os2_home]
|
||||
stdlib = {userbase}/lib/python{py_version_short}
|
||||
platstdlib = {userbase}/lib/python{py_version_short}
|
||||
purelib = {userbase}/lib/python{py_version_short}/site-packages
|
||||
platlib = {userbase}/lib/python{py_version_short}/site-packages
|
||||
include = {userbase}/include/python{py_version_short}
|
||||
scripts = {userbase}/bin
|
||||
data = {userbase}
|
||||
|
||||
[nt_user]
|
||||
stdlib = {userbase}/Python{py_version_nodot}
|
||||
platstdlib = {userbase}/Python{py_version_nodot}
|
||||
purelib = {userbase}/Python{py_version_nodot}/site-packages
|
||||
platlib = {userbase}/Python{py_version_nodot}/site-packages
|
||||
include = {userbase}/Python{py_version_nodot}/Include
|
||||
scripts = {userbase}/Scripts
|
||||
data = {userbase}
|
||||
|
||||
[posix_user]
|
||||
stdlib = {userbase}/lib/python{py_version_short}
|
||||
platstdlib = {userbase}/lib/python{py_version_short}
|
||||
purelib = {userbase}/lib/python{py_version_short}/site-packages
|
||||
platlib = {userbase}/lib/python{py_version_short}/site-packages
|
||||
include = {userbase}/include/python{py_version_short}
|
||||
scripts = {userbase}/bin
|
||||
data = {userbase}
|
||||
|
||||
[osx_framework_user]
|
||||
stdlib = {userbase}/lib/python
|
||||
platstdlib = {userbase}/lib/python
|
||||
purelib = {userbase}/lib/python/site-packages
|
||||
platlib = {userbase}/lib/python/site-packages
|
||||
include = {userbase}/include
|
||||
scripts = {userbase}/bin
|
||||
data = {userbase}
|
||||
@@ -0,0 +1,788 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2012 The Python Software Foundation.
|
||||
# See LICENSE.txt and CONTRIBUTORS.txt.
|
||||
#
|
||||
"""Access to Python's configuration information."""
|
||||
|
||||
import codecs
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
from os.path import pardir, realpath
|
||||
try:
|
||||
import configparser
|
||||
except ImportError:
|
||||
import ConfigParser as configparser
|
||||
|
||||
|
||||
__all__ = [
|
||||
'get_config_h_filename',
|
||||
'get_config_var',
|
||||
'get_config_vars',
|
||||
'get_makefile_filename',
|
||||
'get_path',
|
||||
'get_path_names',
|
||||
'get_paths',
|
||||
'get_platform',
|
||||
'get_python_version',
|
||||
'get_scheme_names',
|
||||
'parse_config_h',
|
||||
]
|
||||
|
||||
|
||||
def _safe_realpath(path):
|
||||
try:
|
||||
return realpath(path)
|
||||
except OSError:
|
||||
return path
|
||||
|
||||
|
||||
if sys.executable:
|
||||
_PROJECT_BASE = os.path.dirname(_safe_realpath(sys.executable))
|
||||
else:
|
||||
# sys.executable can be empty if argv[0] has been changed and Python is
|
||||
# unable to retrieve the real program name
|
||||
_PROJECT_BASE = _safe_realpath(os.getcwd())
|
||||
|
||||
if os.name == "nt" and "pcbuild" in _PROJECT_BASE[-8:].lower():
|
||||
_PROJECT_BASE = _safe_realpath(os.path.join(_PROJECT_BASE, pardir))
|
||||
# PC/VS7.1
|
||||
if os.name == "nt" and "\\pc\\v" in _PROJECT_BASE[-10:].lower():
|
||||
_PROJECT_BASE = _safe_realpath(os.path.join(_PROJECT_BASE, pardir, pardir))
|
||||
# PC/AMD64
|
||||
if os.name == "nt" and "\\pcbuild\\amd64" in _PROJECT_BASE[-14:].lower():
|
||||
_PROJECT_BASE = _safe_realpath(os.path.join(_PROJECT_BASE, pardir, pardir))
|
||||
|
||||
|
||||
def is_python_build():
|
||||
for fn in ("Setup.dist", "Setup.local"):
|
||||
if os.path.isfile(os.path.join(_PROJECT_BASE, "Modules", fn)):
|
||||
return True
|
||||
return False
|
||||
|
||||
_PYTHON_BUILD = is_python_build()
|
||||
|
||||
_cfg_read = False
|
||||
|
||||
def _ensure_cfg_read():
|
||||
global _cfg_read
|
||||
if not _cfg_read:
|
||||
from distlib.resources import finder
|
||||
backport_package = __name__.rsplit('.', 1)[0]
|
||||
_finder = finder(backport_package)
|
||||
_cfgfile = _finder.find('sysconfig.cfg')
|
||||
assert _cfgfile, 'sysconfig.cfg exists'
|
||||
with _cfgfile.as_stream() as s:
|
||||
_SCHEMES.readfp(s)
|
||||
if _PYTHON_BUILD:
|
||||
for scheme in ('posix_prefix', 'posix_home'):
|
||||
_SCHEMES.set(scheme, 'include', '{srcdir}/Include')
|
||||
_SCHEMES.set(scheme, 'platinclude', '{projectbase}/.')
|
||||
|
||||
_cfg_read = True
|
||||
|
||||
|
||||
_SCHEMES = configparser.RawConfigParser()
|
||||
_VAR_REPL = re.compile(r'\{([^{]*?)\}')
|
||||
|
||||
def _expand_globals(config):
|
||||
_ensure_cfg_read()
|
||||
if config.has_section('globals'):
|
||||
globals = config.items('globals')
|
||||
else:
|
||||
globals = tuple()
|
||||
|
||||
sections = config.sections()
|
||||
for section in sections:
|
||||
if section == 'globals':
|
||||
continue
|
||||
for option, value in globals:
|
||||
if config.has_option(section, option):
|
||||
continue
|
||||
config.set(section, option, value)
|
||||
config.remove_section('globals')
|
||||
|
||||
# now expanding local variables defined in the cfg file
|
||||
#
|
||||
for section in config.sections():
|
||||
variables = dict(config.items(section))
|
||||
|
||||
def _replacer(matchobj):
|
||||
name = matchobj.group(1)
|
||||
if name in variables:
|
||||
return variables[name]
|
||||
return matchobj.group(0)
|
||||
|
||||
for option, value in config.items(section):
|
||||
config.set(section, option, _VAR_REPL.sub(_replacer, value))
|
||||
|
||||
#_expand_globals(_SCHEMES)
|
||||
|
||||
# FIXME don't rely on sys.version here, its format is an implementation detail
|
||||
# of CPython, use sys.version_info or sys.hexversion
|
||||
_PY_VERSION = sys.version.split()[0]
|
||||
_PY_VERSION_SHORT = sys.version[:3]
|
||||
_PY_VERSION_SHORT_NO_DOT = _PY_VERSION[0] + _PY_VERSION[2]
|
||||
_PREFIX = os.path.normpath(sys.prefix)
|
||||
_EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
|
||||
_CONFIG_VARS = None
|
||||
_USER_BASE = None
|
||||
|
||||
|
||||
def _subst_vars(path, local_vars):
|
||||
"""In the string `path`, replace tokens like {some.thing} with the
|
||||
corresponding value from the map `local_vars`.
|
||||
|
||||
If there is no corresponding value, leave the token unchanged.
|
||||
"""
|
||||
def _replacer(matchobj):
|
||||
name = matchobj.group(1)
|
||||
if name in local_vars:
|
||||
return local_vars[name]
|
||||
elif name in os.environ:
|
||||
return os.environ[name]
|
||||
return matchobj.group(0)
|
||||
return _VAR_REPL.sub(_replacer, path)
|
||||
|
||||
|
||||
def _extend_dict(target_dict, other_dict):
|
||||
target_keys = target_dict.keys()
|
||||
for key, value in other_dict.items():
|
||||
if key in target_keys:
|
||||
continue
|
||||
target_dict[key] = value
|
||||
|
||||
|
||||
def _expand_vars(scheme, vars):
|
||||
res = {}
|
||||
if vars is None:
|
||||
vars = {}
|
||||
_extend_dict(vars, get_config_vars())
|
||||
|
||||
for key, value in _SCHEMES.items(scheme):
|
||||
if os.name in ('posix', 'nt'):
|
||||
value = os.path.expanduser(value)
|
||||
res[key] = os.path.normpath(_subst_vars(value, vars))
|
||||
return res
|
||||
|
||||
|
||||
def format_value(value, vars):
|
||||
def _replacer(matchobj):
|
||||
name = matchobj.group(1)
|
||||
if name in vars:
|
||||
return vars[name]
|
||||
return matchobj.group(0)
|
||||
return _VAR_REPL.sub(_replacer, value)
|
||||
|
||||
|
||||
def _get_default_scheme():
|
||||
if os.name == 'posix':
|
||||
# the default scheme for posix is posix_prefix
|
||||
return 'posix_prefix'
|
||||
return os.name
|
||||
|
||||
|
||||
def _getuserbase():
|
||||
env_base = os.environ.get("PYTHONUSERBASE", None)
|
||||
|
||||
def joinuser(*args):
|
||||
return os.path.expanduser(os.path.join(*args))
|
||||
|
||||
# what about 'os2emx', 'riscos' ?
|
||||
if os.name == "nt":
|
||||
base = os.environ.get("APPDATA") or "~"
|
||||
if env_base:
|
||||
return env_base
|
||||
else:
|
||||
return joinuser(base, "Python")
|
||||
|
||||
if sys.platform == "darwin":
|
||||
framework = get_config_var("PYTHONFRAMEWORK")
|
||||
if framework:
|
||||
if env_base:
|
||||
return env_base
|
||||
else:
|
||||
return joinuser("~", "Library", framework, "%d.%d" %
|
||||
sys.version_info[:2])
|
||||
|
||||
if env_base:
|
||||
return env_base
|
||||
else:
|
||||
return joinuser("~", ".local")
|
||||
|
||||
|
||||
def _parse_makefile(filename, vars=None):
|
||||
"""Parse a Makefile-style file.
|
||||
|
||||
A dictionary containing name/value pairs is returned. If an
|
||||
optional dictionary is passed in as the second argument, it is
|
||||
used instead of a new dictionary.
|
||||
"""
|
||||
# Regexes needed for parsing Makefile (and similar syntaxes,
|
||||
# like old-style Setup files).
|
||||
_variable_rx = re.compile("([a-zA-Z][a-zA-Z0-9_]+)\s*=\s*(.*)")
|
||||
_findvar1_rx = re.compile(r"\$\(([A-Za-z][A-Za-z0-9_]*)\)")
|
||||
_findvar2_rx = re.compile(r"\${([A-Za-z][A-Za-z0-9_]*)}")
|
||||
|
||||
if vars is None:
|
||||
vars = {}
|
||||
done = {}
|
||||
notdone = {}
|
||||
|
||||
with codecs.open(filename, encoding='utf-8', errors="surrogateescape") as f:
|
||||
lines = f.readlines()
|
||||
|
||||
for line in lines:
|
||||
if line.startswith('#') or line.strip() == '':
|
||||
continue
|
||||
m = _variable_rx.match(line)
|
||||
if m:
|
||||
n, v = m.group(1, 2)
|
||||
v = v.strip()
|
||||
# `$$' is a literal `$' in make
|
||||
tmpv = v.replace('$$', '')
|
||||
|
||||
if "$" in tmpv:
|
||||
notdone[n] = v
|
||||
else:
|
||||
try:
|
||||
v = int(v)
|
||||
except ValueError:
|
||||
# insert literal `$'
|
||||
done[n] = v.replace('$$', '$')
|
||||
else:
|
||||
done[n] = v
|
||||
|
||||
# do variable interpolation here
|
||||
variables = list(notdone.keys())
|
||||
|
||||
# Variables with a 'PY_' prefix in the makefile. These need to
|
||||
# be made available without that prefix through sysconfig.
|
||||
# Special care is needed to ensure that variable expansion works, even
|
||||
# if the expansion uses the name without a prefix.
|
||||
renamed_variables = ('CFLAGS', 'LDFLAGS', 'CPPFLAGS')
|
||||
|
||||
while len(variables) > 0:
|
||||
for name in tuple(variables):
|
||||
value = notdone[name]
|
||||
m = _findvar1_rx.search(value) or _findvar2_rx.search(value)
|
||||
if m is not None:
|
||||
n = m.group(1)
|
||||
found = True
|
||||
if n in done:
|
||||
item = str(done[n])
|
||||
elif n in notdone:
|
||||
# get it on a subsequent round
|
||||
found = False
|
||||
elif n in os.environ:
|
||||
# do it like make: fall back to environment
|
||||
item = os.environ[n]
|
||||
|
||||
elif n in renamed_variables:
|
||||
if (name.startswith('PY_') and
|
||||
name[3:] in renamed_variables):
|
||||
item = ""
|
||||
|
||||
elif 'PY_' + n in notdone:
|
||||
found = False
|
||||
|
||||
else:
|
||||
item = str(done['PY_' + n])
|
||||
|
||||
else:
|
||||
done[n] = item = ""
|
||||
|
||||
if found:
|
||||
after = value[m.end():]
|
||||
value = value[:m.start()] + item + after
|
||||
if "$" in after:
|
||||
notdone[name] = value
|
||||
else:
|
||||
try:
|
||||
value = int(value)
|
||||
except ValueError:
|
||||
done[name] = value.strip()
|
||||
else:
|
||||
done[name] = value
|
||||
variables.remove(name)
|
||||
|
||||
if (name.startswith('PY_') and
|
||||
name[3:] in renamed_variables):
|
||||
|
||||
name = name[3:]
|
||||
if name not in done:
|
||||
done[name] = value
|
||||
|
||||
else:
|
||||
# bogus variable reference (e.g. "prefix=$/opt/python");
|
||||
# just drop it since we can't deal
|
||||
done[name] = value
|
||||
variables.remove(name)
|
||||
|
||||
# strip spurious spaces
|
||||
for k, v in done.items():
|
||||
if isinstance(v, str):
|
||||
done[k] = v.strip()
|
||||
|
||||
# save the results in the global dictionary
|
||||
vars.update(done)
|
||||
return vars
|
||||
|
||||
|
||||
def get_makefile_filename():
|
||||
"""Return the path of the Makefile."""
|
||||
if _PYTHON_BUILD:
|
||||
return os.path.join(_PROJECT_BASE, "Makefile")
|
||||
if hasattr(sys, 'abiflags'):
|
||||
config_dir_name = 'config-%s%s' % (_PY_VERSION_SHORT, sys.abiflags)
|
||||
else:
|
||||
config_dir_name = 'config'
|
||||
return os.path.join(get_path('stdlib'), config_dir_name, 'Makefile')
|
||||
|
||||
|
||||
def _init_posix(vars):
|
||||
"""Initialize the module as appropriate for POSIX systems."""
|
||||
# load the installed Makefile:
|
||||
makefile = get_makefile_filename()
|
||||
try:
|
||||
_parse_makefile(makefile, vars)
|
||||
except IOError as e:
|
||||
msg = "invalid Python installation: unable to open %s" % makefile
|
||||
if hasattr(e, "strerror"):
|
||||
msg = msg + " (%s)" % e.strerror
|
||||
raise IOError(msg)
|
||||
# load the installed pyconfig.h:
|
||||
config_h = get_config_h_filename()
|
||||
try:
|
||||
with open(config_h) as f:
|
||||
parse_config_h(f, vars)
|
||||
except IOError as e:
|
||||
msg = "invalid Python installation: unable to open %s" % config_h
|
||||
if hasattr(e, "strerror"):
|
||||
msg = msg + " (%s)" % e.strerror
|
||||
raise IOError(msg)
|
||||
# On AIX, there are wrong paths to the linker scripts in the Makefile
|
||||
# -- these paths are relative to the Python source, but when installed
|
||||
# the scripts are in another directory.
|
||||
if _PYTHON_BUILD:
|
||||
vars['LDSHARED'] = vars['BLDSHARED']
|
||||
|
||||
|
||||
def _init_non_posix(vars):
|
||||
"""Initialize the module as appropriate for NT"""
|
||||
# set basic install directories
|
||||
vars['LIBDEST'] = get_path('stdlib')
|
||||
vars['BINLIBDEST'] = get_path('platstdlib')
|
||||
vars['INCLUDEPY'] = get_path('include')
|
||||
vars['SO'] = '.pyd'
|
||||
vars['EXE'] = '.exe'
|
||||
vars['VERSION'] = _PY_VERSION_SHORT_NO_DOT
|
||||
vars['BINDIR'] = os.path.dirname(_safe_realpath(sys.executable))
|
||||
|
||||
#
|
||||
# public APIs
|
||||
#
|
||||
|
||||
|
||||
def parse_config_h(fp, vars=None):
|
||||
"""Parse a config.h-style file.
|
||||
|
||||
A dictionary containing name/value pairs is returned. If an
|
||||
optional dictionary is passed in as the second argument, it is
|
||||
used instead of a new dictionary.
|
||||
"""
|
||||
if vars is None:
|
||||
vars = {}
|
||||
define_rx = re.compile("#define ([A-Z][A-Za-z0-9_]+) (.*)\n")
|
||||
undef_rx = re.compile("/[*] #undef ([A-Z][A-Za-z0-9_]+) [*]/\n")
|
||||
|
||||
while True:
|
||||
line = fp.readline()
|
||||
if not line:
|
||||
break
|
||||
m = define_rx.match(line)
|
||||
if m:
|
||||
n, v = m.group(1, 2)
|
||||
try:
|
||||
v = int(v)
|
||||
except ValueError:
|
||||
pass
|
||||
vars[n] = v
|
||||
else:
|
||||
m = undef_rx.match(line)
|
||||
if m:
|
||||
vars[m.group(1)] = 0
|
||||
return vars
|
||||
|
||||
|
||||
def get_config_h_filename():
|
||||
"""Return the path of pyconfig.h."""
|
||||
if _PYTHON_BUILD:
|
||||
if os.name == "nt":
|
||||
inc_dir = os.path.join(_PROJECT_BASE, "PC")
|
||||
else:
|
||||
inc_dir = _PROJECT_BASE
|
||||
else:
|
||||
inc_dir = get_path('platinclude')
|
||||
return os.path.join(inc_dir, 'pyconfig.h')
|
||||
|
||||
|
||||
def get_scheme_names():
|
||||
"""Return a tuple containing the schemes names."""
|
||||
return tuple(sorted(_SCHEMES.sections()))
|
||||
|
||||
|
||||
def get_path_names():
|
||||
"""Return a tuple containing the paths names."""
|
||||
# xxx see if we want a static list
|
||||
return _SCHEMES.options('posix_prefix')
|
||||
|
||||
|
||||
def get_paths(scheme=_get_default_scheme(), vars=None, expand=True):
|
||||
"""Return a mapping containing an install scheme.
|
||||
|
||||
``scheme`` is the install scheme name. If not provided, it will
|
||||
return the default scheme for the current platform.
|
||||
"""
|
||||
_ensure_cfg_read()
|
||||
if expand:
|
||||
return _expand_vars(scheme, vars)
|
||||
else:
|
||||
return dict(_SCHEMES.items(scheme))
|
||||
|
||||
|
||||
def get_path(name, scheme=_get_default_scheme(), vars=None, expand=True):
|
||||
"""Return a path corresponding to the scheme.
|
||||
|
||||
``scheme`` is the install scheme name.
|
||||
"""
|
||||
return get_paths(scheme, vars, expand)[name]
|
||||
|
||||
|
||||
def get_config_vars(*args):
|
||||
"""With no arguments, return a dictionary of all configuration
|
||||
variables relevant for the current platform.
|
||||
|
||||
On Unix, this means every variable defined in Python's installed Makefile;
|
||||
On Windows and Mac OS it's a much smaller set.
|
||||
|
||||
With arguments, return a list of values that result from looking up
|
||||
each argument in the configuration variable dictionary.
|
||||
"""
|
||||
global _CONFIG_VARS
|
||||
if _CONFIG_VARS is None:
|
||||
_CONFIG_VARS = {}
|
||||
# Normalized versions of prefix and exec_prefix are handy to have;
|
||||
# in fact, these are the standard versions used most places in the
|
||||
# distutils2 module.
|
||||
_CONFIG_VARS['prefix'] = _PREFIX
|
||||
_CONFIG_VARS['exec_prefix'] = _EXEC_PREFIX
|
||||
_CONFIG_VARS['py_version'] = _PY_VERSION
|
||||
_CONFIG_VARS['py_version_short'] = _PY_VERSION_SHORT
|
||||
_CONFIG_VARS['py_version_nodot'] = _PY_VERSION[0] + _PY_VERSION[2]
|
||||
_CONFIG_VARS['base'] = _PREFIX
|
||||
_CONFIG_VARS['platbase'] = _EXEC_PREFIX
|
||||
_CONFIG_VARS['projectbase'] = _PROJECT_BASE
|
||||
try:
|
||||
_CONFIG_VARS['abiflags'] = sys.abiflags
|
||||
except AttributeError:
|
||||
# sys.abiflags may not be defined on all platforms.
|
||||
_CONFIG_VARS['abiflags'] = ''
|
||||
|
||||
if os.name in ('nt', 'os2'):
|
||||
_init_non_posix(_CONFIG_VARS)
|
||||
if os.name == 'posix':
|
||||
_init_posix(_CONFIG_VARS)
|
||||
# Setting 'userbase' is done below the call to the
|
||||
# init function to enable using 'get_config_var' in
|
||||
# the init-function.
|
||||
if sys.version >= '2.6':
|
||||
_CONFIG_VARS['userbase'] = _getuserbase()
|
||||
|
||||
if 'srcdir' not in _CONFIG_VARS:
|
||||
_CONFIG_VARS['srcdir'] = _PROJECT_BASE
|
||||
else:
|
||||
_CONFIG_VARS['srcdir'] = _safe_realpath(_CONFIG_VARS['srcdir'])
|
||||
|
||||
# Convert srcdir into an absolute path if it appears necessary.
|
||||
# Normally it is relative to the build directory. However, during
|
||||
# testing, for example, we might be running a non-installed python
|
||||
# from a different directory.
|
||||
if _PYTHON_BUILD and os.name == "posix":
|
||||
base = _PROJECT_BASE
|
||||
try:
|
||||
cwd = os.getcwd()
|
||||
except OSError:
|
||||
cwd = None
|
||||
if (not os.path.isabs(_CONFIG_VARS['srcdir']) and
|
||||
base != cwd):
|
||||
# srcdir is relative and we are not in the same directory
|
||||
# as the executable. Assume executable is in the build
|
||||
# directory and make srcdir absolute.
|
||||
srcdir = os.path.join(base, _CONFIG_VARS['srcdir'])
|
||||
_CONFIG_VARS['srcdir'] = os.path.normpath(srcdir)
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
kernel_version = os.uname()[2] # Kernel version (8.4.3)
|
||||
major_version = int(kernel_version.split('.')[0])
|
||||
|
||||
if major_version < 8:
|
||||
# On Mac OS X before 10.4, check if -arch and -isysroot
|
||||
# are in CFLAGS or LDFLAGS and remove them if they are.
|
||||
# This is needed when building extensions on a 10.3 system
|
||||
# using a universal build of python.
|
||||
for key in ('LDFLAGS', 'BASECFLAGS',
|
||||
# a number of derived variables. These need to be
|
||||
# patched up as well.
|
||||
'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'):
|
||||
flags = _CONFIG_VARS[key]
|
||||
flags = re.sub('-arch\s+\w+\s', ' ', flags)
|
||||
flags = re.sub('-isysroot [^ \t]*', ' ', flags)
|
||||
_CONFIG_VARS[key] = flags
|
||||
else:
|
||||
# Allow the user to override the architecture flags using
|
||||
# an environment variable.
|
||||
# NOTE: This name was introduced by Apple in OSX 10.5 and
|
||||
# is used by several scripting languages distributed with
|
||||
# that OS release.
|
||||
if 'ARCHFLAGS' in os.environ:
|
||||
arch = os.environ['ARCHFLAGS']
|
||||
for key in ('LDFLAGS', 'BASECFLAGS',
|
||||
# a number of derived variables. These need to be
|
||||
# patched up as well.
|
||||
'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'):
|
||||
|
||||
flags = _CONFIG_VARS[key]
|
||||
flags = re.sub('-arch\s+\w+\s', ' ', flags)
|
||||
flags = flags + ' ' + arch
|
||||
_CONFIG_VARS[key] = flags
|
||||
|
||||
# If we're on OSX 10.5 or later and the user tries to
|
||||
# compiles an extension using an SDK that is not present
|
||||
# on the current machine it is better to not use an SDK
|
||||
# than to fail.
|
||||
#
|
||||
# The major usecase for this is users using a Python.org
|
||||
# binary installer on OSX 10.6: that installer uses
|
||||
# the 10.4u SDK, but that SDK is not installed by default
|
||||
# when you install Xcode.
|
||||
#
|
||||
CFLAGS = _CONFIG_VARS.get('CFLAGS', '')
|
||||
m = re.search('-isysroot\s+(\S+)', CFLAGS)
|
||||
if m is not None:
|
||||
sdk = m.group(1)
|
||||
if not os.path.exists(sdk):
|
||||
for key in ('LDFLAGS', 'BASECFLAGS',
|
||||
# a number of derived variables. These need to be
|
||||
# patched up as well.
|
||||
'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'):
|
||||
|
||||
flags = _CONFIG_VARS[key]
|
||||
flags = re.sub('-isysroot\s+\S+(\s|$)', ' ', flags)
|
||||
_CONFIG_VARS[key] = flags
|
||||
|
||||
if args:
|
||||
vals = []
|
||||
for name in args:
|
||||
vals.append(_CONFIG_VARS.get(name))
|
||||
return vals
|
||||
else:
|
||||
return _CONFIG_VARS
|
||||
|
||||
|
||||
def get_config_var(name):
|
||||
"""Return the value of a single variable using the dictionary returned by
|
||||
'get_config_vars()'.
|
||||
|
||||
Equivalent to get_config_vars().get(name)
|
||||
"""
|
||||
return get_config_vars().get(name)
|
||||
|
||||
|
||||
def get_platform():
|
||||
"""Return a string that identifies the current platform.
|
||||
|
||||
This is used mainly to distinguish platform-specific build directories and
|
||||
platform-specific built distributions. Typically includes the OS name
|
||||
and version and the architecture (as supplied by 'os.uname()'),
|
||||
although the exact information included depends on the OS; eg. for IRIX
|
||||
the architecture isn't particularly important (IRIX only runs on SGI
|
||||
hardware), but for Linux the kernel version isn't particularly
|
||||
important.
|
||||
|
||||
Examples of returned values:
|
||||
linux-i586
|
||||
linux-alpha (?)
|
||||
solaris-2.6-sun4u
|
||||
irix-5.3
|
||||
irix64-6.2
|
||||
|
||||
Windows will return one of:
|
||||
win-amd64 (64bit Windows on AMD64 (aka x86_64, Intel64, EM64T, etc)
|
||||
win-ia64 (64bit Windows on Itanium)
|
||||
win32 (all others - specifically, sys.platform is returned)
|
||||
|
||||
For other non-POSIX platforms, currently just returns 'sys.platform'.
|
||||
"""
|
||||
if os.name == 'nt':
|
||||
# sniff sys.version for architecture.
|
||||
prefix = " bit ("
|
||||
i = sys.version.find(prefix)
|
||||
if i == -1:
|
||||
return sys.platform
|
||||
j = sys.version.find(")", i)
|
||||
look = sys.version[i+len(prefix):j].lower()
|
||||
if look == 'amd64':
|
||||
return 'win-amd64'
|
||||
if look == 'itanium':
|
||||
return 'win-ia64'
|
||||
return sys.platform
|
||||
|
||||
if os.name != "posix" or not hasattr(os, 'uname'):
|
||||
# XXX what about the architecture? NT is Intel or Alpha,
|
||||
# Mac OS is M68k or PPC, etc.
|
||||
return sys.platform
|
||||
|
||||
# Try to distinguish various flavours of Unix
|
||||
osname, host, release, version, machine = os.uname()
|
||||
|
||||
# Convert the OS name to lowercase, remove '/' characters
|
||||
# (to accommodate BSD/OS), and translate spaces (for "Power Macintosh")
|
||||
osname = osname.lower().replace('/', '')
|
||||
machine = machine.replace(' ', '_')
|
||||
machine = machine.replace('/', '-')
|
||||
|
||||
if osname[:5] == "linux":
|
||||
# At least on Linux/Intel, 'machine' is the processor --
|
||||
# i386, etc.
|
||||
# XXX what about Alpha, SPARC, etc?
|
||||
return "%s-%s" % (osname, machine)
|
||||
elif osname[:5] == "sunos":
|
||||
if release[0] >= "5": # SunOS 5 == Solaris 2
|
||||
osname = "solaris"
|
||||
release = "%d.%s" % (int(release[0]) - 3, release[2:])
|
||||
# fall through to standard osname-release-machine representation
|
||||
elif osname[:4] == "irix": # could be "irix64"!
|
||||
return "%s-%s" % (osname, release)
|
||||
elif osname[:3] == "aix":
|
||||
return "%s-%s.%s" % (osname, version, release)
|
||||
elif osname[:6] == "cygwin":
|
||||
osname = "cygwin"
|
||||
rel_re = re.compile(r'[\d.]+')
|
||||
m = rel_re.match(release)
|
||||
if m:
|
||||
release = m.group()
|
||||
elif osname[:6] == "darwin":
|
||||
#
|
||||
# For our purposes, we'll assume that the system version from
|
||||
# distutils' perspective is what MACOSX_DEPLOYMENT_TARGET is set
|
||||
# to. This makes the compatibility story a bit more sane because the
|
||||
# machine is going to compile and link as if it were
|
||||
# MACOSX_DEPLOYMENT_TARGET.
|
||||
cfgvars = get_config_vars()
|
||||
macver = cfgvars.get('MACOSX_DEPLOYMENT_TARGET')
|
||||
|
||||
if True:
|
||||
# Always calculate the release of the running machine,
|
||||
# needed to determine if we can build fat binaries or not.
|
||||
|
||||
macrelease = macver
|
||||
# Get the system version. Reading this plist is a documented
|
||||
# way to get the system version (see the documentation for
|
||||
# the Gestalt Manager)
|
||||
try:
|
||||
f = open('/System/Library/CoreServices/SystemVersion.plist')
|
||||
except IOError:
|
||||
# We're on a plain darwin box, fall back to the default
|
||||
# behaviour.
|
||||
pass
|
||||
else:
|
||||
try:
|
||||
m = re.search(r'<key>ProductUserVisibleVersion</key>\s*'
|
||||
r'<string>(.*?)</string>', f.read())
|
||||
finally:
|
||||
f.close()
|
||||
if m is not None:
|
||||
macrelease = '.'.join(m.group(1).split('.')[:2])
|
||||
# else: fall back to the default behaviour
|
||||
|
||||
if not macver:
|
||||
macver = macrelease
|
||||
|
||||
if macver:
|
||||
release = macver
|
||||
osname = "macosx"
|
||||
|
||||
if ((macrelease + '.') >= '10.4.' and
|
||||
'-arch' in get_config_vars().get('CFLAGS', '').strip()):
|
||||
# The universal build will build fat binaries, but not on
|
||||
# systems before 10.4
|
||||
#
|
||||
# Try to detect 4-way universal builds, those have machine-type
|
||||
# 'universal' instead of 'fat'.
|
||||
|
||||
machine = 'fat'
|
||||
cflags = get_config_vars().get('CFLAGS')
|
||||
|
||||
archs = re.findall('-arch\s+(\S+)', cflags)
|
||||
archs = tuple(sorted(set(archs)))
|
||||
|
||||
if len(archs) == 1:
|
||||
machine = archs[0]
|
||||
elif archs == ('i386', 'ppc'):
|
||||
machine = 'fat'
|
||||
elif archs == ('i386', 'x86_64'):
|
||||
machine = 'intel'
|
||||
elif archs == ('i386', 'ppc', 'x86_64'):
|
||||
machine = 'fat3'
|
||||
elif archs == ('ppc64', 'x86_64'):
|
||||
machine = 'fat64'
|
||||
elif archs == ('i386', 'ppc', 'ppc64', 'x86_64'):
|
||||
machine = 'universal'
|
||||
else:
|
||||
raise ValueError(
|
||||
"Don't know machine value for archs=%r" % (archs,))
|
||||
|
||||
elif machine == 'i386':
|
||||
# On OSX the machine type returned by uname is always the
|
||||
# 32-bit variant, even if the executable architecture is
|
||||
# the 64-bit variant
|
||||
if sys.maxsize >= 2**32:
|
||||
machine = 'x86_64'
|
||||
|
||||
elif machine in ('PowerPC', 'Power_Macintosh'):
|
||||
# Pick a sane name for the PPC architecture.
|
||||
# See 'i386' case
|
||||
if sys.maxsize >= 2**32:
|
||||
machine = 'ppc64'
|
||||
else:
|
||||
machine = 'ppc'
|
||||
|
||||
return "%s-%s-%s" % (osname, release, machine)
|
||||
|
||||
|
||||
def get_python_version():
|
||||
return _PY_VERSION_SHORT
|
||||
|
||||
|
||||
def _print_dict(title, data):
|
||||
for index, (key, value) in enumerate(sorted(data.items())):
|
||||
if index == 0:
|
||||
print('%s: ' % (title))
|
||||
print('\t%s = "%s"' % (key, value))
|
||||
|
||||
|
||||
def _main():
|
||||
"""Display all information sysconfig detains."""
|
||||
print('Platform: "%s"' % get_platform())
|
||||
print('Python version: "%s"' % get_python_version())
|
||||
print('Current installation scheme: "%s"' % _get_default_scheme())
|
||||
print()
|
||||
_print_dict('Paths', get_paths())
|
||||
print()
|
||||
_print_dict('Variables', get_config_vars())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
_main()
|
||||
File diff suppressed because it is too large
Load Diff
+1064
File diff suppressed because it is too large
Load Diff
+1301
File diff suppressed because it is too large
Load Diff
+480
@@ -0,0 +1,480 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2013 Vinay Sajip.
|
||||
# Licensed to the Python Software Foundation under a contributor agreement.
|
||||
# See LICENSE.txt and CONTRIBUTORS.txt.
|
||||
#
|
||||
import hashlib
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
try:
|
||||
from threading import Thread
|
||||
except ImportError:
|
||||
from dummy_threading import Thread
|
||||
|
||||
from distlib import DistlibException
|
||||
from distlib.compat import (HTTPBasicAuthHandler, Request, HTTPPasswordMgr,
|
||||
urlparse, build_opener)
|
||||
from distlib.util import cached_property, zip_dir
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
DEFAULT_INDEX = 'https://pypi.python.org/pypi'
|
||||
DEFAULT_REALM = 'pypi'
|
||||
|
||||
class PackageIndex(object):
|
||||
"""
|
||||
This class represents a package index compatible with PyPI, the Python
|
||||
Package Index.
|
||||
"""
|
||||
|
||||
boundary = b'----------ThIs_Is_tHe_distlib_index_bouNdaRY_$'
|
||||
|
||||
def __init__(self, url=None):
|
||||
"""
|
||||
Initialise an instance.
|
||||
|
||||
:param url: The URL of the index. If not specified, the URL for PyPI is
|
||||
used.
|
||||
"""
|
||||
self.url = url or DEFAULT_INDEX
|
||||
self.read_configuration()
|
||||
scheme, netloc, path, params, query, frag = urlparse(self.url)
|
||||
if params or query or frag or scheme not in ('http', 'https'):
|
||||
raise DistlibException('invalid repository: %s' % self.url)
|
||||
self.password_handler = None
|
||||
self.ssl_verifier = None
|
||||
self.gpg = None
|
||||
self.gpg_home = None
|
||||
with open(os.devnull, 'w') as sink:
|
||||
for s in ('gpg2', 'gpg'):
|
||||
try:
|
||||
rc = subprocess.check_call([s, '--version'], stdout=sink,
|
||||
stderr=sink)
|
||||
if rc == 0:
|
||||
self.gpg = s
|
||||
break
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
def _get_pypirc_command(self):
|
||||
"""
|
||||
Get the distutils command for interacting with PyPI configurations.
|
||||
:return: the command.
|
||||
"""
|
||||
from distutils.core import Distribution
|
||||
from distutils.config import PyPIRCCommand
|
||||
d = Distribution()
|
||||
return PyPIRCCommand(d)
|
||||
|
||||
def read_configuration(self):
|
||||
"""
|
||||
Read the PyPI access configuration as supported by distutils, getting
|
||||
PyPI to do the acutal work. This populates ``username``, ``password``,
|
||||
``realm`` and ``url`` attributes from the configuration.
|
||||
"""
|
||||
# get distutils to do the work
|
||||
c = self._get_pypirc_command()
|
||||
c.repository = self.url
|
||||
cfg = c._read_pypirc()
|
||||
self.username = cfg.get('username')
|
||||
self.password = cfg.get('password')
|
||||
self.realm = cfg.get('realm', 'pypi')
|
||||
self.url = cfg.get('repository', self.url)
|
||||
|
||||
def save_configuration(self):
|
||||
"""
|
||||
Save the PyPI access configuration. You must have set ``username`` and
|
||||
``password`` attributes before calling this method.
|
||||
|
||||
Again, distutils is used to do the actual work.
|
||||
"""
|
||||
self.check_credentials()
|
||||
# get distutils to do the work
|
||||
c = self._get_pypirc_command()
|
||||
c._store_pypirc(self.username, self.password)
|
||||
|
||||
def check_credentials(self):
|
||||
"""
|
||||
Check that ``username`` and ``password`` have been set, and raise an
|
||||
exception if not.
|
||||
"""
|
||||
if self.username is None or self.password is None:
|
||||
raise DistlibException('username and password must be set')
|
||||
pm = HTTPPasswordMgr()
|
||||
_, netloc, _, _, _, _ = urlparse(self.url)
|
||||
pm.add_password(self.realm, netloc, self.username, self.password)
|
||||
self.password_handler = HTTPBasicAuthHandler(pm)
|
||||
|
||||
def register(self, metadata):
|
||||
"""
|
||||
Register a distribution on PyPI, using the provided metadata.
|
||||
|
||||
:param metadata: A :class:`Metadata` instance defining at least a name
|
||||
and version number for the distribution to be
|
||||
registered.
|
||||
:return: The HTTP response received from PyPI upon submission of the
|
||||
request.
|
||||
"""
|
||||
self.check_credentials()
|
||||
metadata.validate()
|
||||
d = metadata.todict()
|
||||
d[':action'] = 'verify'
|
||||
request = self.encode_request(d.items(), [])
|
||||
response = self.send_request(request)
|
||||
d[':action'] = 'submit'
|
||||
request = self.encode_request(d.items(), [])
|
||||
return self.send_request(request)
|
||||
|
||||
def _reader(self, name, stream, outbuf):
|
||||
"""
|
||||
Thread runner for reading lines of from a subprocess into a buffer.
|
||||
|
||||
:param name: The logical name of the stream (used for logging only).
|
||||
:param stream: The stream to read from. This will typically a pipe
|
||||
connected to the output stream of a subprocess.
|
||||
:param outbuf: The list to append the read lines to.
|
||||
"""
|
||||
while True:
|
||||
s = stream.readline()
|
||||
if not s:
|
||||
break
|
||||
s = s.decode('utf-8').rstrip()
|
||||
outbuf.append(s)
|
||||
logger.debug('%s: %s' % (name, s))
|
||||
stream.close()
|
||||
|
||||
def get_sign_command(self, filename, signer, sign_password):
|
||||
"""
|
||||
Return a suitable command for signing a file.
|
||||
|
||||
:param filename: The pathname to the file to be signed.
|
||||
:param signer: The identifier of the signer of the file.
|
||||
:param sign_password: The passphrase for the signer's
|
||||
private key used for signing.
|
||||
:return: The signing command as a list suitable to be
|
||||
passed to :class:`subprocess.Popen`.
|
||||
"""
|
||||
cmd = [self.gpg, '--status-fd', '2', '--no-tty']
|
||||
if self.gpg_home:
|
||||
cmd.extend(['--homedir', self.gpg_home])
|
||||
if sign_password is not None:
|
||||
cmd.extend(['--batch', '--passphrase-fd', '0'])
|
||||
td = tempfile.mkdtemp()
|
||||
sf = os.path.join(td, os.path.basename(filename) + '.asc')
|
||||
cmd.extend(['--detach-sign', '--armor', '--local-user',
|
||||
signer, '--output', sf, filename])
|
||||
logger.debug('invoking: %s', ' '.join(cmd))
|
||||
return cmd, sf
|
||||
|
||||
def run_command(self, cmd, input_data=None):
|
||||
"""
|
||||
Run a command in a child process , passing it any input data specified.
|
||||
|
||||
:param cmd: The command to run.
|
||||
:param input_data: If specified, this must be a byte string containing
|
||||
data to be sent to the child process.
|
||||
:return: A tuple consisting of the subprocess' exit code, a list of
|
||||
lines read from the subprocess' ``stdout``, and a list of
|
||||
lines read from the subprocess' ``stderr``.
|
||||
"""
|
||||
kwargs = {
|
||||
'stdout': subprocess.PIPE,
|
||||
'stderr': subprocess.PIPE,
|
||||
}
|
||||
if input_data is not None:
|
||||
kwargs['stdin'] = subprocess.PIPE
|
||||
stdout = []
|
||||
stderr = []
|
||||
p = subprocess.Popen(cmd, **kwargs)
|
||||
# We don't use communicate() here because we may need to
|
||||
# get clever with interacting with the command
|
||||
t1 = Thread(target=self._reader, args=('stdout', p.stdout, stdout))
|
||||
t1.start()
|
||||
t2 = Thread(target=self._reader, args=('stderr', p.stderr, stderr))
|
||||
t2.start()
|
||||
if input_data is not None:
|
||||
p.stdin.write(input_data)
|
||||
p.stdin.close()
|
||||
|
||||
p.wait()
|
||||
t1.join()
|
||||
t2.join()
|
||||
return p.returncode, stdout, stderr
|
||||
|
||||
def sign_file(self, filename, signer, sign_password):
|
||||
"""
|
||||
Sign a file.
|
||||
|
||||
:param filename: The pathname to the file to be signed.
|
||||
:param signer: The identifier of the signer of the file.
|
||||
:param sign_password: The passphrase for the signer's
|
||||
private key used for signing.
|
||||
:return: The absolute pathname of the file where the signature is
|
||||
stored.
|
||||
"""
|
||||
cmd, sig_file = self.get_sign_command(filename, signer, sign_password)
|
||||
rc, stdout, stderr = self.run_command(cmd,
|
||||
sign_password.encode('utf-8'))
|
||||
if rc != 0:
|
||||
raise DistlibException('sign command failed with error '
|
||||
'code %s' % rc)
|
||||
return sig_file
|
||||
|
||||
def upload_file(self, metadata, filename, signer=None, sign_password=None,
|
||||
filetype='sdist', pyversion='source'):
|
||||
"""
|
||||
Upload a release file to the index.
|
||||
|
||||
:param metadata: A :class:`Metadata` instance defining at least a name
|
||||
and version number for the file to be uploaded.
|
||||
:param filename: The pathname of the file to be uploaded.
|
||||
:param signer: The identifier of the signer of the file.
|
||||
:param sign_password: The passphrase for the signer's
|
||||
private key used for signing.
|
||||
:param filetype: The type of the file being uploaded. This is the
|
||||
distutils command which produced that file, e.g.
|
||||
``sdist`` or ``bdist_wheel``.
|
||||
:param pyversion: The version of Python which the release relates
|
||||
to. For code compatible with any Python, this would
|
||||
be ``source``, otherwise it would be e.g. ``3.2``.
|
||||
:return: The HTTP response received from PyPI upon submission of the
|
||||
request.
|
||||
"""
|
||||
self.check_credentials()
|
||||
if not os.path.exists(filename):
|
||||
raise DistlibException('not found: %s' % filename)
|
||||
metadata.validate()
|
||||
d = metadata.todict()
|
||||
sig_file = None
|
||||
if signer:
|
||||
if not self.gpg:
|
||||
logger.warning('no signing program available - not signed')
|
||||
else:
|
||||
sig_file = self.sign_file(filename, signer, sign_password)
|
||||
with open(filename, 'rb') as f:
|
||||
file_data = f.read()
|
||||
md5_digest = hashlib.md5(file_data).hexdigest()
|
||||
sha256_digest = hashlib.sha256(file_data).hexdigest()
|
||||
d.update({
|
||||
':action': 'file_upload',
|
||||
'protcol_version': '1',
|
||||
'filetype': filetype,
|
||||
'pyversion': pyversion,
|
||||
'md5_digest': md5_digest,
|
||||
'sha256_digest': sha256_digest,
|
||||
})
|
||||
files = [('content', os.path.basename(filename), file_data)]
|
||||
if sig_file:
|
||||
with open(sig_file, 'rb') as f:
|
||||
sig_data = f.read()
|
||||
files.append(('gpg_signature', os.path.basename(sig_file),
|
||||
sig_data))
|
||||
shutil.rmtree(os.path.dirname(sig_file))
|
||||
request = self.encode_request(d.items(), files)
|
||||
return self.send_request(request)
|
||||
|
||||
def upload_documentation(self, metadata, doc_dir):
|
||||
"""
|
||||
Upload documentation to the index.
|
||||
|
||||
:param metadata: A :class:`Metadata` instance defining at least a name
|
||||
and version number for the documentation to be
|
||||
uploaded.
|
||||
:param doc_dir: The pathname of the directory which contains the
|
||||
documentation. This should be the directory that
|
||||
contains the ``index.html`` for the documentation.
|
||||
:return: The HTTP response received from PyPI upon submission of the
|
||||
request.
|
||||
"""
|
||||
self.check_credentials()
|
||||
if not os.path.isdir(doc_dir):
|
||||
raise DistlibException('not a directory: %r' % doc_dir)
|
||||
fn = os.path.join(doc_dir, 'index.html')
|
||||
if not os.path.exists(fn):
|
||||
raise DistlibException('not found: %r' % fn)
|
||||
metadata.validate()
|
||||
name, version = metadata.name, metadata.version
|
||||
zip_data = zip_dir(doc_dir).getvalue()
|
||||
fields = [(':action', 'doc_upload'),
|
||||
('name', name), ('version', version)]
|
||||
files = [('content', name, zip_data)]
|
||||
request = self.encode_request(fields, files)
|
||||
return self.send_request(request)
|
||||
|
||||
def get_verify_command(self, signature_filename, data_filename):
|
||||
"""
|
||||
Return a suitable command for verifying a file.
|
||||
|
||||
:param signature_filename: The pathname to the file containing the
|
||||
signature.
|
||||
:param data_filename: The pathname to the file containing the
|
||||
signed data.
|
||||
:return: The verifying command as a list suitable to be
|
||||
passed to :class:`subprocess.Popen`.
|
||||
"""
|
||||
cmd = [self.gpg, '--status-fd', '2', '--no-tty']
|
||||
if self.gpg_home:
|
||||
cmd.extend(['--homedir', self.gpg_home])
|
||||
cmd.extend(['--verify', signature_filename, data_filename])
|
||||
logger.debug('invoking: %s', ' '.join(cmd))
|
||||
return cmd
|
||||
|
||||
def verify_signature(self, signature_filename, data_filename):
|
||||
"""
|
||||
Verify a signature for a file.
|
||||
|
||||
:param signature_filename: The pathname to the file containing the
|
||||
signature.
|
||||
:param data_filename: The pathname to the file containing the
|
||||
signed data.
|
||||
:return: True if the signature was verified, else False.
|
||||
"""
|
||||
if not self.gpg:
|
||||
raise DistlibException('verification unavailable because gpg '
|
||||
'unavailable')
|
||||
cmd = self.get_verify_command(signature_filename, data_filename)
|
||||
rc, stdout, stderr = self.run_command(cmd)
|
||||
if rc not in (0, 1):
|
||||
raise DistlibException('verify command failed with error '
|
||||
'code %s' % rc)
|
||||
return rc == 0
|
||||
|
||||
def download_file(self, url, destfile, digest=None, reporthook=None):
|
||||
"""
|
||||
This is a convenience method for downloading a file from an URL.
|
||||
Normally, this will be a file from the index, though currently
|
||||
no check is made for this (i.e. a file can be downloaded from
|
||||
anywhere).
|
||||
|
||||
The method is just like the :func:`urlretrieve` function in the
|
||||
standard library, except that it allows digest computation to be
|
||||
done during download and checking that the downloaded data
|
||||
matched any expected value.
|
||||
|
||||
:param url: The URL of the file to be downloaded (assumed to be
|
||||
available via an HTTP GET request).
|
||||
:param destfile: The pathname where the downloaded file is to be
|
||||
saved.
|
||||
:param digest: If specified, this must be a (hasher, value)
|
||||
tuple, where hasher is the algorithm used (e.g.
|
||||
``'md5'``) and ``value`` is the expected value.
|
||||
:param reporthook: The same as for :func:`urlretrieve` in the
|
||||
standard library.
|
||||
"""
|
||||
if digest is None:
|
||||
digester = None
|
||||
logger.debug('No digest specified')
|
||||
else:
|
||||
if isinstance(digest, (list, tuple)):
|
||||
hasher, digest = digest
|
||||
else:
|
||||
hasher = 'md5'
|
||||
digester = getattr(hashlib, hasher)()
|
||||
logger.debug('Digest specified: %s' % digest)
|
||||
# The following code is equivalent to urlretrieve.
|
||||
# We need to do it this way so that we can compute the
|
||||
# digest of the file as we go.
|
||||
with open(destfile, 'wb') as dfp:
|
||||
# addinfourl is not a context manager on 2.x
|
||||
# so we have to use try/finally
|
||||
sfp = self.send_request(Request(url))
|
||||
try:
|
||||
headers = sfp.info()
|
||||
blocksize = 8192
|
||||
size = -1
|
||||
read = 0
|
||||
blocknum = 0
|
||||
if "content-length" in headers:
|
||||
size = int(headers["Content-Length"])
|
||||
if reporthook:
|
||||
reporthook(blocknum, blocksize, size)
|
||||
while True:
|
||||
block = sfp.read(blocksize)
|
||||
if not block:
|
||||
break
|
||||
read += len(block)
|
||||
dfp.write(block)
|
||||
if digester:
|
||||
digester.update(block)
|
||||
blocknum += 1
|
||||
if reporthook:
|
||||
reporthook(blocknum, blocksize, size)
|
||||
finally:
|
||||
sfp.close()
|
||||
|
||||
# check that we got the whole file, if we can
|
||||
if size >= 0 and read < size:
|
||||
raise DistlibException(
|
||||
'retrieval incomplete: got only %d out of %d bytes'
|
||||
% (read, size))
|
||||
# if we have a digest, it must match.
|
||||
if digester:
|
||||
actual = digester.hexdigest()
|
||||
if digest != actual:
|
||||
raise DistlibException('%s digest mismatch for %s: expected '
|
||||
'%s, got %s' % (hasher, destfile,
|
||||
digest, actual))
|
||||
logger.debug('Digest verified: %s', digest)
|
||||
|
||||
def send_request(self, req):
|
||||
"""
|
||||
Send a standard library :class:`Request` to PyPI and return its
|
||||
response.
|
||||
|
||||
:param req: The request to send.
|
||||
:return: The HTTP response from PyPI (a standard library HTTPResponse).
|
||||
"""
|
||||
handlers = []
|
||||
if self.password_handler:
|
||||
handlers.append(self.password_handler)
|
||||
if self.ssl_verifier:
|
||||
handlers.append(self.ssl_verifier)
|
||||
opener = build_opener(*handlers)
|
||||
return opener.open(req)
|
||||
|
||||
def encode_request(self, fields, files):
|
||||
"""
|
||||
Encode fields and files for posting to an HTTP server.
|
||||
|
||||
:param fields: The fields to send as a list of (fieldname, value)
|
||||
tuples.
|
||||
:param files: The files to send as a list of (fieldname, filename,
|
||||
file_bytes) tuple.
|
||||
"""
|
||||
# Adapted from packaging, which in turn was adapted from
|
||||
# http://code.activestate.com/recipes/146306
|
||||
|
||||
parts = []
|
||||
boundary = self.boundary
|
||||
for k, values in fields:
|
||||
if not isinstance(values, (list, tuple)):
|
||||
values = [values]
|
||||
|
||||
for v in values:
|
||||
parts.extend((
|
||||
b'--' + boundary,
|
||||
('Content-Disposition: form-data; name="%s"' %
|
||||
k).encode('utf-8'),
|
||||
b'',
|
||||
v.encode('utf-8')))
|
||||
for key, filename, value in files:
|
||||
parts.extend((
|
||||
b'--' + boundary,
|
||||
('Content-Disposition: form-data; name="%s"; filename="%s"' %
|
||||
(key, filename)).encode('utf-8'),
|
||||
b'',
|
||||
value))
|
||||
|
||||
parts.extend((b'--' + boundary + b'--', b''))
|
||||
|
||||
body = b'\r\n'.join(parts)
|
||||
ct = b'multipart/form-data; boundary=' + boundary
|
||||
headers = {
|
||||
'Content-type': ct,
|
||||
'Content-length': str(len(body))
|
||||
}
|
||||
return Request(self.url, body, headers)
|
||||
+1187
File diff suppressed because it is too large
Load Diff
+364
@@ -0,0 +1,364 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2012-2013 Python Software Foundation.
|
||||
# See LICENSE.txt and CONTRIBUTORS.txt.
|
||||
#
|
||||
"""
|
||||
Class representing the list of files in a distribution.
|
||||
|
||||
Equivalent to distutils.filelist, but fixes some problems.
|
||||
"""
|
||||
import fnmatch
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
|
||||
from . import DistlibException
|
||||
from .compat import fsdecode
|
||||
from .util import convert_path
|
||||
|
||||
|
||||
__all__ = ['Manifest']
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# a \ followed by some spaces + EOL
|
||||
_COLLAPSE_PATTERN = re.compile('\\\w*\n', re.M)
|
||||
_COMMENTED_LINE = re.compile('#.*?(?=\n)|\n(?=$)', re.M | re.S)
|
||||
|
||||
|
||||
class Manifest(object):
|
||||
"""A list of files built by on exploring the filesystem and filtered by
|
||||
applying various patterns to what we find there.
|
||||
"""
|
||||
|
||||
def __init__(self, base=None):
|
||||
"""
|
||||
Initialise an instance.
|
||||
|
||||
:param base: The base directory to explore under.
|
||||
"""
|
||||
self.base = os.path.abspath(os.path.normpath(base or os.getcwd()))
|
||||
self.prefix = self.base + os.sep
|
||||
self.allfiles = None
|
||||
self.files = set()
|
||||
|
||||
#
|
||||
# Public API
|
||||
#
|
||||
|
||||
def findall(self):
|
||||
"""Find all files under the base and set ``allfiles`` to the absolute
|
||||
pathnames of files found.
|
||||
"""
|
||||
from stat import S_ISREG, S_ISDIR, S_ISLNK
|
||||
|
||||
self.allfiles = allfiles = []
|
||||
root = self.base
|
||||
stack = [root]
|
||||
pop = stack.pop
|
||||
push = stack.append
|
||||
|
||||
while stack:
|
||||
root = pop()
|
||||
names = os.listdir(root)
|
||||
|
||||
for name in names:
|
||||
fullname = os.path.join(root, name)
|
||||
|
||||
# Avoid excess stat calls -- just one will do, thank you!
|
||||
stat = os.stat(fullname)
|
||||
mode = stat.st_mode
|
||||
if S_ISREG(mode):
|
||||
allfiles.append(fsdecode(fullname))
|
||||
elif S_ISDIR(mode) and not S_ISLNK(mode):
|
||||
push(fullname)
|
||||
|
||||
def add(self, item):
|
||||
"""
|
||||
Add a file to the manifest.
|
||||
|
||||
:param item: The pathname to add. This can be relative to the base.
|
||||
"""
|
||||
if not item.startswith(self.prefix):
|
||||
item = os.path.join(self.base, item)
|
||||
self.files.add(os.path.normpath(item))
|
||||
|
||||
def add_many(self, items):
|
||||
"""
|
||||
Add a list of files to the manifest.
|
||||
|
||||
:param items: The pathnames to add. These can be relative to the base.
|
||||
"""
|
||||
for item in items:
|
||||
self.add(item)
|
||||
|
||||
def sorted(self, wantdirs=False):
|
||||
"""
|
||||
Return sorted files in directory order
|
||||
"""
|
||||
|
||||
def add_dir(dirs, d):
|
||||
dirs.add(d)
|
||||
logger.debug('add_dir added %s', d)
|
||||
if d != self.base:
|
||||
parent, _ = os.path.split(d)
|
||||
assert parent not in ('', '/')
|
||||
add_dir(dirs, parent)
|
||||
|
||||
result = set(self.files) # make a copy!
|
||||
if wantdirs:
|
||||
dirs = set()
|
||||
for f in result:
|
||||
add_dir(dirs, os.path.dirname(f))
|
||||
result |= dirs
|
||||
return [os.path.join(*path_tuple) for path_tuple in
|
||||
sorted(os.path.split(path) for path in result)]
|
||||
|
||||
def clear(self):
|
||||
"""Clear all collected files."""
|
||||
self.files = set()
|
||||
self.allfiles = []
|
||||
|
||||
def process_directive(self, directive):
|
||||
"""
|
||||
Process a directive which either adds some files from ``allfiles`` to
|
||||
``files``, or removes some files from ``files``.
|
||||
|
||||
:param directive: The directive to process. This should be in a format
|
||||
compatible with distutils ``MANIFEST.in`` files:
|
||||
|
||||
http://docs.python.org/distutils/sourcedist.html#commands
|
||||
"""
|
||||
# Parse the line: split it up, make sure the right number of words
|
||||
# is there, and return the relevant words. 'action' is always
|
||||
# defined: it's the first word of the line. Which of the other
|
||||
# three are defined depends on the action; it'll be either
|
||||
# patterns, (dir and patterns), or (dirpattern).
|
||||
action, patterns, thedir, dirpattern = self._parse_directive(directive)
|
||||
|
||||
# OK, now we know that the action is valid and we have the
|
||||
# right number of words on the line for that action -- so we
|
||||
# can proceed with minimal error-checking.
|
||||
if action == 'include':
|
||||
for pattern in patterns:
|
||||
if not self._include_pattern(pattern, anchor=True):
|
||||
logger.warning('no files found matching %r', pattern)
|
||||
|
||||
elif action == 'exclude':
|
||||
for pattern in patterns:
|
||||
if not self._exclude_pattern(pattern, anchor=True):
|
||||
logger.warning('no previously-included files '
|
||||
'found matching %r', pattern)
|
||||
|
||||
elif action == 'global-include':
|
||||
for pattern in patterns:
|
||||
if not self._include_pattern(pattern, anchor=False):
|
||||
logger.warning('no files found matching %r '
|
||||
'anywhere in distribution', pattern)
|
||||
|
||||
elif action == 'global-exclude':
|
||||
for pattern in patterns:
|
||||
if not self._exclude_pattern(pattern, anchor=False):
|
||||
logger.warning('no previously-included files '
|
||||
'matching %r found anywhere in '
|
||||
'distribution', pattern)
|
||||
|
||||
elif action == 'recursive-include':
|
||||
for pattern in patterns:
|
||||
if not self._include_pattern(pattern, prefix=thedir):
|
||||
logger.warning('no files found matching %r '
|
||||
'under directory %r', pattern, thedir)
|
||||
|
||||
elif action == 'recursive-exclude':
|
||||
for pattern in patterns:
|
||||
if not self._exclude_pattern(pattern, prefix=thedir):
|
||||
logger.warning('no previously-included files '
|
||||
'matching %r found under directory %r',
|
||||
pattern, thedir)
|
||||
|
||||
elif action == 'graft':
|
||||
if not self._include_pattern(None, prefix=dirpattern):
|
||||
logger.warning('no directories found matching %r',
|
||||
dirpattern)
|
||||
|
||||
elif action == 'prune':
|
||||
if not self._exclude_pattern(None, prefix=dirpattern):
|
||||
logger.warning('no previously-included directories found '
|
||||
'matching %r', dirpattern)
|
||||
else: # pragma: no cover
|
||||
# This should never happen, as it should be caught in
|
||||
# _parse_template_line
|
||||
raise DistlibException(
|
||||
'invalid action %r' % action)
|
||||
|
||||
#
|
||||
# Private API
|
||||
#
|
||||
|
||||
def _parse_directive(self, directive):
|
||||
"""
|
||||
Validate a directive.
|
||||
:param directive: The directive to validate.
|
||||
:return: A tuple of action, patterns, thedir, dir_patterns
|
||||
"""
|
||||
words = directive.split()
|
||||
if len(words) == 1 and words[0] not in ('include', 'exclude',
|
||||
'global-include',
|
||||
'global-exclude',
|
||||
'recursive-include',
|
||||
'recursive-exclude',
|
||||
'graft', 'prune'):
|
||||
# no action given, let's use the default 'include'
|
||||
words.insert(0, 'include')
|
||||
|
||||
action = words[0]
|
||||
patterns = thedir = dir_pattern = None
|
||||
|
||||
if action in ('include', 'exclude',
|
||||
'global-include', 'global-exclude'):
|
||||
if len(words) < 2:
|
||||
raise DistlibException(
|
||||
'%r expects <pattern1> <pattern2> ...' % action)
|
||||
|
||||
patterns = [convert_path(word) for word in words[1:]]
|
||||
|
||||
elif action in ('recursive-include', 'recursive-exclude'):
|
||||
if len(words) < 3:
|
||||
raise DistlibException(
|
||||
'%r expects <dir> <pattern1> <pattern2> ...' % action)
|
||||
|
||||
thedir = convert_path(words[1])
|
||||
patterns = [convert_path(word) for word in words[2:]]
|
||||
|
||||
elif action in ('graft', 'prune'):
|
||||
if len(words) != 2:
|
||||
raise DistlibException(
|
||||
'%r expects a single <dir_pattern>' % action)
|
||||
|
||||
dir_pattern = convert_path(words[1])
|
||||
|
||||
else:
|
||||
raise DistlibException('unknown action %r' % action)
|
||||
|
||||
return action, patterns, thedir, dir_pattern
|
||||
|
||||
def _include_pattern(self, pattern, anchor=True, prefix=None,
|
||||
is_regex=False):
|
||||
"""Select strings (presumably filenames) from 'self.files' that
|
||||
match 'pattern', a Unix-style wildcard (glob) pattern.
|
||||
|
||||
Patterns are not quite the same as implemented by the 'fnmatch'
|
||||
module: '*' and '?' match non-special characters, where "special"
|
||||
is platform-dependent: slash on Unix; colon, slash, and backslash on
|
||||
DOS/Windows; and colon on Mac OS.
|
||||
|
||||
If 'anchor' is true (the default), then the pattern match is more
|
||||
stringent: "*.py" will match "foo.py" but not "foo/bar.py". If
|
||||
'anchor' is false, both of these will match.
|
||||
|
||||
If 'prefix' is supplied, then only filenames starting with 'prefix'
|
||||
(itself a pattern) and ending with 'pattern', with anything in between
|
||||
them, will match. 'anchor' is ignored in this case.
|
||||
|
||||
If 'is_regex' is true, 'anchor' and 'prefix' are ignored, and
|
||||
'pattern' is assumed to be either a string containing a regex or a
|
||||
regex object -- no translation is done, the regex is just compiled
|
||||
and used as-is.
|
||||
|
||||
Selected strings will be added to self.files.
|
||||
|
||||
Return True if files are found.
|
||||
"""
|
||||
# XXX docstring lying about what the special chars are?
|
||||
found = False
|
||||
pattern_re = self._translate_pattern(pattern, anchor, prefix, is_regex)
|
||||
|
||||
# delayed loading of allfiles list
|
||||
if self.allfiles is None:
|
||||
self.findall()
|
||||
|
||||
for name in self.allfiles:
|
||||
if pattern_re.search(name):
|
||||
self.files.add(name)
|
||||
found = True
|
||||
return found
|
||||
|
||||
def _exclude_pattern(self, pattern, anchor=True, prefix=None,
|
||||
is_regex=False):
|
||||
"""Remove strings (presumably filenames) from 'files' that match
|
||||
'pattern'.
|
||||
|
||||
Other parameters are the same as for 'include_pattern()', above.
|
||||
The list 'self.files' is modified in place. Return True if files are
|
||||
found.
|
||||
|
||||
This API is public to allow e.g. exclusion of SCM subdirs, e.g. when
|
||||
packaging source distributions
|
||||
"""
|
||||
found = False
|
||||
pattern_re = self._translate_pattern(pattern, anchor, prefix, is_regex)
|
||||
for f in list(self.files):
|
||||
if pattern_re.search(f):
|
||||
self.files.remove(f)
|
||||
found = True
|
||||
return found
|
||||
|
||||
def _translate_pattern(self, pattern, anchor=True, prefix=None,
|
||||
is_regex=False):
|
||||
"""Translate a shell-like wildcard pattern to a compiled regular
|
||||
expression.
|
||||
|
||||
Return the compiled regex. If 'is_regex' true,
|
||||
then 'pattern' is directly compiled to a regex (if it's a string)
|
||||
or just returned as-is (assumes it's a regex object).
|
||||
"""
|
||||
if is_regex:
|
||||
if isinstance(pattern, str):
|
||||
return re.compile(pattern)
|
||||
else:
|
||||
return pattern
|
||||
|
||||
if pattern:
|
||||
pattern_re = self._glob_to_re(pattern)
|
||||
else:
|
||||
pattern_re = ''
|
||||
|
||||
base = re.escape(os.path.join(self.base, ''))
|
||||
if prefix is not None:
|
||||
# ditch end of pattern character
|
||||
empty_pattern = self._glob_to_re('')
|
||||
prefix_re = self._glob_to_re(prefix)[:-len(empty_pattern)]
|
||||
sep = os.sep
|
||||
if os.sep == '\\':
|
||||
sep = r'\\'
|
||||
pattern_re = '^' + base + sep.join((prefix_re,
|
||||
'.*' + pattern_re))
|
||||
else: # no prefix -- respect anchor flag
|
||||
if anchor:
|
||||
pattern_re = '^' + base + pattern_re
|
||||
|
||||
return re.compile(pattern_re)
|
||||
|
||||
def _glob_to_re(self, pattern):
|
||||
"""Translate a shell-like glob pattern to a regular expression.
|
||||
|
||||
Return a string containing the regex. Differs from
|
||||
'fnmatch.translate()' in that '*' does not match "special characters"
|
||||
(which are platform-specific).
|
||||
"""
|
||||
pattern_re = fnmatch.translate(pattern)
|
||||
|
||||
# '?' and '*' in the glob pattern become '.' and '.*' in the RE, which
|
||||
# IMHO is wrong -- '?' and '*' aren't supposed to match slash in Unix,
|
||||
# and by extension they shouldn't match such "special characters" under
|
||||
# any OS. So change all non-escaped dots in the RE to match any
|
||||
# character except the special characters (currently: just os.sep).
|
||||
sep = os.sep
|
||||
if os.sep == '\\':
|
||||
# we're using a regex to manipulate a regex, so we need
|
||||
# to escape the backslash twice
|
||||
sep = r'\\\\'
|
||||
escaped = r'\1[^%s]' % sep
|
||||
pattern_re = re.sub(r'((?<!\\)(\\\\)*)\.', escaped, pattern_re)
|
||||
return pattern_re
|
||||
+190
@@ -0,0 +1,190 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2012-2013 Vinay Sajip.
|
||||
# Licensed to the Python Software Foundation under a contributor agreement.
|
||||
# See LICENSE.txt and CONTRIBUTORS.txt.
|
||||
#
|
||||
"""Parser for the environment markers micro-language defined in PEP 345."""
|
||||
|
||||
import ast
|
||||
import os
|
||||
import sys
|
||||
import platform
|
||||
|
||||
from .compat import python_implementation, string_types
|
||||
from .util import in_venv
|
||||
|
||||
__all__ = ['interpret']
|
||||
|
||||
|
||||
class Evaluator(object):
|
||||
"""
|
||||
A limited evaluator for Python expressions.
|
||||
"""
|
||||
|
||||
operators = {
|
||||
'eq': lambda x, y: x == y,
|
||||
'gt': lambda x, y: x > y,
|
||||
'gte': lambda x, y: x >= y,
|
||||
'in': lambda x, y: x in y,
|
||||
'lt': lambda x, y: x < y,
|
||||
'lte': lambda x, y: x <= y,
|
||||
'not': lambda x: not x,
|
||||
'noteq': lambda x, y: x != y,
|
||||
'notin': lambda x, y: x not in y,
|
||||
}
|
||||
|
||||
allowed_values = {
|
||||
'sys_platform': sys.platform,
|
||||
'python_version': '%s.%s' % sys.version_info[:2],
|
||||
# parsing sys.platform is not reliable, but there is no other
|
||||
# way to get e.g. 2.7.2+, and the PEP is defined with sys.version
|
||||
'python_full_version': sys.version.split(' ', 1)[0],
|
||||
'os_name': os.name,
|
||||
'platform_in_venv': str(in_venv()),
|
||||
'platform_release': platform.release(),
|
||||
'platform_version': platform.version(),
|
||||
'platform_machine': platform.machine(),
|
||||
'platform_python_implementation': python_implementation(),
|
||||
}
|
||||
|
||||
def __init__(self, context=None):
|
||||
"""
|
||||
Initialise an instance.
|
||||
|
||||
:param context: If specified, names are looked up in this mapping.
|
||||
"""
|
||||
self.context = context or {}
|
||||
self.source = None
|
||||
|
||||
def get_fragment(self, offset):
|
||||
"""
|
||||
Get the part of the source which is causing a problem.
|
||||
"""
|
||||
fragment_len = 10
|
||||
s = '%r' % (self.source[offset:offset + fragment_len])
|
||||
if offset + fragment_len < len(self.source):
|
||||
s += '...'
|
||||
return s
|
||||
|
||||
def get_handler(self, node_type):
|
||||
"""
|
||||
Get a handler for the specified AST node type.
|
||||
"""
|
||||
return getattr(self, 'do_%s' % node_type, None)
|
||||
|
||||
def evaluate(self, node, filename=None):
|
||||
"""
|
||||
Evaluate a source string or node, using ``filename`` when
|
||||
displaying errors.
|
||||
"""
|
||||
if isinstance(node, string_types):
|
||||
self.source = node
|
||||
kwargs = {'mode': 'eval'}
|
||||
if filename:
|
||||
kwargs['filename'] = filename
|
||||
try:
|
||||
node = ast.parse(node, **kwargs)
|
||||
except SyntaxError as e:
|
||||
s = self.get_fragment(e.offset)
|
||||
raise SyntaxError('syntax error %s' % s)
|
||||
node_type = node.__class__.__name__.lower()
|
||||
handler = self.get_handler(node_type)
|
||||
if handler is None:
|
||||
if self.source is None:
|
||||
s = '(source not available)'
|
||||
else:
|
||||
s = self.get_fragment(node.col_offset)
|
||||
raise SyntaxError("don't know how to evaluate %r %s" % (
|
||||
node_type, s))
|
||||
return handler(node)
|
||||
|
||||
def get_attr_key(self, node):
|
||||
assert isinstance(node, ast.Attribute), 'attribute node expected'
|
||||
return '%s.%s' % (node.value.id, node.attr)
|
||||
|
||||
def do_attribute(self, node):
|
||||
if not isinstance(node.value, ast.Name):
|
||||
valid = False
|
||||
else:
|
||||
key = self.get_attr_key(node)
|
||||
valid = key in self.context or key in self.allowed_values
|
||||
if not valid:
|
||||
raise SyntaxError('invalid expression: %s' % key)
|
||||
if key in self.context:
|
||||
result = self.context[key]
|
||||
else:
|
||||
result = self.allowed_values[key]
|
||||
return result
|
||||
|
||||
def do_boolop(self, node):
|
||||
result = self.evaluate(node.values[0])
|
||||
is_or = node.op.__class__ is ast.Or
|
||||
is_and = node.op.__class__ is ast.And
|
||||
assert is_or or is_and
|
||||
if (is_and and result) or (is_or and not result):
|
||||
for n in node.values[1:]:
|
||||
result = self.evaluate(n)
|
||||
if (is_or and result) or (is_and and not result):
|
||||
break
|
||||
return result
|
||||
|
||||
def do_compare(self, node):
|
||||
def sanity_check(lhsnode, rhsnode):
|
||||
valid = True
|
||||
if isinstance(lhsnode, ast.Str) and isinstance(rhsnode, ast.Str):
|
||||
valid = False
|
||||
#elif (isinstance(lhsnode, ast.Attribute)
|
||||
# and isinstance(rhsnode, ast.Attribute)):
|
||||
# klhs = self.get_attr_key(lhsnode)
|
||||
# krhs = self.get_attr_key(rhsnode)
|
||||
# valid = klhs != krhs
|
||||
if not valid:
|
||||
s = self.get_fragment(node.col_offset)
|
||||
raise SyntaxError('Invalid comparison: %s' % s)
|
||||
|
||||
lhsnode = node.left
|
||||
lhs = self.evaluate(lhsnode)
|
||||
result = True
|
||||
for op, rhsnode in zip(node.ops, node.comparators):
|
||||
sanity_check(lhsnode, rhsnode)
|
||||
op = op.__class__.__name__.lower()
|
||||
if op not in self.operators:
|
||||
raise SyntaxError('unsupported operation: %r' % op)
|
||||
rhs = self.evaluate(rhsnode)
|
||||
result = self.operators[op](lhs, rhs)
|
||||
if not result:
|
||||
break
|
||||
lhs = rhs
|
||||
lhsnode = rhsnode
|
||||
return result
|
||||
|
||||
def do_expression(self, node):
|
||||
return self.evaluate(node.body)
|
||||
|
||||
def do_name(self, node):
|
||||
valid = False
|
||||
if node.id in self.context:
|
||||
valid = True
|
||||
result = self.context[node.id]
|
||||
elif node.id in self.allowed_values:
|
||||
valid = True
|
||||
result = self.allowed_values[node.id]
|
||||
if not valid:
|
||||
raise SyntaxError('invalid expression: %s' % node.id)
|
||||
return result
|
||||
|
||||
def do_str(self, node):
|
||||
return node.s
|
||||
|
||||
|
||||
def interpret(marker, execution_context=None):
|
||||
"""
|
||||
Interpret a marker and return a result depending on environment.
|
||||
|
||||
:param marker: The marker to interpret.
|
||||
:type marker: str
|
||||
:param execution_context: The context used for name lookup.
|
||||
:type execution_context: mapping
|
||||
"""
|
||||
return Evaluator(execution_context).evaluate(marker.strip())
|
||||
+1015
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user