Commits

James Tocknell committed c0b4a35

Improved docs and setup.py

Comments (0)

Files changed (8)

+Copyright (c) 2014, James Tocknell
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above copyright
+      notice, this list of conditions and the following disclaimer in the
+      documentation and/or other materials provided with the distribution.
+    * Neither the name of the <organization> nor the
+      names of its contributors may be used to endorse or promote products
+      derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+include README LICENSE
+recursive-include doc *
+prune doc/_build
+Installable via pip.
+Docs at http://venv_tools.rtfd.org.
 Usage
 =====
-:py:mod:`venv_tools` contains two classes,
+:py:mod:`venv_tools` contains two context managers,
 :py:class:`venv_tools.Venv`
 and
-:py:class:`venv_tools.TemporaryVenv`.
+:py:class:`venv_tools.TemporaryVenv`,
+which are designed to work together:
+
+.. code-block :: python
+
+    with TemporaryVenv() as env_dir, Venv(env_dir):
+        call(["pip", "install", "-r", "requirements.txt"])
+        call(["python", "-m", "profile", "project"])
+
+Or, if you already have a venv:
+
+.. code-block :: python
+
+    with Venv(env_dir):
+        call(["pip", "install", "-r", "requirements.txt"])
+        call(["python", "-m", "profile", "project"])
+
+Because :py:mod:`venv_tools`
+wraps around the `venv.EnvBuilder` API
+in Python 3.3 and above,
+it's possible to use more featureful subclasses,
+such as the example given
+`here <http://docs.python.org/3.3/library/venv.html#an-example-of-extending-envbuilder>`_.
+In fact, for Python 3.3,
+the default `venv_builder` is
+a subclass of `venv.EnvBuilder`
+which includes the option
+`get_pip`.
+This has the advantage that
+if you're using Python 3.3 or above,
+and you have a set of
+packages you keep installing inside your venv,
+you don't need to copy the same code around,
+you can just create a subclass.
+
 Contents:
 
 .. toctree::
-   :maxdepth: 2
+    :maxdepth: 2
 
-   Usage
-   API
+    Usage
+    API
 
 
 
+[metadata]
+provides-extra =
+    virtualenv
+requires-dist =
+    virtualenv; python_version < '3.3' or extra == "virtualenv"
+license-file = LICENSE
+
+[wheel]
+# use py2.py3 tag for pure-python dist:
+universal=1
 import setuptools
 
+import os
+import re
+
+## Utility funcs from https://github.com/pypa/sampleproject/blob/master/setup.py
+here = os.path.abspath(os.path.dirname(__file__))
+# Read the version number from a source file.
+# Code taken from pip's setup.py
+def find_version(*file_paths):
+    import codecs
+    # Open in Latin-1 so that we avoid encoding errors.
+    # Use codecs.open for Python 2 compatibility
+    with codecs.open(os.path.join(here, *file_paths), 'r', 'latin1') as f:
+        version_file = f.read()
+
+    # The version line must have the form
+    # __version__ = 'ver'
+    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.")
+
+deps = ["requests"]
+
+try:
+    import venv
+except ImportError:
+    deps.append("virtualenv")
+
 setuptools.setup(
-        name="venv_tools",
-        version="0.1",
-        packages = "venv_tools",
-        install_requires = ["requests"]
-        author = "James Tocknell",
-        author_email = "aragilar@gmail.com",
-        description = "A bunch of tools for using venvs (and virtualenvs) from python.",
-        license = "BSD",
-        keywords = "virtualenv venv",
-        url = "http://venv_tools.rtfd.org"
+    name="venv_tools",
+    version=find_version("venv_tools", "__init__.py"),
+    packages = ["venv_tools"],
+    install_requires = deps,
+    author = "James Tocknell",
+    author_email = "aragilar@gmail.com",
+    description = "A bunch of tools for using venvs (and virtualenvs) from python.",
+    license = "BSD",
+    keywords = "virtualenv venv",
+    url = "http://venv_tools.rtfd.org",
+    classifiers=[
+        'Development Status :: 3 - Alpha',
+        'Intended Audience :: Developers',
+        "Topic :: Software Development :: Libraries :: Python Modules",
+        "Topic :: System :: Shells",
+        'License :: OSI Approved :: BSD License',
+        'Programming Language :: Python :: 2',
+        'Programming Language :: Python :: 2.6',
+        'Programming Language :: Python :: 2.7',
+        'Programming Language :: Python :: 3',
+        'Programming Language :: Python :: 3.1',
+        'Programming Language :: Python :: 3.2',
+        'Programming Language :: Python :: 3.3',
+    ],
+    extras_require = {
+        "virtualenv": ["virtualenv"]
+    }
 )

venv_tools/__init__.py

         this should not be relied upon. A warning will be raised if it is
         detected that this is running inside a venv.
 
-    :param str env_dir: The absolute path to the venv.
+    :param str path_to_python_exe: The absolute path to the python executable.
+    :param bool use_virtualenv: Use virtualenv instead of the default to create
+        the venv.
     :param venv_builder: An object which creates a venv. It must define a method
         `create` which takes one argument, `env_dir`, and creates a venv at that
         path. Any additional keywords passed to `Venv` will be passed to the