Mercurial > hg > config
annotate python/venvit.py @ 704:6327c66e5f46
moved to http://k0s.org/hg/TextShaper
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Tue, 02 Sep 2014 21:01:55 -0700 |
parents | 0e270a448610 |
children |
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 |
358 | 22 import optparse |
356 | 23 import sys |
24 | |
25 # class for VCS | |
26 # TODO: hg, git, ... | |
27 | |
28 # usage | |
29 | |
30 args = sys.argv[1:] | |
31 if len(args) != 1: | |
358 | 32 print "Usage: %prog <repo-location>" |
356 | 33 |
34 | |
35 # determine name of the package | |
358 | 36 name = args[0] |
37 for i in ('/trunk', '/branches', '/tag'): | |
38 if name.endswith(i): | |
39 name = name[:-len(i)] | |
40 | |
356 | 41 NAME=${NAME%%/} # remove trailing slash |
42 NAME=${NAME##*/} | |
43 | |
44 if svn info $1 2> /dev/null | |
45 then | |
46 CHECKOUT="svn co" | |
47 else | |
48 CHECKOUT="hg clone" | |
49 fi | |
50 | |
51 # create a virtualenv and install the software | |
52 VIRTUAL_ENV_LOCATION="${HOME}/virtualenv/virtualenv.py" | |
53 python ${VIRTUAL_ENV_LOCATION} ${NAME} | |
54 cd ${NAME} | |
55 source bin/activate | |
56 mkdir src/ | |
57 cd src/ | |
58 $CHECKOUT $1 ${NAME} | |
59 cd ${NAME} | |
60 python setup.py develop |