summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorholger krekel <holger@merlinux.eu>2010-10-21 08:07:32 +0200
committerholger krekel <holger@merlinux.eu>2010-10-21 08:07:32 +0200
commit8929f7e6a1d68799968ffd57a3d44e574d9f139a (patch)
treeaf123c305b05099005689707da54e1b8a2e3d07c
parent8d8ece154a239c56c68450d3c178823ddcdd9e2c (diff)
downloadtox-8929f7e6a1d68799968ffd57a3d44e574d9f139a.tar.gz
some refinements to bootstrapping and config option help
-rw-r--r--doc/example/hudson.txt33
-rw-r--r--tox/_config.py4
-rw-r--r--toxbootstrap.py26
3 files changed, 34 insertions, 29 deletions
diff --git a/doc/example/hudson.txt b/doc/example/hudson.txt
index 4b9de8a..b2e8180 100644
--- a/doc/example/hudson.txt
+++ b/doc/example/hudson.txt
@@ -41,24 +41,27 @@ See a real-life example in action with the `pytest Hudson job`_
-------------------------------------------------------------
If you manage many Hudson slaves and want to use the latest officially
-released tox (or latest development version) you can skip installing
-``tox`` alltogether and substitute the above **Python build step**
-with this code::
+released tox (or latest development version) and want to skip manually
+installing ``tox`` then substitute the above **Python build step** code
+with this::
- import urllib, os, sys
+ import urllib, os
url = "https://pytox.googlecode.com/hg/toxbootstrap.py"
#os.environ['USETOXDEV']="1" # use tox dev version
- s = urllib.urlopen(url).read()
- co = compile(s, "toxbootstrap.py", 'exec')
- sys.argv = ['toxbootstrap.py',
- '--recreate'] # change as needed
- exec co in {'__name__': '__main__',
- '__file__': 'toxbootstrap.py'}
-
-The `toxbootstrap.py`_ file downloads all neccessary files to install
-``tox`` in a virtual sub environment. If you uncomment the line
-containing ``USETOXDEV`` you are going to use the latest
-development-release version of tox instead of the latest released version.
+ d = dict(__file__='toxbootstrap.py')
+ exec urllib.urlopen(url).read() in d
+ d['cmdline'](['--recreate'])
+
+The downloaded `toxbootstrap.py`_ file downloads all neccessary files to
+install ``tox`` in a virtual sub environment. Notes:
+
+* uncomment the line containing ``USETOXDEV`` to use the latest
+ development-release version of tox instead of the
+ latest released version.
+
+* adapt the options in the last line as needed (the example code
+ will cause tox to reinstall all virtual environments all the time
+ which is often what one wants in CI server contexts)
.. _`toxbootstrap.py`: https://pytox.googlecode.com/hg/toxbootstrap.py
diff --git a/tox/_config.py b/tox/_config.py
index fb34083..84765a3 100644
--- a/tox/_config.py
+++ b/tox/_config.py
@@ -56,13 +56,13 @@ def prepare_parse():
parser.add_argument("--notest", action="store_true", dest="notest",
help="skip invoking test commands.")
parser.add_argument("--sdistonly", action="store_true", dest="sdistonly",
- help="only perform the sdist activity.")
+ help="only perform the sdist packaging activity.")
parser.add_argument("--indexserver", action="store", dest="indexserver",
default=None, metavar="URL",
help="indexserver for installing deps (default pypi python.org"),
parser.add_argument("-r", "--recreate", action="store_true",
dest="recreate",
- help="recreate virtual environments")
+ help="force recreation of virtual environments")
parser.add_argument("args", nargs="*",
help="additional arguments available to command positional substition")
return parser
diff --git a/toxbootstrap.py b/toxbootstrap.py
index 0db75af..371512b 100644
--- a/toxbootstrap.py
+++ b/toxbootstrap.py
@@ -38,7 +38,7 @@ Getting started
Instead of running "tox", now you can just run "python toxbootstrap.py" which
will take care of installing tox (if not already installed into
-``.tox/toxinstall``)::
+``.tox/_toxinstall``)::
$ python toxbootstrap.py
@@ -61,7 +61,7 @@ ToDo
"""
-__version__ = "0.2"
+__version__ = "0.3"
import sys
import os
@@ -71,6 +71,7 @@ import logging
from subprocess import Popen, PIPE, check_call, CalledProcessError
USETOXDEV=os.environ.get('USETOXDEV', False)
+TENV='_toxinstall'
PY3 = sys.version_info[0] == 3
@@ -171,7 +172,7 @@ def cmdline(argv=None):
os.chdir('.tox')
# create virtual environment
- if not path.isdir('toxinstall') or not has_script('toxinstall', 'python'):
+ if not path.isdir(TENV) or not has_script(TENV, 'python'):
# get virtualenv.py
if not path.isfile('virtualenv.py'):
wget(VIRTUALENVPY_URL)
@@ -180,27 +181,28 @@ def cmdline(argv=None):
# XXX: we use --no-site-packages because: if tox is installed in global
# site-packages, then pip will not install it locally. ideal fix for
# this should be to first look for tox in the global scripts/ directory
- run('%s virtualenv.py --no-site-packages --distribute toxinstall' % sys.executable)
+ run('%s virtualenv.py --no-site-packages --distribute %s' %
+ (sys.executable, TENV))
- assert has_script('toxinstall', 'python'), 'no python script'
- assert has_script('toxinstall', 'pip'), 'no pip script'
+ assert has_script(TENV, 'python'), 'no python script'
+ assert has_script(TENV, 'pip'), 'no pip script'
- pip = get_script_path('toxinstall', 'pip')
+ pip = get_script_path(TENV, 'pip')
# install/upgrade tox itself
if USETOXDEV:
run('%s install -q -i http://pypi.testrun.org '
'--upgrade --download-cache=pip-cache tox' % (pip,))
elif any([
- not has_script('toxinstall', 'tox'),
- get_tox_version('toxinstall') != pypi_get_latest_version('tox')]):
+ not has_script(TENV, 'tox'),
+ get_tox_version(TENV) != pypi_get_latest_version('tox')]):
run('%s install --upgrade --download-cache=pip-cache tox' % (pip,))
- assert has_script('toxinstall', 'tox')
- tox_script = path.abspath(get_script_path('toxinstall', 'tox'))
+ assert has_script(TENV, 'tox')
+ tox_script = path.abspath(get_script_path(TENV, 'tox'))
logging.info('tox is already installed at %s', tox_script)
- virtualenv = get_script_path('toxinstall', 'virtualenv')
+ virtualenv = get_script_path(TENV, 'virtualenv')
# XXX: virtualenv 1.5 is broken; replace it
if crun('%s --version' % (virtualenv,)).strip() == '1.5':