Commits

Tarek Ziadé committed 4147521 Merge

eliminate other head

Comments (0)

Files changed (175)

 syntax: glob
 *.pyc
 *~
+*.swp
 .coverage
 distribute.egg-info
 build
 bin
 include
 \.Python
-eggs
-develop\-eggs
-distribute.installer.egg-info
-distribute.resources.egg-info
-.installed.cfg
+*.swp
 1010d08fd8dfd2f1496843b557b5369a0beba82a 0.6
+4d114c5f2a3ecb4a0fa552075dbbb221b19e291b 0.6.1
+41415244ee90664042d277d0b1f0f59c04ddd0e4 0.6.2
+e033bf2d3d05f4a7130f5f8f5de152c4db9ff32e 0.6.3
+e06c416e911c61771708f5afbf3f35db0e12ba71 0.6.4
+2df182df8a0224d429402de3cddccdb97af6ea21 0.6.5
+f1fb564d6d67a6340ff33df2f5a74b89753f159d 0.6.6
+71f08668d050589b92ecd164a4f5a91f3484313b 0.6.7
+445547a5729ed5517cf1a9baad595420a8831ef8 0.6.8
+669ed9388b17ec461380cc41760a9a7384fb5284 0.6.9
+669ed9388b17ec461380cc41760a9a7384fb5284 0.6.9
+ac7d9b14ac43fecb8b65de548b25773553facaee 0.6.9
+0fd5c506037880409308f2b79c6e901d21e7fe92 0.6.10
+0fd5c506037880409308f2b79c6e901d21e7fe92 0.6.10
+f18396c6e1875476279d8bbffd8e6dadcc695136 0.6.10
+e00987890c0b386f09d0f6b73d8558b72f6367f1 0.6.11
+48a97bc89e2f65fc9b78b358d7dc89ba9ec9524a 0.6.12
+dae247400d0ca1fdfaf38db275622c9bec550b08 0.6.13
+2b9d9977ea75b8eb3766bab808ef31f192d2b1bc 0.6.14
+51a9d1a1f31a4be3107d06cf088aff8e182dc633 0.6.15
+3f1ff138e947bfc1c9bcfe0037030b7bfb4ab3a5 0.6.16
+=======
+CHANGES
+=======
+
+------
+0.6.17
+------
+
+* Support Python >=3.1.4 and >=3.2.1.
+
+------
+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 close http://bitbucket.org/tarek/distribute/issue/52.
+
+* Added an upload_docs command to easily upload project documentation to
+  PyPI's http://packages.python.org.
+  This close http://bitbucket.org/tarek/distribute/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 http://bitbucket.org/tarek/distribute/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 http://bitbucket.org/tarek/distribute/issue/49.
+
+* Fixed 2.6 dependencies.
+  This closes http://bitbucket.org/tarek/distribute/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 http://bitbucket.org/tarek/distribute/issue/16 and
+  http://bitbucket.org/tarek/distribute/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
+  http://bitbucket.org/tarek/distribute/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 http://bitbucket.org/tarek/distribute/issue/10.
+
+---
+0.6
+---
+
+setuptools
+==========
+
+* Packages required at build time where not fully present at install time.
+  This closes http://bitbucket.org/tarek/distribute/issue/12.
+
+* Protected against failures in tarfile extraction. This closes
+  http://bitbucket.org/tarek/distribute/issue/10.
+
+* Made Jython api_tests.txt doctest compatible. This closes
+  http://bitbucket.org/tarek/distribute/issue/7.
+
+* sandbox.py replaced builtin type file with builtin function open. This
+  closes http://bitbucket.org/tarek/distribute/issue/6.
+
+* Immediately close all file handles. This closes
+  http://bitbucket.org/tarek/distribute/issue/3.
+
+* Added compatibility with Subversion 1.6. This references
+  http://bitbucket.org/tarek/distribute/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
+  http://bitbucket.org/tarek/distribute/issue/5.
+
+* Fixed a SandboxViolation for mkdir that could occur in certain cases.
+  This closes http://bitbucket.org/tarek/distribute/issue/13.
+
+* Allow to find_on_path on systems with tight permissions to fail gracefully.
+  This closes http://bitbucket.org/tarek/distribute/issue/9.
+
+* Corrected inconsistency between documentation and code of add_entry.
+  This closes http://bitbucket.org/tarek/distribute/issue/8.
+
+* Immediately close all file handles. This closes
+  http://bitbucket.org/tarek/distribute/issue/3.
+
+easy_install
+============
+
+* Immediately close all file handles. This closes
+  http://bitbucket.org/tarek/distribute/issue/3.
+
+============
+Contributors
+============
+
+* Alex Grönholm
+* Alice Bevan-McGregor
+* Arfrever Frehtes Taifersar Arahesis
+* Christophe Combelles
+* Daniel Stutzbach
+* Hanno Schlichting
+* Jannis Leidel
+* Lennart Regebro
+* Martin von Löwis
+* Noufal Ibrahim
+* Philip Jenvey
+* Reinout van Rees
+* Robert Myers
+* Tarek Ziadé
+* Toshio Kuratomi
+
+If you think you name is missing, please add it (alpha order by first name)
+
+============================
+Quick notes for contributors
+============================
+
+Distribute is using Mercurial.
+
+Grab the code at bitbucket::
+
+    $ hg clone https://tarek@bitbucket.org/tarek/distribute distribute
+
+If you want to work in the 0.6 branch, you have to switch to it::
+
+    $ hg update 0.6-maintenance
+
+    $ hg branch
+    0.6-maintenance
+
+If you make some changes, don't forget to:
+
+- backport it to the 0.7 branch
+- add a note in CHANGES.txt
+
+And remember that 0.6 is only bug fixes, and the APIs should
+be fully backward compatible with Setuptools.
+
+You can run the tests via::
+
+    $ python setup.py test
+recursive-include setuptools *.py *.txt *.exe
+recursive-include tests *.py *.c *.pyx *.txt
+recursive-include setuptools/tests *.html
+recursive-include docs *.py *.txt *.conf *.css *.css_t Makefile indexsidebar.html
+include *.py
+include *.txt
+include MANIFEST.in
+include launcher.c
+===============================
+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.15.tar.gz
+    $ tar -xzvf distribute-0.6.15.tar.gz
+    $ cd distribute-0.6.15
+    $ 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
+

