diff --git a/conda_forge_feedstock_check_solvable/utils.py b/conda_forge_feedstock_check_solvable/utils.py index 72f7451..9cd1ebb 100644 --- a/conda_forge_feedstock_check_solvable/utils.py +++ b/conda_forge_feedstock_check_solvable/utils.py @@ -601,7 +601,27 @@ def _strip_quotes(s): return s -def replace_pin_compatible(reqs, host_reqs): +def replace_pin_compatible(reqs, host_reqs, strict=False): + """Replace pin_compatible with the appropriate version constraint. + + Parameters + ---------- + reqs : list of str + The requirements to replace pin_compatible in. + host_reqs : list of str + The requirements from the host section which is used to determine the + compatibility ranges. + strict : bool, optional + If True, raise an error if the package is not found in the host section. + If False, just add the package without a version constraint. Default is False + to match conda-build behavior. + + Returns + ------- + list of str + The requirements with pin_compatible replaced with the appropriate version + constraint. + """ host_lookup = {req.split(" ")[0]: req.split(" ")[1:] for req in host_reqs} new_reqs = [] @@ -620,16 +640,27 @@ def replace_pin_compatible(reqs, host_reqs): name = _strip_quotes(parts[0].strip()) parts = parts[1:] - if name not in host_lookup: - raise ValueError( - "Very odd pinning: %s! Package %s not found in host %r!" - % (req, name, host_lookup) - ) - if not host_lookup[name]: - raise ValueError( - "Very odd pinning: %s! Package found in host but no version %r!" - % (req, host_lookup[name]) - ) + if name not in host_lookup or not host_lookup[name]: + if strict: + if name not in host_lookup: + raise ValueError( + "Very odd pinning: %s! Package %s not found in host %r!" + % (req, name, host_lookup) + ) + else: + raise ValueError( + ( + "Very odd pinning: %s! Package found in host " + "but no version %r!" + ) + % (req, host_lookup[name]) + ) + else: + if build: + new_reqs.append(name + " * " + build) + else: + new_reqs.append(name) + continue host_version = host_lookup[name][0] if len(host_lookup[name]) > 1: diff --git a/tests/biopython-feedstock/.ci_support/linux_64_python3.12.____cpython.yaml b/tests/biopython-feedstock/.ci_support/linux_64_python3.12.____cpython.yaml new file mode 100644 index 0000000..6c03157 --- /dev/null +++ b/tests/biopython-feedstock/.ci_support/linux_64_python3.12.____cpython.yaml @@ -0,0 +1,27 @@ +c_compiler: +- gcc +c_compiler_version: +- '12' +c_stdlib: +- sysroot +c_stdlib_version: +- '2.12' +cdt_name: +- cos6 +channel_sources: +- conda-forge +channel_targets: +- conda-forge main +docker_image: +- quay.io/condaforge/linux-anvil-cos7-x86_64 +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.12.* *_cpython +target_platform: +- linux-64 +zip_keys: +- - c_stdlib_version + - cdt_name diff --git a/tests/biopython-feedstock/recipe/meta.yaml b/tests/biopython-feedstock/recipe/meta.yaml new file mode 100644 index 0000000..d323237 --- /dev/null +++ b/tests/biopython-feedstock/recipe/meta.yaml @@ -0,0 +1,110 @@ +{% set name = "biopython" %} +{% set version = "1.84" %} +{% set sha256 = "60fbe6f996e8a6866a42698c17e552127d99a9aab3259d6249fbaabd0e0cc7b4" %} + +package: + name: {{ name|lower }} + version: {{ version }} + +source: + fn: {{ name }}-{{ version }}.tar.gz + url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.tar.gz + sha256: {{ sha256 }} + +build: + number: 0 + script: {{ PYTHON }} -m pip install . --no-deps --ignore-installed --no-cache-dir -vvv + skip: true # [py<39] + +requirements: + build: + - python # [build_platform != target_platform] + - cross-python_{{ target_platform }} # [build_platform != target_platform] + - {{ compiler('c') }} + - {{ stdlib("c") }} + host: + - python + - pip + run: + - python + - {{ pin_compatible('numpy') }} + +test: + imports: + - Bio + - Bio.Affy + - Bio.Align + - Bio.Align.Applications + - Bio.AlignIO + - Bio.Application + - Bio.Blast + - Bio.CAPS + - Bio.Cluster + - Bio.Compass + - Bio.Data + - Bio.Emboss + - Bio.Entrez + - Bio.ExPASy + - Bio.GenBank + - Bio.Geo + #Requires soft dependency reportlab + #- Bio.Graphics + #- Bio.Graphics.GenomeDiagram + - Bio.HMM + - Bio.KEGG + - Bio.KEGG.Compound + - Bio.KEGG.Enzyme + - Bio.KEGG.KGML + - Bio.KEGG.Map + - Bio.Medline + - Bio.NMR + - Bio.Nexus + - Bio.PDB + #Requires soft dependency mmtf-python + #- Bio.PDB.mmtf + - Bio.Pathway + - Bio.Pathway.Rep + - Bio.Phylo + - Bio.Phylo.Applications + - Bio.Phylo.PAML + - Bio.PopGen + - Bio.PopGen.GenePop + - Bio.Restriction + - Bio.SCOP + - Bio.SVDSuperimposer + - Bio.SearchIO + - Bio.SearchIO.BlastIO + - Bio.SearchIO.ExonerateIO + - Bio.SearchIO.HmmerIO + - Bio.SearchIO._model + - Bio.SeqIO + - Bio.SeqUtils + - Bio.Sequencing + - Bio.Sequencing.Applications + - Bio.SwissProt + - Bio.TogoWS + - Bio.UniGene + - Bio.UniProt + - Bio.codonalign + - Bio.cpairwise2 + - Bio.motifs + - Bio.motifs.applications + - Bio.motifs.jaspar + - Bio.phenotype + - BioSQL + +about: + home: http://biopython.org + license: LicenseRef-Biopython + license_file: LICENSE.rst + summary: Collection of freely available tools for computational molecular biology + description: | + Biopython is a collection of freely available Python tools for + computational molecular biology + doc_url: http://biopython.org + dev_url: https://github.com/biopython/biopython + +extra: + recipe-maintainers: + - souravsingh + - peterjc diff --git a/tests/test_check_solvable.py b/tests/test_check_solvable.py index 0f84146..3271370 100644 --- a/tests/test_check_solvable.py +++ b/tests/test_check_solvable.py @@ -190,6 +190,16 @@ def test_hpp_fcl_solvable_runs(solver): ) +@flaky +def test_biopython_solvable_runs(solver): + feedstock_dir = os.path.join(os.path.dirname(__file__), "biopython-feedstock") + is_recipe_solvable( + feedstock_dir, + solver=solver, + verbosity=VERB, + ) + + def clone_and_checkout_repo(base_path: pathlib.Path, origin_url: str, ref: str): subprocess.run( f"cd {base_path} && git clone {origin_url} repo",