-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.py
90 lines (73 loc) · 2.89 KB
/
build.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#! /usr/bin/env python
"""
Usage:
build.py <package_names>... [--upload] [--force]
build.py --version
build.py -h | --help
Options:
<package_names>... The package names to build. Use 'all' to build all.
--upload Upload all packages to binstar
--force Force the uploads
-h, --help Show this help text
--version Show Version
"""
from __future__ import print_function
import subprocess
import platform
import sys
import os
from docopt import docopt
active_platform = platform.system()
is_windows = active_platform.lower() == 'windows'
all_packages_list = ['pathlib', 'assimp', 'cyassimp', 'glew', 'glfw3', 'cyrasterize',
'menpo-pyvrml97', 'menpo', 'aniso8601', 'flask-restful',
'flask-compress', 'landmarkerio-server']
def upload_package(package, force):
from conda_build.metadata import MetaData
from conda_build.build import bldpkg_path
built_package_path = bldpkg_path(MetaData(package))
print('Uploading {} from {}'.format(package, built_package_path))
# Set up the binstar upload command
command = ['binstar', 'upload', '-u', 'menpo']
if force:
command += ['--force']
command += [built_package_path]
print('Running command "{}"'.format(' '.join(command)))
# Call binstar
error_code = subprocess.call(command, shell=is_windows)
if error_code != 0:
if force or error_code != 1:
raise EnvironmentError('Executing binstar upload failed with a '
'return code of {}'.format(error_code))
else:
print('Successfully uploaded {}'.format(package))
def run(packages, upload, force):
for package in packages:
print('Beginning to build {}'.format(package))
command = ['conda', 'build', package]
print('Running command "{}"'.format(' '.join(command)))
error_code = subprocess.call(command, shell=is_windows)
if error_code != 0:
raise EnvironmentError('Executing conda build failed with a '
'return code of {}'.format(error_code))
else:
print('Successfully built {}'.format(package))
if upload:
upload_package(package, force)
if __name__ == '__main__':
args = docopt(__doc__, version='0.0.1')
# Try default conda
try:
error_code = subprocess.call(['conda', '-V'], shell=is_windows)
if error_code != 0:
raise EnvironmentError(
'"conda" does not appear to be installed')
except Exception as e:
raise EnvironmentError('Failed to execute "conda"', e)
# Check for package names or 'all'
if (len(args['<package_names>']) == 1 and
args['<package_names>'][0] == 'all'):
packages = all_packages_list
else:
packages = args['<package_names>']
run(packages, args['--upload'], args['--force'])