comparison carton.py @ 29:533a4f9718d9

improve documentation
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 11 Jul 2011 09:09:48 -0700
parents dabf5e1bdf92
children 0b9c124f128b
comparison
equal deleted inserted replaced
28:dabf5e1bdf92 29:533a4f9718d9
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 """ 3 """
4 make a self-extracting virtualenv from directories or URLs 4 make a self-extracting virtualenv from directories or URLs of packages
5 of packages 5
6 6 To package up all files in a virtualenvs source directory (e.g.)::
7 To package up all files in a virtualenvs source directory (e.g.): 7
8 8 python path/to/carton.py myproject project/src/*
9 python path/to/carton.py mozmill mozmill/src/* 9
10 10 This will create a self-extracting file, `myproject.py`, that will unfold
11 This will create a self-extracting file, `mozmill.py`, that will unfold
12 a virtualenv with the specified packages setup for development 11 a virtualenv with the specified packages setup for development
12
13 The sources may be directories, local or HTTP-accessible tarballs, or ordinary
14 files. The `setup.py`s found in the `src` directory after extraction will be
15 run (via `python setup.py develop`) in the order they are provided. This makes
16 it possible to have completely local dependencies (without touching the net)
17 by correctly specifying the source order. If a `setup.py` is overwritten from
18 a later source, it will not be rerun (known limitation).
19
20 The extracted virtualenv will be created in the current directory and will have
21 the same name as provided initially (e.g. `myproject`) unless `--env` is
22 specified.
23
24 Normally, the entire contents of source directories are compressed and
25 packaged as-is. When running with the `--package` flag, a source tarball is
26 produced via `python setup.py sdist` if the directory contains a top-level
27 `setup.py`.
28
29 Since directories are compressed as-is, portable file-based VCS repositories,
30 such a mercurial and git, may be cartoned this way (though note that newer
31 repositories may not be backwards-compatible with older clients).
13 """ 32 """
14 33
15 # imports 34 # imports
16 import os 35 import os
17 import sys 36 import sys
114 if i in setup_pys: 133 if i in setup_pys:
115 continue 134 continue
116 subdir = os.path.join(srcdir, i) 135 subdir = os.path.join(srcdir, i)
117 if os.path.exists(os.path.join(srcdir, i, 'setup.py')): 136 if os.path.exists(os.path.join(srcdir, i, 'setup.py')):
118 call([python, 'setup.py', 'develop'], cwd=subdir) 137 call([python, 'setup.py', 'develop'], cwd=subdir)
138 # TODO: try `setup.py install` if develop fails for distutils packages
119 setup_pys.add(i) 139 setup_pys.add(i)
120 140
121 # add virtualenv to the virtualenv (!) 141 # add virtualenv to the virtualenv (!)
122 virtualenv_dir = os.path.dirname(virtualenv) 142 virtualenv_dir = os.path.dirname(virtualenv)
123 if os.path.exists(os.path.join(virtualenv_dir, 'setup.py')): 143 if os.path.exists(os.path.join(virtualenv_dir, 'setup.py')):