diff options
author | Matt Rendina <rendinam@users.noreply.github.com> | 2017-07-27 13:24:08 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-27 13:24:08 -0400 |
commit | e27c1830c946610f56f6313b160230ef2745e3b5 (patch) | |
tree | b5c5d16bba05d56aa11809cdd34d33051b685316 | |
parent | 66fddf502d24f249ce0db95fa4081f404c503ec4 (diff) | |
parent | 428f7f28fc1744fe55f7e5f09e67e62161ce2474 (diff) | |
download | rambo-e27c1830c946610f56f6313b160230ef2745e3b5.tar.gz |
Merge pull request #2 from rendinam/conda-build-ver
conda-build API compat.; platform default behavior
-rwxr-xr-x[-rw-r--r--] | rambo/__main__.py | 25 | ||||
-rwxr-xr-x | rambo/meta.py | 35 |
2 files changed, 46 insertions, 14 deletions
diff --git a/rambo/__main__.py b/rambo/__main__.py index 5f9eaa9..7a1c29b 100644..100755 --- a/rambo/__main__.py +++ b/rambo/__main__.py @@ -10,6 +10,17 @@ import sys import argparse from . import meta +def get_platform(): + plat_alias = sys.platform + if plat_alias == 'darwin': + plat_alias = 'osx' + is64bit = (sys.maxsize > 2**32) + arch_bits = '64' + if not is64bit: + arch_bits = '32' + platform = '{}-{}'.format(plat_alias, arch_bits) + return platform + def main(argv=None): @@ -19,7 +30,12 @@ def main(argv=None): parser = argparse.ArgumentParser( prog='rambo', description='Recipe Analyzer and Multi-Package Build Optimizer') - parser.add_argument('-p', '--platform', type=str) + parser.add_argument('-p', + '--platform', + type=str, + help='The platform specification string in the format that conda' + ' understands. I.e. "linux-64" or "osx-64". If not specified, the' + ' platform of the host system is used.') parser.add_argument( '--python', type=str, @@ -62,7 +78,7 @@ def main(argv=None): action='version', version='%(prog)s ' + meta.__version__, help='Display version information.') - parser.add_argument('recipes_dir', type=str) + parser.add_argument('recipes_dir', type=str, help='Required') args = parser.parse_args() recipes_dir = os.path.normpath(args.recipes_dir) @@ -77,7 +93,10 @@ def main(argv=None): versions['numpy'] = meta.DEFAULT_MINIMUM_NUMPY_VERSION - meta.Config.platform = args.platform + if args.platform: + meta.Config.platform = args.platform + else: + meta.Config.platform = get_platform() mset = meta.MetaSet( recipes_dir, diff --git a/rambo/meta.py b/rambo/meta.py index 3951f32..24e40a8 100755 --- a/rambo/meta.py +++ b/rambo/meta.py @@ -18,9 +18,9 @@ import json from ._version import __version__ try: import conda_build.api - from conda_build.config import Config + from conda_build.api import Config except ImportError: - print('conda-build must be installed order to use this tool. \n' + print('conda-build must be installed in order to use this tool. \n' 'Either conda-build is not installed, or you are working in an \n' 'activated conda environment. \n' 'If conda-build is installed deactivate the environment currently \n' @@ -28,7 +28,7 @@ except ImportError: 'allow use of conda-build.') DEFAULT_MINIMUM_NUMPY_VERSION = '1.11' - +CONDA_BUILD_MAJOR_VERSION = conda_build.__version__[0] class Meta(object): '''Holds metadata for a recipe obtained from the recipe's meta.yaml file, @@ -61,12 +61,19 @@ class Meta(object): the conda recipe renderer to perform string interpolation and store the values in a dictionary.''' if os.path.isfile(rdir + '/meta.yaml'): - # render() returns a tuple: (MetaData, bool, bool) - self.metaobj = conda_build.api.render( + self.render_payload = conda_build.api.render( rdir, dirty=self.dirty, python=self.versions['python'], - numpy=self.versions['numpy'])[0] + numpy=self.versions['numpy']) + if CONDA_BUILD_MAJOR_VERSION == '2': + # conda-build v2.x render() returns a tuple: + # (MetaData, bool, bool) + self.metaobj = self.render_payload[0] + if CONDA_BUILD_MAJOR_VERSION == '3': + # conda-build v3.x render() return a list of tuples: + # [(MetaData, bool, bool)] + self.metaobj = self.render_payload[0][0] self.mdata = self.metaobj.meta self.valid = self.is_valid() self.complete = self.is_complete() @@ -115,11 +122,17 @@ class Meta(object): def gen_canonical(self): '''Generate the package's canonical name using available information.''' - self.canonical_name = os.path.basename( - conda_build.api.get_output_file_path( - self.metaobj, - python=self.versions['python'], - numpy=self.versions['numpy'])) + if CONDA_BUILD_MAJOR_VERSION == '2': + output_file_path = conda_build.api.get_output_file_path( + self.metaobj, + python=self.versions['python'], + numpy=self.versions['numpy']) + if CONDA_BUILD_MAJOR_VERSION == '3': + output_file_path = conda_build.api.get_output_file_paths( + self.metaobj, + python=self.versions['python'], + numpy=self.versions['numpy'])[0] + self.canonical_name = os.path.basename(output_file_path) class MetaSet(object): |