Commit 481e800a authored by Kenneth Reitz's avatar Kenneth Reitz

virtualenv v1.7.2

parent 9a7c6c33
...@@ -74,7 +74,7 @@ indent() { ...@@ -74,7 +74,7 @@ indent() {
# Virtualenv wrapper. # Virtualenv wrapper.
function virtualenv (){ function virtualenv (){
python "$ROOT_DIR/vendor/virtualenv-1.7/virtualenv.py" "$@" python "$ROOT_DIR/vendor/virtualenv-1.7.2/virtualenv.py" "$@"
} }
# Buildpack Steps. # Buildpack Steps.
......
...@@ -14,20 +14,38 @@ Contributors ...@@ -14,20 +14,38 @@ Contributors
------------ ------------
Alex Grönholm Alex Grönholm
Anatoly Techtonik
Antonio Cuni Antonio Cuni
Armin Ronacher Armin Ronacher
Bradley Ayers
Cap Petschulat
CBWhiz
Chris McDonough Chris McDonough
Christian Stefanescu Christian Stefanescu
Christopher Nilsson Christopher Nilsson
Cliff Xuan
Curt Micol Curt Micol
David Schoonover
Doug Hellmann
Doug Napoleone
Douglas Creager Douglas Creager
Ethan Jucovy
Gunnlaugur Thor Briem Gunnlaugur Thor Briem
Greg Haskins
Jason R. Coombs
Jeff Hammel Jeff Hammel
Jonathan Griffin
Jorge Vargas Jorge Vargas
Josh Bronson Josh Bronson
Konstantin Zemlyak
Kumar McMillan Kumar McMillan
Lars Francke Lars Francke
Marc Abramowitz
Mike Hommey
Miki Tebeka
Philip Jenvey Philip Jenvey
Raul Leal
Ronny Pfannschmidt Ronny Pfannschmidt
Stefano Rivera
Tarek Ziadé Tarek Ziadé
Vinay Sajip Vinay Sajip
Copyright (c) 2007 Ian Bicking and Contributors Copyright (c) 2007 Ian Bicking and Contributors
Copyright (c) 2009 Ian Bicking, The Open Planning Project Copyright (c) 2009 Ian Bicking, The Open Planning Project
Copyright (c) 2011 The virtualenv developers Copyright (c) 2011-2012 The virtualenv developers
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the
......
recursive-include docs *.txt recursive-include bin *
recursive-include docs *
recursive-include scripts * recursive-include scripts *
recursive-include virtualenv_support *.egg *.tar.gz recursive-include virtualenv_support *.egg *.tar.gz
recursive-exclude virtualenv_support *.py recursive-include virtualenv_embedded *
recursive-exclude docs/_templates *.* recursive-exclude docs/_templates *
recursive-exclude docs/_build *
include virtualenv_support/__init__.py include virtualenv_support/__init__.py
include *.py include *.py
include AUTHORS.txt include AUTHORS.txt
......
virtualenv
==========
.. image:: https://secure.travis-ci.org/pypa/virtualenv.png?branch=develop
:target: http://travis-ci.org/pypa/virtualenv
For documentation, see http://www.virtualenv.org/
...@@ -29,7 +29,8 @@ def rebuild(): ...@@ -29,7 +29,8 @@ def rebuild():
varname = match.group(2) varname = match.group(2)
data = match.group(3) data = match.group(3)
print('Found reference to file %s' % filename) print('Found reference to file %s' % filename)
f = open(os.path.join(here, '..', 'virtualenv_support', filename), 'rb') pathname = os.path.join(here, '..', 'virtualenv_embedded', filename)
f = open(pathname, 'rb')
c = f.read() c = f.read()
f.close() f.close()
new_data = c.encode('zlib').encode('base64') new_data = c.encode('zlib').encode('base64')
......
...@@ -11,19 +11,24 @@ except ImportError: ...@@ -11,19 +11,24 @@ except ImportError:
import sys import sys
here = os.path.dirname(__file__) here = os.path.dirname(__file__)
support_files = os.path.join(here, '..', 'virtualenv_support') support_location = os.path.join(here, '..', 'virtualenv_support')
embedded_location = os.path.join(here, '..', 'virtualenv_embedded')
files = [ embedded_files = [
('http://peak.telecommunity.com/dist/ez_setup.py', 'ez_setup.py'), ('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.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/2.5/s/setuptools/setuptools-0.6c11-py2.5.egg', 'setuptools-0.6c11-py2.5.egg'),
('http://pypi.python.org/packages/2.4/s/setuptools/setuptools-0.6c11-py2.4.egg', 'setuptools-0.6c11-py2.4.egg'), ('http://pypi.python.org/packages/2.4/s/setuptools/setuptools-0.6c11-py2.4.egg', 'setuptools-0.6c11-py2.4.egg'),
('http://python-distribute.org/distribute_setup.py', 'distribute_setup.py'), ('http://pypi.python.org/packages/source/d/distribute/distribute-0.6.27.tar.gz', 'distribute-0.6.27.tar.gz'),
('http://pypi.python.org/packages/source/d/distribute/distribute-0.6.24.tar.gz', 'distribute-0.6.24.tar.gz'), ('http://pypi.python.org/packages/source/p/pip/pip-1.1.tar.gz', 'pip-1.1.tar.gz'),
('http://pypi.python.org/packages/source/p/pip/pip-1.0.2.tar.gz', 'pip-1.0.2.tar.gz'),
] ]
def main():
def refresh_files(files, location):
for url, filename in files: for url, filename in files:
sys.stdout.write('fetching %s ... ' % url) sys.stdout.write('fetching %s ... ' % url)
sys.stdout.flush() sys.stdout.flush()
...@@ -31,7 +36,7 @@ def main(): ...@@ -31,7 +36,7 @@ def main():
content = f.read() content = f.read()
f.close() f.close()
print('done.') print('done.')
filename = os.path.join(support_files, filename) filename = os.path.join(location, filename)
if os.path.exists(filename): if os.path.exists(filename):
f = open(filename, 'rb') f = open(filename, 'rb')
cur_content = f.read() cur_content = f.read()
...@@ -46,6 +51,11 @@ def main(): ...@@ -46,6 +51,11 @@ def main():
f.write(content) f.write(content)
f.close() f.close()
def main():
refresh_files(embedded_files, embedded_location)
refresh_files(support_files, support_location)
if __name__ == '__main__': if __name__ == '__main__':
main() main()
......
...@@ -35,15 +35,18 @@ master_doc = 'index' ...@@ -35,15 +35,18 @@ master_doc = 'index'
# General substitutions. # General substitutions.
project = 'virtualenv' project = 'virtualenv'
copyright = '2007-2011, Ian Bicking, The Open Planning Project, The virtualenv developers' copyright = '2007-2012, Ian Bicking, The Open Planning Project, The virtualenv developers'
# The default replacements for |version| and |release|, also used in various # The default replacements for |version| and |release|, also used in various
# other places throughout the built documents. # other places throughout the built documents.
# try:
# The short X.Y version. from virtualenv import __version__
# The short X.Y version.
release = "1.7" version = '.'.join(__version__.split('.')[:2])
version = ".".join(release.split(".")[:2]) # The full version, including alpha/beta/rc tags.
release = __version__
except ImportError:
version = release = 'dev'
# There are two options for replacing |today|: either, you set today to some # There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used: # non-false value, then it is used:
...@@ -83,7 +86,7 @@ html_theme_path = ['_theme'] ...@@ -83,7 +86,7 @@ html_theme_path = ['_theme']
# Add any paths that contain custom static files (such as style sheets) here, # Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files, # relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css". # so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static'] # html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format. # using the given strftime format.
......
...@@ -13,23 +13,12 @@ virtualenv ...@@ -13,23 +13,12 @@ virtualenv
.. comment: split here .. comment: split here
Status and License Installation
------------------ ------------
``virtualenv`` is a successor to `workingenv
<http://cheeseshop.python.org/pypi/workingenv.py>`_, and an extension
of `virtual-python
<http://peak.telecommunity.com/DevCenter/EasyInstall#creating-a-virtual-python>`_.
It was written by Ian Bicking, sponsored by the `Open Planning
Project <http://openplans.org>`_ and is now maintained by a
`group of developers <https://github.com/pypa/virtualenv/raw/master/AUTHORS.txt>`_.
It is licensed under an
`MIT-style permissive license <https://github.com/pypa/virtualenv/raw/master/LICENSE.txt>`_.
You can install it with ``pip install virtualenv``, or the `latest You can install virtualenv with ``pip install virtualenv``, or the `latest
development version <https://github.com/pypa/virtualenv/tarball/develop#egg=virtualenv-dev>`_ development version <https://github.com/pypa/virtualenv/tarball/develop>`_
with ``pip install virtualenv==dev``. with ``pip install https://github.com/pypa/virtualenv/tarball/develop``.
You can also use ``easy_install``, or if you have no Python package manager 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 available at all, you can just grab the single file `virtualenv.py`_ and run
...@@ -37,7 +26,6 @@ it with ``python virtualenv.py``. ...@@ -37,7 +26,6 @@ it with ``python virtualenv.py``.
.. _virtualenv.py: https://raw.github.com/pypa/virtualenv/master/virtualenv.py .. _virtualenv.py: https://raw.github.com/pypa/virtualenv/master/virtualenv.py
What It Does What It Does
------------ ------------
...@@ -83,9 +71,9 @@ Distribute instead of setuptools, just call virtualenv like this:: ...@@ -83,9 +71,9 @@ Distribute instead of setuptools, just call virtualenv like this::
$ python virtualenv.py --distribute ENV $ python virtualenv.py --distribute ENV
You can also set the environment variable VIRTUALENV_USE_DISTRIBUTE. You can also set the environment variable VIRTUALENV_DISTRIBUTE.
A new virtualenv also includes the `pip <http://pypy.python.org/pypi/pip>`_ 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 installer, so you can use ``ENV/bin/pip`` to install additional packages into
the environment. the environment.
...@@ -105,7 +93,7 @@ virtualenv can not only be configured by passing command line options such as ...@@ -105,7 +93,7 @@ virtualenv can not only be configured by passing command line options such as
For example, to automatically install Distribute instead of setuptools For example, to automatically install Distribute instead of setuptools
you can also set an environment variable:: you can also set an environment variable::
$ export VIRTUALENV_USE_DISTRIBUTE=true $ export VIRTUALENV_DISTRIBUTE=true
$ python virtualenv.py ENV $ python virtualenv.py ENV
It's the same as passing the option to virtualenv directly:: It's the same as passing the option to virtualenv directly::
...@@ -126,7 +114,7 @@ virtualenv can not only be configured by passing command line options such as ...@@ -126,7 +114,7 @@ virtualenv can not only be configured by passing command line options such as
virtualenv also looks for a standard ini config file. On Unix and Mac OS X virtualenv also looks for a standard ini config file. On Unix and Mac OS X
that's ``$HOME/.virtualenv/virtualenv.ini`` and on Windows, it's that's ``$HOME/.virtualenv/virtualenv.ini`` and on Windows, it's
``%HOME%\\virtualenv\\virtualenv.ini``. ``%APPDATA%\virtualenv\virtualenv.ini``.
The names of the settings are derived from the long command line option, 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 ``--distribute`` would look like this::
...@@ -241,7 +229,8 @@ activate script ...@@ -241,7 +229,8 @@ activate script
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~
In a newly created virtualenv there will be a ``bin/activate`` shell In a newly created virtualenv there will be a ``bin/activate`` shell
script, or a ``Scripts/activate.bat`` batch file on Windows. script. For Windows systems, activation scripts are provided for CMD.exe
and Powershell.
On Posix systems you can do:: On Posix systems you can do::
...@@ -266,9 +255,65 @@ value before running the ``activate`` script. ...@@ -266,9 +255,65 @@ value before running the ``activate`` script.
On Windows you just do:: On Windows you just do::
> \path\to\env\Scripts\activate.bat > \path\to\env\Scripts\activate
And type `deactivate` to undo the changes.
Based on your active shell (CMD.exe or Powershell.exe), Windows will use
either activate.bat or activate.ps1 (as appropriate) to activate the
virtual environment. If using Powershell, see the notes about code signing
below.
.. note::
If using Powershell, the ``activate`` script is subject to the
`execution policies`_ on the system. By default on Windows 7, the system's
excution policy is set to ``Restricted``, meaning no scripts like the
``activate`` script are allowed to be executed. But that can't stop us
from changing that slightly to allow it to be executed.
In order to use the script, you have to relax your system's execution
policy to ``AllSigned``, meaning all scripts on the system must be
digitally signed to be executed. Since the virtualenv activation
script is signed by one of the authors (Jannis Leidel) this level of
the execution policy suffices. As an administrator run::
PS C:\> Set-ExecutionPolicy AllSigned
Then you'll be asked to trust the signer, when executing the script.
You will be prompted with the following::
And use ``deactivate.bat`` to undo the changes. PS C:\> virtualenv .\foo
New python executable in C:\foo\Scripts\python.exe
Installing setuptools................done.
Installing pip...................done.
PS C:\> .\foo\scripts\activate
Do you want to run software from this untrusted publisher?
File C:\foo\scripts\activate.ps1 is published by E=jannis@leidel.info,
CN=Jannis Leidel, L=Berlin, S=Berlin, C=DE, Description=581796-Gh7xfJxkxQSIO4E0
and is not trusted on your system. Only run scripts from trusted publishers.
[V] Never run [D] Do not run [R] Run once [A] Always run [?] Help
(default is "D"):A
(foo) PS C:\>
If you select ``[A] Always Run``, the certificate will be added to the
Trusted Publishers of your user account, and will be trusted in this
user's context henceforth. If you select ``[R] Run Once``, the script will
be run, but you will be prometed on a subsequent invocation. Advanced users
can add the signer's certificate to the Trusted Publishers of the Computer
account to apply to all users (though this technique is out of scope of this
document).
Alternatively, you may relax the system execution policy to allow running
of local scripts without verifying the code signature using the following::
PS C:\> Set-ExecutionPolicy RemoteSigned
Since the ``activate.ps1`` script is generated locally for each virtualenv,
it is not considered a remote script and can then be executed.
.. _`execution policies`: http://technet.microsoft.com/en-us/library/dd347641.aspx
The ``--system-site-packages`` Option The ``--system-site-packages`` Option
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...@@ -381,7 +426,16 @@ provide an option ``--never-download`` like so:: ...@@ -381,7 +426,16 @@ provide an option ``--never-download`` like so::
If this option is provided, virtualenv will never try to download If this option is provided, virtualenv will never try to download
setuptools/distribute or pip. Instead, it will exit with status code 1 setuptools/distribute or pip. Instead, it will exit with status code 1
if it fails to find local distributions for any of these required if it fails to find local distributions for any of these required
packages. packages. The local distribution lookup is done in this order and the
following locations:
#. 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 Compare & Contrast with Alternatives
------------------------------------ ------------------------------------
...@@ -425,13 +479,15 @@ Contributing ...@@ -425,13 +479,15 @@ Contributing
------------ ------------
Refer to the `contributing to pip`_ documentation - it applies equally to Refer to the `contributing to pip`_ documentation - it applies equally to
virtualenv. virtualenv, except that virtualenv issues should filed on the `virtualenv
repo`_ at GitHub.
Virtualenv's release schedule is tied to pip's -- each time there's a new pip Virtualenv's release schedule is tied to pip's -- each time there's a new pip
release, there will be a new virtualenv release that bundles the new version of release, there will be a new virtualenv release that bundles the new version of
pip. pip.
.. _contributing to pip: http://www.pip-installer.org/en/latest/how-to-contribute.html .. _contributing to pip: http://www.pip-installer.org/en/latest/contributing.html
.. _virtualenv repo: https://github.com/pypa/virtualenv/
Running the tests Running the tests
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
...@@ -483,5 +539,19 @@ Other Documentation and Links ...@@ -483,5 +539,19 @@ Other Documentation and Links
<http://code.google.com/p/modwsgi/wiki/VirtualEnvironments>`_. <http://code.google.com/p/modwsgi/wiki/VirtualEnvironments>`_.
* `virtualenv commands * `virtualenv commands
<http://thisismedium.com/tech/extending-virtualenv/>`_ for some more <https://github.com/thisismedium/virtualenv-commands>`_ for some more
workflow-related tools around virtualenv. workflow-related tools around virtualenv.
Status and License
------------------
``virtualenv`` is a successor to `workingenv
<http://cheeseshop.python.org/pypi/workingenv.py>`_, and an extension
of `virtual-python
<http://peak.telecommunity.com/DevCenter/EasyInstall#creating-a-virtual-python>`_.
It was written by Ian Bicking, sponsored by the `Open Planning
Project <http://openplans.org>`_ and is now maintained by a
`group of developers <https://github.com/pypa/virtualenv/raw/master/AUTHORS.txt>`_.
It is licensed under an
`MIT-style permissive license <https://github.com/pypa/virtualenv/raw/master/LICENSE.txt>`_.
Changes & News Changes & News
-------------- --------------
.. warning::
Python bugfix releases 2.6.8, 2.7.3, 3.1.5 and 3.2.3 include a change that
will cause "import random" to fail with "cannot import name urandom" on any
virtualenv created on a Unix host with an earlier release of Python
2.6/2.7/3.1/3.2, if the underlying system Python is upgraded. This is due to
the fact that a virtualenv uses the system Python's standard library but
contains its own copy of the Python interpreter, so an upgrade to the system
Python results in a mismatch between the version of the Python interpreter
and the version of the standard library. It can be fixed by removing
``$ENV/bin/python`` and re-running virtualenv on the same target directory
with the upgraded Python.
1.7.2 (2012-06-22)
~~~~~~~~~~~~~~~~~~
* Updated to distribute 0.6.27.
* Fix activate.fish on OS X. Fixes #8. Thanks David Schoonover.
* Create a virtualenv-x.x script with the Python version when installing, so
virtualenv for multiple Python versions can be installed to the same
script location. Thanks Miki Tebeka.
* Restored ability to create a virtualenv with a path longer than 78
characters, without breaking creation of virtualenvs with non-ASCII paths.
Thanks, Bradley Ayers.
* Added ability to create virtualenvs without having installed Apple's
developers tools (using an own implementation of ``install_name_tool``).
Thanks Mike Hommey.
* Fixed PyPy and Jython support on Windows. Thanks Konstantin Zemlyak.
* Added pydoc script to ease use. Thanks Marc Abramowitz. Fixes #149.
* Fixed creating a bootstrap script on Python 3. Thanks Raul Leal. Fixes #280.
* Fixed inconsistency when having set the ``PYTHONDONTWRITEBYTECODE`` env var
with the --distribute option or the ``VIRTUALENV_USE_DISTRIBUTE`` env var.
``VIRTUALENV_USE_DISTRIBUTE`` is now considered again as a legacy alias.
1.7.1.2 (2012-02-17)
~~~~~~~~~~~~~~~~~~~~
* Fixed minor issue in `--relocatable`. Thanks, Cap Petschulat.
1.7.1.1 (2012-02-16)
~~~~~~~~~~~~~~~~~~~~
* Bumped the version string in ``virtualenv.py`` up, too.
* Fixed rST rendering bug of long description.
1.7.1 (2012-02-16)
~~~~~~~~~~~~~~~~~~
* Update embedded pip to version 1.1.
* Fix `--relocatable` under Python 3. Thanks Doug Hellmann.
* Added environ PATH modification to activate_this.py. Thanks Doug
Napoleone. Fixes #14.
* Support creating virtualenvs directly from a Python build directory on
Windows. Thanks CBWhiz. Fixes #139.
* Use non-recursive symlinks to fix things up for posix_local install
scheme. Thanks michr.
* Made activate script available for use with msys and cygwin on Windows.
Thanks Greg Haskins, Cliff Xuan, Jonathan Griffin and Doug Napoleone.
Fixes #176.
* Fixed creation of virtualenvs on Windows when Python is not installed for
all users. Thanks Anatoly Techtonik for report and patch and Doug
Napoleone for testing and confirmation. Fixes #87.
* Fixed creation of virtualenvs using -p in installs where some modules
that ought to be in the standard library (e.g. `readline`) are actually
installed in `site-packages` next to `virtualenv.py`. Thanks Greg Haskins
for report and fix. Fixes #167.
* Added activation script for Powershell (signed by Jannis Leidel). Many
thanks to Jason R. Coombs.
1.7 (2011-11-30) 1.7 (2011-11-30)
~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
* Updated embedded Distribute release to 0.6.24. Thanks Alex Grönholm. * Gave user-provided ``--extra-search-dir`` priority over default dirs for
finding setuptools/distribute (it already had priority for finding pip).
Thanks Ethan Jucovy.
* Updated embedded Distribute release to 0.6.24. Thanks Alex Gronholm.
* Made ``--no-site-packages`` behavior the default behavior. The * Made ``--no-site-packages`` behavior the default behavior. The
``--no-site-packages`` flag is still permitted, but displays a warning when ``--no-site-packages`` flag is still permitted, but displays a warning when
...@@ -162,7 +253,7 @@ Changes & News ...@@ -162,7 +253,7 @@ Changes & News
* Fix problem with ``virtualenv --relocate`` when ``bin/`` has * Fix problem with ``virtualenv --relocate`` when ``bin/`` has
subdirectories (e.g., ``bin/.svn/``); from Alan Franzoni. subdirectories (e.g., ``bin/.svn/``); from Alan Franzoni.
* If you set ``$VIRTUALENV_USE_DISTRIBUTE`` then virtualenv will use * If you set ``$VIRTUALENV_DISTRIBUTE`` then virtualenv will use
Distribute by default (so you don't have to remember to use Distribute by default (so you don't have to remember to use
``--distribute``). ``--distribute``).
......
import sys, os import os
import re
import shutil
import sys
try: try:
from setuptools import setup from setuptools import setup
kw = {'entry_points': setup_params = {
"""[console_scripts]\nvirtualenv = virtualenv:main\n""", 'entry_points': {
'zip_safe': False} 'console_scripts': [
'virtualenv=virtualenv:main',
'virtualenv-%s.%s=virtualenv:main' % sys.version_info[:2]
],
},
'zip_safe': False,
'test_suite': 'nose.collector',
'tests_require': ['nose', 'Mock'],
}
except ImportError: except ImportError:
from distutils.core import setup from distutils.core import setup
if sys.platform == 'win32': if sys.platform == 'win32':
print('Note: without Setuptools installed you will have to use "python -m virtualenv ENV"') print('Note: without Setuptools installed you will have to use "python -m virtualenv ENV"')
kw = {} setup_params = {}
else: else:
kw = {'scripts': ['scripts/virtualenv']} script = 'scripts/virtualenv'
script_ver = script + '-%s.%s' % sys.version_info[:2]
shutil.copy(script, script_ver)
setup_params = {'scripts': [script, script_ver]}
here = os.path.dirname(os.path.abspath(__file__)) here = os.path.dirname(os.path.abspath(__file__))
...@@ -23,10 +38,32 @@ f = open(os.path.join(here, 'docs', 'news.txt')) ...@@ -23,10 +38,32 @@ f = open(os.path.join(here, 'docs', 'news.txt'))
long_description += "\n\n" + f.read() long_description += "\n\n" + f.read()
f.close() f.close()
setup(name='virtualenv',
def get_version():
f = open(os.path.join(here, 'virtualenv.py'))
version_file = f.read()
f.close()
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
version_file, re.M)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string.")
# Hack to prevent stupid TypeError: 'NoneType' object is not callable error on
# exit of python setup.py test # in multiprocessing/util.py _exit_function when
# running python setup.py test (see
# http://www.eby-sarna.com/pipermail/peak/2010-May/003357.html)
try:
import multiprocessing
except ImportError:
pass
setup(
name='virtualenv',
# If you change the version here, change it in virtualenv.py and # If you change the version here, change it in virtualenv.py and
# docs/conf.py as well # docs/conf.py as well
version="1.7", version=get_version(),
description="Virtual Python Environment builder", description="Virtual Python Environment builder",
long_description=long_description, long_description=long_description,
classifiers=[ classifiers=[
...@@ -52,7 +89,4 @@ setup(name='virtualenv', ...@@ -52,7 +89,4 @@ setup(name='virtualenv',
py_modules=['virtualenv'], py_modules=['virtualenv'],
packages=['virtualenv_support'], packages=['virtualenv_support'],
package_data={'virtualenv_support': ['*-py%s.egg' % sys.version[:3], '*.tar.gz']}, package_data={'virtualenv_support': ['*-py%s.egg' % sys.version[:3], '*.tar.gz']},
test_suite='nose.collector', **setup_params)
tests_require=['nose', 'Mock'],
**kw
)
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# You cannot run it directly. # You cannot run it directly.
# Created by Davide Di Blasi <davidedb@gmail.com>. # Created by Davide Di Blasi <davidedb@gmail.com>.
alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate' alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate && unalias pydoc'
# Unset irrelavent variables. # Unset irrelavent variables.
deactivate nondestructive deactivate nondestructive
...@@ -28,5 +28,7 @@ endif ...@@ -28,5 +28,7 @@ endif
set prompt = "[$env_name] $prompt" set prompt = "[$env_name] $prompt"
unset env_name unset env_name
alias pydoc python -m pydoc
rehash rehash
...@@ -15,6 +15,11 @@ function deactivate -d "Exit virtualenv and return to normal shell environment" ...@@ -15,6 +15,11 @@ function deactivate -d "Exit virtualenv and return to normal shell environment"
if test -n "$_OLD_FISH_PROMPT_OVERRIDE" if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
functions -e fish_prompt functions -e fish_prompt
set -e _OLD_FISH_PROMPT_OVERRIDE set -e _OLD_FISH_PROMPT_OVERRIDE
. ( begin
printf "function fish_prompt\n\t#"
functions _old_fish_prompt
end | psub )
functions -e _old_fish_prompt
end end
set -e VIRTUAL_ENV set -e VIRTUAL_ENV
...@@ -39,31 +44,22 @@ if set -q PYTHONHOME ...@@ -39,31 +44,22 @@ if set -q PYTHONHOME
end end
if test -z "$VIRTUAL_ENV_DISABLE_PROMPT" if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
# fish shell uses a function, instead of env vars, # fish uses a function instead of an env var to generate the prompt.
# to produce the prompt. Overriding the existing function is easy.
# However, adding to the current prompt, instead of clobbering it,
# is a little more work.
set -l oldpromptfile (tempfile)
if test $status
# save the current fish_prompt function...
echo "function _old_fish_prompt" >> $oldpromptfile
echo -n \# >> $oldpromptfile
functions fish_prompt >> $oldpromptfile
# we've made the "_old_fish_prompt" file, source it.
. $oldpromptfile
rm -f $oldpromptfile
if test -n "__VIRTUAL_PROMPT__" # save the current fish_prompt function as the function _old_fish_prompt
# We've been given us a prompt override. . ( begin
# printf "function _old_fish_prompt\n\t#"
# FIXME: Unsure how to handle this *safely*. We could just eval() functions fish_prompt
# whatever is given, but the risk is a bit much. end | psub )
echo "activate.fish: Alternative prompt prefix is not supported under fish-shell." 1>&2
echo "activate.fish: Alter the fish_prompt in this file as needed." 1>&2
end
# with the original prompt function renamed, we can override with our own. # with the original prompt function renamed, we can override with our own.
function fish_prompt function fish_prompt
# Prompt override?
if test -n "__VIRTUAL_PROMPT__"
printf "%s%s%s" "__VIRTUAL_PROMPT__" (set_color normal) (_old_fish_prompt)
return
end
# ...Otherwise, prepend env
set -l _checkbase (basename "$VIRTUAL_ENV") set -l _checkbase (basename "$VIRTUAL_ENV")
if test $_checkbase = "__" if test $_checkbase = "__"
# special case for Aspen magic directories # special case for Aspen magic directories
...@@ -73,7 +69,6 @@ if test -z "$VIRTUAL_ENV_DISABLE_PROMPT" ...@@ -73,7 +69,6 @@ if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
printf "%s(%s)%s%s" (set_color -b blue white) (basename "$VIRTUAL_ENV") (set_color normal) (_old_fish_prompt) printf "%s(%s)%s%s" (set_color -b blue white) (basename "$VIRTUAL_ENV") (set_color normal) (_old_fish_prompt)
end end
end end
set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV" set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
end
end end
# This file must be dot sourced from PoSh; you cannot run it
# directly. Do this: . ./activate.ps1
# FIXME: clean up unused vars.
$script:THIS_PATH = $myinvocation.mycommand.path
$script:BASE_DIR = split-path (resolve-path "$THIS_PATH/..") -Parent
$script:DIR_NAME = split-path $BASE_DIR -Leaf
function global:deactivate ( [switch] $NonDestructive ){
if ( test-path variable:_OLD_VIRTUAL_PATH ) {
$env:PATH = $variable:_OLD_VIRTUAL_PATH
remove-variable "_OLD_VIRTUAL_PATH" -scope global
}
if ( test-path function:_old_virtual_prompt ) {
$function:prompt = $function:_old_virtual_prompt
remove-item function:\_old_virtual_prompt
}
if ($env:VIRTUAL_ENV) {
$old_env = split-path $env:VIRTUAL_ENV -leaf
remove-item env:VIRTUAL_ENV -erroraction silentlycontinue
}
if ( !$NonDestructive ) {
# Self destruct!
remove-item function:deactivate
}
}
# unset irrelevant variables
deactivate -nondestructive
$VIRTUAL_ENV = $BASE_DIR
$env:VIRTUAL_ENV = $VIRTUAL_ENV
$global:_OLD_VIRTUAL_PATH = $env:PATH
$env:PATH = "$env:VIRTUAL_ENV/Scripts;" + $env:PATH
function global:_old_virtual_prompt { "" }
$function:_old_virtual_prompt = $function:prompt
function global:prompt {
# Add a prefix to the current prompt, but don't discard it.
write-host "($(split-path $env:VIRTUAL_ENV -leaf)) " -nonewline
& $function:_old_virtual_prompt
}
# SIG # Begin signature block
# MIISeAYJKoZIhvcNAQcCoIISaTCCEmUCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB
# gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR
# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUS5reBwSg3zOUwhXf2jPChZzf
# yPmggg6tMIIGcDCCBFigAwIBAgIBJDANBgkqhkiG9w0BAQUFADB9MQswCQYDVQQG
# EwJJTDEWMBQGA1UEChMNU3RhcnRDb20gTHRkLjErMCkGA1UECxMiU2VjdXJlIERp
# Z2l0YWwgQ2VydGlmaWNhdGUgU2lnbmluZzEpMCcGA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# AYI3AgEEMBwGCisGAQQBgjcCAQsxDjAMBgorBgEEAYI3AgEVMCMGCSqGSIb3DQEJ
# BDEWBBRVGw0FDSiaIi38dWteRUAg/9Pr6DANBgkqhkiG9w0BAQEFAASCAgCInvOZ
# FdaNFzbf6trmFDZKMojyx3UjKMCqNjHVBbuKY0qXwFC/ElYDV1ShJ2CBZbdurydO
# OQ6cIQ0KREOCwmX/xB49IlLHHUxNhEkVv7HGU3EKAFf9IBt9Yr7jikiR9cjIsfHK
# 4cjkoKJL7g28yEpLLkHt1eo37f1Ga9lDWEa5Zq3U5yX+IwXhrUBm1h8Xr033FhTR
# VEpuSz6LHtbrL/zgJnCzJ2ahjtJoYevdcWiNXffosJHFaSfYDDbiNsPRDH/1avmb
# 5j/7BhP8BcBaR6Fp8tFbNGIcWHHGcjqLMnTc4w13b7b4pDhypqElBa4+lCmwdvv9
# GydYtRgPz8GHeoBoKj30YBlMzRIfFYaIFGIC4Ai3UEXkuH9TxYohVbGm/W0Kl4Lb
# RJ1FwiVcLcTOJdgNId2vQvKc+jtNrjcg5SP9h2v/C4aTx8tyc6tE3TOPh2f9b8DL
# S+SbVArJpuJqrPTxDDoO1QNjTgLcdVYeZDE+r/NjaGZ6cMSd8db3EaG3ijD/0bud
# SItbm/OlNVbQOFRR76D+ZNgPcU5iNZ3bmvQQIg6aSB9MHUpIE/SeCkNl9YeVk1/1
# GFULgNMRmIYP4KLvu9ylh5Gu3hvD5VNhH6+FlXANwFy07uXks5uF8mfZVxVCnodG
# xkNCx+6PsrA5Z7WP4pXcmYnMn97npP/Q9EHJWw==
# SIG # End signature block
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
# you cannot run it directly # you cannot run it directly
deactivate () { deactivate () {
unset pydoc
# reset old environment variables # reset old environment variables
if [ -n "$_OLD_VIRTUAL_PATH" ] ; then if [ -n "$_OLD_VIRTUAL_PATH" ] ; then
PATH="$_OLD_VIRTUAL_PATH" PATH="$_OLD_VIRTUAL_PATH"
...@@ -18,7 +20,7 @@ deactivate () { ...@@ -18,7 +20,7 @@ deactivate () {
# be called to get it to forget past commands. Without forgetting # be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected # past commands the $PATH changes we made may not be respected
if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
hash -r hash -r 2>/dev/null
fi fi
if [ -n "$_OLD_VIRTUAL_PS1" ] ; then if [ -n "$_OLD_VIRTUAL_PS1" ] ; then
...@@ -68,9 +70,11 @@ if [ -z "$VIRTUAL_ENV_DISABLE_PROMPT" ] ; then ...@@ -68,9 +70,11 @@ if [ -z "$VIRTUAL_ENV_DISABLE_PROMPT" ] ; then
export PS1 export PS1
fi fi
alias pydoc="python -m pydoc"
# This should detect bash and zsh, which have a hash command that must # This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting # be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected # past commands the $PATH changes we made may not be respected
if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
hash -r hash -r 2>/dev/null
fi fi
"""By using execfile(this_file, dict(__file__=this_file)) you will
activate this virtualenv environment.
This can be used when you must use an existing Python interpreter, not
the virtualenv bin/python
"""
try:
__file__
except NameError:
raise AssertionError(
"You must run this like execfile('path/to/activate_this.py', dict(__file__='path/to/activate_this.py'))")
import sys
import os
old_os_path = os.environ['PATH']
os.environ['PATH'] = os.path.dirname(os.path.abspath(__file__)) + os.pathsep + old_os_path
base = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if sys.platform == 'win32':
site_packages = os.path.join(base, 'Lib', 'site-packages')
else:
site_packages = os.path.join(base, 'lib', 'python%s' % sys.version[:3], 'site-packages')
prev_sys_path = list(sys.path)
import site
site.addsitedir(site_packages)
sys.real_prefix = sys.prefix
sys.prefix = base
# Move the added items to the front of the path:
new_sys_path = []
for item in list(sys.path):
if item not in prev_sys_path:
new_sys_path.append(item)
sys.path.remove(item)
sys.path[:0] = new_sys_path
import os
import sys
import warnings
import opcode # opcode is not a virtualenv module, so we can use it to find the stdlib
# Important! To work on pypy, this must be a module that resides in the
# lib-python/modified-x.y.z directory
dirname = os.path.dirname
distutils_path = os.path.join(os.path.dirname(opcode.__file__), 'distutils')
if os.path.normpath(distutils_path) == os.path.dirname(os.path.normpath(__file__)):
warnings.warn(
"The virtualenv distutils package at %s appears to be in the same location as the system distutils?")
else:
__path__.insert(0, distutils_path)
exec(open(os.path.join(distutils_path, '__init__.py')).read())
from distutils import dist, sysconfig
try:
basestring
except NameError:
basestring = str
## patch build_ext (distutils doesn't know how to get the libs directory
## path on windows - it hardcodes the paths around the patched sys.prefix)
if sys.platform == 'win32':
from distutils.command.build_ext import build_ext as old_build_ext
class build_ext(old_build_ext):
def finalize_options (self):
if self.library_dirs is None:
self.library_dirs = []
elif isinstance(self.library_dirs, basestring):
self.library_dirs = self.library_dirs.split(os.pathsep)
self.library_dirs.insert(0, os.path.join(sys.real_prefix, "Libs"))
old_build_ext.finalize_options(self)
from distutils.command import build_ext as build_ext_module
build_ext_module.build_ext = build_ext
## distutils.dist patches:
old_find_config_files = dist.Distribution.find_config_files
def find_config_files(self):
found = old_find_config_files(self)
system_distutils = os.path.join(distutils_path, 'distutils.cfg')
#if os.path.exists(system_distutils):
# found.insert(0, system_distutils)
# What to call the per-user config file
if os.name == 'posix':
user_filename = ".pydistutils.cfg"
else:
user_filename = "pydistutils.cfg"
user_filename = os.path.join(sys.prefix, user_filename)
if os.path.isfile(user_filename):
for item in list(found):
if item.endswith('pydistutils.cfg'):
found.remove(item)
found.append(user_filename)
return found
dist.Distribution.find_config_files = find_config_files
## distutils.sysconfig patches:
old_get_python_inc = sysconfig.get_python_inc
def sysconfig_get_python_inc(plat_specific=0, prefix=None):
if prefix is None:
prefix = sys.real_prefix
return old_get_python_inc(plat_specific, prefix)
sysconfig_get_python_inc.__doc__ = old_get_python_inc.__doc__
sysconfig.get_python_inc = sysconfig_get_python_inc
old_get_python_lib = sysconfig.get_python_lib
def sysconfig_get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
if standard_lib and prefix is None:
prefix = sys.real_prefix
return old_get_python_lib(plat_specific, standard_lib, prefix)
sysconfig_get_python_lib.__doc__ = old_get_python_lib.__doc__
sysconfig.get_python_lib = sysconfig_get_python_lib
old_get_config_vars = sysconfig.get_config_vars
def sysconfig_get_config_vars(*args):
real_vars = old_get_config_vars(*args)
if sys.platform == 'win32':
lib_dir = os.path.join(sys.real_prefix, "libs")
if isinstance(real_vars, dict) and 'LIBDIR' not in real_vars:
real_vars['LIBDIR'] = lib_dir # asked for all
elif isinstance(real_vars, list) and 'LIBDIR' in args:
real_vars = real_vars + [lib_dir] # asked for list
return real_vars
sysconfig_get_config_vars.__doc__ = old_get_config_vars.__doc__
sysconfig.get_config_vars = sysconfig_get_config_vars
This diff is collapsed.
This diff is collapsed.
virtualenv
==========
See docs/index.txt for user documentation.
Contributor notes
-----------------
* virtualenv is designed to work on python 2 and 3 with a single code base.
Use Python 3 print-function syntax, and always use sys.exc_info()[1]
inside the `except` block to get at exception objects.
* virtualenv uses git-flow_ to `coordinate development`_.
.. _git-flow: https://github.com/nvie/gitflow
.. _coordinate development: http://nvie.com/posts/a-successful-git-branching-model/
import virtualenv
from mock import patch, Mock
def test_version():
"""Should have a version string"""
assert virtualenv.virtualenv_version == "1.7", "Should have version"
@patch('os.path.exists')
def test_resolve_interpreter_with_absolute_path(mock_exists):
"""Should return absolute path if given and exists"""
mock_exists.return_value = True
virtualenv.is_executable = Mock(return_value=True)
exe = virtualenv.resolve_interpreter("/usr/bin/python42")
assert exe == "/usr/bin/python42", "Absolute path should return as is"
mock_exists.assert_called_with("/usr/bin/python42")
virtualenv.is_executable.assert_called_with("/usr/bin/python42")
@patch('os.path.exists')
def test_resolve_intepreter_with_nonexistant_interpreter(mock_exists):
"""Should exit when with absolute path if not exists"""
mock_exists.return_value = False
try:
virtualenv.resolve_interpreter("/usr/bin/python42")
assert False, "Should raise exception"
except SystemExit:
pass
mock_exists.assert_called_with("/usr/bin/python42")
@patch('os.path.exists')
def test_resolve_intepreter_with_invalid_interpreter(mock_exists):
"""Should exit when with absolute path if not exists"""
mock_exists.return_value = True
virtualenv.is_executable = Mock(return_value=False)
try:
virtualenv.resolve_interpreter("/usr/bin/python42")
assert False, "Should raise exception"
except SystemExit:
pass
mock_exists.assert_called_with("/usr/bin/python42")
virtualenv.is_executable.assert_called_with("/usr/bin/python42")
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment