def test_no_case(self): # No cases should still give us a result with a single case in it. a = DummyPackage('pkgA', ['wibble']) self.index.add_pkg('python', '2.7.2') self.index.add_pkg('wibble', '3.5.0') r = special_case_version_matrix(a, self.index) self.assertEqual(r, set([()]))
def test_numpy_xx_only(self): # Only a numpy x.x spec. # Build an index that contains numpy 1.9 and 1.10 on python 2.7 and # 3.5 for a total of 4 numpy/python combinations. pythons = ['2.7', '3.5'] # Only major/minor in the numpy list here because that is what is used # for the build matrix. numpys = ['1.9', '1.10'] self.construct_numpy_index(pythons, numpys) # Case 1: Only a numpy x.x spec... numpy_dep_case = ('numpy x.x', 'python') # ...expect all four cases to be in the matrix. expect_result = [] for python in pythons: for numpy in numpys: expect_result.append((('python', python), ('numpy', numpy))) a = DummyPackage('pkgA', numpy_dep_case, numpy_dep_case) r = special_case_version_matrix(a, self.index) self.assertEqual(set(r), set(expect_result), msg='got: {}\nexpected: {}'.format(r, expect_result))
def test_noarch_python(self): a = DummyPackage('pkgA', ['python']) a.noarch = 'python' self.index.add_pkg('python', '2.7.2') self.index.add_pkg('python', '3.5.0') r = special_case_version_matrix(a, self.index) self.assertEqual(r, set(((), )))
def test_numpy_xx_and_restrictive_specifcation(self): # Case 3: # A numpy x.x spec and a numpy version restriction which does # eliminate one the numpy versions in the DummyIndex. # Build an index that contains numpy 1.9 and 1.10 on python 2.7 and # 3.5 for a total of 4 numpy/python combinations. pythons = ['2.7', '3.5'] # Only major/minor in the numpy list here because that is what is used # for the build matrix. numpys = ['1.9', '1.10'] self.construct_numpy_index(pythons, numpys) # A numpy x.x spec and a numpy version restriction which does # eliminate one the numpy versions in the DummyIndex. numpy_dep_case = ('numpy x.x', 'numpy >=1.10', 'python') # Expect only the numpy 1.9 case to survive. expect_result = [] for python in pythons: for numpy in numpys[1:]: expect_result.append((('python', python), ('numpy', numpy))) a = DummyPackage('pkgA', numpy_dep_case, numpy_dep_case) r = special_case_version_matrix(a, self.index) self.assertEqual(set(r), set(expect_result), msg='got: {}\nexpected: {}'.format(r, expect_result))
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, platform=meta_config(meta).subdir) mtx = special_case_version_matrix(meta, index) mtx = list(filter_cases(mtx, ['python >=2.7,<3|>=3.5', 'numpy >=1.11', 'r-base >=3.3.2'])) if existing_matrix: mtx = [tuple(mtx_case) + tuple(MatrixCaseEnvVar(*item) for item in case) for case in sorted(existing_matrix) for mtx_case in mtx] return mtx
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, platform=meta_config(meta).subdir) mtx = special_case_version_matrix(meta, index) mtx = list( filter_cases(mtx, [ 'python >=2.7,<3|>=3.5', 'numpy >=1.11', 'r-base ==3.3.2|==3.4.1' ])) if existing_matrix: mtx = [ tuple(mtx_case) + tuple(MatrixCaseEnvVar(*item) for item in case) for case in sorted(existing_matrix) for mtx_case in mtx ] return mtx
def test_numpy_simplest_case(self): a = DummyPackage('pkgA', ['python', 'numpy']) self.index.add_pkg('numpy', '1.8.0', 'py27', depends=['python']) self.index.add_pkg('python', '2.7.2') r = special_case_version_matrix(a, self.index) self.assertEqual(r, set([(('python', '2.7'), ('numpy', '1.8')), ]) )
def test_constrained_python(self): a = DummyPackage('pkgA', ['python <3']) self.index.add_pkg('python', '2.7.2') self.index.add_pkg('python', '3.5.0') r = special_case_version_matrix(a, self.index) self.assertEqual(r, set(((('python', '2.7'), ), )) )
def compute_build_matrix(meta, existing_matrix=None): index = conda.api.get_index() mtx = special_case_version_matrix(meta, index) mtx = list(filter_cases(mtx, ['python >=2.7,<3|>=3.4', 'numpy >=1.10'])) if existing_matrix: mtx = [tuple(mtx_case) + tuple(MatrixCaseEnvVar(*item) for item in case) for case in sorted(existing_matrix) for mtx_case in mtx] return mtx
def test_r_matrix(self): a = DummyPackage('pkgA', ['r-base']) self.index.add_pkg('r-base', '4.5.6') self.index.add_pkg('r-base', '4.5.7') r = special_case_version_matrix(a, self.index) self.assertEqual(r, set(((('r-base', '4.5.6'),), (('r-base', '4.5.7'),), )) )
def test_dependency_on_py27(self): # If a dependency can't hit the python version, it should not # be considered a case. a = DummyPackage('pkgA', ['python', 'oldschool']) self.index.add_pkg('oldschool', '1.8.0', 'py27', depends=['python <3']) self.index.add_pkg('python', '2.7.2') self.index.add_pkg('python', '3.5.0') r = special_case_version_matrix(a, self.index) # TODO: Enable this test. return
def test_numpy_without_python(self): # Conda recipes which do not depend on python, but do on python, do # not have the full conda metadata, but still need to be handled. a = DummyPackage('pkgA', ['numpy']) self.index.add_pkg('numpy', '1.8.0', 'py27', depends=['python']) self.index.add_pkg('python', '2.7.2') r = special_case_version_matrix(a, self.index) self.assertEqual(r, set([(('python', '2.7'), ('numpy', '1.8')), ]) )
def test_numpy_repeated_python27(self): # Repeating python 2.7 will result in the latest version being found a = DummyPackage('pkgA', ['python', 'numpy']) self.index.add_pkg('numpy', '1.8.0', 'py27', depends=['python <3']) self.index.add_pkg('python', '2.7.2') self.index.add_pkg('python', '2.7.0') r = special_case_version_matrix(a, self.index) self.assertEqual(r, set([(('python', '2.7'), ('numpy', '1.8')), ]) )
def test_dependency_on_py27(self): # If a dependency can't hit the python version, it should not # be considered a case. a = DummyPackage('pkgA', ['python', 'oldschool']) self.index.add_pkg('oldschool', '1.8.0', 'py27', depends=['python <3']) self.index.add_pkg('python', '2.7.2') self.index.add_pkg('python', '3.5.0') r = special_case_version_matrix(a, self.index) # No python 3 should be here. self.assertEqual(r, set([ (('python', '2.7'), ), ]))
def test_numpy_repeated_python(self): a = DummyPackage('pkgA', ['python', 'numpy']) self.index.add_pkg('numpy', '1.8.0', 'py27', depends=['python <3']) self.index.add_pkg('numpy', '1.8.0', 'py35', depends=['python']) self.index.add_pkg('numpy', '1.9.0', 'py35', depends=['python >=3']) self.index.add_pkg('python', '2.7.2') self.index.add_pkg('python', '3.5.0') r = special_case_version_matrix(a, self.index) self.assertEqual(r, set(((('python', '2.7'), ('numpy', '1.8')), (('python', '3.5'), ('numpy', '1.8')), (('python', '3.5'), ('numpy', '1.9')), )) )
def test_perl_and_python_matrix(self): a = DummyPackage('pkgA', ['perl', 'python']) self.index.add_pkg('perl', '4.5.6') self.index.add_pkg('perl', '4.5.7') self.index.add_pkg('python', '2.7') self.index.add_pkg('python', '3.5') r = special_case_version_matrix(a, self.index) expected = set(((('python', '3.5'), ('perl', '4.5.7')), (('python', '2.7'), ('perl', '4.5.7')), (('python', '2.7'), ('perl', '4.5.6')), (('python', '3.5'), ('perl', '4.5.6')))) self.assertEqual(r, expected)
def test_dependency_on_py27(self): # If a dependency can't hit the python version, it should not # be considered a case. a = DummyPackage('pkgA', ['python', 'oldschool']) self.index.add_pkg('oldschool', '1.8.0', 'py27', depends=['python <3']) self.index.add_pkg('python', '2.7.2') self.index.add_pkg('python', '3.5.0') r = special_case_version_matrix(a, self.index) # No python 3 should be here. self.assertEqual(r, set([(('python', '2.7'), ), ] ))
def resolve_all(cls, meta, index=None, extra_conditions=None): """ Given a package, return a list of ResolvedDistributions, one for each possible (necessary) version permutation. """ if index is None: with vn_matrix.override_conda_logging('WARN'): index = get_index() cases = sorted(vn_matrix.special_case_version_matrix(meta, index)) if extra_conditions: cases = list(vn_matrix.filter_cases(cases, extra_conditions)) result = [] for case in cases: dist = cls(meta, case) if not dist.skip(): result.append(dist) return result
def compute_build_matrix(meta): index = conda.api.get_index() mtx = special_case_version_matrix(meta, index) mtx = list(filter_cases(mtx, ['python >=2.7,<3|>=3.4', 'numpy >=1.9'])) return mtx
def test_python_itself(self): a = DummyPackage('python', version="a.b.c") r = special_case_version_matrix(a, self.index) self.assertEqual(r, set(((('python', 'a.b'),), )) )
def compute_build_matrix(meta): index = conda.api.get_index() mtx = special_case_version_matrix(meta, index) mtx = list(filter_cases(mtx, ['python >=2.7,<3|>=3.4', 'numpy >=1.10'])) return mtx