Mercurial > hg > config
annotate python/install_config.py @ 258:2862f4453296
add a hack to override setuptools
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Wed, 02 Jan 2013 15:41:11 -0800 |
parents | c37750a70f94 |
children | 06fcec56e8fe |
rev | line source |
---|---|
1 | 1 #!/usr/bin/env python |
234
761e7dfc675e
updates from most recent usage
Jeff Hammel <jhammel@mozilla.com>
parents:
219
diff
changeset
|
2 |
1 | 3 """ |
4 installs config to a user's home directory | |
5 this can be done with | |
16 | 6 curl http://k0s.org/hg/config/raw-file/tip/python/install_config.py | python |
1 | 7 """ |
8 | |
9 SRC='http://k0s.org/hg/config' | |
218 | 10 |
11 import imp | |
1 | 12 import os |
131
52cf3e146a4c
make the install script slightly nicer
Jeff Hammel <jhammel@mozilla.com>
parents:
130
diff
changeset
|
13 import subprocess |
6 | 14 import sys |
131
52cf3e146a4c
make the install script slightly nicer
Jeff Hammel <jhammel@mozilla.com>
parents:
130
diff
changeset
|
15 |
52cf3e146a4c
make the install script slightly nicer
Jeff Hammel <jhammel@mozilla.com>
parents:
130
diff
changeset
|
16 # go home |
14
ac34d580c6d7
make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents:
7
diff
changeset
|
17 HOME=os.environ['HOME'] |
ac34d580c6d7
make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents:
7
diff
changeset
|
18 os.chdir(HOME) |
1 | 19 |
131
52cf3e146a4c
make the install script slightly nicer
Jeff Hammel <jhammel@mozilla.com>
parents:
130
diff
changeset
|
20 commands = [ # make the home directory a repository |
251
c37750a70f94
no need for subversion config anymore
Jeff Hammel <jhammel@mozilla.com>
parents:
245
diff
changeset
|
21 ['hg', 'init'], |
c37750a70f94
no need for subversion config anymore
Jeff Hammel <jhammel@mozilla.com>
parents:
245
diff
changeset
|
22 ['hg', 'pull', SRC], |
c37750a70f94
no need for subversion config anymore
Jeff Hammel <jhammel@mozilla.com>
parents:
245
diff
changeset
|
23 ['hg', 'update', '-C'], |
c37750a70f94
no need for subversion config anymore
Jeff Hammel <jhammel@mozilla.com>
parents:
245
diff
changeset
|
24 ] |
6 | 25 |
29
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
26 def execute(*commands): |
131
52cf3e146a4c
make the install script slightly nicer
Jeff Hammel <jhammel@mozilla.com>
parents:
130
diff
changeset
|
27 """execute a series of commands""" |
29
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
28 for command in commands: |
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
29 print ' '.join(command) |
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
30 code = subprocess.call(command) |
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
31 if code: |
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
32 sys.exit(code) |
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
33 |
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
34 execute(*commands) |
131
52cf3e146a4c
make the install script slightly nicer
Jeff Hammel <jhammel@mozilla.com>
parents:
130
diff
changeset
|
35 |
218 | 36 # get the which command |
37 sys.path.append(os.path.join(HOME, 'python')) | |
38 from which import which | |
39 | |
40 | |
131
52cf3e146a4c
make the install script slightly nicer
Jeff Hammel <jhammel@mozilla.com>
parents:
130
diff
changeset
|
41 # make a (correct) .hg/hgrc file for $HOME |
218 | 42 hgrc = """[paths] |
43 default = http://k0s.org/hg/config | |
44 default-push = ssh://k0s.org/hg/config | |
45 """ | |
46 f = file('.hg/hgrc', 'w') | |
47 f.write(hgrc) | |
48 f.close() | |
1 | 49 |
29
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
50 def install_develop(package): |
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
51 src = 'http://k0s.org/hg/%s' % package |
41
eda848575afb
chdir to the directory before running python setup.py develop as this seems to be necessary
Jeff Hammel <k0scist@gmail.com>
parents:
36
diff
changeset
|
52 directory = '%s/src/%s' % (package, package) |
29
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
53 commands = [ ['virtualenv/virtualenv.py', package], |
44 | 54 ['mkdir', '-p', directory ], |
55 ['hg', 'clone', src, directory] ] | |
29
8344c7a9847c
install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents:
22
diff
changeset
|
56 execute(*commands) |
41
eda848575afb
chdir to the directory before running python setup.py develop as this seems to be necessary
Jeff Hammel <k0scist@gmail.com>
parents:
36
diff
changeset
|
57 old_directory = os.getcwd() |
eda848575afb
chdir to the directory before running python setup.py develop as this seems to be necessary
Jeff Hammel <k0scist@gmail.com>
parents:
36
diff
changeset
|
58 os.chdir(directory) |
eda848575afb
chdir to the directory before running python setup.py develop as this seems to be necessary
Jeff Hammel <k0scist@gmail.com>
parents:
36
diff
changeset
|
59 command = ['../../bin/python', 'setup.py', 'develop'] |
eda848575afb
chdir to the directory before running python setup.py develop as this seems to be necessary
Jeff Hammel <k0scist@gmail.com>
parents:
36
diff
changeset
|
60 execute(command) |
eda848575afb
chdir to the directory before running python setup.py develop as this seems to be necessary
Jeff Hammel <k0scist@gmail.com>
parents:
36
diff
changeset
|
61 os.chdir(old_directory) |
218 | 62 |
63 # do git stuff | |
64 git = which('git') | |
65 if git: | |
66 # get virtual env | |
219 | 67 virtualenv_commands = [['git', 'clone', 'https://github.com/pypa/virtualenv.git'], |
218 | 68 ['ln', '-s', HOME + '/virtualenv/virtualenv.py', HOME + '/bin/']] |
69 execute(*virtualenv_commands) | |
6 | 70 |
218 | 71 # setup git's global ignore, since git is silly about this |
72 # and doesn't look for the file in the right place | |
73 execute(['git', 'config', '--global', 'core.excludesfile', os.path.join(HOME, '.gitignore')]) | |
32
f878d9f62211
fix syntax error and actually execute the commands
Jeff Hammel <k0scist@gmail.com>
parents:
31
diff
changeset
|
74 |
218 | 75 # install some python |
76 install_develop('smartopen') | |
77 install_develop('silvermirror') # XXX this won't actually work since python-dev isn't installed; install it first | |
78 | |
79 postinstall_commands = [ ['ln', '-s', os.path.join(HOME, 'smartopen', 'bin', 'smartopen'), os.path.join(HOME, 'bin', 'smartopen') ], | |
80 ['ln', '-s', os.path.join(HOME, 'silvermirror', 'bin', 'silvermirror'), os.path.join(HOME, 'bin', 'silvermirror') ], | |
81 ] | |
82 execute(*postinstall_commands) | |
234
761e7dfc675e
updates from most recent usage
Jeff Hammel <jhammel@mozilla.com>
parents:
219
diff
changeset
|
83 else: |
761e7dfc675e
updates from most recent usage
Jeff Hammel <jhammel@mozilla.com>
parents:
219
diff
changeset
|
84 print "git not installed" |
45
069a739d88ad
get fluxbox menu from a webpage, i.e. http://k0s.org/programs.html
Jeff Hammel <k0scist@gmail.com>
parents:
43
diff
changeset
|
85 |
36
d83f35b9b799
adding xclip package and echo which packages need installation
Jeff Hammel <k0scist@gmail.com>
parents:
34
diff
changeset
|
86 # - ubuntu packages to install: |
245
aa31dc7ccb66
add irssi to packages to install
Jeff Hammel <jhammel@mozilla.com>
parents:
234
diff
changeset
|
87 PACKAGES="mercurial unison fluxbox antiword xclip graphviz python-dev python-lxml curl arandr git emacs irssi" |
43 | 88 print "Ensure the following packages are installed:" |
218 | 89 print "sudo apt-get install %s" % PACKAGES |