Skip to content

Commit

Permalink
Provide conda-forge-build-setup boostrap and feedstock level overrides.
Browse files Browse the repository at this point in the history
  • Loading branch information
jakirkham committed Nov 29, 2016
1 parent 044d3ee commit 14d327a
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 10 deletions.
109 changes: 107 additions & 2 deletions conda_smithy/configure_feedstock.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,24 @@ def render_run_docker_build(jinja_env, forge_config, forge_dir):
matrix = prepare_matrix_for_env_vars(matrix)
forge_config = update_matrix(forge_config, matrix)

build_setup = ""

# If the recipe supplies its own conda-forge-build-setup script,
# we use it instead of the global one.
cfbs_fpath = os.path.join(forge_dir, 'recipe',
'run_conda_forge_build_setup_linux')
if os.path.exists(cfbs_fpath):
build_setup += textwrap.dedent("""\
# Overriding global conda-forge-build-setup with local copy.
source {recipe_dir}/run_conda_forge_build_setup_linux
""".format(recipe_dir=forge_config["recipe_dir"]))
else:
build_setup += textwrap.dedent("""\
source run_conda_forge_build_setup
""")

# If there is a "yum_requirements.txt" file in the recipe, we honour it.
yum_requirements_fpath = os.path.join(forge_dir, 'recipe',
'yum_requirements.txt')
Expand All @@ -80,7 +98,8 @@ def render_run_docker_build(jinja_env, forge_config, forge_dir):
raise ValueError("No yum requirements enabled in the "
"yum_requirements.txt, please remove the file "
"or add some.")
build_setup = textwrap.dedent("""\
build_setup += textwrap.dedent("""\
# Install the yum requirements defined canonically in the
# "recipe/yum_requirements.txt" file. After updating that file,
# run "conda smithy rerender" and this line be updated
Expand All @@ -89,7 +108,21 @@ def render_run_docker_build(jinja_env, forge_config, forge_dir):
""".format(' '.join(requirements)))
forge_config['build_setup'] = build_setup

forge_config['build_setup'] = build_setup

# If the recipe supplies its own conda-forge-build-setup upload script,
# we use it instead of the global one.
upload_fpath = os.path.join(forge_dir, 'recipe',
'upload_or_check_non_existence.py')
if os.path.exists(cfbs_fpath):
forge_config['upload_script'] = (
"{recipe_dir}/upload_or_check_non_existence.py".format(
recipe_dir=forge_config["recipe_dir"]
)
)
else:
forge_config['upload_script'] = "upload_or_check_non_existence"

# TODO: Conda has a convenience for accessing nested yaml content.
templates = forge_config.get('templates', {})
Expand Down Expand Up @@ -188,6 +221,41 @@ def render_travis(jinja_env, forge_config, forge_dir):
forge_config["travis"]["enabled"] = True
matrix = prepare_matrix_for_env_vars(matrix)
forge_config = update_matrix(forge_config, matrix)

build_setup = ""

# If the recipe supplies its own conda-forge-build-setup script,
# we use it instead of the global one.
cfbs_fpath = os.path.join(forge_dir, 'recipe',
'run_conda_forge_build_setup_osx')
if os.path.exists(cfbs_fpath):
build_setup += textwrap.dedent("""\
# Overriding global conda-forge-build-setup with local copy.
source {recipe_dir}/run_conda_forge_build_setup_osx
""".format(recipe_dir=forge_config["recipe_dir"]))
else:
build_setup += textwrap.dedent("""\
source run_conda_forge_build_setup
""")

build_setup = build_setup.strip()
build_setup = build_setup.replace("\n", "\n ")

forge_config['build_setup'] = build_setup

# If the recipe supplies its own conda-forge-build-setup upload script,
# we use it instead of the global one.
upload_fpath = os.path.join(forge_dir, 'recipe',
'upload_or_check_non_existence.py')
if os.path.exists(cfbs_fpath):
forge_config['upload_script'] = (
"{recipe_dir}/upload_or_check_non_existence.py".format(
recipe_dir=forge_config["recipe_dir"]
)
)
else:
forge_config['upload_script'] = "upload_or_check_non_existence"

template = jinja_env.get_template('travis.yml.tmpl')
with write_file(target_fname) as fh:
fh.write(template.render(**forge_config))
Expand Down Expand Up @@ -314,6 +382,43 @@ def render_appveyor(jinja_env, forge_config, forge_dir):
del old_matrix

forge_config = update_matrix(forge_config, matrix)

build_setup = ""

# If the recipe supplies its own conda-forge-build-setup script,
# we use it instead of the global one.
cfbs_fpath = os.path.join(forge_dir, 'recipe',
'run_conda_forge_build_setup_osx')
if os.path.exists(cfbs_fpath):
build_setup += textwrap.dedent("""\
# Overriding global conda-forge-build-setup with local copy.
{recipe_dir}\\run_conda_forge_build_setup_win.bat
""".format(recipe_dir=forge_config["recipe_dir"]))
else:
build_setup += textwrap.dedent("""\
run_conda_forge_build_setup
""")

build_setup = build_setup.rstrip()
build_setup = build_setup.replace("\n", "\n - cmd: ")
build_setup = build_setup.lstrip()

forge_config['build_setup'] = build_setup

# If the recipe supplies its own conda-forge-build-setup upload script,
# we use it instead of the global one.
upload_fpath = os.path.join(forge_dir, 'recipe',
'upload_or_check_non_existence.py')
if os.path.exists(cfbs_fpath):
forge_config['upload_script'] = (
"{recipe_dir}/upload_or_check_non_existence.py".format(
recipe_dir=forge_config["recipe_dir"]
)
)
else:
forge_config['upload_script'] = "upload_or_check_non_existence"

template = jinja_env.get_template('appveyor.yml.tmpl')
with write_file(target_fname) as fh:
fh.write(template.render(**forge_config))
Expand Down
5 changes: 3 additions & 2 deletions conda_smithy/templates/appveyor.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ install:

- cmd: conda install -n root --quiet --yes obvious-ci
- cmd: conda install -n root --quiet --yes conda-forge-build-setup
- cmd: run_conda_forge_build_setup
{% if build_setup -%}
{{ build_setup }}{% endif %}

# Skip .NET project specific build phase.
build: off
Expand All @@ -70,5 +71,5 @@ test_script:
- "%CMD_IN_ENV% conda build {{ recipe_dir }} --quiet"
deploy_script:
{%- for owner, channel in channels['targets'] %}
- cmd: upload_or_check_non_existence .\{{ recipe_dir }} {{ owner }} --channel={{ channel }}
- cmd: {{ upload_script }} .\{{ recipe_dir }} {{ owner }} --channel={{ channel }}
{% endfor %}
7 changes: 3 additions & 4 deletions conda_smithy/templates/run_docker_build.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,13 @@ echo "$config" > ~/.condarc
conda clean --lock
conda install --yes --quiet conda-forge-build-setup
source run_conda_forge_build_setup
{% if build_setup %}
{% if build_setup -%}
{{ build_setup }}{% endif -%}
{%- block build %}
conda build /recipe_root --quiet || exit 1
{%- for owner, channel in channels['targets'] %}
upload_or_check_non_existence /recipe_root {{ owner }} --channel={{ channel }} || exit 1
{{ upload_script }} /recipe_root {{ owner }} --channel={{ channel }} || exit 1
{%- endfor -%}
{%- endblock -%}
Expand Down
5 changes: 3 additions & 2 deletions conda_smithy/templates/travis.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ install:
{%- endfor %}
conda config --set show_channel_urls true
conda install --yes --quiet conda-forge-build-setup
source run_conda_forge_build_setup
{% if build_setup -%}
{{ build_setup }}{% endif %}

script:
- conda build ./{{ recipe_dir }}
{% for owner, channel in channels['targets'] %}
- upload_or_check_non_existence ./{{ recipe_dir }} {{ owner }} --channel={{ channel }}
- {{ upload_script }} ./{{ recipe_dir }} {{ owner }} --channel={{ channel }}
{% endfor %}

0 comments on commit 14d327a

Please sign in to comment.