Mercurial > hg > MakeItSo
comparison makeitso/python_package/INSTALL.py @ 133:cd51ef9288ea
WIP
| author | Jeff Hammel <jhammel@mozilla.com> |
|---|---|
| date | Thu, 03 Nov 2011 11:00:01 -0700 |
| parents | makeitso/python_package/INSTALL.sh@cc17537254d2 |
| children | 702216c49594 |
comparison
equal
deleted
inserted
replaced
| 132:06e6eac2fd4d | 133:cd51ef9288ea |
|---|---|
| 1 #!/usr/bin/env python | |
| 2 | |
| 3 """ | |
| 4 installation script for {{project}} | |
| 5 {{description}} | |
| 6 """ | |
| 7 | |
| 8 import os | |
| 9 import sys | |
| 10 import urllib2 | |
| 11 import subprocess | |
| 12 try: | |
| 13 from subprocess import check_call as call | |
| 14 except: | |
| 15 from subprocess import call | |
| 16 | |
| 17 REPO='{{repo}}' | |
| 18 DEST='{{project}}' # name of the virtualenv | |
| 19 VIRTUALENV='https://raw.github.com/pypa/virtualenv/develop/virtualenv.py' | |
| 20 | |
| 21 def which(binary, path=os.environ['PATH']): | |
| 22 dirs = path.split(os.pathsep) | |
| 23 for dir in dirs: | |
| 24 if os.path.isfile(os.path.join(dir, fileName)): | |
| 25 return os.path.join(dir, fileName) | |
| 26 if os.path.isfile(os.path.join(dir, fileName + ".exe")): | |
| 27 return os.path.join(dir, fileName + ".exe") | |
| 28 | |
| 29 def main(args=sys.argv[1:]): | |
| 30 | |
| 31 # create a virtualenv | |
| 32 virtualenv = which('virtualenv') or which('virtualenv.py') | |
| 33 if virtualenv: | |
| 34 call([virtualenv, DEST]) | |
| 35 else: | |
| 36 process = subproces.Popen([sys.executable, '-', DEST], stdin=subprocess.PIPE) | |
| 37 process.communicate(stdin=urllib2.urlopen(VIRTUALENV).read()) | |
| 38 | |
| 39 # create a src directory | |
| 40 src = os.path.join(DEST, 'src') | |
| 41 os.mkdir(src) | |
| 42 | |
| 43 # clone the repository | |
| 44 call(['hg', 'clone', REPO], cwd=src) | |
| 45 | |
| 46 """ | |
| 47 XXX unfinished | |
| 48 | |
| 49 hg clone ${REPO} | |
| 50 cd {{project}} | |
| 51 python setup.py develop | |
| 52 """ |
