Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide setup overrides #285

Merged
merged 2 commits into from
Dec 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 105 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_root/run_conda_forge_build_setup_linux

""")
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,19 @@ 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(upload_fpath):
forge_config['upload_script'] = (
"/recipe_root/upload_or_check_non_existence.py"
)
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 +219,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(upload_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 @@ -317,6 +383,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
""".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(upload_fpath):
forge_config['upload_script'] = (
"{recipe_dir}\\upload_or_check_non_existence".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 %}