-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbuild.py
More file actions
51 lines (36 loc) · 1.29 KB
/
build.py
File metadata and controls
51 lines (36 loc) · 1.29 KB
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
#!/usr/bin/env python
import sys
import os
import sh
from argparse import ArgumentParser
def build_and_publish(path, channel):
try:
token = os.environ['ANACONDA_TOKEN']
except KeyError:
sys.exit("Must set $ANACONDA_TOKEN")
anaconda = sh.Command('anaconda').bake(t=token)
conda = sh.Command('conda')
binfile = conda.build("--output", path).strip()
print "Building..."
conda.build(path)
print "Upload to Anaconda.org..."
anaconda.upload(binfile, force=True, channel=channel)
def conda_paths(project_name):
conda_recipes_dir = os.path.join(project_name, 'conda')
if not os.path.isdir(conda_recipes_dir):
sys.exit('no such dir: {}'.format(conda_recipes_dir))
for name in sorted(os.listdir(conda_recipes_dir)):
yield os.path.join(conda_recipes_dir, name)
def parse_args():
parser = ArgumentParser()
parser.add_argument('-p', '--project', required=True)
parser.add_argument('-c', '--channel', required=False, default='main')
parser.add_argument('-s', '--site', required=False, default=None)
args = parser.parse_args()
return args
def main():
args = parse_args()
for conda_path in conda_paths(args.project):
build_and_publish(conda_path, channel=args.channel)
if __name__ == '__main__':
main()