annotate python/venvit.py @ 357:b4e679b5a9c3

now kill
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 28 Jun 2013 10:32:30 -0700
parents 915f88af9624
children 0e270a448610
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
21
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
22 import sys
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
23
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
24 # class for VCS
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
25 # TODO: hg, git, ...
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
26
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
27 # usage
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
28
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
29 args = sys.argv[1:]
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
30 if len(args) != 1:
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
31 print "Usage: %prog <svn-or-hg-location>"
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
32
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
33
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
34 # determine name of the package
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
35 NAME=
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
36 for i in /trunk /branches /tag
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
37 do
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
38 NAME=${NAME%%$i*}
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
39 done
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
40 NAME=${NAME%%/} # remove trailing slash
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
41 NAME=${NAME##*/}
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
42
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
43 if svn info $1 2> /dev/null
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
44 then
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
45 CHECKOUT="svn co"
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
46 else
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
47 CHECKOUT="hg clone"
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
48 fi
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
49
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
50 # create a virtualenv and install the software
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
51 VIRTUAL_ENV_LOCATION="${HOME}/virtualenv/virtualenv.py"
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
52 python ${VIRTUAL_ENV_LOCATION} ${NAME}
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
53 cd ${NAME}
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
54 source bin/activate
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
55 mkdir src/
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
56 cd src/
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
57 $CHECKOUT $1 ${NAME}
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
58 cd ${NAME}
915f88af9624 transition
Jeff Hammel <jhammel@mozilla.com>
parents: 70
diff changeset
59 python setup.py develop