bootstrap.sh

-#!/bin/sh
-rm -rf bin include lib
-python virtualenv.py --no-site-packages --distribute .
-bin/pip install nose
-bin/pip install distribute==dev
-

distribute.egg-info/entry_points.txt

+[distutils.commands]
+bdist_rpm = setuptools.command.bdist_rpm:bdist_rpm
+rotate = setuptools.command.rotate:rotate
+develop = setuptools.command.develop:develop
+setopt = setuptools.command.setopt:setopt
+build_py = setuptools.command.build_py:build_py
+saveopts = setuptools.command.saveopts:saveopts
+egg_info = setuptools.command.egg_info:egg_info
+register = setuptools.command.register:register
+upload_docs = setuptools.command.upload_docs:upload_docs
+install_egg_info = setuptools.command.install_egg_info:install_egg_info
+alias = setuptools.command.alias:alias
+easy_install = setuptools.command.easy_install:easy_install
+install_scripts = setuptools.command.install_scripts:install_scripts
+bdist_wininst = setuptools.command.bdist_wininst:bdist_wininst
+bdist_egg = setuptools.command.bdist_egg:bdist_egg
+install = setuptools.command.install:install
+test = setuptools.command.test:test
+install_lib = setuptools.command.install_lib:install_lib
+build_ext = setuptools.command.build_ext:build_ext
+sdist = setuptools.command.sdist:sdist
+
+[egg_info.writers]
+dependency_links.txt = setuptools.command.egg_info:overwrite_arg
+requires.txt = setuptools.command.egg_info:write_requirements
+PKG-INFO = setuptools.command.egg_info:write_pkg_info
+eager_resources.txt = setuptools.command.egg_info:overwrite_arg
+top_level.txt = setuptools.command.egg_info:write_toplevel_names
+namespace_packages.txt = setuptools.command.egg_info:overwrite_arg
+entry_points.txt = setuptools.command.egg_info:write_entries
+depends.txt = setuptools.command.egg_info:warn_depends_obsolete
+
+[console_scripts]
+easy_install = setuptools.command.easy_install:main
+easy_install-2.7 = setuptools.command.easy_install:main
+
+[setuptools.file_finders]
+svn_cvs = setuptools.command.sdist:_default_revctrl
+
+[distutils.setup_keywords]
+dependency_links = setuptools.dist:assert_string_list
+entry_points = setuptools.dist:check_entry_points
+extras_require = setuptools.dist:check_extras
+package_data = setuptools.dist:check_package_data
+install_requires = setuptools.dist:check_requirements
+use_2to3 = setuptools.dist:assert_bool
+use_2to3_fixers = setuptools.dist:assert_string_list
+include_package_data = setuptools.dist:assert_bool
+exclude_package_data = setuptools.dist:check_package_data
+namespace_packages = setuptools.dist:check_nsp
+test_suite = setuptools.dist:check_test_suite
+eager_resources = setuptools.dist:assert_string_list
+zip_safe = setuptools.dist:assert_bool
+test_loader = setuptools.dist:check_importable
+packages = setuptools.dist:check_packages
+convert_2to3_doctests = setuptools.dist:assert_string_list
+tests_require = setuptools.dist:check_requirements
+
+[setuptools.installation]
+eggsecutable = setuptools.command.easy_install:bootstrap
+

distribute.resources/CHANGES.txt

-=======
-CHANGES
-=======
-
----
-0.1
----
-
-
-

distribute.resources/README.txt

-=========================================
-Installing and Using distribute.resources
-=========================================
-
-.. contents:: **Table of Contents**
-
-

distribute.resources/distribute/__init__.py

-from pkgutil import extend_path
-__path__ = extend_path(__path__, __name__)
-

distribute.resources/distribute/resources/__init__.py

