Skip to content

Commit

Permalink
Merge pull request #87 from pelson/better_matrix_determination
Browse files Browse the repository at this point in the history
Handle Perl and R matrix items.
  • Loading branch information
pelson committed Mar 22, 2016
2 parents 858d9ee + e9598bd commit a549480
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 24 deletions.
73 changes: 52 additions & 21 deletions conda_smithy/configure_feedstock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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
Expand All @@ -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))

Expand All @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion conda_smithy/templates/appveyor.yml.tmpl
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion conda_smithy/templates/run_docker_build_matrix.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
3 changes: 2 additions & 1 deletion conda_smithy/templates/travis.yml.tmpl
Original file line number Diff line number Diff line change
@@ -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.
Expand Down

0 comments on commit a549480

Please sign in to comment.