prefix-dev / rattler-build

rattler-build is a universal package builder for Windows, macOS and Linux
https://prefix-dev.github.io/rattler-build
BSD 3-Clause "New" or "Revised" License
212 stars 45 forks source link

`rattler-build test` cannot install test dependencies #1048

Closed rjz-viv closed 1 month ago

rjz-viv commented 2 months ago

I am not able to run tests via rattler-build test for recipes that have dependencies in the script test section. Taking the example rich recipe and adding a script test section to it:

context:
  version: "13.4.2"

package:
  name: "rich"
  version: ${{ version }}

source:
  - url: https://pypi.io/packages/source/r/rich/rich-${{ version }}.tar.gz
    sha256: d653d6bccede5844304c605d5aac802c7cf9621efd700b46c7ec2b51ea914898

build:
  # Thanks to `noarch: python` this package works on all platforms
  noarch: python
  script:
    - python -m pip install . -vv --no-deps --no-build-isolation

requirements:
  host:
    - pip
    - poetry-core >=1.0.0
    - python 3.10
  run:
    # sync with normalized deps from poetry-generated setup.py
    - markdown-it-py >=2.2.0
    - pygments >=2.13.0,<3.0.0
    - python 3.10
    - typing_extensions >=4.0.0,<5.0.0

tests:
  - python:
      imports:
        - rich
      pip_check: true
  - script:
      - python -c "import rich"
    requirements:
      run:
        - python

about:
  homepage: https://github.com/Textualize/rich
  license: MIT
  license_file: LICENSE
  summary: Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal
  description: |
    Rich is a Python library for rich text and beautiful formatting in the terminal.

    The Rich API makes it easy to add color and style to terminal output. Rich
    can also render pretty tables, progress bars, markdown, syntax highlighted
    source code, tracebacks, and more — out of the box.
  documentation: https://rich.readthedocs.io
  repository: https://github.com/Textualize/rich

I can build and run the tests successfully with rattler-build build, but cannot run the tests:

