aboutsummaryrefslogtreecommitdiff
path: root/cbc/utils.py
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-06-29 00:29:14 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-06-29 00:29:14 -0400
commitf293e7d7c76f383eae64f224834815f1b14a78e6 (patch)
treeb5759354b46470d25beafccfdeb48eabae03ff83 /cbc/utils.py
parent3f6e82f632027904e2912664cbb1c60cdc79a509 (diff)
downloadcbc-f293e7d7c76f383eae64f224834815f1b14a78e6.tar.gz
Getting closer to the real deal
Diffstat (limited to 'cbc/utils.py')
-rw-r--r--cbc/utils.py42
1 files changed, 40 insertions, 2 deletions
diff --git a/cbc/utils.py b/cbc/utils.py
index 096e156..e276566 100644
--- a/cbc/utils.py
+++ b/cbc/utils.py
@@ -1,4 +1,6 @@
-from subprocess import Popen, PIPE, check_output, CalledProcessError
+from .meta import MetaData
+from .exceptions import CondaBuildError
+from subprocess import Popen, PIPE, STDOUT, check_call, check_output, CalledProcessError
def conda_search(pkgname):
@@ -27,4 +29,40 @@ def conda_install(pkgname):
print(line)
except CalledProcessError as cpe:
print('{0}\nexit={1}'.format(' '.join(cpe.cmd), cpe.returncode))
- \ No newline at end of file
+
+
+def conda_reinstall(pkgname):
+ # Until I can figure out a good way to build with the conda API
+ # we'll use the CLI interface:
+ commands = ['conda remove --yes {0}'.format(pkgname).split(),
+ 'conda install --use-local --yes {0}'.format(pkgname).split()]
+ for command in commands:
+ try:
+ for line in (check_output(command).decode('utf-8').splitlines()):
+ print(line)
+ except CalledProcessError as cpe:
+ print('{0}\nexit={1}'.format(' '.join(cpe.cmd), cpe.returncode))
+
+
+def conda_builder(metadata, args):
+ if not isinstance(metadata, MetaData):
+ raise CondaBuildError('Expecting instance of conda_build.metadata.MetaData, got: "{0}"'.format(type(metadata)))
+
+ bad_egg = 'UNKNOWN.egg-info'
+ command = ['conda', 'build', metadata.env.pkgdir ]
+
+ try:
+ for line in (check_output(command).decode('utf-8').splitlines()):
+ if line.startswith('#'):
+ continue
+ print(line)
+ if bad_egg in line:
+ raise CondaBuildError('Bad setuptools metadata produced UNKNOWN.egg-info instead of {0}*.egg-info!'.format(metadata.local['package']['name']))
+ #OK Conda, let's play rough. stdout/stderr only, no exit for you.
+ except SystemExit:
+ print('Discarding SystemExit issued by setuptools')
+ except CalledProcessError as cpe:
+ print(cpe)
+ return False
+
+ return True \ No newline at end of file