-"""Package resource API
---------------------
-
-A resource is a logical file contained within a package, or a logical
-subdirectory thereof.  The package resource API expects resource names
-to have their path parts separated with ``/``, *not* whatever the local
-path separator is.  Do not use os.path operations to manipulate resource
-names being passed into the API.
-
-The package resource API is designed to work with normal filesystem packages,
-.egg files, and unpacked .egg files.  It can also work in a limited way with
-.zip files and with custom PEP 302 loaders that support the ``get_data()``
-method.
-"""
-
-import sys
-import os
-import zipimport
-import time
-import re
-import imp
-from types import ModuleType
-
-
-try:
-    frozenset
-except NameError:
-    from sets import ImmutableSet as frozenset
-
-# capture these to bypass sandboxing
-from os import utime, rename, unlink, mkdir
-from os import open as os_open
-from os.path import isdir, split
-
-from distribute.resources.manager import ResourceManager
-from distribute.resources.workingset import WorkingSet
-from distribute.resources.environment import Environment
-from distribute.resources.exceptions import (ResolutionError, VersionConflict,
-                                             DistributionNotFound,
-                                             UnknownExtra, ExtractionError)
-
-def _bypass_ensure_directory(name, mode=0777):
-    # Sandbox-bypassing version of ensure_directory()
-    dirname, filename = split(name)
-    if dirname and filename and not isdir(dirname):
-        _bypass_ensure_directory(dirname)
-        mkdir(dirname, mode)
-
-def get_provider(moduleOrReq):
-    """Return an IResourceProvider for the named module or requirement"""
-    if isinstance(moduleOrReq,Requirement):
-        return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
-    try:
-        module = sys.modules[moduleOrReq]
-    except KeyError:
-        __import__(moduleOrReq)
-        module = sys.modules[moduleOrReq]
-    loader = getattr(module, '__loader__', None)
-    return _find_adapter(_provider_factories, loader)(module)
-
-def run_script(dist_spec, script_name):
-    """Locate distribution `dist_spec` and run its `script_name` script"""
-    ns = sys._getframe(1).f_globals
-    name = ns['__name__']
-    ns.clear()
-    ns['__name__'] = name
-    require(dist_spec)[0].run_script(script_name, ns)
-
-run_main = run_script   # backward compatibility
-
-def get_distribution(dist):
-    """Return a current distribution object for a Requirement or string"""
-    if isinstance(dist,basestring): dist = Requirement.parse(dist)
-    if isinstance(dist,Requirement): dist = get_provider(dist)
-    if not isinstance(dist,Distribution):
-        raise TypeError("Expected string, Requirement, or Distribution", dist)
-    return dist
-
-def StringIO(*args, **kw):
-    """Thunk to load the real StringIO on demand"""
-    global StringIO
-    try:
-        from cStringIO import StringIO
-    except ImportError:
-        from StringIO import StringIO
-    return StringIO(*args,**kw)
-
-def _mkstemp(*args,**kw):
-    from tempfile import mkstemp
-    old_open = os.open
-    try:
-        os.open = os_open   # temporarily bypass sandboxing
-        return mkstemp(*args,**kw)
-    finally:
-        os.open = old_open  # and then put it back
-
-# Set up global resource manager
-_manager = ResourceManager()
-def _initialize(g):
-    for name in dir(_manager):
-        if not name.startswith('_'):
-            g[name] = getattr(_manager, name)
-_initialize(globals())
-
-

distribute.resources/distribute/resources/dist.py

