From fbbac5db7f8e88119ab61f4bfec89c698cdfe00b Mon Sep 17 00:00:00 2001 From: Phil Elson Date: Tue, 22 Mar 2016 08:20:12 +0000 Subject: [PATCH 1/2] Handle Perl and R matrix items. --- conda_smithy/templates/appveyor.yml.tmpl | 3 ++- conda_smithy/templates/run_docker_build_matrix.tmpl | 3 ++- conda_smithy/templates/travis.yml.tmpl | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/conda_smithy/templates/appveyor.yml.tmpl b/conda_smithy/templates/appveyor.yml.tmpl index c2447027f..143de9b4e 100644 --- a/conda_smithy/templates/appveyor.yml.tmpl +++ b/conda_smithy/templates/appveyor.yml.tmpl @@ -1,7 +1,8 @@ {%- set conda_vars = {'python': 'CONDA_PY', 'numpy': 'CONDA_NPY'} -%} {% macro matrix_env(arch, matrix_item) -%} - TARGET_ARCH: {{ arch }}{% for dep_name, version in matrix_item | sort %} - {{ conda_vars.get(dep_name, dep_name) }}: {{version|replace('.', '')}}{% endfor %} + {%- if dep_name in conda_vars %}{% set version = version|replace('.', '') %}{% endif %} + {{ conda_vars.get(dep_name, 'CONDA_' + dep_name|upper) }}: {{ version }}{% endfor %} {%- endmacro %} # This file was automatically generated by conda-smithy. To update a component of this # file, make changes to conda-forge.yaml and/or recipe/meta.yaml, and run diff --git a/conda_smithy/templates/run_docker_build_matrix.tmpl b/conda_smithy/templates/run_docker_build_matrix.tmpl index c54142ac5..3d941e501 100644 --- a/conda_smithy/templates/run_docker_build_matrix.tmpl +++ b/conda_smithy/templates/run_docker_build_matrix.tmpl @@ -4,7 +4,8 @@ {% macro matrix_env(matrix_item) -%} {% for dep_name, version in matrix_item | sort %} - export {{ conda_vars.get(dep_name, dep_name) }}={{version|replace('.', '')}}{% endfor %} + {%- if dep_name in conda_vars %}{% set version = version|replace('.', '') %}{% endif %} + export {{ conda_vars.get(dep_name, 'CONDA_' + dep_name|upper) }}={{ version }}{% endfor %} {%- endmacro %} {% block build -%}# Embarking on {{ matrix|length }} case(s). diff --git a/conda_smithy/templates/travis.yml.tmpl b/conda_smithy/templates/travis.yml.tmpl index 0339d0820..b8073fbc4 100644 --- a/conda_smithy/templates/travis.yml.tmpl +++ b/conda_smithy/templates/travis.yml.tmpl @@ -1,6 +1,7 @@ {%- set conda_vars = {'python': 'CONDA_PY', 'numpy': 'CONDA_NPY'} -%} {% macro matrix_env(matrix_item) -%} - {% for dep_name, version in matrix_item | sort %}{{ conda_vars.get(dep_name, dep_name) }}={{version|replace('.', '')}} {% endfor %} + {% for dep_name, version in matrix_item | sort %}{%- if dep_name in conda_vars %}{% set version = version|replace('.', '') %}{% endif -%} + {{ conda_vars.get(dep_name, 'CONDA_' + dep_name|upper) }}={{ version }} {% endfor %} {%- endmacro %} # This file was generated automatically from conda-smithy. To update this configuration, # update the conda-forge.yaml and/or the recipe/meta.yaml. From e9598bd4aab5f13ffe48fbaffa842526b5ea23e6 Mon Sep 17 00:00:00 2001 From: Phil Elson Date: Tue, 22 Mar 2016 08:51:26 +0000 Subject: [PATCH 2/2] Be far more sophisticated about skipping matrix cases. --- conda_smithy/configure_feedstock.py | 73 ++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 21 deletions(-) diff --git a/conda_smithy/configure_feedstock.py b/conda_smithy/configure_feedstock.py index c127e470e..ad0757175 100755 --- a/conda_smithy/configure_feedstock.py +++ b/conda_smithy/configure_feedstock.py @@ -12,6 +12,7 @@ import conda_build.metadata from conda_build.metadata import MetaData from conda_build_all.version_matrix import special_case_version_matrix, filter_cases +from conda_build_all.resolved_distribution import ResolvedDistribution from jinja2 import Environment, FileSystemLoader @@ -23,20 +24,30 @@ def render_run_docker_build(jinja_env, forge_config, forge_dir): meta = forge_config['package'] meta.parse_again() matrix = compute_build_matrix(meta) - - if matrix: - forge_config = forge_config.copy() - forge_config['matrix'] = matrix + cases_not_skipped = [] + for case in matrix: + if not ResolvedDistribution(meta, case).skip(): + cases_not_skipped.append(case) + matrix = cases_not_skipped + + target_fname = os.path.join(forge_dir, 'ci_support', 'run_docker_build.sh') + if not matrix: + # There is nothing to be built (it is all skipped), but to keep the + # show on the road, we put in a basic matrix configuration (it will + # be skipped anyway). + matrix = [()] + + forge_config = forge_config.copy() + forge_config['matrix'] = matrix # TODO: Conda has a convenience for accessing nested yaml content. template_name = forge_config.get('templates', {}).get('run_docker_build', 'run_docker_build_matrix.tmpl') template = jinja_env.get_template(template_name) - run_docker_build_fname = os.path.join(forge_dir, 'ci_support', 'run_docker_build.sh') - with open(run_docker_build_fname, 'w') as fh: + with open(target_fname, 'w') as fh: fh.write(template.render(**forge_config)) - st = os.stat(run_docker_build_fname) - os.chmod(run_docker_build_fname, st.st_mode | stat.S_IEXEC) + st = os.stat(target_fname) + os.chmod(target_fname, st.st_mode | stat.S_IEXEC) @contextmanager @@ -53,12 +64,24 @@ def render_travis(jinja_env, forge_config, forge_dir): meta.parse_again() matrix = compute_build_matrix(meta) - if matrix: - forge_config = forge_config.copy() - forge_config['matrix'] = matrix + cases_not_skipped = [] + for case in matrix: + if not ResolvedDistribution(meta, case).skip(): + cases_not_skipped.append(case) + matrix = cases_not_skipped - template = jinja_env.get_template('travis.yml.tmpl') target_fname = os.path.join(forge_dir, '.travis.yml') + + if not matrix: + # There is nothing to be built (it is all skipped), but to keep the + # show on the road, we put in a basic matrix configuration (it will + # be skipped anyway). + matrix = [()] + + forge_config = forge_config.copy() + forge_config['matrix'] = matrix + + template = jinja_env.get_template('travis.yml.tmpl') with open(target_fname, 'w') as fh: fh.write(template.render(**forge_config)) @@ -76,18 +99,26 @@ def render_appveyor(jinja_env, forge_config, forge_dir): meta.parse_again() matrix = compute_build_matrix(meta) - if matrix: + cases_not_skipped = [] + for case in matrix: + if not ResolvedDistribution(meta, case).skip(): + cases_not_skipped.append(case) + matrix = cases_not_skipped + + target_fname = os.path.join(forge_dir, 'appveyor.yml') + + if not matrix: + # There are no cases to build (not even a case without any special + # dependencies), so remove the appveyor.yml if it exists. + if os.path.exists(target_fname): + os.remove(target_fname) + else: forge_config = forge_config.copy() forge_config['matrix'] = matrix - # TODO: Remove the appveyor result if it is Win skip. - # Note: This should look at all of the matrix items, and only - # skip if *all* of them skip. We definitely want to unit test that. - - template = jinja_env.get_template('appveyor.yml.tmpl') - target_fname = os.path.join(forge_dir, 'appveyor.yml') - with open(target_fname, 'w') as fh: - fh.write(template.render(**forge_config)) + template = jinja_env.get_template('appveyor.yml.tmpl') + with open(target_fname, 'w') as fh: + fh.write(template.render(**forge_config)) def copytree(src, dst, ignore=(), root_dst=None):