зеркало из https://github.com/mozilla/gecko-dev.git
Bug 914500 - Upgrade virtualenv to 1.10.1; r=mshal
This commit is contained in:
Родитель
c22783c523
Коммит
099b5e4a15
|
@ -9,7 +9,9 @@ Maintainers
|
|||
Brian Rosner
|
||||
Carl Meyer
|
||||
Jannis Leidel
|
||||
Paul Moore
|
||||
Paul Nasrat
|
||||
Marcus Smith
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
@ -17,42 +19,73 @@ Contributors
|
|||
Alex Grönholm
|
||||
Anatoly Techtonik
|
||||
Antonio Cuni
|
||||
Antonio Valentino
|
||||
Armin Ronacher
|
||||
Barry Warsaw
|
||||
Benjamin Root
|
||||
Bradley Ayers
|
||||
Branden Rolston
|
||||
Brandon Carl
|
||||
Brian Kearns
|
||||
Cap Petschulat
|
||||
CBWhiz
|
||||
Chris Adams
|
||||
Chris McDonough
|
||||
Christos Kontas
|
||||
Christian Hudon
|
||||
Christian Stefanescu
|
||||
Christopher Nilsson
|
||||
Cliff Xuan
|
||||
Curt Micol
|
||||
Damien Nozay
|
||||
Dan Sully
|
||||
Daniel Hahler
|
||||
Daniel Holth
|
||||
David Schoonover
|
||||
Denis Costa
|
||||
Doug Hellmann
|
||||
Doug Napoleone
|
||||
Douglas Creager
|
||||
Eduard-Cristian Stefan
|
||||
Erik M. Bray
|
||||
Ethan Jucovy
|
||||
Gabriel de Perthuis
|
||||
Gunnlaugur Thor Briem
|
||||
Graham Dennis
|
||||
Greg Haskins
|
||||
Jason Penney
|
||||
Jason R. Coombs
|
||||
Jeff Hammel
|
||||
Jeremy Orem
|
||||
Jason Penney
|
||||
Jason R. Coombs
|
||||
John Kleint
|
||||
Jonathan Griffin
|
||||
Jonathan Hitchcock
|
||||
Jorge Vargas
|
||||
Josh Bronson
|
||||
Kamil Kisiel
|
||||
Kyle Gibson
|
||||
Konstantin Zemlyak
|
||||
Kumar McMillan
|
||||
Lars Francke
|
||||
Marc Abramowitz
|
||||
Mika Laitio
|
||||
Mike Hommey
|
||||
Miki Tebeka
|
||||
Paul Moore
|
||||
Philip Jenvey
|
||||
Philippe Ombredanne
|
||||
Piotr Dobrogost
|
||||
Preston Holmes
|
||||
Ralf Schmitt
|
||||
Raul Leal
|
||||
Ronny Pfannschmidt
|
||||
Satrajit Ghosh
|
||||
Sergio de Carvalho
|
||||
Stefano Rivera
|
||||
Tarek Ziadé
|
||||
Thomas Aglassinger
|
||||
Vinay Sajip
|
||||
Vitaly Babiy
|
||||
Vladimir Rutsky
|
||||
Wang Xuerui
|
|
@ -1,6 +1,6 @@
|
|||
Copyright (c) 2007 Ian Bicking and Contributors
|
||||
Copyright (c) 2009 Ian Bicking, The Open Planning Project
|
||||
Copyright (c) 2011-2012 The virtualenv developers
|
||||
Copyright (c) 2011-2013 The virtualenv developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Metadata-Version: 1.1
|
||||
Name: virtualenv
|
||||
Version: 1.8.4
|
||||
Version: 1.10.1
|
||||
Summary: Virtual Python Environment builder
|
||||
Home-page: http://www.virtualenv.org
|
||||
Author: Jannis Leidel, Carl Meyer and Brian Rosner
|
||||
|
@ -8,28 +8,15 @@ Author-email: python-virtualenv@groups.google.com
|
|||
License: MIT
|
||||
Description:
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
You can install virtualenv with ``pip install virtualenv``, or the `latest
|
||||
development version <https://github.com/pypa/virtualenv/tarball/develop>`_
|
||||
with ``pip install https://github.com/pypa/virtualenv/tarball/develop``.
|
||||
|
||||
You can also use ``easy_install``, or if you have no Python package manager
|
||||
available at all, you can just grab the single file `virtualenv.py`_ and run
|
||||
it with ``python virtualenv.py``.
|
||||
|
||||
.. _virtualenv.py: https://raw.github.com/pypa/virtualenv/master/virtualenv.py
|
||||
|
||||
What It Does
|
||||
------------
|
||||
|
||||
``virtualenv`` is a tool to create isolated Python environments.
|
||||
|
||||
The basic problem being addressed is one of dependencies and versions,
|
||||
and indirectly permissions. Imagine you have an application that
|
||||
and indirectly permissions. Imagine you have an application that
|
||||
needs version 1 of LibFoo, but another application requires version
|
||||
2. How can you use both these applications? If you install
|
||||
2. How can you use both these applications? If you install
|
||||
everything into ``/usr/lib/python2.7/site-packages`` (or whatever your
|
||||
platform's standard location is), it's easy to end up in a situation
|
||||
where you unintentionally upgrade an application that shouldn't be
|
||||
|
@ -42,39 +29,99 @@ Description:
|
|||
Also, what if you can't install packages into the global
|
||||
``site-packages`` directory? For instance, on a shared host.
|
||||
|
||||
In all these cases, ``virtualenv`` can help you. It creates an
|
||||
In all these cases, ``virtualenv`` can help you. It creates an
|
||||
environment that has its own installation directories, that doesn't
|
||||
share libraries with other virtualenv environments (and optionally
|
||||
doesn't access the globally installed libraries either).
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
.. warning::
|
||||
|
||||
We advise installing virtualenv-1.9 or greater. Prior to version 1.9, the
|
||||
pip included in virtualenv did not not download from PyPI over SSL.
|
||||
|
||||
.. warning::
|
||||
|
||||
When using pip to install virtualenv, we advise using pip 1.3 or greater.
|
||||
Prior to version 1.3, pip did not not download from PyPI over SSL.
|
||||
|
||||
.. warning::
|
||||
|
||||
We advise against using easy_install to install virtualenv when using
|
||||
setuptools < 0.9.7, because easy_install didn't download from PyPI over SSL
|
||||
and was broken in some subtle ways.
|
||||
|
||||
To install globally with `pip` (if you have pip 1.3 or greater installed globally):
|
||||
|
||||
::
|
||||
|
||||
$ [sudo] pip install virtualenv
|
||||
|
||||
Or to get the latest unreleased dev version:
|
||||
|
||||
::
|
||||
|
||||
$ [sudo] pip install https://github.com/pypa/virtualenv/tarball/develop
|
||||
|
||||
|
||||
To install globally from source:
|
||||
|
||||
::
|
||||
|
||||
$ curl -O https://pypi.python.org/packages/source/v/virtualenv/virtualenv-X.X.tar.gz
|
||||
$ tar xvfz virtualenv-X.X.tar.gz
|
||||
$ cd virtualenv-X.X
|
||||
$ [sudo] python setup.py install
|
||||
|
||||
|
||||
To *use* locally from source:
|
||||
|
||||
::
|
||||
|
||||
$ curl -O https://pypi.python.org/packages/source/v/virtualenv/virtualenv-X.X.tar.gz
|
||||
$ tar xvfz virtualenv-X.X.tar.gz
|
||||
$ cd virtualenv-X.X
|
||||
$ python virtualenv.py myVE
|
||||
|
||||
.. note::
|
||||
|
||||
The ``virtualenv.py`` script is *not* supported if run without the
|
||||
necessary pip/setuptools/virtualenv distributions available locally. All
|
||||
of the installation methods above include a ``virtualenv_support``
|
||||
directory alongside ``virtualenv.py`` which contains a complete set of
|
||||
pip and setuptools distributions, and so are fully supported.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
The basic usage is::
|
||||
|
||||
$ python virtualenv.py ENV
|
||||
|
||||
If you install it you can also just do ``virtualenv ENV``.
|
||||
$ virtualenv ENV
|
||||
|
||||
This creates ``ENV/lib/pythonX.X/site-packages``, where any libraries you
|
||||
install will go. It also creates ``ENV/bin/python``, which is a Python
|
||||
interpreter that uses this environment. Anytime you use that interpreter
|
||||
install will go. It also creates ``ENV/bin/python``, which is a Python
|
||||
interpreter that uses this environment. Anytime you use that interpreter
|
||||
(including when a script has ``#!/path/to/ENV/bin/python`` in it) the libraries
|
||||
in that environment will be used.
|
||||
|
||||
It also installs either `Setuptools
|
||||
<http://peak.telecommunity.com/DevCenter/setuptools>`_ or `distribute
|
||||
<http://pypi.python.org/pypi/distribute>`_ into the environment. To use
|
||||
Distribute instead of setuptools, just call virtualenv like this::
|
||||
<http://peak.telecommunity.com/DevCenter/setuptools>`_ into the environment.
|
||||
|
||||
$ python virtualenv.py --distribute ENV
|
||||
.. note::
|
||||
|
||||
You can also set the environment variable VIRTUALENV_DISTRIBUTE.
|
||||
Virtualenv (<1.10) used to provide a ``--distribute`` option to use the
|
||||
setuptools fork Distribute_. Since Distribute has been merged back into
|
||||
setuptools this option is now no-op, it will always use the improved
|
||||
setuptools releases.
|
||||
|
||||
A new virtualenv also includes the `pip <http://pypi.python.org/pypi/pip>`_
|
||||
installer, so you can use ``ENV/bin/pip`` to install additional packages into
|
||||
the environment.
|
||||
|
||||
.. _Distribute: https://pypi.python.org/pypi/distribute
|
||||
|
||||
activate script
|
||||
~~~~~~~~~~~~~~~
|
||||
|
@ -88,10 +135,10 @@ Description:
|
|||
$ source bin/activate
|
||||
|
||||
This will change your ``$PATH`` so its first entry is the virtualenv's
|
||||
``bin/`` directory. (You have to use ``source`` because it changes your
|
||||
``bin/`` directory. (You have to use ``source`` because it changes your
|
||||
shell environment in-place.) This is all it does; it's purely a
|
||||
convenience. If you directly run a script or the python interpreter
|
||||
from the virtualenv's ``bin/`` directory (e.g. ``path/to/env/bin/pip``
|
||||
convenience. If you directly run a script or the python interpreter
|
||||
from the virtualenv's ``bin/`` directory (e.g. ``path/to/env/bin/pip``
|
||||
or ``/path/to/env/bin/python script.py``) there's no need for
|
||||
activation.
|
||||
|
||||
|
@ -99,9 +146,9 @@ Description:
|
|||
undo the changes to your ``$PATH``.
|
||||
|
||||
The ``activate`` script will also modify your shell prompt to indicate
|
||||
which environment is currently active. You can disable this behavior,
|
||||
which environment is currently active. You can disable this behavior,
|
||||
which can be useful if you have your own custom prompt that already
|
||||
displays the active environment name. To do so, set the
|
||||
displays the active environment name. To do so, set the
|
||||
``VIRTUAL_ENV_DISABLE_PROMPT`` environment variable to any non-empty
|
||||
value before running the ``activate`` script.
|
||||
|
||||
|
@ -175,7 +222,7 @@ Description:
|
|||
(or wherever your global site-packages directory is).
|
||||
|
||||
This can be used if you have control over the global site-packages directory,
|
||||
and you want to depend on the packages there. If you want isolation from the
|
||||
and you want to depend on the packages there. If you want isolation from the
|
||||
global system, do not use this flag.
|
||||
|
||||
|
||||
|
@ -183,7 +230,7 @@ Description:
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
virtualenv can not only be configured by passing command line options such as
|
||||
``--distribute`` but also by two other means:
|
||||
``--python`` but also by two other means:
|
||||
|
||||
- Environment variables
|
||||
|
||||
|
@ -192,15 +239,15 @@ Description:
|
|||
the name of the command line options are capitalized and have dashes
|
||||
(``'-'``) replaced with underscores (``'_'``).
|
||||
|
||||
For example, to automatically install Distribute instead of setuptools
|
||||
you can also set an environment variable::
|
||||
For example, to automatically use a custom Python binary instead of the
|
||||
one virtualenv is run with you can also set an environment variable::
|
||||
|
||||
$ export VIRTUALENV_DISTRIBUTE=true
|
||||
$ python virtualenv.py ENV
|
||||
$ export VIRTUALENV_PYTHON=/opt/python-3.3/bin/python
|
||||
$ virtualenv ENV
|
||||
|
||||
It's the same as passing the option to virtualenv directly::
|
||||
|
||||
$ python virtualenv.py --distribute ENV
|
||||
$ virtualenv --python=/opt/python-3.3/bin/python ENV
|
||||
|
||||
This also works for appending command line options, like ``--find-links``.
|
||||
Just leave an empty space between the passsed values, e.g.::
|
||||
|
@ -210,7 +257,7 @@ Description:
|
|||
|
||||
is the same as calling::
|
||||
|
||||
$ python virtualenv.py --extra-search-dir=/path/to/dists --extra-search-dir=/path/to/other/dists ENV
|
||||
$ virtualenv --extra-search-dir=/path/to/dists --extra-search-dir=/path/to/other/dists ENV
|
||||
|
||||
- Config files
|
||||
|
||||
|
@ -219,10 +266,10 @@ Description:
|
|||
``%APPDATA%\virtualenv\virtualenv.ini``.
|
||||
|
||||
The names of the settings are derived from the long command line option,
|
||||
e.g. the option ``--distribute`` would look like this::
|
||||
e.g. the option ``--python`` would look like this::
|
||||
|
||||
[virtualenv]
|
||||
distribute = true
|
||||
python = /opt/python-3.3/bin/python
|
||||
|
||||
Appending options like ``--extra-search-dir`` can be written on multiple
|
||||
lines::
|
||||
|
@ -256,20 +303,20 @@ Description:
|
|||
-----------------------------------
|
||||
|
||||
While this creates an environment, it doesn't put anything into the
|
||||
environment. Developers may find it useful to distribute a script
|
||||
environment. Developers may find it useful to distribute a script
|
||||
that sets up a particular environment, for example a script that
|
||||
installs a particular web application.
|
||||
|
||||
To create a script like this, call
|
||||
``virtualenv.create_bootstrap_script(extra_text)``, and write the
|
||||
result to your new bootstrapping script. Here's the documentation
|
||||
result to your new bootstrapping script. Here's the documentation
|
||||
from the docstring:
|
||||
|
||||
Creates a bootstrap script, which is like this script but with
|
||||
extend_parser, adjust_options, and after_install hooks.
|
||||
|
||||
This returns a string that (written to disk of course) can be used
|
||||
as a bootstrap script with your own customizations. The script
|
||||
as a bootstrap script with your own customizations. The script
|
||||
will be the standard virtualenv.py script, with your extra text
|
||||
added (your extra text should be Python code).
|
||||
|
||||
|
@ -285,8 +332,8 @@ Description:
|
|||
|
||||
``after_install(options, home_dir)``:
|
||||
|
||||
After everything is installed, this function is called. This
|
||||
is probably the function you are most likely to use. An
|
||||
After everything is installed, this function is called. This
|
||||
is probably the function you are most likely to use. An
|
||||
example would be::
|
||||
|
||||
def after_install(options, home_dir):
|
||||
|
@ -332,23 +379,23 @@ Description:
|
|||
---------------------------------------
|
||||
|
||||
Sometimes you can't or don't want to use the Python interpreter
|
||||
created by the virtualenv. For instance, in a `mod_python
|
||||
created by the virtualenv. For instance, in a `mod_python
|
||||
<http://www.modpython.org/>`_ or `mod_wsgi <http://www.modwsgi.org/>`_
|
||||
environment, there is only one interpreter.
|
||||
|
||||
Luckily, it's easy. You must use the custom Python interpreter to
|
||||
*install* libraries. But to *use* libraries, you just have to be sure
|
||||
the path is correct. A script is available to correct the path. You
|
||||
Luckily, it's easy. You must use the custom Python interpreter to
|
||||
*install* libraries. But to *use* libraries, you just have to be sure
|
||||
the path is correct. A script is available to correct the path. You
|
||||
can setup the environment like::
|
||||
|
||||
activate_this = '/path/to/env/bin/activate_this.py'
|
||||
execfile(activate_this, dict(__file__=activate_this))
|
||||
|
||||
This will change ``sys.path`` and even change ``sys.prefix``, but also allow
|
||||
you to use an existing interpreter. Items in your environment will show up
|
||||
first on ``sys.path``, before global items. However, global items will
|
||||
you to use an existing interpreter. Items in your environment will show up
|
||||
first on ``sys.path``, before global items. However, global items will
|
||||
always be accessible (as if the ``--system-site-packages`` flag had been used
|
||||
in creating the environment, whether it was or not). Also, this cannot undo
|
||||
in creating the environment, whether it was or not). Also, this cannot undo
|
||||
the activation of other environments, or modules that have been imported.
|
||||
You shouldn't try to, for instance, activate an environment before a web
|
||||
request; you should activate *one* environment as early as possible, and not
|
||||
|
@ -358,29 +405,39 @@ Description:
|
|||
-------------------------------
|
||||
|
||||
Note: this option is somewhat experimental, and there are probably
|
||||
caveats that have not yet been identified. Also this does not
|
||||
currently work on Windows.
|
||||
caveats that have not yet been identified.
|
||||
|
||||
Normally environments are tied to a specific path. That means that
|
||||
.. warning::
|
||||
|
||||
The ``--relocatable`` option currently has a number of issues,
|
||||
and is not guaranteed to work in all circumstances. It is possible
|
||||
that the option will be deprecated in a future version of ``virtualenv``.
|
||||
|
||||
Normally environments are tied to a specific path. That means that
|
||||
you cannot move an environment around or copy it to another computer.
|
||||
You can fix up an environment to make it relocatable with the
|
||||
command::
|
||||
|
||||
$ virtualenv --relocatable ENV
|
||||
|
||||
This will make some of the files created by setuptools or distribute
|
||||
use relative paths, and will change all the scripts to use ``activate_this.py``
|
||||
instead of using the location of the Python interpreter to select the
|
||||
environment.
|
||||
This will make some of the files created by setuptools use relative paths,
|
||||
and will change all the scripts to use ``activate_this.py`` instead of using
|
||||
the location of the Python interpreter to select the environment.
|
||||
|
||||
**Note:** scripts which have been made relocatable will only work if
|
||||
the virtualenv is activated, specifically the python executable from
|
||||
the virtualenv must be the first one on the system PATH. Also note that
|
||||
the activate scripts are not currently made relocatable by
|
||||
``virtualenv --relocatable``.
|
||||
|
||||
**Note:** you must run this after you've installed *any* packages into
|
||||
the environment. If you make an environment relocatable, then
|
||||
the environment. If you make an environment relocatable, then
|
||||
install a new package, you must run ``virtualenv --relocatable``
|
||||
again.
|
||||
|
||||
Also, this **does not make your packages cross-platform**. You can
|
||||
Also, this **does not make your packages cross-platform**. You can
|
||||
move the directory around, but it can only be used on other similar
|
||||
computers. Some known environmental differences that can cause
|
||||
computers. Some known environmental differences that can cause
|
||||
incompatibilities: a different version of Python, when one platform
|
||||
uses UCS2 for its internal unicode representation and another uses
|
||||
UCS4 (a compile-time option), obvious platform changes like Windows
|
||||
|
@ -395,50 +452,38 @@ Description:
|
|||
The ``--extra-search-dir`` option
|
||||
---------------------------------
|
||||
|
||||
When it creates a new environment, virtualenv installs either setuptools
|
||||
or distribute, and pip. In normal operation when virtualenv is
|
||||
installed, the bundled version of these packages included in the
|
||||
``virtualenv_support`` directory is used. When ``virtualenv.py`` is run
|
||||
standalone and ``virtualenv_support`` is not available, the latest
|
||||
releases of these packages are fetched from the `Python Package Index
|
||||
<http://pypi.python.org>`_ (PyPI).
|
||||
.. note::
|
||||
|
||||
As an alternative, you can provide your own versions of setuptools,
|
||||
distribute and/or pip on the filesystem, and tell virtualenv to use
|
||||
those distributions instead of downloading them from the Internet. To
|
||||
use this feature, pass one or more ``--extra-search-dir`` options to
|
||||
Currently, this feature only partially works for pip, and not at
|
||||
all for setuptools. For details,
|
||||
see `Issue #327 <https://github.com/pypa/virtualenv/issues/327>`_
|
||||
|
||||
This option allows you to provide your own versions of setuptools
|
||||
and/or pip on the filesystem, and tell virtualenv to use those distributions
|
||||
instead of the ones in ``virtualenv_support``.
|
||||
|
||||
To use this feature, pass one or more ``--extra-search-dir`` options to
|
||||
virtualenv like this::
|
||||
|
||||
$ virtualenv --extra-search-dir=/path/to/distributions ENV
|
||||
|
||||
The ``/path/to/distributions`` path should point to a directory that
|
||||
contains setuptools, distribute and/or pip distributions. Setuptools
|
||||
distributions must be ``.egg`` files; pip distributions should be
|
||||
`.tar.gz` source distributions, and distribute distributions may be
|
||||
either (if found an egg will be used preferentially).
|
||||
contains setuptools and/or pip distributions. Setuptools distributions
|
||||
must be ``.egg`` files; pip distributions should be `.tar.gz` source
|
||||
distributions.
|
||||
|
||||
Virtualenv will still download these packages if no satisfactory local
|
||||
distributions are found.
|
||||
If no satisfactory local distributions are found, virtualenv will fail. Virtualenv will never download packages.
|
||||
|
||||
If you are really concerned about virtualenv fetching these packages
|
||||
from the Internet and want to ensure that it never will, you can also
|
||||
provide an option ``--never-download`` like so::
|
||||
The distribution lookup is done in the following locations, with the most
|
||||
recent version found used:
|
||||
|
||||
$ virtualenv --extra-search-dir=/path/to/distributions --never-download ENV
|
||||
|
||||
If this option is provided, virtualenv will never try to download
|
||||
setuptools/distribute or pip. Instead, it will exit with status code 1
|
||||
if it fails to find local distributions for any of these required
|
||||
packages. The local distribution lookup is done in the following
|
||||
locations, with the most recent version found used:
|
||||
|
||||
#. The current directory.
|
||||
#. The directory where virtualenv.py is located.
|
||||
#. A ``virtualenv_support`` directory relative to the directory where
|
||||
virtualenv.py is located.
|
||||
#. If the file being executed is not named virtualenv.py (i.e. is a boot
|
||||
script), a ``virtualenv_support`` directory relative to wherever
|
||||
virtualenv.py is actually installed.
|
||||
#. The current directory.
|
||||
#. The directory where virtualenv.py is located.
|
||||
#. A ``virtualenv_support`` directory relative to the directory where
|
||||
virtualenv.py is located.
|
||||
#. If the file being executed is not named virtualenv.py (i.e. is a boot
|
||||
script), a ``virtualenv_support`` directory relative to wherever
|
||||
virtualenv.py is actually installed.
|
||||
|
||||
|
||||
Compare & Contrast with Alternatives
|
||||
|
@ -447,33 +492,33 @@ Description:
|
|||
There are several alternatives that create isolated environments:
|
||||
|
||||
* ``workingenv`` (which I do not suggest you use anymore) is the
|
||||
predecessor to this library. It used the main Python interpreter,
|
||||
predecessor to this library. It used the main Python interpreter,
|
||||
but relied on setting ``$PYTHONPATH`` to activate the environment.
|
||||
This causes problems when running Python scripts that aren't part of
|
||||
the environment (e.g., a globally installed ``hg`` or ``bzr``). It
|
||||
the environment (e.g., a globally installed ``hg`` or ``bzr``). It
|
||||
also conflicted a lot with Setuptools.
|
||||
|
||||
* `virtual-python
|
||||
<http://peak.telecommunity.com/DevCenter/EasyInstall#creating-a-virtual-python>`_
|
||||
is also a predecessor to this library. It uses only symlinks, so it
|
||||
couldn't work on Windows. It also symlinks over the *entire*
|
||||
standard library and global ``site-packages``. As a result, it
|
||||
is also a predecessor to this library. It uses only symlinks, so it
|
||||
couldn't work on Windows. It also symlinks over the *entire*
|
||||
standard library and global ``site-packages``. As a result, it
|
||||
won't see new additions to the global ``site-packages``.
|
||||
|
||||
This script only symlinks a small portion of the standard library
|
||||
into the environment, and so on Windows it is feasible to simply
|
||||
copy these files over. Also, it creates a new/empty
|
||||
copy these files over. Also, it creates a new/empty
|
||||
``site-packages`` and also adds the global ``site-packages`` to the
|
||||
path, so updates are tracked separately. This script also installs
|
||||
path, so updates are tracked separately. This script also installs
|
||||
Setuptools automatically, saving a step and avoiding the need for
|
||||
network access.
|
||||
|
||||
* `zc.buildout <http://pypi.python.org/pypi/zc.buildout>`_ doesn't
|
||||
create an isolated Python environment in the same style, but
|
||||
achieves similar results through a declarative config file that sets
|
||||
up scripts with very particular packages. As a declarative system,
|
||||
up scripts with very particular packages. As a declarative system,
|
||||
it is somewhat easier to repeat and manage, but more difficult to
|
||||
experiment with. ``zc.buildout`` includes the ability to setup
|
||||
experiment with. ``zc.buildout`` includes the ability to setup
|
||||
non-Python systems (e.g., a database server or an Apache instance).
|
||||
|
||||
I *strongly* recommend anyone doing application development or
|
||||
|
@ -539,7 +584,7 @@ Description:
|
|||
using virtualenv (virtualenvwrapper)
|
||||
<http://www.doughellmann.com/articles/CompletelyDifferent-2008-05-virtualenvwrapper/index.html>`_
|
||||
including some handy scripts to make working with multiple
|
||||
environments easier. He also wrote `an example of using virtualenv
|
||||
environments easier. He also wrote `an example of using virtualenv
|
||||
to try IPython
|
||||
<http://www.doughellmann.com/articles/CompletelyDifferent-2008-02-ipython-and-virtualenv/index.html>`_.
|
||||
|
||||
|
@ -583,6 +628,68 @@ Description:
|
|||
``$ENV/bin/python`` and re-running virtualenv on the same target directory
|
||||
with the upgraded Python.
|
||||
|
||||
1.10.1 (2013-08-07)
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* **New Signing Key** Release 1.10.1 is using a different key than normal with
|
||||
fingerprint: 7C6B 7C5D 5E2B 6356 A926 F04F 6E3C BCE9 3372 DCFA
|
||||
* Upgraded pip to v1.4.1
|
||||
* Upgraded setuptools to v0.9.8
|
||||
|
||||
|
||||
1.10 (2013-07-23)
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
* **BACKWARDS INCOMPATIBLE** Dropped support for Python 2.5. The minimum
|
||||
supported Python version is now Python 2.6.
|
||||
|
||||
* **BACKWARDS INCOMPATIBLE** Using ``virtualenv.py`` as an isolated script
|
||||
(i.e. without an associated ``virtualenv_support`` directory) is no longer
|
||||
supported for security reasons and will fail with an error.
|
||||
|
||||
Along with this, ``--never-download`` is now always pinned to ``True``, and
|
||||
is only being maintained in the short term for backward compatibility
|
||||
(Pull #412).
|
||||
|
||||
* **IMPORTANT** Switched to the new setuptools (v0.9.7) which has been merged
|
||||
with Distribute_ again and works for Python 2 and 3 with one codebase.
|
||||
The ``--distribute`` and ``--setuptools`` options are now no-op.
|
||||
|
||||
* Updated to pip 1.4.
|
||||
|
||||
* Added support for PyPy3k
|
||||
|
||||
* Added the option to use a version number with the ``-p`` option to get the
|
||||
system copy of that Python version (Windows only)
|
||||
|
||||
* Removed embedded ``ez_setup.py``, ``distribute_setup.py`` and
|
||||
``distribute_from_egg.py`` files as part of switching to merged setuptools.
|
||||
|
||||
* Fixed ``--relocatable`` to work better on Windows.
|
||||
|
||||
* Fixed issue with readline on Windows.
|
||||
|
||||
.. _Distribute: https://pypi.python.org/pypi/distribute
|
||||
|
||||
1.9.1 (2013-03-08)
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* Updated to pip 1.3.1 that fixed a major backward incompatible change of
|
||||
parsing URLs to externally hosted packages that got accidentily included
|
||||
in pip 1.3.
|
||||
|
||||
1.9 (2013-03-07)
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
* Unset VIRTUAL_ENV environment variable in deactivate.bat (Pull #364)
|
||||
* Upgraded distribute to 0.6.34.
|
||||
* Added ``--no-setuptools`` and ``--no-pip`` options (Pull #336).
|
||||
* Fixed Issue #373. virtualenv-1.8.4 was failing in cygwin (Pull #382).
|
||||
* Fixed Issue #378. virtualenv is now "multiarch" aware on debian/ubuntu (Pull #379).
|
||||
* Fixed issue with readline module path on pypy and OSX (Pull #374).
|
||||
* Made 64bit detection compatible with Python 2.5 (Pull #393).
|
||||
|
||||
|
||||
1.8.4 (2012-11-25)
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
@ -595,6 +702,9 @@ Description:
|
|||
|
||||
* Added some more integration tests.
|
||||
|
||||
* Removed the unsupported embedded setuptools egg for Python 2.4 to reduce
|
||||
file size.
|
||||
|
||||
1.8.3 (2012-11-21)
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
@ -1196,7 +1306,7 @@ Description:
|
|||
|
||||
Keywords: setuptools deployment installation distutils
|
||||
Platform: UNKNOWN
|
||||
Classifier: Development Status :: 4 - Beta
|
||||
Classifier: Development Status :: 5 - Production/Stable
|
||||
Classifier: Intended Audience :: Developers
|
||||
Classifier: License :: OSI Approved :: MIT License
|
||||
Classifier: Programming Language :: Python :: 2
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
virtualenv
|
||||
==========
|
||||
|
||||
.. image:: https://pypip.in/v/virtualenv/badge.png
|
||||
:target: https://pypi.python.org/pypi/virtualenv
|
||||
|
||||
.. image:: https://secure.travis-ci.org/pypa/virtualenv.png?branch=develop
|
||||
:target: http://travis-ci.org/pypa/virtualenv
|
||||
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
"""
|
||||
Refresh any files in ../virtualenv_support/ that come from elsewhere
|
||||
"""
|
||||
|
||||
import os
|
||||
try:
|
||||
from urllib.request import urlopen
|
||||
except ImportError:
|
||||
from urllib2 import urlopen
|
||||
import sys
|
||||
|
||||
here = os.path.dirname(__file__)
|
||||
support_location = os.path.join(here, '..', 'virtualenv_support')
|
||||
embedded_location = os.path.join(here, '..', 'virtualenv_embedded')
|
||||
|
||||
embedded_files = [
|
||||
('http://peak.telecommunity.com/dist/ez_setup.py', 'ez_setup.py'),
|
||||
('http://python-distribute.org/distribute_setup.py', 'distribute_setup.py'),
|
||||
]
|
||||
|
||||
support_files = [
|
||||
('http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg', 'setuptools-0.6c11-py2.6.egg'),
|
||||
('http://pypi.python.org/packages/2.5/s/setuptools/setuptools-0.6c11-py2.5.egg', 'setuptools-0.6c11-py2.5.egg'),
|
||||
('http://pypi.python.org/packages/source/d/distribute/distribute-0.6.31.tar.gz', 'distribute-0.6.31.tar.gz'),
|
||||
('http://pypi.python.org/packages/source/p/pip/pip-1.2.1.tar.gz', 'pip-1.2.1.tar.gz'),
|
||||
]
|
||||
|
||||
|
||||
def refresh_files(files, location):
|
||||
for url, filename in files:
|
||||
sys.stdout.write('fetching %s ... ' % url)
|
||||
sys.stdout.flush()
|
||||
f = urlopen(url)
|
||||
content = f.read()
|
||||
f.close()
|
||||
print('done.')
|
||||
filename = os.path.join(location, filename)
|
||||
if os.path.exists(filename):
|
||||
f = open(filename, 'rb')
|
||||
cur_content = f.read()
|
||||
f.close()
|
||||
else:
|
||||
cur_content = ''
|
||||
if cur_content == content:
|
||||
print(' %s up-to-date' % filename)
|
||||
else:
|
||||
print(' overwriting %s' % filename)
|
||||
f = open(filename, 'wb')
|
||||
f.write(content)
|
||||
f.close()
|
||||
|
||||
|
||||
def main():
|
||||
refresh_files(embedded_files, embedded_location)
|
||||
refresh_files(support_files, support_location)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -11,10 +11,11 @@
|
|||
# All configuration values have a default value; values that are commented out
|
||||
# serve to show the default value.
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
# If your extensions are in another directory, add it here.
|
||||
#sys.path.append('some/directory')
|
||||
sys.path.insert(0, os.path.abspath(os.pardir))
|
||||
|
||||
# General configuration
|
||||
# ---------------------
|
||||
|
@ -28,14 +29,14 @@ extensions = ['sphinx.ext.autodoc']
|
|||
#templates_path = ['_templates']
|
||||
|
||||
# The suffix of source filenames.
|
||||
source_suffix = '.txt'
|
||||
source_suffix = '.rst'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
|
||||
# General substitutions.
|
||||
project = 'virtualenv'
|
||||
copyright = '2007-2012, Ian Bicking, The Open Planning Project, The virtualenv developers'
|
||||
copyright = '2007-2013, Ian Bicking, The Open Planning Project, The virtualenv developers'
|
||||
|
||||
# The default replacements for |version| and |release|, also used in various
|
||||
# other places throughout the built documents.
|
||||
|
|
|
@ -1,40 +1,24 @@
|
|||
virtualenv
|
||||
==========
|
||||
|
||||
* `Discussion list <http://groups.google.com/group/python-virtualenv/>`_
|
||||
* `Bugs <https://github.com/pypa/virtualenv/issues/>`_
|
||||
|
||||
.. contents::
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
news
|
||||
`Changes & News <news.html>`_ `|`
|
||||
`Mailing list <http://groups.google.com/group/python-virtualenv>`_ `|`
|
||||
`Issues <https://github.com/pypa/virtualenv/issues>`_ `|`
|
||||
`Github <https://github.com/pypa/virtualenv>`_ `|`
|
||||
`PyPI <https://pypi.python.org/pypi/virtualenv/>`_ `|`
|
||||
IRC: #pip on Freenode
|
||||
|
||||
.. comment: split here
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
You can install virtualenv with ``pip install virtualenv``, or the `latest
|
||||
development version <https://github.com/pypa/virtualenv/tarball/develop>`_
|
||||
with ``pip install https://github.com/pypa/virtualenv/tarball/develop``.
|
||||
|
||||
You can also use ``easy_install``, or if you have no Python package manager
|
||||
available at all, you can just grab the single file `virtualenv.py`_ and run
|
||||
it with ``python virtualenv.py``.
|
||||
|
||||
.. _virtualenv.py: https://raw.github.com/pypa/virtualenv/master/virtualenv.py
|
||||
|
||||
What It Does
|
||||
------------
|
||||
|
||||
``virtualenv`` is a tool to create isolated Python environments.
|
||||
|
||||
The basic problem being addressed is one of dependencies and versions,
|
||||
and indirectly permissions. Imagine you have an application that
|
||||
and indirectly permissions. Imagine you have an application that
|
||||
needs version 1 of LibFoo, but another application requires version
|
||||
2. How can you use both these applications? If you install
|
||||
2. How can you use both these applications? If you install
|
||||
everything into ``/usr/lib/python2.7/site-packages`` (or whatever your
|
||||
platform's standard location is), it's easy to end up in a situation
|
||||
where you unintentionally upgrade an application that shouldn't be
|
||||
|
@ -47,39 +31,99 @@ the versions of those libraries can break the application.
|
|||
Also, what if you can't install packages into the global
|
||||
``site-packages`` directory? For instance, on a shared host.
|
||||
|
||||
In all these cases, ``virtualenv`` can help you. It creates an
|
||||
In all these cases, ``virtualenv`` can help you. It creates an
|
||||
environment that has its own installation directories, that doesn't
|
||||
share libraries with other virtualenv environments (and optionally
|
||||
doesn't access the globally installed libraries either).
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
.. warning::
|
||||
|
||||
We advise installing virtualenv-1.9 or greater. Prior to version 1.9, the
|
||||
pip included in virtualenv did not not download from PyPI over SSL.
|
||||
|
||||
.. warning::
|
||||
|
||||
When using pip to install virtualenv, we advise using pip 1.3 or greater.
|
||||
Prior to version 1.3, pip did not not download from PyPI over SSL.
|
||||
|
||||
.. warning::
|
||||
|
||||
We advise against using easy_install to install virtualenv when using
|
||||
setuptools < 0.9.7, because easy_install didn't download from PyPI over SSL
|
||||
and was broken in some subtle ways.
|
||||
|
||||
To install globally with `pip` (if you have pip 1.3 or greater installed globally):
|
||||
|
||||
::
|
||||
|
||||
$ [sudo] pip install virtualenv
|
||||
|
||||
Or to get the latest unreleased dev version:
|
||||
|
||||
::
|
||||
|
||||
$ [sudo] pip install https://github.com/pypa/virtualenv/tarball/develop
|
||||
|
||||
|
||||
To install globally from source:
|
||||
|
||||
::
|
||||
|
||||
$ curl -O https://pypi.python.org/packages/source/v/virtualenv/virtualenv-X.X.tar.gz
|
||||
$ tar xvfz virtualenv-X.X.tar.gz
|
||||
$ cd virtualenv-X.X
|
||||
$ [sudo] python setup.py install
|
||||
|
||||
|
||||
To *use* locally from source:
|
||||
|
||||
::
|
||||
|
||||
$ curl -O https://pypi.python.org/packages/source/v/virtualenv/virtualenv-X.X.tar.gz
|
||||
$ tar xvfz virtualenv-X.X.tar.gz
|
||||
$ cd virtualenv-X.X
|
||||
$ python virtualenv.py myVE
|
||||
|
||||
.. note::
|
||||
|
||||
The ``virtualenv.py`` script is *not* supported if run without the
|
||||
necessary pip/setuptools/virtualenv distributions available locally. All
|
||||
of the installation methods above include a ``virtualenv_support``
|
||||
directory alongside ``virtualenv.py`` which contains a complete set of
|
||||
pip and setuptools distributions, and so are fully supported.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
The basic usage is::
|
||||
|
||||
$ python virtualenv.py ENV
|
||||
|
||||
If you install it you can also just do ``virtualenv ENV``.
|
||||
$ virtualenv ENV
|
||||
|
||||
This creates ``ENV/lib/pythonX.X/site-packages``, where any libraries you
|
||||
install will go. It also creates ``ENV/bin/python``, which is a Python
|
||||
interpreter that uses this environment. Anytime you use that interpreter
|
||||
install will go. It also creates ``ENV/bin/python``, which is a Python
|
||||
interpreter that uses this environment. Anytime you use that interpreter
|
||||
(including when a script has ``#!/path/to/ENV/bin/python`` in it) the libraries
|
||||
in that environment will be used.
|
||||
|
||||
It also installs either `Setuptools
|
||||
<http://peak.telecommunity.com/DevCenter/setuptools>`_ or `distribute
|
||||
<http://pypi.python.org/pypi/distribute>`_ into the environment. To use
|
||||
Distribute instead of setuptools, just call virtualenv like this::
|
||||
<http://peak.telecommunity.com/DevCenter/setuptools>`_ into the environment.
|
||||
|
||||
$ python virtualenv.py --distribute ENV
|
||||
.. note::
|
||||
|
||||
You can also set the environment variable VIRTUALENV_DISTRIBUTE.
|
||||
Virtualenv (<1.10) used to provide a ``--distribute`` option to use the
|
||||
setuptools fork Distribute_. Since Distribute has been merged back into
|
||||
setuptools this option is now no-op, it will always use the improved
|
||||
setuptools releases.
|
||||
|
||||
A new virtualenv also includes the `pip <http://pypi.python.org/pypi/pip>`_
|
||||
installer, so you can use ``ENV/bin/pip`` to install additional packages into
|
||||
the environment.
|
||||
|
||||
.. _Distribute: https://pypi.python.org/pypi/distribute
|
||||
|
||||
activate script
|
||||
~~~~~~~~~~~~~~~
|
||||
|
@ -93,10 +137,10 @@ On Posix systems you can do::
|
|||
$ source bin/activate
|
||||
|
||||
This will change your ``$PATH`` so its first entry is the virtualenv's
|
||||
``bin/`` directory. (You have to use ``source`` because it changes your
|
||||
``bin/`` directory. (You have to use ``source`` because it changes your
|
||||
shell environment in-place.) This is all it does; it's purely a
|
||||
convenience. If you directly run a script or the python interpreter
|
||||
from the virtualenv's ``bin/`` directory (e.g. ``path/to/env/bin/pip``
|
||||
convenience. If you directly run a script or the python interpreter
|
||||
from the virtualenv's ``bin/`` directory (e.g. ``path/to/env/bin/pip``
|
||||
or ``/path/to/env/bin/python script.py``) there's no need for
|
||||
activation.
|
||||
|
||||
|
@ -104,9 +148,9 @@ After activating an environment you can use the function ``deactivate`` to
|
|||
undo the changes to your ``$PATH``.
|
||||
|
||||
The ``activate`` script will also modify your shell prompt to indicate
|
||||
which environment is currently active. You can disable this behavior,
|
||||
which environment is currently active. You can disable this behavior,
|
||||
which can be useful if you have your own custom prompt that already
|
||||
displays the active environment name. To do so, set the
|
||||
displays the active environment name. To do so, set the
|
||||
``VIRTUAL_ENV_DISABLE_PROMPT`` environment variable to any non-empty
|
||||
value before running the ``activate`` script.
|
||||
|
||||
|
@ -180,7 +224,7 @@ environment will inherit packages from ``/usr/lib/python2.7/site-packages``
|
|||
(or wherever your global site-packages directory is).
|
||||
|
||||
This can be used if you have control over the global site-packages directory,
|
||||
and you want to depend on the packages there. If you want isolation from the
|
||||
and you want to depend on the packages there. If you want isolation from the
|
||||
global system, do not use this flag.
|
||||
|
||||
|
||||
|
@ -188,7 +232,7 @@ Environment variables and configuration files
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
virtualenv can not only be configured by passing command line options such as
|
||||
``--distribute`` but also by two other means:
|
||||
``--python`` but also by two other means:
|
||||
|
||||
- Environment variables
|
||||
|
||||
|
@ -197,15 +241,15 @@ virtualenv can not only be configured by passing command line options such as
|
|||
the name of the command line options are capitalized and have dashes
|
||||
(``'-'``) replaced with underscores (``'_'``).
|
||||
|
||||
For example, to automatically install Distribute instead of setuptools
|
||||
you can also set an environment variable::
|
||||
For example, to automatically use a custom Python binary instead of the
|
||||
one virtualenv is run with you can also set an environment variable::
|
||||
|
||||
$ export VIRTUALENV_DISTRIBUTE=true
|
||||
$ python virtualenv.py ENV
|
||||
$ export VIRTUALENV_PYTHON=/opt/python-3.3/bin/python
|
||||
$ virtualenv ENV
|
||||
|
||||
It's the same as passing the option to virtualenv directly::
|
||||
|
||||
$ python virtualenv.py --distribute ENV
|
||||
$ virtualenv --python=/opt/python-3.3/bin/python ENV
|
||||
|
||||
This also works for appending command line options, like ``--find-links``.
|
||||
Just leave an empty space between the passsed values, e.g.::
|
||||
|
@ -215,7 +259,7 @@ virtualenv can not only be configured by passing command line options such as
|
|||
|
||||
is the same as calling::
|
||||
|
||||
$ python virtualenv.py --extra-search-dir=/path/to/dists --extra-search-dir=/path/to/other/dists ENV
|
||||
$ virtualenv --extra-search-dir=/path/to/dists --extra-search-dir=/path/to/other/dists ENV
|
||||
|
||||
- Config files
|
||||
|
||||
|
@ -224,10 +268,10 @@ virtualenv can not only be configured by passing command line options such as
|
|||
``%APPDATA%\virtualenv\virtualenv.ini``.
|
||||
|
||||
The names of the settings are derived from the long command line option,
|
||||
e.g. the option ``--distribute`` would look like this::
|
||||
e.g. the option ``--python`` would look like this::
|
||||
|
||||
[virtualenv]
|
||||
distribute = true
|
||||
python = /opt/python-3.3/bin/python
|
||||
|
||||
Appending options like ``--extra-search-dir`` can be written on multiple
|
||||
lines::
|
||||
|
@ -261,20 +305,20 @@ Creating Your Own Bootstrap Scripts
|
|||
-----------------------------------
|
||||
|
||||
While this creates an environment, it doesn't put anything into the
|
||||
environment. Developers may find it useful to distribute a script
|
||||
environment. Developers may find it useful to distribute a script
|
||||
that sets up a particular environment, for example a script that
|
||||
installs a particular web application.
|
||||
|
||||
To create a script like this, call
|
||||
``virtualenv.create_bootstrap_script(extra_text)``, and write the
|
||||
result to your new bootstrapping script. Here's the documentation
|
||||
result to your new bootstrapping script. Here's the documentation
|
||||
from the docstring:
|
||||
|
||||
Creates a bootstrap script, which is like this script but with
|
||||
extend_parser, adjust_options, and after_install hooks.
|
||||
|
||||
This returns a string that (written to disk of course) can be used
|
||||
as a bootstrap script with your own customizations. The script
|
||||
as a bootstrap script with your own customizations. The script
|
||||
will be the standard virtualenv.py script, with your extra text
|
||||
added (your extra text should be Python code).
|
||||
|
||||
|
@ -290,8 +334,8 @@ If you include these functions, they will be called:
|
|||
|
||||
``after_install(options, home_dir)``:
|
||||
|
||||
After everything is installed, this function is called. This
|
||||
is probably the function you are most likely to use. An
|
||||
After everything is installed, this function is called. This
|
||||
is probably the function you are most likely to use. An
|
||||
example would be::
|
||||
|
||||
def after_install(options, home_dir):
|
||||
|
@ -337,23 +381,23 @@ Using Virtualenv without ``bin/python``
|
|||
---------------------------------------
|
||||
|
||||
Sometimes you can't or don't want to use the Python interpreter
|
||||
created by the virtualenv. For instance, in a `mod_python
|
||||
created by the virtualenv. For instance, in a `mod_python
|
||||
<http://www.modpython.org/>`_ or `mod_wsgi <http://www.modwsgi.org/>`_
|
||||
environment, there is only one interpreter.
|
||||
|
||||
Luckily, it's easy. You must use the custom Python interpreter to
|
||||
*install* libraries. But to *use* libraries, you just have to be sure
|
||||
the path is correct. A script is available to correct the path. You
|
||||
Luckily, it's easy. You must use the custom Python interpreter to
|
||||
*install* libraries. But to *use* libraries, you just have to be sure
|
||||
the path is correct. A script is available to correct the path. You
|
||||
can setup the environment like::
|
||||
|
||||
activate_this = '/path/to/env/bin/activate_this.py'
|
||||
execfile(activate_this, dict(__file__=activate_this))
|
||||
|
||||
This will change ``sys.path`` and even change ``sys.prefix``, but also allow
|
||||
you to use an existing interpreter. Items in your environment will show up
|
||||
first on ``sys.path``, before global items. However, global items will
|
||||
you to use an existing interpreter. Items in your environment will show up
|
||||
first on ``sys.path``, before global items. However, global items will
|
||||
always be accessible (as if the ``--system-site-packages`` flag had been used
|
||||
in creating the environment, whether it was or not). Also, this cannot undo
|
||||
in creating the environment, whether it was or not). Also, this cannot undo
|
||||
the activation of other environments, or modules that have been imported.
|
||||
You shouldn't try to, for instance, activate an environment before a web
|
||||
request; you should activate *one* environment as early as possible, and not
|
||||
|
@ -363,29 +407,39 @@ Making Environments Relocatable
|
|||
-------------------------------
|
||||
|
||||
Note: this option is somewhat experimental, and there are probably
|
||||
caveats that have not yet been identified. Also this does not
|
||||
currently work on Windows.
|
||||
caveats that have not yet been identified.
|
||||
|
||||
Normally environments are tied to a specific path. That means that
|
||||
.. warning::
|
||||
|
||||
The ``--relocatable`` option currently has a number of issues,
|
||||
and is not guaranteed to work in all circumstances. It is possible
|
||||
that the option will be deprecated in a future version of ``virtualenv``.
|
||||
|
||||
Normally environments are tied to a specific path. That means that
|
||||
you cannot move an environment around or copy it to another computer.
|
||||
You can fix up an environment to make it relocatable with the
|
||||
command::
|
||||
|
||||
$ virtualenv --relocatable ENV
|
||||
|
||||
This will make some of the files created by setuptools or distribute
|
||||
use relative paths, and will change all the scripts to use ``activate_this.py``
|
||||
instead of using the location of the Python interpreter to select the
|
||||
environment.
|
||||
This will make some of the files created by setuptools use relative paths,
|
||||
and will change all the scripts to use ``activate_this.py`` instead of using
|
||||
the location of the Python interpreter to select the environment.
|
||||
|
||||
**Note:** scripts which have been made relocatable will only work if
|
||||
the virtualenv is activated, specifically the python executable from
|
||||
the virtualenv must be the first one on the system PATH. Also note that
|
||||
the activate scripts are not currently made relocatable by
|
||||
``virtualenv --relocatable``.
|
||||
|
||||
**Note:** you must run this after you've installed *any* packages into
|
||||
the environment. If you make an environment relocatable, then
|
||||
the environment. If you make an environment relocatable, then
|
||||
install a new package, you must run ``virtualenv --relocatable``
|
||||
again.
|
||||
|
||||
Also, this **does not make your packages cross-platform**. You can
|
||||
Also, this **does not make your packages cross-platform**. You can
|
||||
move the directory around, but it can only be used on other similar
|
||||
computers. Some known environmental differences that can cause
|
||||
computers. Some known environmental differences that can cause
|
||||
incompatibilities: a different version of Python, when one platform
|
||||
uses UCS2 for its internal unicode representation and another uses
|
||||
UCS4 (a compile-time option), obvious platform changes like Windows
|
||||
|
@ -400,50 +454,38 @@ If you use this flag to create an environment, currently, the
|
|||
The ``--extra-search-dir`` option
|
||||
---------------------------------
|
||||
|
||||
When it creates a new environment, virtualenv installs either setuptools
|
||||
or distribute, and pip. In normal operation when virtualenv is
|
||||
installed, the bundled version of these packages included in the
|
||||
``virtualenv_support`` directory is used. When ``virtualenv.py`` is run
|
||||
standalone and ``virtualenv_support`` is not available, the latest
|
||||
releases of these packages are fetched from the `Python Package Index
|
||||
<http://pypi.python.org>`_ (PyPI).
|
||||
.. note::
|
||||
|
||||
As an alternative, you can provide your own versions of setuptools,
|
||||
distribute and/or pip on the filesystem, and tell virtualenv to use
|
||||
those distributions instead of downloading them from the Internet. To
|
||||
use this feature, pass one or more ``--extra-search-dir`` options to
|
||||
Currently, this feature only partially works for pip, and not at
|
||||
all for setuptools. For details,
|
||||
see `Issue #327 <https://github.com/pypa/virtualenv/issues/327>`_
|
||||
|
||||
This option allows you to provide your own versions of setuptools
|
||||
and/or pip on the filesystem, and tell virtualenv to use those distributions
|
||||
instead of the ones in ``virtualenv_support``.
|
||||
|
||||
To use this feature, pass one or more ``--extra-search-dir`` options to
|
||||
virtualenv like this::
|
||||
|
||||
$ virtualenv --extra-search-dir=/path/to/distributions ENV
|
||||
|
||||
The ``/path/to/distributions`` path should point to a directory that
|
||||
contains setuptools, distribute and/or pip distributions. Setuptools
|
||||
distributions must be ``.egg`` files; pip distributions should be
|
||||
`.tar.gz` source distributions, and distribute distributions may be
|
||||
either (if found an egg will be used preferentially).
|
||||
contains setuptools and/or pip distributions. Setuptools distributions
|
||||
must be ``.egg`` files; pip distributions should be `.tar.gz` source
|
||||
distributions.
|
||||
|
||||
Virtualenv will still download these packages if no satisfactory local
|
||||
distributions are found.
|
||||
If no satisfactory local distributions are found, virtualenv will fail. Virtualenv will never download packages.
|
||||
|
||||
If you are really concerned about virtualenv fetching these packages
|
||||
from the Internet and want to ensure that it never will, you can also
|
||||
provide an option ``--never-download`` like so::
|
||||
The distribution lookup is done in the following locations, with the most
|
||||
recent version found used:
|
||||
|
||||
$ virtualenv --extra-search-dir=/path/to/distributions --never-download ENV
|
||||
|
||||
If this option is provided, virtualenv will never try to download
|
||||
setuptools/distribute or pip. Instead, it will exit with status code 1
|
||||
if it fails to find local distributions for any of these required
|
||||
packages. The local distribution lookup is done in the following
|
||||
locations, with the most recent version found used:
|
||||
|
||||
#. The current directory.
|
||||
#. The directory where virtualenv.py is located.
|
||||
#. A ``virtualenv_support`` directory relative to the directory where
|
||||
virtualenv.py is located.
|
||||
#. If the file being executed is not named virtualenv.py (i.e. is a boot
|
||||
script), a ``virtualenv_support`` directory relative to wherever
|
||||
virtualenv.py is actually installed.
|
||||
#. The current directory.
|
||||
#. The directory where virtualenv.py is located.
|
||||
#. A ``virtualenv_support`` directory relative to the directory where
|
||||
virtualenv.py is located.
|
||||
#. If the file being executed is not named virtualenv.py (i.e. is a boot
|
||||
script), a ``virtualenv_support`` directory relative to wherever
|
||||
virtualenv.py is actually installed.
|
||||
|
||||
|
||||
Compare & Contrast with Alternatives
|
||||
|
@ -452,33 +494,33 @@ Compare & Contrast with Alternatives
|
|||
There are several alternatives that create isolated environments:
|
||||
|
||||
* ``workingenv`` (which I do not suggest you use anymore) is the
|
||||
predecessor to this library. It used the main Python interpreter,
|
||||
predecessor to this library. It used the main Python interpreter,
|
||||
but relied on setting ``$PYTHONPATH`` to activate the environment.
|
||||
This causes problems when running Python scripts that aren't part of
|
||||
the environment (e.g., a globally installed ``hg`` or ``bzr``). It
|
||||
the environment (e.g., a globally installed ``hg`` or ``bzr``). It
|
||||
also conflicted a lot with Setuptools.
|
||||
|
||||
* `virtual-python
|
||||
<http://peak.telecommunity.com/DevCenter/EasyInstall#creating-a-virtual-python>`_
|
||||
is also a predecessor to this library. It uses only symlinks, so it
|
||||
couldn't work on Windows. It also symlinks over the *entire*
|
||||
standard library and global ``site-packages``. As a result, it
|
||||
is also a predecessor to this library. It uses only symlinks, so it
|
||||
couldn't work on Windows. It also symlinks over the *entire*
|
||||
standard library and global ``site-packages``. As a result, it
|
||||
won't see new additions to the global ``site-packages``.
|
||||
|
||||
This script only symlinks a small portion of the standard library
|
||||
into the environment, and so on Windows it is feasible to simply
|
||||
copy these files over. Also, it creates a new/empty
|
||||
copy these files over. Also, it creates a new/empty
|
||||
``site-packages`` and also adds the global ``site-packages`` to the
|
||||
path, so updates are tracked separately. This script also installs
|
||||
path, so updates are tracked separately. This script also installs
|
||||
Setuptools automatically, saving a step and avoiding the need for
|
||||
network access.
|
||||
|
||||
* `zc.buildout <http://pypi.python.org/pypi/zc.buildout>`_ doesn't
|
||||
create an isolated Python environment in the same style, but
|
||||
achieves similar results through a declarative config file that sets
|
||||
up scripts with very particular packages. As a declarative system,
|
||||
up scripts with very particular packages. As a declarative system,
|
||||
it is somewhat easier to repeat and manage, but more difficult to
|
||||
experiment with. ``zc.buildout`` includes the ability to setup
|
||||
experiment with. ``zc.buildout`` includes the ability to setup
|
||||
non-Python systems (e.g., a database server or an Apache instance).
|
||||
|
||||
I *strongly* recommend anyone doing application development or
|
||||
|
@ -544,7 +586,7 @@ Other Documentation and Links
|
|||
using virtualenv (virtualenvwrapper)
|
||||
<http://www.doughellmann.com/articles/CompletelyDifferent-2008-05-virtualenvwrapper/index.html>`_
|
||||
including some handy scripts to make working with multiple
|
||||
environments easier. He also wrote `an example of using virtualenv
|
||||
environments easier. He also wrote `an example of using virtualenv
|
||||
to try IPython
|
||||
<http://www.doughellmann.com/articles/CompletelyDifferent-2008-02-ipython-and-virtualenv/index.html>`_.
|
||||
|
|
@ -14,6 +14,68 @@ Changes & News
|
|||
``$ENV/bin/python`` and re-running virtualenv on the same target directory
|
||||
with the upgraded Python.
|
||||
|
||||
1.10.1 (2013-08-07)
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* **New Signing Key** Release 1.10.1 is using a different key than normal with
|
||||
fingerprint: 7C6B 7C5D 5E2B 6356 A926 F04F 6E3C BCE9 3372 DCFA
|
||||
* Upgraded pip to v1.4.1
|
||||
* Upgraded setuptools to v0.9.8
|
||||
|
||||
|
||||
1.10 (2013-07-23)
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
* **BACKWARDS INCOMPATIBLE** Dropped support for Python 2.5. The minimum
|
||||
supported Python version is now Python 2.6.
|
||||
|
||||
* **BACKWARDS INCOMPATIBLE** Using ``virtualenv.py`` as an isolated script
|
||||
(i.e. without an associated ``virtualenv_support`` directory) is no longer
|
||||
supported for security reasons and will fail with an error.
|
||||
|
||||
Along with this, ``--never-download`` is now always pinned to ``True``, and
|
||||
is only being maintained in the short term for backward compatibility
|
||||
(Pull #412).
|
||||
|
||||
* **IMPORTANT** Switched to the new setuptools (v0.9.7) which has been merged
|
||||
with Distribute_ again and works for Python 2 and 3 with one codebase.
|
||||
The ``--distribute`` and ``--setuptools`` options are now no-op.
|
||||
|
||||
* Updated to pip 1.4.
|
||||
|
||||
* Added support for PyPy3k
|
||||
|
||||
* Added the option to use a version number with the ``-p`` option to get the
|
||||
system copy of that Python version (Windows only)
|
||||
|
||||
* Removed embedded ``ez_setup.py``, ``distribute_setup.py`` and
|
||||
``distribute_from_egg.py`` files as part of switching to merged setuptools.
|
||||
|
||||
* Fixed ``--relocatable`` to work better on Windows.
|
||||
|
||||
* Fixed issue with readline on Windows.
|
||||
|
||||
.. _Distribute: https://pypi.python.org/pypi/distribute
|
||||
|
||||
1.9.1 (2013-03-08)
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* Updated to pip 1.3.1 that fixed a major backward incompatible change of
|
||||
parsing URLs to externally hosted packages that got accidentily included
|
||||
in pip 1.3.
|
||||
|
||||
1.9 (2013-03-07)
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
* Unset VIRTUAL_ENV environment variable in deactivate.bat (Pull #364)
|
||||
* Upgraded distribute to 0.6.34.
|
||||
* Added ``--no-setuptools`` and ``--no-pip`` options (Pull #336).
|
||||
* Fixed Issue #373. virtualenv-1.8.4 was failing in cygwin (Pull #382).
|
||||
* Fixed Issue #378. virtualenv is now "multiarch" aware on debian/ubuntu (Pull #379).
|
||||
* Fixed issue with readline module path on pypy and OSX (Pull #374).
|
||||
* Made 64bit detection compatible with Python 2.5 (Pull #393).
|
||||
|
||||
|
||||
1.8.4 (2012-11-25)
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
@ -26,6 +88,9 @@ Changes & News
|
|||
|
||||
* Added some more integration tests.
|
||||
|
||||
* Removed the unsupported embedded setuptools egg for Python 2.4 to reduce
|
||||
file size.
|
||||
|
||||
1.8.3 (2012-11-21)
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
|
@ -30,11 +30,11 @@ except ImportError:
|
|||
here = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
## Get long_description from index.txt:
|
||||
f = open(os.path.join(here, 'docs', 'index.txt'))
|
||||
f = open(os.path.join(here, 'docs', 'index.rst'))
|
||||
long_description = f.read().strip()
|
||||
long_description = long_description.split('split here', 1)[1]
|
||||
f.close()
|
||||
f = open(os.path.join(here, 'docs', 'news.txt'))
|
||||
f = open(os.path.join(here, 'docs', 'news.rst'))
|
||||
long_description += "\n\n" + f.read()
|
||||
f.close()
|
||||
|
||||
|
@ -61,13 +61,11 @@ except ImportError:
|
|||
|
||||
setup(
|
||||
name='virtualenv',
|
||||
# If you change the version here, change it in virtualenv.py and
|
||||
# docs/conf.py as well
|
||||
version=get_version(),
|
||||
description="Virtual Python Environment builder",
|
||||
long_description=long_description,
|
||||
classifiers=[
|
||||
'Development Status :: 4 - Beta',
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
'Intended Audience :: Developers',
|
||||
'License :: OSI Approved :: MIT License',
|
||||
'Programming Language :: Python :: 2',
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,5 +1,7 @@
|
|||
@echo off
|
||||
|
||||
set VIRTUAL_ENV=
|
||||
|
||||
if defined _OLD_VIRTUAL_PROMPT (
|
||||
set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
|
||||
set _OLD_VIRTUAL_PROMPT=
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
# Called from virtualenv with parameters:
|
||||
# [--always-unzip] [-v] egg_name
|
||||
# So, the distribute egg is always the last argument.
|
||||
import sys
|
||||
eggname = sys.argv[-1]
|
||||
sys.path.insert(0, eggname)
|
||||
from setuptools.command.easy_install import main
|
||||
main(sys.argv[1:])
|
|
@ -1,541 +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.31"
|
||||
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"""
|
||||
existing_content = open(path).read()
|
||||
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):
|
||||
return open(path).read() == 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,284 +0,0 @@
|
|||
#!python
|
||||
"""Bootstrap setuptools 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 ez_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 sys
|
||||
DEFAULT_VERSION = "0.6c11"
|
||||
DEFAULT_URL = "http://pypi.python.org/packages/%s/s/setuptools/" % sys.version[:3]
|
||||
|
||||
md5_data = {
|
||||
'setuptools-0.6b1-py2.3.egg': '8822caf901250d848b996b7f25c6e6ca',
|
||||
'setuptools-0.6b1-py2.4.egg': 'b79a8a403e4502fbb85ee3f1941735cb',
|
||||
'setuptools-0.6b2-py2.3.egg': '5657759d8a6d8fc44070a9d07272d99b',
|
||||
'setuptools-0.6b2-py2.4.egg': '4996a8d169d2be661fa32a6e52e4f82a',
|
||||
'setuptools-0.6b3-py2.3.egg': 'bb31c0fc7399a63579975cad9f5a0618',
|
||||
'setuptools-0.6b3-py2.4.egg': '38a8c6b3d6ecd22247f179f7da669fac',
|
||||
'setuptools-0.6b4-py2.3.egg': '62045a24ed4e1ebc77fe039aa4e6f7e5',
|
||||
'setuptools-0.6b4-py2.4.egg': '4cb2a185d228dacffb2d17f103b3b1c4',
|
||||
'setuptools-0.6c1-py2.3.egg': 'b3f2b5539d65cb7f74ad79127f1a908c',
|
||||
'setuptools-0.6c1-py2.4.egg': 'b45adeda0667d2d2ffe14009364f2a4b',
|
||||
'setuptools-0.6c10-py2.3.egg': 'ce1e2ab5d3a0256456d9fc13800a7090',
|
||||
'setuptools-0.6c10-py2.4.egg': '57d6d9d6e9b80772c59a53a8433a5dd4',
|
||||
'setuptools-0.6c10-py2.5.egg': 'de46ac8b1c97c895572e5e8596aeb8c7',
|
||||
'setuptools-0.6c10-py2.6.egg': '58ea40aef06da02ce641495523a0b7f5',
|
||||
'setuptools-0.6c11-py2.3.egg': '2baeac6e13d414a9d28e7ba5b5a596de',
|
||||
'setuptools-0.6c11-py2.4.egg': 'bd639f9b0eac4c42497034dec2ec0c2b',
|
||||
'setuptools-0.6c11-py2.5.egg': '64c94f3bf7a72a13ec83e0b24f2749b2',
|
||||
'setuptools-0.6c11-py2.6.egg': 'bfa92100bd772d5a213eedd356d64086',
|
||||
'setuptools-0.6c2-py2.3.egg': 'f0064bf6aa2b7d0f3ba0b43f20817c27',
|
||||
'setuptools-0.6c2-py2.4.egg': '616192eec35f47e8ea16cd6a122b7277',
|
||||
'setuptools-0.6c3-py2.3.egg': 'f181fa125dfe85a259c9cd6f1d7b78fa',
|
||||
'setuptools-0.6c3-py2.4.egg': 'e0ed74682c998bfb73bf803a50e7b71e',
|
||||
'setuptools-0.6c3-py2.5.egg': 'abef16fdd61955514841c7c6bd98965e',
|
||||
'setuptools-0.6c4-py2.3.egg': 'b0b9131acab32022bfac7f44c5d7971f',
|
||||
'setuptools-0.6c4-py2.4.egg': '2a1f9656d4fbf3c97bf946c0a124e6e2',
|
||||
'setuptools-0.6c4-py2.5.egg': '8f5a052e32cdb9c72bcf4b5526f28afc',
|
||||
'setuptools-0.6c5-py2.3.egg': 'ee9fd80965da04f2f3e6b3576e9d8167',
|
||||
'setuptools-0.6c5-py2.4.egg': 'afe2adf1c01701ee841761f5bcd8aa64',
|
||||
'setuptools-0.6c5-py2.5.egg': 'a8d3f61494ccaa8714dfed37bccd3d5d',
|
||||
'setuptools-0.6c6-py2.3.egg': '35686b78116a668847237b69d549ec20',
|
||||
'setuptools-0.6c6-py2.4.egg': '3c56af57be3225019260a644430065ab',
|
||||
'setuptools-0.6c6-py2.5.egg': 'b2f8a7520709a5b34f80946de5f02f53',
|
||||
'setuptools-0.6c7-py2.3.egg': '209fdf9adc3a615e5115b725658e13e2',
|
||||
'setuptools-0.6c7-py2.4.egg': '5a8f954807d46a0fb67cf1f26c55a82e',
|
||||
'setuptools-0.6c7-py2.5.egg': '45d2ad28f9750e7434111fde831e8372',
|
||||
'setuptools-0.6c8-py2.3.egg': '50759d29b349db8cfd807ba8303f1902',
|
||||
'setuptools-0.6c8-py2.4.egg': 'cba38d74f7d483c06e9daa6070cce6de',
|
||||
'setuptools-0.6c8-py2.5.egg': '1721747ee329dc150590a58b3e1ac95b',
|
||||
'setuptools-0.6c9-py2.3.egg': 'a83c4020414807b496e4cfbe08507c03',
|
||||
'setuptools-0.6c9-py2.4.egg': '260a2be2e5388d66bdaee06abec6342a',
|
||||
'setuptools-0.6c9-py2.5.egg': 'fe67c3e5a17b12c0e7c541b7ea43a8e6',
|
||||
'setuptools-0.6c9-py2.6.egg': 'ca37b1ff16fa2ede6e19383e7b59245a',
|
||||
}
|
||||
|
||||
import sys, os
|
||||
try: from hashlib import md5
|
||||
except ImportError: from md5 import md5
|
||||
|
||||
def _validate_md5(egg_name, data):
|
||||
if egg_name in md5_data:
|
||||
digest = md5(data).hexdigest()
|
||||
if digest != md5_data[egg_name]:
|
||||
print >>sys.stderr, (
|
||||
"md5 validation of %s failed! (Possible download problem?)"
|
||||
% egg_name
|
||||
)
|
||||
sys.exit(2)
|
||||
return data
|
||||
|
||||
def use_setuptools(
|
||||
version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
|
||||
download_delay=15
|
||||
):
|
||||
"""Automatically find/download setuptools and make it available on sys.path
|
||||
|
||||
`version` should be a valid setuptools 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 setuptools will be downloaded, if
|
||||
it is not already available. If `download_delay` is specified, it should
|
||||
be the number of seconds that will be paused before initiating a download,
|
||||
should one be required. If an older version of setuptools is installed,
|
||||
this routine will print a message to ``sys.stderr`` and raise SystemExit in
|
||||
an attempt to abort the calling script.
|
||||
"""
|
||||
was_imported = 'pkg_resources' in sys.modules or 'setuptools' in sys.modules
|
||||
def do_download():
|
||||
egg = download_setuptools(version, download_base, to_dir, download_delay)
|
||||
sys.path.insert(0, egg)
|
||||
import setuptools; setuptools.bootstrap_install_from = egg
|
||||
try:
|
||||
import pkg_resources
|
||||
except ImportError:
|
||||
return do_download()
|
||||
try:
|
||||
pkg_resources.require("setuptools>="+version); return
|
||||
except pkg_resources.VersionConflict, e:
|
||||
if was_imported:
|
||||
print >>sys.stderr, (
|
||||
"The required version of setuptools (>=%s) is not available, and\n"
|
||||
"can't be installed while this script is running. Please install\n"
|
||||
" a more recent version first, using 'easy_install -U setuptools'."
|
||||
"\n\n(Currently using %r)"
|
||||
) % (version, e.args[0])
|
||||
sys.exit(2)
|
||||
except pkg_resources.DistributionNotFound:
|
||||
pass
|
||||
|
||||
del pkg_resources, sys.modules['pkg_resources'] # reload ok
|
||||
return do_download()
|
||||
|
||||
def download_setuptools(
|
||||
version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
|
||||
delay = 15
|
||||
):
|
||||
"""Download setuptools from a specified location and return its filename
|
||||
|
||||
`version` should be a valid setuptools 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.
|
||||
"""
|
||||
import urllib2, shutil
|
||||
egg_name = "setuptools-%s-py%s.egg" % (version,sys.version[:3])
|
||||
url = download_base + egg_name
|
||||
saveto = os.path.join(to_dir, egg_name)
|
||||
src = dst = None
|
||||
if not os.path.exists(saveto): # Avoid repeated downloads
|
||||
try:
|
||||
from distutils import log
|
||||
if delay:
|
||||
log.warn("""
|
||||
---------------------------------------------------------------------------
|
||||
This script requires setuptools version %s to run (even to display
|
||||
help). I will attempt to download it for you (from
|
||||
%s), but
|
||||
you may need to enable firewall access for this script first.
|
||||
I will start the download in %d seconds.
|
||||
|
||||
(Note: if this machine does not have network access, please obtain the file
|
||||
|
||||
%s
|
||||
|
||||
and place it in this directory before rerunning this script.)
|
||||
---------------------------------------------------------------------------""",
|
||||
version, download_base, delay, url
|
||||
); from time import sleep; sleep(delay)
|
||||
log.warn("Downloading %s", url)
|
||||
src = urllib2.urlopen(url)
|
||||
# Read/write all in one block, so we don't create a corrupt file
|
||||
# if the download is interrupted.
|
||||
data = _validate_md5(egg_name, src.read())
|
||||
dst = open(saveto,"wb"); dst.write(data)
|
||||
finally:
|
||||
if src: src.close()
|
||||
if dst: dst.close()
|
||||
return os.path.realpath(saveto)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def main(argv, version=DEFAULT_VERSION):
|
||||
"""Install or upgrade setuptools and EasyInstall"""
|
||||
try:
|
||||
import setuptools
|
||||
except ImportError:
|
||||
egg = None
|
||||
try:
|
||||
egg = download_setuptools(version, delay=0)
|
||||
sys.path.insert(0,egg)
|
||||
from setuptools.command.easy_install import main
|
||||
return main(list(argv)+[egg]) # we're done here
|
||||
finally:
|
||||
if egg and os.path.exists(egg):
|
||||
os.unlink(egg)
|
||||
else:
|
||||
if setuptools.__version__ == '0.0.1':
|
||||
print >>sys.stderr, (
|
||||
"You have an obsolete version of setuptools installed. Please\n"
|
||||
"remove it from your system entirely before rerunning this script."
|
||||
)
|
||||
sys.exit(2)
|
||||
|
||||
req = "setuptools>="+version
|
||||
import pkg_resources
|
||||
try:
|
||||
pkg_resources.require(req)
|
||||
except pkg_resources.VersionConflict:
|
||||
try:
|
||||
from setuptools.command.easy_install import main
|
||||
except ImportError:
|
||||
from easy_install import main
|
||||
main(list(argv)+[download_setuptools(delay=0)])
|
||||
sys.exit(0) # try to force an exit
|
||||
else:
|
||||
if argv:
|
||||
from setuptools.command.easy_install import main
|
||||
main(argv)
|
||||
else:
|
||||
print "Setuptools version",version,"or greater has been installed."
|
||||
print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)'
|
||||
|
||||
def update_md5(filenames):
|
||||
"""Update our built-in md5 registry"""
|
||||
|
||||
import re
|
||||
|
||||
for name in filenames:
|
||||
base = os.path.basename(name)
|
||||
f = open(name,'rb')
|
||||
md5_data[base] = md5(f.read()).hexdigest()
|
||||
f.close()
|
||||
|
||||
data = [" %r: %r,\n" % it for it in md5_data.items()]
|
||||
data.sort()
|
||||
repl = "".join(data)
|
||||
|
||||
import inspect
|
||||
srcfile = inspect.getsourcefile(sys.modules[__name__])
|
||||
f = open(srcfile, 'rb'); src = f.read(); f.close()
|
||||
|
||||
match = re.search("\nmd5_data = {\n([^}]+)}", src)
|
||||
if not match:
|
||||
print >>sys.stderr, "Internal error!"
|
||||
sys.exit(2)
|
||||
|
||||
src = src[:match.start(1)] + repl + src[match.end(1):]
|
||||
f = open(srcfile,'w')
|
||||
f.write(src)
|
||||
f.close()
|
||||
|
||||
|
||||
if __name__=='__main__':
|
||||
if len(sys.argv)>2 and sys.argv[1]=='--md5update':
|
||||
update_md5(sys.argv[2:])
|
||||
else:
|
||||
main(sys.argv[1:])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -83,6 +83,7 @@ ENABLE_USER_SITE = None
|
|||
USER_SITE = None
|
||||
USER_BASE = None
|
||||
|
||||
_is_64bit = (getattr(sys, 'maxsize', None) or getattr(sys, 'maxint')) > 2**32
|
||||
_is_pypy = hasattr(sys, 'pypy_version_info')
|
||||
_is_jython = sys.platform[:4] == 'java'
|
||||
if _is_jython:
|
||||
|
@ -236,9 +237,9 @@ def addsitepackages(known_paths, sys_prefix=sys.prefix, exec_prefix=sys.exec_pre
|
|||
os.path.join(prefix, "lib", "site-python"),
|
||||
os.path.join(prefix, "python" + sys.version[:3], "lib-dynload")]
|
||||
lib64_dir = os.path.join(prefix, "lib64", "python" + sys.version[:3], "site-packages")
|
||||
if (os.path.exists(lib64_dir) and
|
||||
if (os.path.exists(lib64_dir) and
|
||||
os.path.realpath(lib64_dir) not in [os.path.realpath(p) for p in sitedirs]):
|
||||
if sys.maxsize > 2**32:
|
||||
if _is_64bit:
|
||||
sitedirs.insert(0, lib64_dir)
|
||||
else:
|
||||
sitedirs.append(lib64_dir)
|
||||
|
@ -559,13 +560,17 @@ def virtual_install_main_packages():
|
|||
if _is_jython:
|
||||
paths = [os.path.join(sys.real_prefix, 'Lib')]
|
||||
elif _is_pypy:
|
||||
if sys.pypy_version_info >= (1, 5):
|
||||
if sys.version_info > (3, 2):
|
||||
cpyver = '%d' % sys.version_info[0]
|
||||
elif sys.pypy_version_info >= (1, 5):
|
||||
cpyver = '%d.%d' % sys.version_info[:2]
|
||||
else:
|
||||
cpyver = '%d.%d.%d' % sys.version_info[:3]
|
||||
paths = [os.path.join(sys.real_prefix, 'lib_pypy'),
|
||||
os.path.join(sys.real_prefix, 'lib-python', 'modified-%s' % cpyver),
|
||||
os.path.join(sys.real_prefix, 'lib-python', cpyver)]
|
||||
if sys.pypy_version_info < (1, 9):
|
||||
paths.insert(1, os.path.join(sys.real_prefix,
|
||||
'lib-python', 'modified-%s' % cpyver))
|
||||
hardcoded_relative_dirs = paths[:] # for the special 'darwin' case below
|
||||
#
|
||||
# This is hardcoded in the Python executable, but relative to sys.prefix:
|
||||
|
@ -580,7 +585,7 @@ def virtual_install_main_packages():
|
|||
hardcoded_relative_dirs = paths[:] # for the special 'darwin' case below
|
||||
lib64_path = os.path.join(sys.real_prefix, 'lib64', 'python'+sys.version[:3])
|
||||
if os.path.exists(lib64_path):
|
||||
if sys.maxsize > 2**32:
|
||||
if _is_64bit:
|
||||
paths.insert(0, lib64_path)
|
||||
else:
|
||||
paths.append(lib64_path)
|
||||
|
@ -594,7 +599,7 @@ def virtual_install_main_packages():
|
|||
except AttributeError:
|
||||
# This is a non-multiarch aware Python. Fallback to the old way.
|
||||
arch = sys.platform
|
||||
plat_path = os.path.join(sys.real_prefix, 'lib',
|
||||
plat_path = os.path.join(sys.real_prefix, 'lib',
|
||||
'python'+sys.version[:3],
|
||||
'plat-%s' % arch)
|
||||
if os.path.exists(plat_path):
|
||||
|
@ -626,14 +631,14 @@ def force_global_eggs_after_local_site_packages():
|
|||
maintains the "least surprise" result that packages in the
|
||||
virtualenv always mask global packages, never the other way
|
||||
around.
|
||||
|
||||
|
||||
"""
|
||||
egginsert = getattr(sys, '__egginsert', 0)
|
||||
for i, path in enumerate(sys.path):
|
||||
if i > egginsert and path.startswith(sys.prefix):
|
||||
egginsert = i
|
||||
sys.__egginsert = egginsert + 1
|
||||
|
||||
|
||||
def virtual_addsitepackages(known_paths):
|
||||
force_global_eggs_after_local_site_packages()
|
||||
return addsitepackages(known_paths, sys_prefix=sys.real_prefix)
|
||||
|
|
Двоичные данные
python/virtualenv/virtualenv_support/distribute-0.6.31.tar.gz
Двоичные данные
python/virtualenv/virtualenv_support/distribute-0.6.31.tar.gz
Двоичный файл не отображается.
Двоичные данные
python/virtualenv/virtualenv_support/pip-1.2.1.tar.gz
Двоичные данные
python/virtualenv/virtualenv_support/pip-1.2.1.tar.gz
Двоичный файл не отображается.
Двоичный файл не отображается.
Двоичные данные
python/virtualenv/virtualenv_support/setuptools-0.6c11-py2.5.egg
Двоичные данные
python/virtualenv/virtualenv_support/setuptools-0.6c11-py2.5.egg
Двоичный файл не отображается.
Двоичные данные
python/virtualenv/virtualenv_support/setuptools-0.6c11-py2.6.egg
Двоичные данные
python/virtualenv/virtualenv_support/setuptools-0.6c11-py2.6.egg
Двоичный файл не отображается.
Двоичные данные
python/virtualenv/virtualenv_support/setuptools-0.6c11-py2.7.egg
Двоичные данные
python/virtualenv/virtualenv_support/setuptools-0.6c11-py2.7.egg
Двоичный файл не отображается.
Двоичный файл не отображается.
Загрузка…
Ссылка в новой задаче