-import os
-import sys
-
-from distribute.resources.util import PY_MAJOR, EGG_NAME, safe_name
-from distribute.resources.util import (normalize_cached, safe_version,
-                                       normalize_path, issue_warning,
-                                       split_sections, safe_extra)
-from distribute.resources.requirement import parse_requirements
-from distribute.resources.namespace import (_namespace_packages,
-                                            fixup_namespace_packages,
-                                            declare_namespace)
-from distribute.resources.version import parse_version
-from distribute.resources.exceptions import UnknownExtra
-from distribute.resources.entrypoint import EntryPoint
-
-EGG_DIST    = 3
-BINARY_DIST = 2
-SOURCE_DIST = 1
-CHECKOUT_DIST = 0
-DEVELOP_DIST = -1
-
-class Distribution(object):
-    """Wrap an actual or potential sys.path entry w/metadata"""
-
-    _ep_map = None
-
-    def __init__(self,
-        location=None, metadata=None, project_name=None, version=None,
-        py_version=PY_MAJOR, platform=None, precedence = EGG_DIST
-    ):
-        self.project_name = safe_name(project_name or 'Unknown')
-        if version is not None:
-            self._version = safe_version(version)
-        self.py_version = py_version
-        self.platform = platform
-        self.location = location
-        self.precedence = precedence
-        from distribute.resources.providers import empty_provider
-        self._provider = metadata or empty_provider
-
-    @classmethod
-    def from_location(cls,location,basename,metadata=None,**kw):
-        project_name, version, py_version, platform = [None]*4
-        basename, ext = os.path.splitext(basename)
-        if ext.lower() in (".egg",".egg-info"):
-            match = EGG_NAME(basename)
-            if match:
-                project_name, version, py_version, platform = match.group(
-                    'name','ver','pyver','plat'
-                )
-        return cls(
-            location, metadata, project_name=project_name, version=version,
-            py_version=py_version, platform=platform, **kw
-        )
-
-    @property
-    def hashcmp(self):
-        return getattr(self, 'parsed_version', ()), self.precedence, self.key, \
-            -len(self.location or ''), self.location, self.py_version, \
-            self.platform
-
-    def __lt__(self, other):
-        return self.hashcmp < other.hashcmp
-    def __eq__(self, other):
-        return hasattr(other, 'hashcmp') and self.hashcmp == other.hashcmp
-    def __cmp__(self, other):
-        return cmp(self.hashcmp, other)
-    def __hash__(self):
-        return hash(self.hashcmp)
-
-    # These properties have to be lazy so that we don't have to load any
-    # metadata until/unless it's actually needed.  (i.e., some distributions
-    # may not know their name or version without loading PKG-INFO)
-
-    @property
-    def key(self):
-        try:
-            return self._key
-        except AttributeError:
-            self._key = key = self.project_name.lower()
-            return key
-
-    @property
-    def parsed_version(self):
-        try:
-            return self._parsed_version
-        except AttributeError:
-            self._parsed_version = pv = parse_version(self.version)
-            return pv
-
-    @property
-    def version(self):
-        try:
-            return self._version
-        except AttributeError:
-            for line in self._get_metadata('PKG-INFO'):
-                if line.lower().startswith('version:'):
-                    self._version = safe_version(line.split(':',1)[1].strip())
-                    return self._version
-            else:
-                raise ValueError(
-                    "Missing 'Version:' header and/or PKG-INFO file", self
-                )
-
-    @property
-    def _dep_map(self):
-        try:
-            return self.__dep_map
-        except AttributeError:
-            dm = self.__dep_map = {None: []}
-            for name in 'requires.txt', 'depends.txt':
-                for extra,reqs in split_sections(self._get_metadata(name)):
-                    if extra: extra = safe_extra(extra)
-                    dm.setdefault(extra,[]).extend(parse_requirements(reqs))
-            return dm
-
-    def requires(self,extras=()):
-        """List of Requirements needed for this distro if `extras` are used"""
-        dm = self._dep_map
-        deps = []
-        deps.extend(dm.get(None,()))
-        for ext in extras:
-            try:
-                deps.extend(dm[safe_extra(ext)])
-            except KeyError:
-                raise UnknownExtra(
-                    "%s has no such extra feature %r" % (self, ext)
-                )
-        return deps
-
-    def _get_metadata(self,name):
-        if self.has_metadata(name):
-            for line in self.get_metadata_lines(name):
-                yield line
-
-    def activate(self,path=None):
-        """Ensure distribution is importable on `path` (default=sys.path)"""
-        if path is None: path = sys.path
-        self.insert_on(path)
-        if path is sys.path:
-            fixup_namespace_packages(self.location)
-            for namespace in self._get_metadata('namespace_packages.txt'):
-                declare_namespace(namespace)
-
-    def egg_name(self):
-        """Return what this distribution's standard .egg filename should be"""
-        filename = "%s-%s-py%s" % (
-            to_filename(self.project_name), to_filename(self.version),
-            self.py_version or PY_MAJOR
-        )
-
-        if self.platform:
-            filename += '-'+self.platform
-        return filename
-
-    def __repr__(self):
-        if self.location:
-            return "%s (%s)" % (self,self.location)
-        else:
-            return str(self)
-
-    def __str__(self):
-        try: version = getattr(self,'version',None)
-        except ValueError: version = None
-        version = version or "[unknown version]"
-        return "%s %s" % (self.project_name,version)
-
-    def __getattr__(self,attr):
-        """Delegate all unrecognized public attributes to .metadata provider"""
-        if attr.startswith('_'):
-            raise AttributeError,attr
-        return getattr(self._provider, attr)
-
-    @classmethod
-    def from_filename(cls,filename,metadata=None, **kw):
-        return cls.from_location(
-            normalize_cached(filename), os.path.basename(filename), metadata,
-            **kw
-        )
-
-    def as_requirement(self):
-        """Return a ``Requirement`` that matches this distribution exactly"""
-        return Requirement.parse('%s==%s' % (self.project_name, self.version))
-
-    def load_entry_point(self, group, name):
-        """Return the `name` entry point of `group` or raise ImportError"""
-        ep = self.get_entry_info(group,name)
-        if ep is None:
-            raise ImportError("Entry point %r not found" % ((group,name),))
-        return ep.load()
-
-    def get_entry_map(self, group=None):
-        """Return the entry point map for `group`, or the full entry map"""
-        if self._ep_map is None:
-            self._ep_map = EntryPoint.parse_map(
-                self._get_metadata('entry_points.txt'), self
-            )
-        if group is not None:
-            return self._ep_map.get(group,{})
-        return self._ep_map
-
-    def get_entry_info(self, group, name):
-        """Return the EntryPoint object for `group`+`name`, or ``None``"""
-        return self.get_entry_map(group).get(name)
-
-    def insert_on(self, path, loc = None):
-        """Insert self.location in path before its nearest parent directory"""
-
-        loc = loc or self.location
-        if not loc:
-            return
-
-        if path is sys.path:
-            self.check_version_conflict()
-
-        nloc = normalize_cached(loc)
-        bdir = os.path.dirname(nloc)
-        npath= map(normalize_cached, path)
-
-        bp = None
-        for p, item in enumerate(npath):
-            if item==nloc:
-                break
-            elif item==bdir and self.precedence==EGG_DIST:
-                # if it's an .egg, give it precedence over its directory
-                path.insert(p, loc)
-                npath.insert(p, nloc)
-                break
-        else:
-            path.append(loc)
-            return
-
-        # p is the spot where we found or inserted loc; now remove duplicates
-        while 1:
-            try:
-                np = npath.index(nloc, p+1)
-            except ValueError:
-                break
-            else:
-                del npath[np], path[np]
-                p = np  # ha!
-        return
-
-
-    def check_version_conflict(self):
-        if self.key=='distribute':
-            return      # ignore the inevitable distribute self-conflicts  :(
-
-        nsp = dict.fromkeys(self._get_metadata('namespace_packages.txt'))
-        loc = normalize_path(self.location)
-        for modname in self._get_metadata('top_level.txt'):
-            if (modname not in sys.modules or modname in nsp
-                or modname in _namespace_packages
-            ):
-                continue
-            if modname in ('pkg_resources', 'setuptools', 'site', 'distribute'):
-                continue
-            fn = getattr(sys.modules[modname], '__file__', None)
-            if fn and normalize_path(fn).startswith(loc):
-                continue
-            issue_warning(
-                "Module %s was already imported from %s, but %s is being added"
-                " to sys.path" % (modname, fn, self.location),
-            )
-
-    def has_version(self):
-        try:
-            self.version
-        except ValueError:
-            issue_warning("Unbuilt egg for "+repr(self))
-            return False
-        return True
-
-    def clone(self,**kw):
-        """Copy this distribution, substituting in any changed keyword args"""
-        for attr in (
-            'project_name', 'version', 'py_version', 'platform', 'location',
-            'precedence'
-        ):
-            kw.setdefault(attr, getattr(self,attr,None))
-        kw.setdefault('metadata', self._provider)
-        return self.__class__(**kw)
-
-    @property
-    def extras(self):
-        return [dep for dep in self._dep_map if dep]
-

distribute.resources/distribute/resources/entrypoint.py

