-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Stephen Tu
committed
Aug 2, 2014
1 parent
e47ff6b
commit f7795ad
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.pyc | ||
*.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |