Skip to content

Commit

Permalink
Merge pull request #82 from johanneskoester/master
Browse files Browse the repository at this point in the history
Handle all cases of missing packages when building version matrix.
  • Loading branch information
marqh authored Mar 23, 2017
2 parents ff9f7cf + 52f9ef5 commit c595c43
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ install:
fi

# Now do the things we need to do to install it.
- conda install --file requirements.txt nose mock python=${PYTHON} ${EXTRA_DEPS} --yes --quiet
- conda install -c conda-forge --file requirements.txt nose mock python=${PYTHON} ${EXTRA_DEPS} --yes --quiet
- python setup.py install
- mkdir not_the_source_root && cd not_the_source_root

Expand Down
21 changes: 16 additions & 5 deletions conda_build_all/version_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,17 @@ def minor_vn(version_str):
cases = set()
unsolvable_cases = set()

def get_pkgs(spec):
try:
return r.get_pkgs(spec)
except NO_PACKAGES_EXCEPTION:
# If no package is found in the channel, we do nothing
# this is reasonable because add_case_if_soluble does the same
# for concrete cases.
# This behavior is important because otherwise this will crash if
# a package is not available for a certain platform (e.g. win).
return []

def add_case_if_soluble(case):
# Whilst we strictly don't need to, shortcutting cases we've already seen makes a
# *huge* performance difference.
Expand All @@ -192,13 +203,13 @@ def add_case_if_soluble(case):
if 'numpy' in requirement_specs:
np_spec = requirement_specs.pop('numpy')
py_spec = requirement_specs.pop('python', None)
for numpy_pkg in r.get_pkgs(np_spec):
for numpy_pkg in get_pkgs(np_spec):
np_vn = minor_vn(index[numpy_pkg.fn]['version'])
numpy_deps = index[numpy_pkg.fn]['depends']
numpy_deps = {MatchSpec(spec).name: MatchSpec(spec)
for spec in numpy_deps}
# This would be problematic if python wasn't a dep of numpy.
for python_pkg in r.get_pkgs(numpy_deps['python']):
for python_pkg in get_pkgs(numpy_deps['python']):
if py_spec and not py_spec.match(python_pkg.fn):
continue
py_vn = minor_vn(index[python_pkg.fn]['version'])
Expand All @@ -208,15 +219,15 @@ def add_case_if_soluble(case):
add_case_if_soluble(case)
elif 'python' in requirement_specs:
py_spec = requirement_specs.pop('python')
for python_pkg in r.get_pkgs(py_spec):
for python_pkg in get_pkgs(py_spec):
py_vn = minor_vn(index[python_pkg.fn]['version'])
case = (('python', py_vn), )
add_case_if_soluble(case)

if 'perl' in requirement_specs:
pl_spec = requirement_specs.pop('perl')
for case_base in list(cases or [()]):
for perl_pkg in r.get_pkgs(pl_spec):
for perl_pkg in get_pkgs(pl_spec):
pl_vn = index[perl_pkg.fn]['version']
case = case_base + (('perl', pl_vn), )
add_case_if_soluble(case)
Expand All @@ -226,7 +237,7 @@ def add_case_if_soluble(case):
if 'r-base' in requirement_specs:
r_spec = requirement_specs.pop('r-base')
for case_base in list(cases or [()]):
for r_pkg in r.get_pkgs(r_spec):
for r_pkg in get_pkgs(r_spec):
r_vn = index[r_pkg.fn]['version']
case = case_base + (('r-base', r_vn), )
add_case_if_soluble(case)
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ conda >=4
conda-build >=1.21.7
anaconda-client
mock
requests==2.11 # work around conda/conda#3947

0 comments on commit c595c43

Please sign in to comment.