[user@dev ~]$ rattler-build test --package-file output/noarch/rich-13.4.2-pyh4616a5c_0.conda 

 ╭─ Running tests for package: rich-13.4.2-pyh4616a5c_0.conda
 │ Removing previously cached package "/home/user/.cache/rattler/cache/pkgs/rich-13.4.2-pyh4616a5c_0"
 │ Creating test environment in "/tmp/.tmp91W7Mt"
 │ Collecting tests from "/home/user/.cache/rattler/cache/pkgs/rich-13.4.2-pyh4616a5c_0"
 │
 │ ╭─ Running python test
 │ │ 
 │ │ Resolving environment for:
 │ │   Platform: linux-64
 │ │   Channels: 
 │ │    - file:///tmp/.tmpZrm7RB/
 │ │    - conda-forge
 │ │   Specs:
 │ │    - rich ==13.4.2 pyh4616a5c_0
 │ │    - pip
 │ │ 
 │ │ ╭───────────────────┬───────────┬────────────────────┬─────────────┬────────────╮
 │ │ │ Package           ┆ Version   ┆ Build              ┆ Channel     ┆ Size       │
 │ │ ╞═══════════════════╪═══════════╪════════════════════╪═════════════╪════════════╡
 │ │ │ _libgcc_mutex     ┆ 0.1       ┆ conda_forge        ┆ conda-forge ┆ 2.50 KiB   │
 │ │ │ _openmp_mutex     ┆ 4.5       ┆ 2_gnu              ┆ conda-forge ┆ 23.07 KiB  │
 │ │ │ bzip2             ┆ 1.0.8     ┆ h4bc722e_7         ┆ conda-forge ┆ 246.86 KiB │
 │ │ │ ca-certificates   ┆ 2024.8.30 ┆ hbcca054_0         ┆ conda-forge ┆ 155.28 KiB │
 │ │ │ ld_impl_linux-64  ┆ 2.40      ┆ hf3520f5_7         ┆ conda-forge ┆ 691.02 KiB │
 │ │ │ libffi            ┆ 3.4.2     ┆ h7f98852_5         ┆ conda-forge ┆ 56.93 KiB  │
 │ │ │ libgcc            ┆ 14.1.0    ┆ h77fa898_1         ┆ conda-forge ┆ 826.54 KiB │
 │ │ │ libgcc-ng         ┆ 14.1.0    ┆ h69a702a_1         ┆ conda-forge ┆ 50.95 KiB  │
 │ │ │ libgomp           ┆ 14.1.0    ┆ h77fa898_1         ┆ conda-forge ┆ 449.43 KiB │
 │ │ │ libnsl            ┆ 2.0.1     ┆ hd590300_0         ┆ conda-forge ┆ 32.62 KiB  │
 │ │ │ libsqlite         ┆ 3.46.1    ┆ hadc24fc_0         ┆ conda-forge ┆ 844.94 KiB │
 │ │ │ libuuid           ┆ 2.38.1    ┆ h0b41bf4_0         ┆ conda-forge ┆ 32.81 KiB  │
 │ │ │ libzlib           ┆ 1.3.1     ┆ h4ab18f5_1         ┆ conda-forge ┆ 60.13 KiB  │
 │ │ │ markdown-it-py    ┆ 3.0.0     ┆ pyhd8ed1ab_0       ┆ conda-forge ┆ 62.85 KiB  │
 │ │ │ mdurl             ┆ 0.1.2     ┆ pyhd8ed1ab_0       ┆ conda-forge ┆ 14.34 KiB  │
 │ │ │ ncurses           ┆ 6.5       ┆ he02047a_1         ┆ conda-forge ┆ 868.25 KiB │
 │ │ │ openssl           ┆ 3.3.2     ┆ hb9d3cd8_0         ┆ conda-forge ┆ 2.76 MiB   │
 │ │ │ pip               ┆ 24.2      ┆ pyh8b19718_1       ┆ conda-forge ┆ 1.18 MiB   │
 │ │ │ pygments          ┆ 2.18.0    ┆ pyhd8ed1ab_0       ┆ conda-forge ┆ 858.69 KiB │
 │ │ │ python            ┆ 3.10.0    ┆ h543edf9_3_cpython ┆ conda-forge ┆ 29.83 MiB  │
 │ │ │ readline          ┆ 8.2       ┆ h8228510_1         ┆ conda-forge ┆ 274.86 KiB │
 │ │ │ rich              ┆ 13.4.2    ┆ pyh4616a5c_0       ┆ .tmpZrm7RB  ┆ 191.01 KiB │
 │ │ │ setuptools        ┆ 73.0.1    ┆ pyhd8ed1ab_0       ┆ conda-forge ┆ 1.39 MiB   │
 │ │ │ sqlite            ┆ 3.46.1    ┆ h9eae976_0         ┆ conda-forge ┆ 839.05 KiB │
 │ │ │ tk                ┆ 8.6.13    ┆ noxft_h4845f30_101 ┆ conda-forge ┆ 3.17 MiB   │
 │ │ │ typing_extensions ┆ 4.12.2    ┆ pyha770c72_0       ┆ conda-forge ┆ 38.95 KiB  │
 │ │ │ tzdata            ┆ 2024a     ┆ h8827d51_1         ┆ conda-forge ┆ 121.25 KiB │
 │ │ │ wheel             ┆ 0.44.0    ┆ pyhd8ed1ab_0       ┆ conda-forge ┆ 57.21 KiB  │
 │ │ │ xz                ┆ 5.2.6     ┆ h166bdaf_0         ┆ conda-forge ┆ 408.56 KiB │
 │ │ ╰───────────────────┴───────────┴────────────────────┴─────────────┴────────────╯
 │ │  Successfully updated the environment
 │ │ + python /tmp/.tmp50MsBm/conda_build_script.py
 │ │  python imports test passed!
 │ │ + pip check
 │ │ No broken requirements found.
 │ │  pip check passed!
 │ │
 │ ╰─────────────────── (took 2 seconds)
 │
 │ ╭─ Running script test
 │ │ 
 │ │ Resolving environment for:
 │ │   Platform: noarch
 │ │   Channels: 
 │ │    - file:///tmp/.tmpZrm7RB/
 │ │    - conda-forge
 │ │   Specs:
 │ │    - python
 │ │    - rich ==13.4.2 pyh4616a5c_0
 │ │
 │ ╰─────────────────── (took 0 seconds)
 │
 ╰─────────────────── (took 2 seconds)
Error:   × failed to setup test environment: Cannot solve the request because of: No candidates were found for python *.
  │ 
  ╰─▶ Cannot solve the request because of: No candidates were found for python *.
wolfv commented 2 months ago

That is weird! You should not actually need to add python explicitly since rich depends on python as well ...

wolfv commented 2 months ago

I tested locally with the latest version on osx-arm64 and it worked fine. Anythign else you can share about your configuration?

rjz-viv commented 2 months ago

I am running Ubuntu 24.04 with the latest rattler-build release via conda-forge

