Mercurial > hg > config
annotate python/venvit.py @ 356:915f88af9624
transition
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Fri, 28 Jun 2013 10:32:21 -0700 |
parents | a9110cc98d94 |
children | 0e270a448610 |
rev | line source |
---|---|
70
a9110cc98d94
adding notes on a venvit idea
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
a9110cc98d94
adding notes on a venvit idea
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
2 """ |
a9110cc98d94
adding notes on a venvit idea
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
3 venvit.py -- the equivalent of ez_setup.py for virtualenv, but less intrusive; |
a9110cc98d94
adding notes on a venvit idea
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
4 It wants a one-step installation to install python into a new virtualenv. |
a9110cc98d94
adding notes on a venvit idea
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
5 venvit is meant to be used via e.g. curl, although you can download it as well: |
a9110cc98d94
adding notes on a venvit idea
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
6 |
a9110cc98d94
adding notes on a venvit idea
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
7 curl http://example.com/path/to/venvit.py | python - <package> |
a9110cc98d94
adding notes on a venvit idea
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
8 |
a9110cc98d94
adding notes on a venvit idea
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
9 If <package> is a package name, it tries to install it from the cheeseshop. |
a9110cc98d94
adding notes on a venvit idea
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
10 |
a9110cc98d94
adding notes on a venvit idea
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
11 If it is a svn/hg/git/tgz/etc URL, it should download and install the software |
a9110cc98d94
adding notes on a venvit idea
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
12 in source. |
a9110cc98d94
adding notes on a venvit idea
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
13 |
a9110cc98d94
adding notes on a venvit idea
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
14 Only useful output -- like the scripts installed -- should be output to the |
a9110cc98d94
adding notes on a venvit idea
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
15 user. |
a9110cc98d94
adding notes on a venvit idea
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
16 |
a9110cc98d94
adding notes on a venvit idea
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
17 Ideally, packages could have a venvit__init__.py (or a better name) that |
a9110cc98d94
adding notes on a venvit idea
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
18 will be executed after installation (or a venvit.txt which would just be output |
a9110cc98d94
adding notes on a venvit idea
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
19 to console, maybe falling back to the README |
a9110cc98d94
adding notes on a venvit idea
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
20 """ |
356 | 21 |
22 import sys | |
23 | |
24 # class for VCS | |
25 # TODO: hg, git, ... | |
26 | |
27 # usage | |
28 | |
29 args = sys.argv[1:] | |
30 if len(args) != 1: | |
31 print "Usage: %prog <svn-or-hg-location>" | |
32 | |
33 | |
34 # determine name of the package | |
35 NAME= | |
36 for i in /trunk /branches /tag | |
37 do | |
38 NAME=${NAME%%$i*} | |
39 done | |
40 NAME=${NAME%%/} # remove trailing slash | |
41 NAME=${NAME##*/} | |
42 | |
43 if svn info $1 2> /dev/null | |
44 then | |
45 CHECKOUT="svn co" | |
46 else | |
47 CHECKOUT="hg clone" | |
48 fi | |
49 | |
50 # create a virtualenv and install the software | |
51 VIRTUAL_ENV_LOCATION="${HOME}/virtualenv/virtualenv.py" | |
52 python ${VIRTUAL_ENV_LOCATION} ${NAME} | |
53 cd ${NAME} | |
54 source bin/activate | |
55 mkdir src/ | |
56 cd src/ | |
57 $CHECKOUT $1 ${NAME} | |
58 cd ${NAME} | |
59 python setup.py develop |