-from distribute.resources.util import (MODULE, yield_lines, split_sections,
-                                      compatible_platforms)
-from distribute.resources.requirement import Requirement
-
-def load_entry_point(dist, group, name):
-    """Return `name` entry point of `group` for `dist` or raise ImportError"""
-    return get_distribution(dist).load_entry_point(group, name)
-
-def get_entry_map(dist, group=None):
-    """Return the entry point map for `group`, or the full entry map"""
-    return get_distribution(dist).get_entry_map(group)
-
-def get_entry_info(dist, group, name):
-    """Return the EntryPoint object for `group`+`name`, or ``None``"""
-    return get_distribution(dist).get_entry_info(group, name)
-
-class EntryPoint(object):
-    """Object representing an advertised importable object"""
-
-    def __init__(self, name, module_name, attrs=(), extras=(), dist=None):
-        if not MODULE(module_name):
-            raise ValueError("Invalid module name", module_name)
-        self.name = name
-        self.module_name = module_name
-        self.attrs = tuple(attrs)
-        self.extras = Requirement.parse(("x[%s]" % ','.join(extras))).extras
-        self.dist = dist
-
-    def __str__(self):
-        s = "%s = %s" % (self.name, self.module_name)
-        if self.attrs:
-            s += ':' + '.'.join(self.attrs)
-        if self.extras:
-            s += ' [%s]' % ','.join(self.extras)
-        return s
-
-    def __repr__(self):
-        return "EntryPoint.parse(%r)" % str(self)
-
-    def load(self, require=True, env=None, installer=None):
-        if require: self.require(env, installer)
-        entry = __import__(self.module_name, globals(),globals(), ['__name__'])
-        for attr in self.attrs:
-            try:
-                entry = getattr(entry,attr)
-            except AttributeError:
-                raise ImportError("%r has no %r attribute" % (entry,attr))
-        return entry
-
-    def require(self, env=None, installer=None):
-        from distribute.resources.workingset import working_set
-        if self.extras and not self.dist:
-            raise UnknownExtra("Can't require() without a distribution", self)
-        entries = working_set.resolve(self.dist.requires(self.extras), env,
-                                      installer)
-        for entry in entries:
-            working_set.add(entry)
-
-    @classmethod
-    def parse(cls, src, dist=None):
-        """Parse a single entry point from string `src`
-
-        Entry point syntax follows the form::
-
-            name = some.module:some.attr [extra1,extra2]
-
-        The entry name and module name are required, but the ``:attrs`` and
-        ``[extras]`` parts are optional
-        """
-        try:
-            attrs = extras = ()
-            name,value = src.split('=',1)
-            if '[' in value:
-                value,extras = value.split('[',1)
-                req = Requirement.parse("x["+extras)
-                if req.specs: raise ValueError
-                extras = req.extras
-            if ':' in value:
-                value,attrs = value.split(':',1)
-                if not MODULE(attrs.rstrip()):
-                    raise ValueError
-                attrs = attrs.rstrip().split('.')
-        except ValueError:
-            raise ValueError(
-                "EntryPoint must be in 'name=module:attrs [extras]' format",
-                src
-            )
-        else:
-            return cls(name.strip(), value.strip(), attrs, extras, dist)
-
-    @classmethod
-    def parse_group(cls, group, lines, dist=None):
-        """Parse an entry point group"""
-        if not MODULE(group):
-            raise ValueError("Invalid group name", group)
-        this = {}
-        for line in yield_lines(lines):
-            ep = cls.parse(line, dist)
-            if ep.name in this:
-                raise ValueError("Duplicate entry point", group, ep.name)
-            this[ep.name]=ep
-        return this
-
-    @classmethod
-    def parse_map(cls, data, dist=None):
-        """Parse a map of entry point groups"""
-        if isinstance(data,dict):
-            data = data.items()
-        else:
-            data = split_sections(data)
-        maps = {}
-        for group, lines in data:
-            if group is None:
-                if not lines:
-                    continue
-                raise ValueError("Entry points must be listed in groups")
-            group = group.strip()
-            if group in maps:
-                raise ValueError("Duplicate group name", group)
-            maps[group] = cls.parse_group(group, lines, dist)
-        return maps
-

distribute.resources/distribute/resources/environment.py