user@dev:~$ micromamba list
List of packages in environment: "/home/user/envs/dev"

  Name             Version    Build        Channel    
────────────────────────────────────────────────────────
  _libgcc_mutex    0.1        conda_forge  conda-forge
  _openmp_mutex    4.5        2_gnu        conda-forge
  ca-certificates  2024.8.30  hbcca054_0   conda-forge
  libgcc           14.1.0     h77fa898_1   conda-forge
  libgomp          14.1.0     h77fa898_1   conda-forge
  openssl          3.3.2      hb9d3cd8_0   conda-forge
  rattler-build    0.21.0     hbfb6850_0   conda-forge
rjz-viv commented 2 months ago

Interestingly, if I remove the noarch: python line from the build section I can run the tests with rattler-build test without issue, although I get these warnings in the build

 │ │ ⚠ warning Warnings:
 │ │ ⚠ warning Overdepending against markdown-it-py
 │ │ ⚠ warning Overdepending against pygments
 │ │ ⚠ warning Overdepending against typing_extensions
 │ │ ⚠ warning Overdepending against python_abi
rjz-viv commented 1 month ago

I'm still having the same issue on v0.23.0. Is there anything else I can try?

(base) [user@dev rich]$ micromamba list
List of packages in environment: "/home/user/micromamba"

  Name             Version    Build        Channel    
────────────────────────────────────────────────────────
  _libgcc_mutex    0.1        conda_forge  conda-forge
  _openmp_mutex    4.5        2_gnu        conda-forge
  ca-certificates  2024.8.30  hbcca054_0   conda-forge
  libgcc           14.1.0     h77fa898_1   conda-forge
  libgomp          14.1.0     h77fa898_1   conda-forge
  openssl          3.3.2      hb9d3cd8_0   conda-forge
  rattler-build    0.23.0     h51b9b6e_0   conda-forge

