Skip to content

Commit

Permalink
build.py script (untested)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Tu committed Aug 2, 2014
1 parent e47ff6b commit f7795ad
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.pyc
*.swp
58 changes: 58 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env python

import sys
import os

from argparse import ArgumentParser
from subprocess import check_call, check_output
from binstar_client.utils import get_config, get_binstar, store_token

def ensure_tool(name):
check_call(['which', name])

def build_and_publish(path):
binfile = check_output(['conda', 'build', '--output', path])
binfile = binfile.strip()

print >>sys.stderr, "conda build {}".format(path)
check_call(['conda', 'build', path])

print >>sys.stderr, "binstar upload --force {}".format(binfile)
check_call(['binstar', 'upload', '--force', binfile])

def main():
parser = ArgumentParser()
parser.add_argument('-u', '--username', required=True)
parser.add_argument('-P', '--password', required=True)
parser.add_argument('-p', '--project', required=True)
args = parser.parse_args()

# make sure we have a conda environment
ensure_tool('conda')
ensure_tool('binstar')

# make sure the project has a conda recipes folder
conda_recipes_dir = os.path.join(args.project, 'conda')
if not os.path.isdir(conda_recipes_dir):
print >>sys.stderr, 'no such dir: {}'.format(conda_recipes_dir)
return 1

# login to binstar
# this code is taken from:
# binstar_client/commands/login.py
bs = get_binstar()
config = get_config()
url = config.get('url', 'https://api.binstar.org')
token = bs.authenticate(args.username, args.password, 'binstar_client', url, created_with='')
if token is None:
print >>sys.stderr, 'could not login'
return 1
store_token(token)

for name in sorted(os.listdir(conda_recipes_dir)):
build_and_publish(os.path.join(conda_recipes_dir, name))

return 0

if __name__ == '__main__':
sys.exit(main())

0 comments on commit f7795ad

Please sign in to comment.