-
-from distribute.resources.util import get_supported_platform, PY_MAJOR
-from distribute.resources.util import compatible_platforms
-from distribute.resources.exceptions import VersionConflict
-from distribute.resources.providers import find_distributions
-
-def _sort_dists(dists):
-    tmp = [(dist.hashcmp,dist) for dist in dists]
-    tmp.sort()
-    dists[::-1] = [d for hc,d in tmp]
-
-class Environment(object):
-    """Searchable snapshot of distributions on a search path"""
-
-    def __init__(self, search_path=None, platform=get_supported_platform(),
-                 python=PY_MAJOR):
-        """Snapshot distributions available on a search path
-
-        Any distributions found on `search_path` are added to the environment.
-        `search_path` should be a sequence of ``sys.path`` items.  If not
-        supplied, ``sys.path`` is used.
-
-        `platform` is an optional string specifying the name of the platform
-        that platform-specific distributions must be compatible with.  If
-        unspecified, it defaults to the current platform.  `python` is an
-        optional string naming the desired version of Python (e.g. ``'2.4'``);
-        it defaults to the current version.
-
-        You may explicitly set `platform` (and/or `python`) to ``None`` if you
-        wish to map *all* distributions, not just those compatible with the
-        running platform or Python version.
-        """
-        self._distmap = {}
-        self._cache = {}
-        self.platform = platform
-        self.python = python
-        self.scan(search_path)
-
-    def can_add(self, dist):
-        """Is distribution `dist` acceptable for this environment?
-
-        The distribution must match the platform and python version
-        requirements specified when this environment was created, or False
-        is returned.
-        """
-        return (self.python is None or dist.py_version is None
-                or dist.py_version==self.python) \
-                        and compatible_platforms(dist.platform,self.platform)
-
-    def remove(self, dist):
-        """Remove `dist` from the environment"""
-        self._distmap[dist.key].remove(dist)
-
-    def scan(self, search_path=None):
-        """Scan `search_path` for distributions usable in this environment
-
-        Any distributions found are added to the environment.
-        `search_path` should be a sequence of ``sys.path`` items.  If not
-        supplied, ``sys.path`` is used.  Only distributions conforming to
-        the platform/python version defined at initialization are added.
-        """
-        if search_path is None:
-            search_path = sys.path
-
-        for item in search_path:
-            for dist in find_distributions(item):
-                self.add(dist)
-
-    def __getitem__(self,project_name):
-        """Return a newest-to-oldest list of distributions for `project_name`
-        """
-        try:
-            return self._cache[project_name]
-        except KeyError:
-            project_name = project_name.lower()
-            if project_name not in self._distmap:
-                return []
-
-        if project_name not in self._cache:
-            dists = self._cache[project_name] = self._distmap[project_name]
-            _sort_dists(dists)
-
-        return self._cache[project_name]
-
-    def add(self,dist):
-        """Add `dist` if we ``can_add()`` it and it isn't already added"""
-        if self.can_add(dist) and dist.has_version():
-            dists = self._distmap.setdefault(dist.key,[])
-            if dist not in dists:
-                dists.append(dist)
-                if dist.key in self._cache:
-                    _sort_dists(self._cache[dist.key])
-
-    def best_match(self, req, working_set, installer=None):
-        """Find distribution best matching `req` and usable on `working_set`
-
-        This calls the ``find(req)`` method of the `working_set` to see if a
-        suitable distribution is already active.  (This may raise
-        ``VersionConflict`` if an unsuitable version of the project is already
-        active in the specified `working_set`.)  If a suitable distribution
-        isn't active, this method returns the newest distribution in the
-        environment that meets the ``Requirement`` in `req`.  If no suitable
-        distribution is found, and `installer` is supplied, then the result of
-        calling the environment's ``obtain(req, installer)`` method will be
-        returned.
-        """
-        dist = working_set.find(req)
-        if dist is not None:
-            return dist
-        for dist in self[req.key]:
-            if dist in req:
-                return dist
-        return self.obtain(req, installer) # try and download/install
-
-    def obtain(self, requirement, installer=None):
-        """Obtain a distribution matching `requirement` (e.g. via download)
-
-        Obtain a distro that matches requirement (e.g. via download).  In the
-        base ``Environment`` class, this routine just returns
-        ``installer(requirement)``, unless `installer` is None, in which case
-        None is returned instead.  This method is a hook that allows subclasses
-        to attempt other ways of obtaining a distribution before falling back
-        to the `installer` argument."""
-        if installer is not None:
-            return installer(requirement)
-
-    def __iter__(self):
-        """Yield the unique project names of the available distributions"""
-        for key in self._distmap.keys():
-            if self[key]:
-                yield key
-
-    def __iadd__(self, other):
-        """In-place addition of a distribution or environment"""
-        if isinstance(other,Distribution):
-            self.add(other)
-        elif isinstance(other,Environment):
-            for project in other:
-                for dist in other[project]:
-                    self.add(dist)
-        else:
-            raise TypeError("Can't add %r to environment" % (other,))
-        return self
-
-    def __add__(self, other):
-        """Add an environment or distribution to an environment"""
-        new = self.__class__([], platform=None, python=None)
-        for env in self, other:
-            new += env
-        return new
-

distribute.resources/distribute/resources/exceptions.py

-
-class ResolutionError(Exception):
-    """Abstract base for dependency resolution errors"""
-    def __repr__(self):
-        return self.__class__.__name__+repr(self.args)
-
-class VersionConflict(ResolutionError):
-    """An already-installed version conflicts with the requested version"""
-
-class DistributionNotFound(ResolutionError):
-    """A requested distribution was not found"""
-
-class UnknownExtra(ResolutionError):
-    """Distribution doesn't have an "extra feature" of the given name"""
-
-class ExtractionError(RuntimeError):
-    """An error occurred extracting a resource
-
-    The following attributes are available from instances of this exception:
-
-    manager
-        The resource manager that raised this exception
-
-    cache_path
-        The base directory for resource extraction
-
-    original_error
-        The exception instance that caused extraction to fail
-    """
-
-
-

distribute.resources/distribute/resources/manager.py

