diff --git a/conda_smithy/configure_feedstock.py b/conda_smithy/configure_feedstock.py index ff0c1e0c2..44a9f1285 100755 --- a/conda_smithy/configure_feedstock.py +++ b/conda_smithy/configure_feedstock.py @@ -11,6 +11,25 @@ import conda.api import conda.config + +try: + from conda.base.constants import ( + DEFAULT_CHANNELS_UNIX, + DEFAULT_CHANNELS_WIN, + ) +except ImportError: + # old conda + DEFAULT_CHANNELS_UNIX = ( + 'https://repo.continuum.io/pkgs/free', + 'https://repo.continuum.io/pkgs/pro', + ) + + DEFAULT_CHANNELS_WIN = ( + 'https://repo.continuum.io/pkgs/free', + 'https://repo.continuum.io/pkgs/pro', + 'https://repo.continuum.io/pkgs/msys2', + ) + import conda_build.metadata try: import conda_build.api @@ -44,7 +63,11 @@ def render_run_docker_build(jinja_env, forge_config, forge_dir): meta = forge_config['package'] with fudge_subdir('linux-64', build_config=meta_config(meta)): meta.parse_again() - matrix = compute_build_matrix(meta, forge_config.get('matrix')) + matrix = compute_build_matrix( + meta, + forge_config.get('matrix'), + forge_config.get('channels', {}).get('sources', tuple()) + ) cases_not_skipped = [] for case in matrix: pkgs, vars = split_case(case) @@ -145,7 +168,11 @@ def render_circle(jinja_env, forge_config, forge_dir): meta = forge_config['package'] with fudge_subdir('linux-64', build_config=meta_config(meta)): meta.parse_again() - matrix = compute_build_matrix(meta, forge_config.get('matrix')) + matrix = compute_build_matrix( + meta, + forge_config.get('matrix'), + forge_config.get('channels', {}).get('sources', tuple()) + ) cases_not_skipped = [] for case in matrix: @@ -198,7 +225,11 @@ def render_travis(jinja_env, forge_config, forge_dir): meta = forge_config['package'] with fudge_subdir('osx-64', build_config=meta_config(meta)): meta.parse_again() - matrix = compute_build_matrix(meta, forge_config.get('matrix')) + matrix = compute_build_matrix( + meta, + forge_config.get('matrix'), + forge_config.get('channels', {}).get('sources', tuple()) + ) cases_not_skipped = [] for case in matrix: @@ -330,7 +361,11 @@ def render_appveyor(jinja_env, forge_config, forge_dir): for platform, arch in [['win-32', 'x86'], ['win-64', 'x64']]: with fudge_subdir(platform, build_config=meta_config(meta)): meta.parse_again() - matrix = compute_build_matrix(meta, forge_config.get('matrix')) + matrix = compute_build_matrix( + meta, + forge_config.get('matrix'), + forge_config.get('channels', {}).get('sources', tuple()) + ) cases_not_skipped = [] for case in matrix: @@ -500,8 +535,26 @@ def meta_of_feedstock(forge_dir, config=None): return meta -def compute_build_matrix(meta, existing_matrix=None): - index = conda.api.get_index() +def compute_build_matrix(meta, existing_matrix=None, channel_sources=tuple()): + channel_sources = tuple(channel_sources) + + # Override what `defaults` means depending on the platform used. + try: + i = channel_sources.index("defaults") + + defaults = DEFAULT_CHANNELS_UNIX + if meta_config(meta).subdir.startswith("win"): + defaults = DEFAULT_CHANNELS_WIN + + channel_sources = ( + channel_sources[:i] + + defaults + + channel_sources[i+1:] + ) + except ValueError: + pass + + index = conda.api.get_index(channel_urls=channel_sources) mtx = special_case_version_matrix(meta, index) mtx = list(filter_cases(mtx, ['python >=2.7,<3|>=3.4', 'numpy >=1.10'])) if existing_matrix: @@ -529,7 +582,8 @@ def main(forge_file_directory): 'travis': {}, 'circle': {}, 'appveyor': {}, - 'channels': {'sources': ['conda-forge'], 'targets': [['conda-forge', 'main']]}, + 'channels': {'sources': ['conda-forge', 'defaults'], + 'targets': [['conda-forge', 'main']]}, 'github': {'user_or_org': 'conda-forge', 'repo_name': ''}, 'recipe_dir': recipe_dir} forge_dir = os.path.abspath(forge_file_directory) diff --git a/conda_smithy/templates/appveyor.yml.tmpl b/conda_smithy/templates/appveyor.yml.tmpl index 12c69ebda..45406f51b 100644 --- a/conda_smithy/templates/appveyor.yml.tmpl +++ b/conda_smithy/templates/appveyor.yml.tmpl @@ -41,17 +41,10 @@ install: # Cywing's git breaks conda-build. (See https://github.com/conda-forge/conda-smithy-feedstock/pull/2.) - cmd: rmdir C:\cygwin /s /q - # Add our channels. + # Add a hack to update conda as the included copy is too old. - cmd: set "OLDPATH=%PATH%" - cmd: set "PATH=%CONDA_INSTALL_LOCN%\\Scripts;%CONDA_INSTALL_LOCN%\\Library\\bin;%PATH%" - - cmd: conda config --set show_channel_urls true - {%- for channel in channels.get('sources', [])|reverse %} - - cmd: conda config --add channels {{ channel }}{% endfor %} - - # Add a hack to switch to `conda` version `4.1.12` before activating. - # This is required to handle a long path activation issue. - # Please see PR ( https://github.com/conda/conda/pull/3349 ). - - cmd: conda install --yes --quiet conda=4.1.12 + - cmd: conda update --yes --quiet conda - cmd: set "PATH=%OLDPATH%" - cmd: set "OLDPATH=" @@ -59,6 +52,13 @@ install: - cmd: call %CONDA_INSTALL_LOCN%\Scripts\activate.bat - cmd: set PYTHONUNBUFFERED=1 + # Add our channels. + - cmd: conda config --set show_channel_urls true + - cmd: conda config --remove channels defaults + {%- for channel in channels.get('sources', [])|reverse %} + - cmd: conda config --add channels {{ channel }}{% endfor %} + + # Configure the VM. - cmd: conda install -n root --quiet --yes obvious-ci - cmd: conda install -n root --quiet --yes conda-forge-build-setup {% if build_setup -%} diff --git a/conda_smithy/templates/run_docker_build.tmpl b/conda_smithy/templates/run_docker_build.tmpl index 451b45282..6b7a009b1 100644 --- a/conda_smithy/templates/run_docker_build.tmpl +++ b/conda_smithy/templates/run_docker_build.tmpl @@ -16,7 +16,6 @@ channels: {%- for channel in channels.get('sources', []) %} - {{ channel }} {%- endfor %} - - defaults # As we need conda-build conda-build: root-dir: /feedstock_root/build_artefacts diff --git a/conda_smithy/templates/travis.yml.tmpl b/conda_smithy/templates/travis.yml.tmpl index 36e8a6a3d..b1f30dab8 100644 --- a/conda_smithy/templates/travis.yml.tmpl +++ b/conda_smithy/templates/travis.yml.tmpl @@ -44,7 +44,7 @@ install: bash $MINICONDA_FILE -b source /Users/travis/miniconda3/bin/activate root - + conda config --remove channels defaults {%- for channel in channels.get('sources', [])|reverse %} conda config --add channels {{ channel }} {%- endfor %}