From f293e7d7c76f383eae64f224834815f1b14a78e6 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Mon, 29 Jun 2015 00:29:14 -0400 Subject: Getting closer to the real deal --- cbc/utils.py | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) (limited to 'cbc/utils.py') 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 -- cgit