-
-class ResourceManager:
-    """Manage resource extraction and packages"""
-    extraction_path = None
-
-    def __init__(self):
-        self.cached_files = {}
-
-    def resource_exists(self, package_or_requirement, resource_name):
-        """Does the named resource exist?"""
-        return get_provider(package_or_requirement).has_resource(resource_name)
-
-    def resource_isdir(self, package_or_requirement, resource_name):
-        """Is the named resource an existing directory?"""
-        return get_provider(package_or_requirement).resource_isdir(
-            resource_name
-        )
-
-    def resource_filename(self, package_or_requirement, resource_name):
-        """Return a true filesystem path for specified resource"""
-        return get_provider(package_or_requirement).get_resource_filename(
-            self, resource_name
-        )
-
-    def resource_stream(self, package_or_requirement, resource_name):
-        """Return a readable file-like object for specified resource"""
-        return get_provider(package_or_requirement).get_resource_stream(
-            self, resource_name
-        )
-
-    def resource_string(self, package_or_requirement, resource_name):
-        """Return specified resource as a string"""
-        return get_provider(package_or_requirement).get_resource_string(
-            self, resource_name
-        )
-
-    def resource_listdir(self, package_or_requirement, resource_name):
-        """List the contents of the named resource directory"""
-        return get_provider(package_or_requirement).resource_listdir(
-            resource_name
-        )
-
-    def extraction_error(self):
-        """Give an error message for problems extracting file(s)"""
-
-        old_exc = sys.exc_info()[1]
-        cache_path = self.extraction_path or get_default_cache()
-
-        err = ExtractionError("""Can't extract file(s) to egg cache
-
-The following error occurred while trying to extract file(s) to the Python egg
-cache:
-
-  %s
-
-The Python egg cache directory is currently set to:
-
-  %s
-
-Perhaps your account does not have write access to this directory?  You can
-change the cache directory by setting the PYTHON_EGG_CACHE environment
-variable to point to an accessible directory.
-"""         % (old_exc, cache_path)
-        )
-        err.manager        = self
-        err.cache_path     = cache_path
-        err.original_error = old_exc
-        raise err
-
-    def get_cache_path(self, archive_name, names=()):
-        """Return absolute location in cache for `archive_name` and `names`
-
-        The parent directory of the resulting path will be created if it does
-        not already exist.  `archive_name` should be the base filename of the
-        enclosing egg (which may not be the name of the enclosing zipfile!),
-        including its ".egg" extension.  `names`, if provided, should be a
-        sequence of path name parts "under" the egg's extraction location.
-
-        This method should only be called by resource providers that need to
-        obtain an extraction location, and only for names they intend to
-        extract, as it tracks the generated names for possible cleanup later.
-        """
-        extract_path = self.extraction_path or get_default_cache()
-        target_path = os.path.join(extract_path, archive_name+'-tmp', *names)
-        try:
-            _bypass_ensure_directory(target_path)
-        except:
-            self.extraction_error()
-
-        self.cached_files[target_path] = 1
-        return target_path
-
-    def postprocess(self, tempname, filename):
-        """Perform any platform-specific postprocessing of `tempname`
-
-        This is where Mac header rewrites should be done; other platforms don't
-        have anything special they should do.
-
-        Resource providers should call this method ONLY after successfully
-        extracting a compressed resource.  They must NOT call it on resources
-        that are already in the filesystem.
-
-        `tempname` is the current (temporary) name of the file, and `filename`
-        is the name it will be renamed to by the caller after this routine
-        returns.
-        """
-
-        if os.name == 'posix':
-            # Make the resource executable
-            mode = ((os.stat(tempname).st_mode) | 0555) & 07777
-            os.chmod(tempname, mode)
-
-    def set_extraction_path(self, path):
-        """Set the base path where resources will be extracted to, if needed.
-
-        If you do not call this routine before any extractions take place, the
-        path defaults to the return value of ``get_default_cache()``.  (Which
-        is based on the ``PYTHON_EGG_CACHE`` environment variable, with various
-        platform-specific fallbacks.  See that routine's documentation for more
-        details.)
-
-        Resources are extracted to subdirectories of this path based upon
-        information given by the ``IResourceProvider``.  You may set this to a
-        temporary directory, but then you must call ``cleanup_resources()`` to
-        delete the extracted files when done.  There is no guarantee that
-        ``cleanup_resources()`` will be able to remove all extracted files.
-
-        (Note: you may not change the extraction path for a given resource
-        manager once resources have been extracted, unless you first call
-        ``cleanup_resources()``.)
-        """
-        if self.cached_files:
-            raise ValueError(
-                "Can't change extraction path, files already extracted"
-            )
-
-        self.extraction_path = path
-
-    def cleanup_resources(self, force=False):
-        """
-        Delete all extracted resource files and directories, returning a list
-        of the file and directory names that could not be successfully removed.
-        This function does not have any concurrency protection, so it should
-        generally only be called when the extraction path is a temporary
-        directory exclusive to a single process.  This method is not
-        automatically called; you must call it explicitly or register it as an
-        ``atexit`` function if you wish to ensure cleanup of a temporary
-        directory used for extractions.
-        """
-        # XXX
-

distribute.resources/distribute/resources/namespace.py

-import zipimport
-import imp
-import sys
-import os
-
-from pkgutil import get_importer, ImpImporter
-from distribute.resources.util import find_adapter, normalize_cached
-
-_namespace_handlers = {}
-_namespace_packages = {}
-
-def register_namespace_handler(importer_type, namespace_handler):
-    """Register `namespace_handler` to declare namespace packages
-
-    `importer_type` is the type or class of a PEP 302 "Importer" (sys.path item
-    handler), and `namespace_handler` is a callable like this::
-
-        def namespace_handler(importer,path_entry,moduleName,module):
-            # return a path_entry to use for child packages
-
-    Namespace handlers are only called if the importer object has already
-    agreed that it can handle the relevant path item, and they should only
-    return a subpath if the module __path__ does not already contain an
-    equivalent subpath.  For an example namespace handler, see
-    ``pkg_resources.file_ns_handler``.
-    """
-    _namespace_handlers[importer_type] = namespace_handler
-
-def _handle_ns(packageName, path_item):
-    """Ensure that named package includes a subpath of path_item (if needed)"""
-    importer = get_importer(path_item)
-    if importer is None:
-        return None
-    loader = importer.find_module(packageName)
-    if loader is None:
-        return None
-    module = sys.modules.get(packageName)
-    if module is None:
-        module = sys.modules[packageName] = ModuleType(packageName)
-        module.__path__ = []; _set_parent_ns(packageName)
-    elif not hasattr(module,'__path__'):
-        raise TypeError("Not a package:", packageName)
-    handler = find_adapter(_namespace_handlers, importer)
-    subpath = handler(importer,path_item,packageName,module)
-    if subpath is not None:
-        path = module.__path__; path.append(subpath)
-        loader.load_module(packageName); module.__path__ = path
-    return subpath
-
-def declare_namespace(packageName):
-    """Declare that package 'packageName' is a namespace package"""
-
-    imp.acquire_lock()
-    try:
-        if packageName in _namespace_packages:
-            return
-
-        path, parent = sys.path, None
-        if '.' in packageName:
-            parent = '.'.join(packageName.split('.')[:-1])
-            declare_namespace(parent)
-            __import__(parent)
-            try:
-                path = sys.modules[parent].__path__
-            except AttributeError:
-                raise TypeError("Not a package:", parent)
-
-        # Track what packages are namespaces, so when new path items are added,
-        # they can be updated
-        _namespace_packages.setdefault(parent,[]).append(packageName)
-        _namespace_packages.setdefault(packageName,[])
-
-        for path_item in path:
-            # Ensure all the parent's path items are reflected in the child,
-            # if they apply
-            _handle_ns(packageName, path_item)
-
-    finally:
-        imp.release_lock()
-
-def fixup_namespace_packages(path_item, parent=None):
-    """Ensure that previously-declared namespace packages include path_item"""
-    imp.acquire_lock()
-    try:
-        for package in _namespace_packages.get(parent,()):
-            subpath = _handle_ns(package, path_item)
-            if subpath: fixup_namespace_packages(subpath,package)
-    finally:
-        imp.release_lock()
-
-def file_ns_handler(importer, path_item, packageName, module):
-    """Compute an ns-package subpath for a filesystem or zipfile importer"""
-
-    subpath = os.path.join(path_item, packageName.split('.')[-1])
-    normalized = normalize_cached(subpath)
-    for item in module.__path__:
-        if normalize_cached(item)==normalized:
-            break
-    else:
-        # Only return the path if it's not already there
-        return subpath
-
-register_namespace_handler(ImpImporter, file_ns_handler)
-register_namespace_handler(zipimport.zipimporter,file_ns_handler)
-
-
-def null_ns_handler(importer, path_item, packageName, module):
-    return None
-
-register_namespace_handler(object,null_ns_handler)
-
-def _set_parent_ns(packageName):
-    parts = packageName.split('.')
-    name = parts.pop()
-    if parts:
-        parent = '.'.join(parts)
-        setattr(sys.modules[parent], name, sys.modules[packageName])
-

