Commit dcbbc566 authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

RF: Get package name from recipe, rather than from CI env var, so CUDA package

names are generated
parent cea46aec
......@@ -19,7 +19,7 @@ import subprocess as sp
import yaml
__version__ = '0.14.4'
__version__ = '0.14.5'
"""Current version of the fsl-ci-rules."""
......
......@@ -7,6 +7,7 @@
#
import re
import os
import os.path as op
import jinja2 as j2
......@@ -25,19 +26,28 @@ def get_recipe_variable(text : str, varname : str) -> Optional[str]:
{% set varname = 'value' %}
and returns the value. Returns None if the variable cannot be found
and returns the value. Returns None if the variable cannot be found.
Includes a hack to accommodate FSL CUDA projects - for these projects,
different packages are generated from the same conda recipe for different
CUDA versions, with the resulting packages named <package>-cuda-X.Y. For
these recipes, the CUDA_VER environment variable is queried to determine
the appropriate CUDA version.
"""
pat = r'{{% +set +{} += +[\'"](.*)[\'"] *(\+ *cuda_label)? *%}}'\
.format(varname)
lines = list(text.split('\n'))
cudaver = os.environ.get('CUDA_VER', None)
for line in lines:
match = re.fullmatch(pat, line.strip())
if match:
name, cuda = match.groups()
name, iscuda = match.groups()
if cuda is None: return name
else: return name + '-cuda-X.Y'
if not iscuda: return name
elif cudaver is not None: return name + '-cuda-' + cudaver
else: return name + '-cuda-X.Y'
return None
......
......@@ -9,7 +9,6 @@
import os
import os.path as op
import sys
import urllib.parse as urlparse
from fsl_ci import (sprun,
......@@ -113,7 +112,6 @@ def main():
project_ref = os.environ.get('FSLCONDA_REVISION', '')
project_repo = os.environ.get('FSLCONDA_REPOSITORY', '')
recipe_name = os.environ['CI_PROJECT_NAME']
recipe_url = os.environ['CI_PROJECT_URL']
recipe_ref = os.environ['CI_COMMIT_REF_NAME']
job_name = os.environ['CI_JOB_NAME']
......@@ -124,9 +122,16 @@ def main():
skip_platforms = os.environ.get('FSLCONDA_SKIP_PLATFORM', '')
skip_platforms = skip_platforms.split()
# get the package name from the un-rendered metayaml text
with open('meta.yaml', 'rt') as f:
meta = f.read()
package_name = get_recipe_variable(meta, 'name')
# then load the rendered meta.yaml for use
# by the get_platform_shortcut.. function
meta = load_meta_yaml('meta.yaml')
platform = get_platform_shortcut_if_not_applicable(
meta, recipe_name, job_name, skip_platforms)
meta, package_name, job_name, skip_platforms)
# We direct builds for each platform type into a
# separate sub-directory, because the outputs from
......@@ -149,7 +154,7 @@ def main():
os.makedirs(output_dir)
fprint('************************************')
fprint(f'Building conda recipe for: {recipe_name}')
fprint(f'Building conda recipe for: {package_name}')
fprint(f'Recipe URL: {recipe_url}')
fprint(f'Recipe revision: {recipe_ref}')
fprint( 'Project repository (empty means to ')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment