Skip to content

Commit

Permalink
Add support for yum_requirements to azure builds
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusvniekerk committed Feb 3, 2019
1 parent 3428c11 commit 1826839
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 32 deletions.
79 changes: 47 additions & 32 deletions conda_smithy/configure_feedstock.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,37 +709,9 @@ def _circle_specific_setup(jinja_env, forge_config, forge_dir, platform):
)

if platform == "linux":
# 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"
)
if os.path.exists(yum_requirements_fpath):
with open(yum_requirements_fpath) as fh:
requirements = [
line.strip()
for line in fh
if line.strip() and not line.strip().startswith("#")
]
if not requirements:
raise ValueError(
"No yum requirements enabled in the "
"yum_requirements.txt, please remove the file "
"or add some."
)
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 will be updated
# automatically.
/usr/bin/sudo -n yum install -y {}
""".format(
" ".join(requirements)
)
)
yum_build_setup = generate_yum_requirements(forge_dir)
if yum_build_setup:
forge_config["yum_build_setup"] = yum_build_setup

forge_config["build_setup"] = build_setup

Expand Down Expand Up @@ -772,6 +744,42 @@ def _circle_specific_setup(jinja_env, forge_config, forge_dir, platform):
set_exe_file(target_fname, True)


def generate_yum_requirements(forge_dir):
# 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"
)
yum_build_setup = ''
if os.path.exists(yum_requirements_fpath):
with open(yum_requirements_fpath) as fh:
requirements = [
line.strip()
for line in fh
if line.strip() and not line.strip().startswith("#")
]
if not requirements:
raise ValueError(
"No yum requirements enabled in the "
"yum_requirements.txt, please remove the file "
"or add some."
)
yum_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 will be updated
# automatically.
/usr/bin/sudo -n yum install -y {}
""".format(
" ".join(requirements)
)
)
return yum_build_setup


def _get_platforms_of_provider(provider, forge_config):
platforms = []
keep_noarchs = []
Expand Down Expand Up @@ -1004,7 +1012,14 @@ def _azure_specific_setup(jinja_env, forge_config, forge_dir, platform):
template_files = platform_templates.get(platform, [])

# Explicitly add in a newline character to ensure that jinja templating doesn't do something stupid
forge_config["build_setup"] = "run_conda_forge_build_setup\n"
build_setup = "run_conda_forge_build_setup\n"

if platform == "linux":
yum_build_setup = generate_yum_requirements(forge_dir)
if yum_build_setup:
forge_config['yum_build_setup'] = yum_build_setup

forge_config["build_setup"] = build_setup

forge_config["docker"]["interactive"] = False
_render_template_exe_files(
Expand Down
2 changes: 2 additions & 0 deletions conda_smithy/templates/build_steps.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ setup_conda_rc "${FEEDSTOCK_ROOT}" "${RECIPE_ROOT}" "${CONFIG_FILE}"

{% if build_setup -%}
{{ build_setup }}{% endif -%}
{% if yum_build_setup is defined -%}
{{ yum_build_setup }}{% endif -%}

# make the build number clobber
make_build_number "${FEEDSTOCK_ROOT}" "${RECIPE_ROOT}" "${CONFIG_FILE}"
Expand Down
24 changes: 24 additions & 0 deletions news/yum-azure.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
**Added:**

* <news item>

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* yum_requirements will now work on azure based linux builds.

**Security:**

* <news item>

0 comments on commit 1826839

Please sign in to comment.