Skip to content

Commit dc3f730

Browse files
committed
Added the ability to add extra yum deps to the feedstock.
1 parent a9c7e7f commit dc3f730

File tree

1 file changed

+36
-8
lines changed

1 file changed

+36
-8
lines changed

conda_smithy/configure_feedstock.py

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import os
55
import shutil
66
import stat
7+
import textwrap
78
import yaml
89
import warnings
910

@@ -40,9 +41,33 @@ def render_run_docker_build(jinja_env, forge_config, forge_dir):
4041
forge_config = forge_config.copy()
4142
forge_config['matrix'] = matrix
4243

44+
# If there is a "yum_requirements.txt" file in the recipe, we honour it.
45+
yum_requirements_fpath = os.path.join(forge_dir, 'recipe',
46+
'yum_requirements.txt')
47+
if os.path.exists(yum_requirements_fpath):
48+
with open(yum_requirements_fpath) as fh:
49+
requirements = [line.strip() for line in fh
50+
if line.strip() and not line.strip().startswith('#')]
51+
if not requirements:
52+
raise ValueError("No yum requirements enabled in the "
53+
"yum_requirements.txt, please remove the file "
54+
"or add some.")
55+
build_setup = textwrap.dedent("""\
56+
# Install the yum requirements defined canonically in the
57+
# "recipe/yum_requirements.txt" file. After updating that file,
58+
# run "conda smithy rerender" and this line be updated
59+
# automatically.
60+
yum install -y {}
61+
62+
63+
""".format(' '.join(requirements)))
64+
forge_config['build_setup'] = build_setup
65+
4366
# TODO: Conda has a convenience for accessing nested yaml content.
44-
template_name = forge_config.get('templates', {}).get('run_docker_build',
45-
'run_docker_build_matrix.tmpl')
67+
templates = forge_config.get('templates', {})
68+
template_name = templates.get('run_docker_build',
69+
'run_docker_build_matrix.tmpl')
70+
4671
template = jinja_env.get_template(template_name)
4772
with open(target_fname, 'w') as fh:
4873
fh.write(template.render(**forge_config))
@@ -169,9 +194,9 @@ def main(forge_file_directory):
169194
recipe_dir = 'recipe'
170195
config = {'docker': {'image': 'pelson/obvious-ci:latest_x64', 'command': 'bash'},
171196
'templates': {'run_docker_build': 'run_docker_build_matrix.tmpl'},
172-
'travis': [],
173-
'circle': [],
174-
'appveyor': [],
197+
'travis': {},
198+
'circle': {},
199+
'appveyor': {},
175200
'channels': {'sources': ['conda-forge'], 'targets': [['conda-forge', 'main']]},
176201
'recipe_dir': recipe_dir}
177202
forge_dir = os.path.abspath(forge_file_directory)
@@ -183,9 +208,12 @@ def main(forge_file_directory):
183208
with open(forge_yml, "r") as fh:
184209
file_config = list(yaml.load_all(fh))[0]
185210
# The config is just the union of the defaults, and the overriden
186-
# values. (XXX except dicts within dicts need to be dealt with!)
187-
config.update(file_config)
188-
211+
# values.
212+
for key, value in file_config.items():
213+
config_item = config.setdefault(key, value)
214+
# Deal with dicts within dicts.
215+
if isinstance(value, dict):
216+
config_item.update(value)
189217
config['package'] = meta = meta_of_feedstock(forge_file_directory)
190218

191219
tmplt_dir = os.path.join(conda_forge_content, 'templates')

0 commit comments

Comments
 (0)