Skip to content

Commit

Permalink
Merge pull request #275 from msarahan/conda_build_2
Browse files Browse the repository at this point in the history
adjust fudge_subdir for non-global config in conda-build 2
  • Loading branch information
pelson authored Sep 1, 2016
2 parents 804e09f + 7163944 commit abe5656
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 16 deletions.
33 changes: 21 additions & 12 deletions conda_smithy/configure_feedstock.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@


def render_run_docker_build(jinja_env, forge_config, forge_dir):
with fudge_subdir('linux-64'):
meta = forge_config['package']
meta = forge_config['package']
with fudge_subdir('linux-64', meta):
meta.parse_again()
matrix = compute_build_matrix(meta, forge_config.get('matrix'))
cases_not_skipped = []
Expand Down Expand Up @@ -79,8 +79,8 @@ def render_run_docker_build(jinja_env, forge_config, forge_dir):


def render_circle(jinja_env, forge_config, forge_dir):
with fudge_subdir('linux-64'):
meta = forge_config['package']
meta = forge_config['package']
with fudge_subdir('linux-64', meta):
meta.parse_again()
matrix = compute_build_matrix(meta, forge_config.get('matrix'))

Expand All @@ -101,30 +101,39 @@ def render_circle(jinja_env, forge_config, forge_dir):


@contextmanager
def fudge_subdir(subdir):
def fudge_subdir(subdir, meta=None):
"""
Override the subdir (aka platform) that conda and conda_build see
both when fetching the index and in parsing conda build MetaData.
"""
# Store conda-build and conda.config's existing settings.
conda_orig = conda.config.subdir
cb_orig = conda_build.metadata.subdir
if meta and hasattr(meta, 'config'):
cb_orig = meta.config.subdir
else:
cb_meta_orig = conda_build.metadata.subdir

# Set them to what we want.
conda.config.subdir = subdir
conda_build.metadata.subdir = subdir
if meta and hasattr(meta, 'config'):
meta.config.subdir = subdir
else:
conda_build.metadata.subdir = subdir

yield

# Set them back to what they were
conda.config.subdir = conda_orig
conda_build.metadata.subdir = cb_orig
if meta and hasattr(meta, 'config'):
meta.config.subdir = cb_orig
else:
conda_build.metadata.subdir = cb_meta_orig


def render_travis(jinja_env, forge_config, forge_dir):
with fudge_subdir('osx-64'):
meta = forge_config['package']
meta = forge_config['package']
with fudge_subdir('osx-64', meta):
meta.parse_again()
matrix = compute_build_matrix(meta, forge_config.get('matrix'))

Expand Down Expand Up @@ -221,8 +230,8 @@ def sort_without_target_arch(case):
def render_appveyor(jinja_env, forge_config, forge_dir):
full_matrix = []
for platform, arch in [['win-32', 'x86'], ['win-64', 'x64']]:
with fudge_subdir(platform):
meta = forge_config['package']
meta = forge_config['package']
with fudge_subdir(platform, meta):
meta.parse_again()
matrix = compute_build_matrix(meta, forge_config.get('matrix'))

Expand Down
18 changes: 14 additions & 4 deletions conda_smithy/tests/test_configure_feedstock.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,30 @@ def test_metadata_reading(self):
name: foo_the_rest # [not (win or osx)]
""")
meta = conda_build.metadata.MetaData(recipe_dir)
with cnfgr_fdstk.fudge_subdir('win-64'):
with cnfgr_fdstk.fudge_subdir('win-64', meta):
meta.parse_again()
self.assertEqual(meta.name(), 'foo_win')

with cnfgr_fdstk.fudge_subdir('osx-64'):
with cnfgr_fdstk.fudge_subdir('osx-64', meta):
meta.parse_again()
self.assertEqual(meta.name(), 'foo_osx')

def test_fetch_index(self):
with tmp_directory() as recipe_dir:
with open(os.path.join(recipe_dir, 'meta.yaml'), 'w') as fh:
fh.write("""
package:
name: foo_win # [win]
name: foo_osx # [osx]
name: foo_the_rest # [not (win or osx)]
""")
meta = conda_build.metadata.MetaData(recipe_dir)

# Get the index for OSX and Windows. They should be different.

with cnfgr_fdstk.fudge_subdir('win-64'):
with cnfgr_fdstk.fudge_subdir('win-64', meta):
win_index = conda.api.get_index()
with cnfgr_fdstk.fudge_subdir('osx-64'):
with cnfgr_fdstk.fudge_subdir('osx-64', meta):
osx_index = conda.api.get_index()
self.assertNotEqual(win_index.keys(), osx_index.keys(),
('The keys for the Windows and OSX index were the same.'
Expand Down

0 comments on commit abe5656

Please sign in to comment.