(base) [user@dev rich]$ rattler-build test --package-file ./output/noarch/rich-13.4.2-pyh4616a5c_0.conda

 ╭─ Running tests for package: rich-13.4.2-pyh4616a5c_0.conda
 │ Removing previously cached package "/home/user/.cache/rattler/cache/pkgs/rich-13.4.2-pyh4616a5c_0"
 │ Creating test environment in "/tmp/.tmpl79FJA"
 │ Collecting tests from "/home/user/.cache/rattler/cache/pkgs/rich-13.4.2-pyh4616a5c_0"
 │
 │ ╭─ Running python test
 │ │ 
 │ │ Resolving test environment:
 │ │   Platform: linux-64 [__unix=0=0, __linux=6.8.0=0, __glibc=2.34=0, __archspec=1=skylake]
 │ │   Channels: 
 │ │    - file:///tmp/.tmpXeGGFs/
 │ │    - conda-forge
 │ │   Specs:
 │ │    - rich ==13.4.2 pyh4616a5c_0
 │ │    - pip
 │ │ 
 │ │ ╭───────────────────┬───────────┬────────────────────┬─────────────┬────────────╮
 │ │ │ Package           ┆ Version   ┆ Build              ┆ Channel     ┆ Size       │
 │ │ ╞═══════════════════╪═══════════╪════════════════════╪═════════════╪════════════╡
 │ │ │ _libgcc_mutex     ┆ 0.1       ┆ conda_forge        ┆ conda-forge ┆ 2.50 KiB   │
 │ │ │ _openmp_mutex     ┆ 4.5       ┆ 2_gnu              ┆ conda-forge ┆ 23.07 KiB  │
 │ │ │ bzip2             ┆ 1.0.8     ┆ h4bc722e_7         ┆ conda-forge ┆ 246.86 KiB │
 │ │ │ ca-certificates   ┆ 2024.8.30 ┆ hbcca054_0         ┆ conda-forge ┆ 155.28 KiB │
 │ │ │ ld_impl_linux-64  ┆ 2.43      ┆ h712a8e2_1         ┆ conda-forge ┆ 653.92 KiB │
 │ │ │ libffi            ┆ 3.4.2     ┆ h7f98852_5         ┆ conda-forge ┆ 56.93 KiB  │
 │ │ │ libgcc            ┆ 14.1.0    ┆ h77fa898_1         ┆ conda-forge ┆ 826.54 KiB │
 │ │ │ libgcc-ng         ┆ 14.1.0    ┆ h69a702a_1         ┆ conda-forge ┆ 50.95 KiB  │
 │ │ │ libgomp           ┆ 14.1.0    ┆ h77fa898_1         ┆ conda-forge ┆ 449.43 KiB │
 │ │ │ libnsl            ┆ 2.0.1     ┆ hd590300_0         ┆ conda-forge ┆ 32.62 KiB  │
 │ │ │ libsqlite         ┆ 3.46.1    ┆ hadc24fc_0         ┆ conda-forge ┆ 844.94 KiB │
 │ │ │ libuuid           ┆ 2.38.1    ┆ h0b41bf4_0         ┆ conda-forge ┆ 32.81 KiB  │
 │ │ │ libzlib           ┆ 1.3.1     ┆ hb9d3cd8_2         ┆ conda-forge ┆ 59.53 KiB  │
 │ │ │ markdown-it-py    ┆ 3.0.0     ┆ pyhd8ed1ab_0       ┆ conda-forge ┆ 62.85 KiB  │
 │ │ │ mdurl             ┆ 0.1.2     ┆ pyhd8ed1ab_0       ┆ conda-forge ┆ 14.34 KiB  │
 │ │ │ ncurses           ┆ 6.5       ┆ he02047a_1         ┆ conda-forge ┆ 868.25 KiB │
 │ │ │ openssl           ┆ 3.3.2     ┆ hb9d3cd8_0         ┆ conda-forge ┆ 2.76 MiB   │
 │ │ │ pip               ┆ 24.2      ┆ pyh8b19718_1       ┆ conda-forge ┆ 1.18 MiB   │
 │ │ │ pygments          ┆ 2.18.0    ┆ pyhd8ed1ab_0       ┆ conda-forge ┆ 858.69 KiB │
 │ │ │ python            ┆ 3.10.0    ┆ h543edf9_3_cpython ┆ conda-forge ┆ 29.83 MiB  │
 │ │ │ readline          ┆ 8.2       ┆ h8228510_1         ┆ conda-forge ┆ 274.86 KiB │
 │ │ │ rich              ┆ 13.4.2    ┆ pyh4616a5c_0       ┆ .tmpXeGGFs  ┆ 86.01 MiB  │
 │ │ │ setuptools        ┆ 75.1.0    ┆ pyhd8ed1ab_0       ┆ conda-forge ┆ 759.24 KiB │
 │ │ │ sqlite            ┆ 3.46.1    ┆ h9eae976_0         ┆ conda-forge ┆ 839.05 KiB │
 │ │ │ tk                ┆ 8.6.13    ┆ noxft_h4845f30_101 ┆ conda-forge ┆ 3.17 MiB   │
 │ │ │ typing_extensions ┆ 4.12.2    ┆ pyha770c72_0       ┆ conda-forge ┆ 38.95 KiB  │
 │ │ │ tzdata            ┆ 2024b     ┆ hc8b5060_0         ┆ conda-forge ┆ 119.49 KiB │
 │ │ │ wheel             ┆ 0.44.0    ┆ pyhd8ed1ab_0       ┆ conda-forge ┆ 57.21 KiB  │
 │ │ │ xz                ┆ 5.2.6     ┆ h166bdaf_0         ┆ conda-forge ┆ 408.56 KiB │
 │ │ ╰───────────────────┴───────────┴────────────────────┴─────────────┴────────────╯
 │ │ 
 │ │ Installing test environment
 │ │  Successfully updated the test environment
 │ │ + python /tmp/.tmpCApGI9/conda_build_script.py
 │ │  python imports test passed!
 │ │ + pip check
 │ │ No broken requirements found.
 │ │  pip check passed!
 │ │
 │ ╰─────────────────── (took 2 seconds)
 │
 │ ╭─ Running script test
 │ │ 
 │ │ Resolving test environment:
 │ │   Platform: noarch [__unix=0=0, __linux=6.8.0=0, __glibc=2.34=0, __archspec=1=skylake]
 │ │   Channels: 
 │ │    - file:///tmp/.tmpXeGGFs/
 │ │    - conda-forge
 │ │   Specs:
 │ │    - python
 │ │    - rich ==13.4.2 pyh4616a5c_0
 │ │
 │ ╰─────────────────── (took 0 seconds)
 │
 ╰─────────────────── (took 4 seconds)
Error:   × failed to setup test environment: Cannot solve the request because of: No candidates were found for python *.
  │ 
  ╰─▶ Cannot solve the request because of: No candidates were found for python *.```
wolfv commented 1 month ago

Yes, indeed, there might be something strange going on with *. that is added to the matchspec. I will have a look!

wolfv commented 1 month ago

I can reproduce! Let me fix it :)