diff --git a/conda_forge_tick/migrators/cstdlib.py b/conda_forge_tick/migrators/cstdlib.py index 6f20e2d50..bac801e0f 100644 --- a/conda_forge_tick/migrators/cstdlib.py +++ b/conda_forge_tick/migrators/cstdlib.py @@ -73,8 +73,22 @@ def _process_section(output_index, attrs, lines): line_script = line_host = line_run = line_constrain = line_test = 0 indent_c = indent_m2c = indent_other = "" selector_c = selector_m2c = selector_other = "" + test_indent = None + curr_indent = None last_line_was_build = False for i, line in enumerate(lines): + # skip comments or blank lines + if not line.strip() or line.strip().startswith("#"): + continue + + curr_indent = len(line) - len(line.lstrip()) + if test_indent is not None and curr_indent > test_indent: + # we're still in the test section, skip + continue + elif test_indent is not None: + # we're done with the test section + test_indent = None + if last_line_was_build: # process this separately from the if-else-chain below keys_after_nonreq_build = [ @@ -120,16 +134,17 @@ def _process_section(output_index, attrs, lines): line_constrain = i elif re.match(r"^\s*test:.*", line): line_test = i - # ensure we don't read past test section (may contain unrelated deps) - break + test_indent = len(line) - len(line.lstrip()) if line_build: # double-check whether there are compilers in the build section # that may have gotten ignored by selectors; we explicitly only # want to match with compilers in build, not host or run - build_reqs = lines[ - line_build : (line_host or line_run or line_constrain or line_test or -1) - ] + if line_test > line_build: + end_build = line_host or line_run or line_constrain or line_test or -1 + else: + end_build = line_host or line_run or line_constrain or -1 + build_reqs = lines[line_build:end_build] needs_stdlib |= any(pat_compiler.search(line) for line in build_reqs) if not needs_stdlib: diff --git a/tests/test_stdlib.py b/tests/test_stdlib.py index 98dee3f2c..a1accf049 100644 --- a/tests/test_stdlib.py +++ b/tests/test_stdlib.py @@ -48,6 +48,10 @@ ("gz-common", "5_5.6.0", False), # test recipe with quoting ("libhdbpp-timescale", "2.1.0", False), + # test section before build + ("unicorn", "2.0.1.post1", False), + # commented compiler dep + ("pysyntect", "0.3.0", False), ], ) def test_stdlib(feedstock, new_ver, expect_cbc, tmpdir): diff --git a/tests/test_yaml/stdlib_pysyntect_after_meta.yaml b/tests/test_yaml/stdlib_pysyntect_after_meta.yaml new file mode 100644 index 000000000..862771ee9 --- /dev/null +++ b/tests/test_yaml/stdlib_pysyntect_after_meta.yaml @@ -0,0 +1,64 @@ +{% set name = "pysyntect" %} +{% set version = "0.3.0" %} + +package: + name: {{ name|lower }} + version: {{ version }} + +source: + url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.tar.gz + sha256: ffcb227dc57bffe6e194842944f8d16e49d77d6affd08c8c213d0e2d4e956c43 + +build: + number: 0 + # the distributed binaries are already relocatable + binary_relocation: false + missing_dso_whitelist: + - /usr/lib/libresolv.9.dylib # [osx] + +requirements: + build: + - posix # [win] + # - {{ compiler('c') }} + - {{ compiler('cxx') }} + - {{ stdlib("c") }} + - clang + - llvm + - rust + - llvmdev + - llvm-tools + - libclang + - maturin + - toml + - pip + host: + - python + - pip + run: + - python + +test: + # Some packages might need a `test/commands` key to check CLI. + # List all the packages/modules that `run_test.py` imports. + imports: + - syntect + +about: + home: https://github.com/spyder-ide/pysyntect + license: MIT AND Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND MPL-2.0 AND Zlib AND Unlicense + license_family: MIT + license_file: LICENSE + summary: Python bindings for the syntect Rust library + + # The remaining entries in this section are optional, but recommended. + description: | + Python bindings for the Syntect library. Pysyntect provides a lightweight, + fast engine to compute syntax highlighting using Sublime Text syntax + definitions and TextMate theme definitions, which are shared by + many editors. + dev_url: https://github.com/spyder-ide/pysyntect + +extra: + recipe-maintainers: + - andfoy + - ccordoba12 diff --git a/tests/test_yaml/stdlib_pysyntect_before_meta.yaml b/tests/test_yaml/stdlib_pysyntect_before_meta.yaml new file mode 100644 index 000000000..979107bab --- /dev/null +++ b/tests/test_yaml/stdlib_pysyntect_before_meta.yaml @@ -0,0 +1,63 @@ +{% set name = "pysyntect" %} +{% set version = "0.2.0" %} + +package: + name: {{ name|lower }} + version: {{ version }} + +source: + url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.tar.gz + sha256: ffcb227dc57bffe6e194842944f8d16e49d77d6affd08c8c213d0e2d4e956c44 + +build: + number: 0 + # the distributed binaries are already relocatable + binary_relocation: false + missing_dso_whitelist: + - /usr/lib/libresolv.9.dylib # [osx] + +requirements: + build: + - posix # [win] + # - {{ compiler('c') }} + - {{ compiler('cxx') }} + - clang + - llvm + - rust + - llvmdev + - llvm-tools + - libclang + - maturin + - toml + - pip + host: + - python + - pip + run: + - python + +test: + # Some packages might need a `test/commands` key to check CLI. + # List all the packages/modules that `run_test.py` imports. + imports: + - syntect + +about: + home: https://github.com/spyder-ide/pysyntect + license: MIT AND Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND MPL-2.0 AND Zlib AND Unlicense + license_family: MIT + license_file: LICENSE + summary: Python bindings for the syntect Rust library + + # The remaining entries in this section are optional, but recommended. + description: | + Python bindings for the Syntect library. Pysyntect provides a lightweight, + fast engine to compute syntax highlighting using Sublime Text syntax + definitions and TextMate theme definitions, which are shared by + many editors. + dev_url: https://github.com/spyder-ide/pysyntect + +extra: + recipe-maintainers: + - andfoy + - ccordoba12 diff --git a/tests/test_yaml/stdlib_unicorn_after_meta.yaml b/tests/test_yaml/stdlib_unicorn_after_meta.yaml new file mode 100644 index 000000000..04728f5a7 --- /dev/null +++ b/tests/test_yaml/stdlib_unicorn_after_meta.yaml @@ -0,0 +1,107 @@ +{% set name = "unicorn" %} +{% set version = "2.0.1.post1" %} + +package: + name: {{ name|lower }}-split + version: {{ version }} + +source: + url: https://github.com/unicorn-engine/unicorn/archive/{{ version.replace("rc", "-rc") }}.tar.gz + sha256: 6b276c857c69ee5ec3e292c3401c8c972bae292e0e4cb306bb9e5466c0f14737 + folder: source + +build: + number: 0 + skip: true # [win] + run_exports: + - {{ pin_subpackage('unicorn', max_pin='x.x.x') }} + +requirements: + build: + - python # [build_platform != target_platform] + - cross-python_{{ target_platform }} # [build_platform != target_platform] + - {{ compiler('c') }} + - {{ stdlib("c") }} + - pkg-config + - cmake + - make # [unix] + - ninja # [win] + host: + +outputs: + - name: unicorn + build: + script: + - cmake --install source/build + test: + commands: + - test -f $PREFIX/lib/libunicorn$SHLIB_EXT # [unix] + - if not exist %LIBRARY_BIN%\\unicorn.dll exit 1 # [win] + requirements: + build: + - {{ compiler('c') }} + - {{ stdlib("c") }} + - pkg-config + - cmake + - make # [unix] + - ninja # [win] + + - name: python-unicorn + build: + skip: true # [win] + script: + - export LIBUNICORN_PATH="${PREFIX}/lib" + - cd source/bindings/python + - ${PYTHON} -m pip install . -vv + requirements: + build: + - python # [build_platform != target_platform] + - cross-python_{{ target_platform }} # [build_platform != target_platform] + host: + - {{ pin_subpackage("unicorn", exact=True) }} + - pip + - python + run: + - python + - {{ pin_subpackage("unicorn", exact=True) }} + test: + imports: + - unicorn + commands: + - pip check + requires: + - pip + +about: + home: https://www.unicorn-engine.org/ + license: LGPL-2.0-only AND GPL-2.0-only AND GPL-2.0-or-later + license_file: + - source/COPYING + - source/COPYING_GLIB + - source/COPYING.LGPL2 + - source/qemu/LICENSE + summary: Unicorn CPU emulator framework (ARM, AArch64, M68K, Mips, Sparc, X86) + description: | + Unicorn is a lightweight, multi-platform, multi-architecture CPU emulator framework + based on [QEMU](http://qemu.org). + + Unicorn offers some unparalleled features: + + - Multi-architecture: ARM, ARM64 (ARMv8), M68K, MIPS, SPARC, and X86 (16, 32, 64-bit) + - Clean/simple/lightweight/intuitive architecture-neutral API + - Implemented in pure C language, with bindings for Crystal, Clojure, Visual Basic, Perl, + Rust, Ruby, Python, Java, .NET, Go, Delphi/Free Pascal, Haskell, Pharo, and Lua. + - Native support for Windows & *nix (with Mac OSX, Linux, *BSD & Solaris confirmed) + - High performance via Just-In-Time compilation + - Support for fine-grained instrumentation at various levels + - Thread-safety by design + - Distributed under free software license GPLv2 + doc_url: https://www.unicorn-engine.org/docs/ + dev_url: https://github.com/unicorn-engine/unicorn + +extra: + feedstock-name: unicorn + recipe-maintainers: + - chrisburr + - pavelzw + - '0xbe7a' diff --git a/tests/test_yaml/stdlib_unicorn_before_meta.yaml b/tests/test_yaml/stdlib_unicorn_before_meta.yaml new file mode 100644 index 000000000..6d8e62a2f --- /dev/null +++ b/tests/test_yaml/stdlib_unicorn_before_meta.yaml @@ -0,0 +1,105 @@ +{% set name = "unicorn" %} +{% set version = "2.0.0" %} + +package: + name: {{ name|lower }}-split + version: {{ version }} + +source: + url: https://github.com/unicorn-engine/unicorn/archive/{{ version.replace("rc", "-rc") }}.tar.gz + sha256: 6b276c857c69ee5ec3e292c3401c8c972bae292e0e4cb306bb9e5466c0f14739 + folder: source + +build: + number: 6 + skip: true # [win] + run_exports: + - {{ pin_subpackage('unicorn', max_pin='x.x.x') }} + +requirements: + build: + - python # [build_platform != target_platform] + - cross-python_{{ target_platform }} # [build_platform != target_platform] + - {{ compiler('c') }} + - pkg-config + - cmake + - make # [unix] + - ninja # [win] + host: + +outputs: + - name: unicorn + build: + script: + - cmake --install source/build + test: + commands: + - test -f $PREFIX/lib/libunicorn$SHLIB_EXT # [unix] + - if not exist %LIBRARY_BIN%\\unicorn.dll exit 1 # [win] + requirements: + build: + - {{ compiler('c') }} + - pkg-config + - cmake + - make # [unix] + - ninja # [win] + + - name: python-unicorn + build: + skip: true # [win] + script: + - export LIBUNICORN_PATH="${PREFIX}/lib" + - cd source/bindings/python + - ${PYTHON} -m pip install . -vv + requirements: + build: + - python # [build_platform != target_platform] + - cross-python_{{ target_platform }} # [build_platform != target_platform] + host: + - {{ pin_subpackage("unicorn", exact=True) }} + - pip + - python + run: + - python + - {{ pin_subpackage("unicorn", exact=True) }} + test: + imports: + - unicorn + commands: + - pip check + requires: + - pip + +about: + home: https://www.unicorn-engine.org/ + license: LGPL-2.0-only AND GPL-2.0-only AND GPL-2.0-or-later + license_file: + - source/COPYING + - source/COPYING_GLIB + - source/COPYING.LGPL2 + - source/qemu/LICENSE + summary: Unicorn CPU emulator framework (ARM, AArch64, M68K, Mips, Sparc, X86) + description: | + Unicorn is a lightweight, multi-platform, multi-architecture CPU emulator framework + based on [QEMU](http://qemu.org). + + Unicorn offers some unparalleled features: + + - Multi-architecture: ARM, ARM64 (ARMv8), M68K, MIPS, SPARC, and X86 (16, 32, 64-bit) + - Clean/simple/lightweight/intuitive architecture-neutral API + - Implemented in pure C language, with bindings for Crystal, Clojure, Visual Basic, Perl, + Rust, Ruby, Python, Java, .NET, Go, Delphi/Free Pascal, Haskell, Pharo, and Lua. + - Native support for Windows & *nix (with Mac OSX, Linux, *BSD & Solaris confirmed) + - High performance via Just-In-Time compilation + - Support for fine-grained instrumentation at various levels + - Thread-safety by design + - Distributed under free software license GPLv2 + doc_url: https://www.unicorn-engine.org/docs/ + dev_url: https://github.com/unicorn-engine/unicorn + +extra: + feedstock-name: unicorn + recipe-maintainers: + - chrisburr + - pavelzw + - '0xbe7a'