distribute.resources/distribute/resources/providers.py

-
-__all__ = ['IMetadataProvider', 'IResourceProvider', 'FileMetadata',
-           'PathMetadata', 'EggMetadata', 'EmptyProvider', 'empty_provider',
-           'NullProvider', 'EggProvider', 'DefaultProvider', 'ZipProvider',
-           'register_finder', 'register_namespace_handler',
-           'register_loader_type', 'fixup_namespace_packages', 'get_importer']
-
-_provider_factories = {}
-
-import os
-import zipimport
-
-from pkgutil import get_importer, ImpImporter
-from distribute.resources.util import normalize_path
-from distribute.resources.dist import Distribution, DEVELOP_DIST
-from distribute.resources.util import normalize_cached, yield_lines
-from distribute.resources.util import find_adapter
-
-
-def register_loader_type(loader_type, provider_factory):
-    """Register `provider_factory` to make providers for `loader_type`
-
-    `loader_type` is the type or class of a PEP 302 ``module.__loader__``,
-    and `provider_factory` is a function that, passed a *module* object,
-    returns an ``IResourceProvider`` for that module.
-    """
-    _provider_factories[loader_type] = provider_factory
-
-
-class IMetadataProvider:
-
-    def has_metadata(name):
-        """Does the package's distribution contain the named metadata?"""
-
-    def get_metadata(name):
-        """The named metadata resource as a string"""
-
-    def get_metadata_lines(name):
-        """Yield named metadata resource as list of non-blank non-comment lines
-
-       Leading and trailing whitespace is stripped from each line, and lines
-       with ``#`` as the first non-blank character are omitted."""
-
-    def metadata_isdir(name):
-        """Is the named metadata a directory?  (like ``os.path.isdir()``)"""
-
-    def metadata_listdir(name):
-        """List of metadata names in the directory (like ``os.listdir()``)"""
-
-    def run_script(script_name, namespace):
-        """Execute the named script in the supplied namespace dictionary"""
-
-class IResourceProvider(IMetadataProvider):
-    """An object that provides access to package resources"""
-
-    def get_resource_filename(manager, resource_name):
-        """Return a true filesystem path for `resource_name`
-
-        `manager` must be an ``IResourceManager``"""
-
-    def get_resource_stream(manager, resource_name):
-        """Return a readable file-like object for `resource_name`
-
-        `manager` must be an ``IResourceManager``"""
-
-    def get_resource_string(manager, resource_name):
-        """Return a string containing the contents of `resource_name`
-
-        `manager` must be an ``IResourceManager``"""
-
-    def has_resource(resource_name):
-        """Does the package contain the named resource?"""
-
-    def resource_isdir(resource_name):
-        """Is the named resource a directory?  (like ``os.path.isdir()``)"""
-
-    def resource_listdir(resource_name):
-        """List of resource names in the directory (like ``os.listdir()``)"""
-
-class NullProvider:
-    """Try to implement resources and metadata for arbitrary PEP 302 loaders"""
-
-    egg_name = None
-    egg_info = None
-    loader = None
-
-    def __init__(self, module):
-        self.loader = getattr(module, '__loader__', None)
-        self.module_path = os.path.dirname(getattr(module, '__file__', ''))
-
-    def get_resource_filename(self, manager, resource_name):
-        return self._fn(self.module_path, resource_name)
-
-    def get_resource_stream(self, manager, resource_name):
-        return StringIO(self.get_resource_string(manager, resource_name))
-
-    def get_resource_string(self, manager, resource_name):
-        return self._get(self._fn(self.module_path, resource_name))
-
-    def has_resource(self, resource_name):
-        return self._has(self._fn(self.module_path, resource_name))
-
-    def has_metadata(self, name):
-        return self.egg_info and self._has(self._fn(self.egg_info,name))
-
-    def get_metadata(self, name):
-        if not self.egg_info:
-            return ""
-        metadata = self._get(self._fn(self.egg_info,name))
-        if not isinstance(metadata, str):
-            return metadata.decode()        # convert binary to string for py3k
-        return metadata
-
-    def get_metadata_lines(self, name):
-        return yield_lines(self.get_metadata(name))
-
-    def resource_isdir(self,resource_name):
-        return self._isdir(self._fn(self.module_path, resource_name))
-
-    def metadata_isdir(self,name):
-        return self.egg_info and self._isdir(self._fn(self.egg_info,name))