aboutsummaryrefslogtreecommitdiff
path: root/rambo
diff options
context:
space:
mode:
authorMatt Rendina <mrendina@stsci.edu>2017-07-27 13:20:09 -0400
committerMatt Rendina <mrendina@stsci.edu>2017-07-27 13:20:09 -0400
commit428f7f28fc1744fe55f7e5f09e67e62161ce2474 (patch)
treeb5c5d16bba05d56aa11809cdd34d33051b685316 /rambo
parent66fddf502d24f249ce0db95fa4081f404c503ec4 (diff)
downloadrambo-428f7f28fc1744fe55f7e5f09e67e62161ce2474.tar.gz
conda-build API compat.; platform default behavior
* Accommodate both conda-build 2.x and 3.x APIs. * Default platform used if not specified as argument
Diffstat (limited to 'rambo')
-rwxr-xr-x[-rw-r--r--]rambo/__main__.py25
-rwxr-xr-xrambo/meta.py35
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):