Skip to content

Commit

Permalink
Merge branch 'config_channels' into set_ci_eol
Browse files Browse the repository at this point in the history
  • Loading branch information
jakirkham committed Jan 5, 2017
2 parents de87a23 + 0a99bfb commit 3f7a5e8
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 18 deletions.
76 changes: 69 additions & 7 deletions conda_smithy/configure_feedstock.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,33 @@

import conda.api
import conda.config

try:
# Try conda's API in newer 4.2.x and 4.3.x.
from conda.exports import (
DEFAULT_CHANNELS_UNIX,
DEFAULT_CHANNELS_WIN,
)
except ImportError:
try:
# Fallback for old versions of 4.2.x and 4.3.x.
from conda.base.constants import (
DEFAULT_CHANNELS_UNIX,
DEFAULT_CHANNELS_WIN,
)
except ImportError:
# Fallback for very old conda (e.g. 4.1.x).
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
Expand Down Expand Up @@ -44,7 +71,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)
Expand Down Expand Up @@ -145,7 +176,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:
Expand Down Expand Up @@ -198,7 +233,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:
Expand Down Expand Up @@ -330,7 +369,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:
Expand Down Expand Up @@ -500,8 +543,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:
Expand Down Expand Up @@ -529,7 +590,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)
Expand Down
18 changes: 9 additions & 9 deletions conda_smithy/templates/appveyor.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,24 @@ 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="

# Actually activate `conda`.
- 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 -%}
Expand Down
1 change: 0 additions & 1 deletion conda_smithy/templates/run_docker_build.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion conda_smithy/templates/travis.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down

0 comments on commit 3f7a5e8

Please sign in to comment.