/
run_setups.py
69 lines (58 loc) · 1.88 KB
/
run_setups.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
""" Run setups """
from __future__ import print_function
import os
from os.path import join as pjoin, isdir
import shutil
from glob import glob
if os.name == 'nt':
bin_sdir = 'Scripts'
else:
bin_sdir = 'bin'
from subprocess import CalledProcessError, Popen, PIPE
def mycall(cmd):
print('Running: ', cmd)
proc = Popen(cmd, stdout=PIPE, stderr=PIPE)
out, err = proc.communicate()
return out.strip()
def plat_pjoin(*pth_seq):
stripped_paths = []
for pth in pth_seq:
if pth.startswith('"') and pth.endswith('"'):
pth = pth[1:-1]
stripped_paths.append(pth)
out_path = pjoin(*stripped_paths)
return '"{0}"'.format(out_path) if os.name == 'nt' else out_path
try:
mycall(['virtualenv', '--help'])
except CalledProcessError:
raise RuntimeError("Need virtualenv installed")
# Run setups
mycall(['python', 'setup.py', 'sdist', '--formats=zip'])
sdist = glob(pjoin('dist', '*.zip'))[0]
mycall(['python', 'setupegg.py', 'bdist_egg'])
egg = glob(pjoin('dist', '*.egg'))[0]
if os.name == 'nt':
mycall(['python', 'setup.py', 'bdist_wininst'])
exe = glob(pjoin('dist', '*.exe'))[0]
def mk_venv(sdir):
if isdir(sdir):
shutil.rmtree(sdir)
mycall(['virtualenv', sdir])
return pjoin(sdir, bin_sdir)
def new_venv(sdir):
if isdir('build'):
shutil.rmtree('build')
return mk_venv(sdir)
bin_dir = new_venv('venv_repo')
mycall([pjoin(bin_dir, 'python'), 'setup.py', 'install'])
bin_dir = new_venv('venv_sdist')
mycall([pjoin(bin_dir, 'easy_install'), sdist])
bin_dir = new_venv('venv_egg')
mycall([pjoin(bin_dir, 'easy_install'), egg])
if os.name == 'nt':
bin_dir = new_venv('venv_exe')
mycall([pjoin(bin_dir, 'easy_install'), exe])
# A virtualenv with spaces in the path
# This does not work for Unices
bin_dir = new_venv('venv with spaces')
mycall([pjoin(bin_dir, 'python'), 'setup.py', 'install'])