Commit d7585451 authored by Kenneth Reitz's avatar Kenneth Reitz

new distribute

parent 5935632b
......@@ -149,8 +149,8 @@ if [ ! "$SKIP_INSTALL" ]; then
# Prepare it for the real world
which python
puts-step "Installing Distribute (0.6.32)"
cd $ROOT_DIR/vendor/distribute-0.6.32/
puts-step "Installing Distribute (0.6.34)"
cd $ROOT_DIR/vendor/distribute-0.6.34/
python install # &> /dev/null
......@@ -197,13 +197,14 @@ done
# Set context environment variables.
set-env PATH '$HOME/.heroku/python/bin:$PATH'
set-env PYTHONHOME /app/.heroku/python/
# set-env PYTHONHOME /app/.heroku/python/
set-default-env LIBRARY_PATH /app/.heroku/vendor/lib
set-default-env LD_LIBRARY_PATH /app/.heroku/vendor/lib
set-default-env LANG en_US.UTF-8
set-default-env PYTHONHASHSEED random
set-default-env PYTHONPATH /app/
un-set-env PYTHONHOME
# ### Fin.
......@@ -36,6 +36,11 @@ function set-default-env (){
echo "export $1=\${$1:-$2}" >> $PROFILE_PATH
# Usage: $ set-default-env key value
function un-set-env (){
echo "unset $1" >> $PROFILE_PATH
# Does some serious copying.
function deep-cp (){
find -H $1 -maxdepth 1 -name '.*' -a \( -type d -o -type f -o -type l \) -exec cp -a '{}' $2 \;
This diff is collapsed.
* Alex Grönholm
* Alice Bevan-McGregor
* Arfrever Frehtes Taifersar Arahesis
* Christophe Combelles
* Daniel Stutzbach
* Daniel Holth
* Hanno Schlichting
* Jannis Leidel
* Jason R. Coombs
* Jim Fulton
* Jonathan Lange
* Justin Azoff
* Lennart Regebro
* Marc Abramowitz
* Martin von Löwis
* Noufal Ibrahim
* Pete Hollobon
* Philip Jenvey
* Reinout van Rees
* Robert Myers
* Stefan H. Holek
* 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
If you want to contribute changes, we recommend you fork the repository on
bitbucket, commit the changes to your repository, and then make a pull request
on bitbucket. If you make some changes, don't forget to:
- add a note in CHANGES.txt
And remember that 0.6 (the only development line) is only bug fixes, and the
APIs should be fully backward compatible with Setuptools.
You can run the tests via::
$ python 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
recursive-include _markerlib *.py
include *.py
include *.txt
include launcher.c
This diff is collapsed.
Installing and Using Distribute
.. contents:: **Table of Contents**
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 for more
- 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 : ``.
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 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 ```` script provided online.
```` is the simplest and preferred way on all systems.
` <>`_
and execute it, using the Python interpreter of your choice.
If your shell has the ``curl`` program you can do::
$ curl -O
$ python
Notice this file is also provided in the source release.
Run easy_install or pip::
$ pip install distribute
Source installation
Download the source tarball, uncompress it, then run the install command::
$ curl -O
$ tar -xzvf distribute-0.6.32.tar.gz
$ cd distribute-0.6.32
$ python 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.
- 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
To use `pkg_resources` to access data files in the egg, you should
require the Setuptools distribution explicitly::
from setuptools import setup
Only if you need Distribute-specific functionality should you depend
on it explicitly. In this case, replace the Setuptools dependency::
from setuptools import setup
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 --distribute
For previous zc.buildout versions, *the only thing* you need to do
is use the bootstrap at ``. 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
Feedback and getting involved
- Mailing list:
- Issue tracker:
- Code Repository:
import ast
from _markerlib.markers import default_environment, compile, interpret
except ImportError:
if 'ast' in globals():
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)()
# -*- coding: utf-8 -*-
"""Interpret PEP 345 environment markers.
EXPR [in|==|!=|not in] EXPR [or|and] ...
where EXPR belongs to any of those:
python_version = '%s.%s' % (sys.version_info[0], sys.version_info[1])
python_full_version = sys.version.split()[0] =
sys.platform = sys.platform
platform.version = platform.version()
platform.machine = platform.machine()
platform.python_implementation = platform.python_implementation()
a free string, like '2.6', or 'win32'
__all__ = ['default_environment', 'compile', 'interpret']
import ast
import os
import platform
import sys
import weakref
_builtin_compile = compile
from platform import python_implementation
# restricted set of variables
_VARS = {'sys.platform': sys.platform,
'python_version': '%s.%s' % sys.version_info[:2],
# FIXME 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],
'platform.version': platform.version(),
'platform.machine': platform.machine(),
'platform.python_implementation': python_implementation(),
'extra': None # wheel extension
def default_environment():
"""Return copy of default PEP 385 globals dictionary."""
return dict(_VARS)
class ASTWhitelist(ast.NodeTransformer):
def __init__(self, statement):
self.statement = statement # for error messages
ALLOWED = (ast.Compare, ast.BoolOp, ast.Attribute, ast.Name, ast.Load, ast.Str)
# Bool operations
ALLOWED += (ast.And, ast.Or)
# Comparison operations
ALLOWED += (ast.Eq, ast.Gt, ast.GtE, ast.In, ast.Is, ast.IsNot, ast.Lt, ast.LtE, ast.NotEq, ast.NotIn)
def visit(self, node):
"""Ensure statement only contains allowed nodes."""
if not isinstance(node, self.ALLOWED):
raise SyntaxError('Not allowed in environment markers.\n%s\n%s' %
(' ' * node.col_offset) + '^'))
return ast.NodeTransformer.visit(self, node)
def visit_Attribute(self, node):
"""Flatten one level of attribute access."""
new_node = ast.Name("%s.%s" % (, node.attr), node.ctx)
return ast.copy_location(new_node, node)
def parse_marker(marker):
tree = ast.parse(marker, mode='eval')
new_tree = ASTWhitelist(marker).generic_visit(tree)
return new_tree
def compile_marker(parsed_marker):
return _builtin_compile(parsed_marker, '<environment marker>', 'eval',
_cache = weakref.WeakValueDictionary()
def compile(marker):
"""Return compiled marker as a function accepting an environment dict."""
return _cache[marker]
except KeyError:
if not marker.strip():
def marker_fn(environment=None, override=None):
return True
compiled_marker = compile_marker(parse_marker(marker))
def marker_fn(environment=None, override=None):
"""override updates environment"""
if override is None:
override = {}
if environment is None:
environment = default_environment()
return eval(compiled_marker, environment)
marker_fn.__doc__ = marker
_cache[marker] = marker_fn
return _cache[marker]
def interpret(marker, environment=None):
return compile(marker)(environment)
This diff is collapsed.
# Makefile for Sphinx documentation
# You can set these variables from the command line.
SPHINXBUILD = sphinx-build
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
.PHONY: help clean html web pickle htmlhelp latex changes linkcheck
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " changes to make an overview over all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
-rm -rf build/*
mkdir -p build/html build/doctrees
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html
@echo "Build finished. The HTML pages are in build/html."
mkdir -p build/pickle build/doctrees
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) build/pickle
@echo "Build finished; now you can process the pickle files."
web: pickle
mkdir -p build/json build/doctrees
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) build/json
@echo "Build finished; now you can process the JSON files."
mkdir -p build/htmlhelp build/doctrees
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) build/htmlhelp
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in build/htmlhelp."
mkdir -p build/latex build/doctrees
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex
@echo "Build finished; the LaTeX files are in build/latex."
@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
"run these through (pdf)latex."
mkdir -p build/changes build/doctrees
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) build/changes
@echo "The overview file is in build/changes."
mkdir -p build/linkcheck build/doctrees
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) build/linkcheck
@echo "Link check complete; look for any errors in the above output " \
"or in build/linkcheck/output.txt."
<p>Current version: <b>{{ version }}</b></p>
<p>Get Distribute from the <a href=""> Python Package Index</a>
<h3>Questions? Suggestions? Contributions?</h3>
<p>Visit the <a href="">Distribute project page</a> </p>
* 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;
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;