Skip to content

Add v1 recipe debugging using py-rattler-build - #5950

Merged
jaimergp merged 20 commits into
conda:mainfrom
jsmolic:v1-integration-debug
Jul 11, 2026
Merged

Add v1 recipe debugging using py-rattler-build#5950
jaimergp merged 20 commits into
conda:mainfrom
jsmolic:v1-integration-debug

Conversation

@jsmolic

@jsmolic jsmolic commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

Description

This PR introduces support for debugging v1 recipes using
py-rattler-build's debug API [1].

While py-rattler-build provides more functionality, we are currently
using it only to setup debug environment and scripts, to match
conda-debug's behavior with v0 recipes.

The process loads and renders the recipe, and invokes
DebugSession.create() method to setup the environment before printing
debugging instructions to the console.

[1] https://rattler-build.prefix.dev/dev/py-rattler-build/reference/debug/

NOTE: This PR depends on #5924

Checklist - did you ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • Add / update necessary tests?
  • Add / update outdated documentation?

@jsmolic
jsmolic requested a review from a team as a code owner April 13, 2026 03:10
@github-project-automation github-project-automation Bot moved this to 🆕 New in 🔎 Review Apr 13, 2026
@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Apr 13, 2026
@codspeed-hq

codspeed-hq Bot commented Apr 13, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 5 untouched benchmarks


Comparing jsmolic:v1-integration-debug (213cb88) with main (abcbaeb)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (56b320b) during the generation of this report, so abcbaeb was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@jsmolic
jsmolic force-pushed the v1-integration-debug branch from 5fc7b14 to 0f0f302 Compare April 19, 2026 12:36
@jsmolic
jsmolic force-pushed the v1-integration-debug branch 2 times, most recently from db8167d to 7a752fa Compare April 29, 2026 13:54
jaimergp
jaimergp previously approved these changes Apr 29, 2026
@jaimergp
jaimergp enabled auto-merge (squash) April 29, 2026 14:12
@github-project-automation github-project-automation Bot moved this from 🆕 New to ✅ Approved in 🔎 Review Apr 29, 2026
@jaimergp
jaimergp disabled auto-merge April 29, 2026 14:53
@jsmolic
jsmolic force-pushed the v1-integration-debug branch from 7a752fa to bd9073b Compare April 29, 2026 14:56
@jsmolic

jsmolic commented Apr 29, 2026

Copy link
Copy Markdown
Contributor Author

Example debug session:

recipe.yaml:

schema_version: 1

context:
  name: myproject
  version: "2.0.0"

recipe:
  version: ${{ version }}

outputs:
  # First output: The library
  - package:
      name: ${{ name }}-lib
    build:
      script:
        interpreter: python
        content: |
          import os
          from pathlib import Path

          prefix = Path(os.environ["PREFIX"])
          lib_dir = prefix / "lib" / "python"
          lib_dir.mkdir(parents=True, exist_ok=True)

          (lib_dir / "myproject_lib.py").write_text('VERSION = "2.0.0"')
          print(f"Created library at {lib_dir}")
    requirements:
      build:
        - python

  # Second output: Uses the library as a host dependency
  - package:
      name: ${{ name }}-tools
    build:
      script:
        interpreter: python
        content: |
          import os
          from pathlib import Path

          prefix = Path(os.environ["PREFIX"])

          # Read and print the lib file (installed as host dependency)
          lib_file = prefix / "lib" / "python" / "myproject_lib.py"
          print(f"Reading library from: {lib_file}")
          print(lib_file.read_text())
    requirements:
      build:
        - python
      host:
        - ${{ name }}-lib%
$ conda-debug test-recipe --output-id myproject-tools
-No sources to fetch
Adding 0 packages to subdir linux-64.
Successfully added 0 packages to subdir linux-64.
Writing repodata to linux-64/repodata.json
Adding 0 packages to subdir noarch.
Successfully added 0 packages to subdir noarch.
Writing repodata to noarch/repodata.json
  Platform: linux-64 [__unix=0=0, __linux=5.15.32=0, __glibc=2.40=0, __archspec=1=zen3]
  Channels: 
   - file:///home/jakov/miniforge3/conda-bld/
   - conda-canary
   - conda-forge
   - https://repo.anaconda.com/pkgs/main/
   - https://repo.anaconda.com/pkgs/r/
  Specs:
   - python
sharded repodata seems to be missing for https://conda.anaconda.org/conda-canary/linux-64/, falling back to repodata.json files
sharded repodata seems to be missing for https://conda.anaconda.org/conda-canary/noarch/, falling back to repodata.json files
sharded repodata seems to be missing for https://repo.anaconda.com/pkgs/main/linux-64/, falling back to repodata.json files
sharded repodata seems to be missing for https://repo.anaconda.com/pkgs/r/linux-64/, falling back to repodata.json files
sharded repodata seems to be missing for https://repo.anaconda.com/pkgs/main/noarch/, falling back to repodata.json files
sharded repodata seems to be missing for https://repo.anaconda.com/pkgs/r/noarch/, falling back to repodata.json files
- ⠁ Downloading repodata [00:00:00] [────────────────────────────────────────]      0 B @ 0 B/s                            ⠂ Downloading repoda   Downloadin ⠁ solving                          ⠉ solving                                            
╭──────────────────┬───────────┬──────────────────────┬─────────────┬─────────────╮
│ Package          ┆ Version   ┆ Build                ┆ Channel     ┆        Size │
╞══════════════════╪═══════════╪══════════════════════╪═════════════╪═════════════╡
│ _libgcc_mutex    ┆ 0.1       ┆ main                 ┆ conda-forge ┆    2.46 KiB │
│ _openmp_mutex    ┆ 5.1       ┆ 1_gnu                ┆ main        ┆   20.82 KiB │
│ bzip2            ┆ 1.0.8     ┆ hda65f42_9           ┆ conda-forge ┆  254.08 KiB │
│ ca-certificates  ┆ 2026.4.22 ┆ hbd8a1cb_0           ┆ conda-forge ┆  127.97 KiB │
│ icu              ┆ 78.3      ┆ h33c6efd_0           ┆ conda-forge ┆   12.13 MiB │
│ ld_impl_linux-64 ┆ 2.45.1    ┆ default_hbd61a6d_102 ┆ conda-forge ┆  710.94 KiB │
│ libexpat         ┆ 2.7.5     ┆ hecca717_0           ┆ conda-forge ┆   74.83 KiB │
│ libffi           ┆ 3.5.2     ┆ h3435931_0           ┆ conda-forge ┆   57.22 KiB │
│ libgcc           ┆ 15.2.0    ┆ he0feb66_18          ┆ conda-forge ┆ 1017.37 KiB │
│ libgcc-ng        ┆ 15.2.0    ┆ h69a702a_18          ┆ conda-forge ┆   26.88 KiB │
│ libgomp          ┆ 15.2.0    ┆ he0feb66_18          ┆ conda-forge ┆  589.12 KiB │
│ liblzma          ┆ 5.8.3     ┆ hb03c661_0           ┆ conda-forge ┆  110.82 KiB │
│ libmpdec         ┆ 4.0.0     ┆ hb03c661_1           ┆ conda-forge ┆   90.23 KiB │
│ libsqlite        ┆ 3.53.0    ┆ hf4e2dac_0           ┆ conda-forge ┆  936.39 KiB │
│ libstdcxx        ┆ 15.2.0    ┆ h934c35e_18          ┆ conda-forge ┆    5.58 MiB │
│ libuuid          ┆ 2.42      ┆ h5347b49_0           ┆ conda-forge ┆   39.35 KiB │
│ libxcb           ┆ 1.17.0    ┆ h9b100fa_0           ┆ main        ┆  430.36 KiB │
│ libzlib          ┆ 1.3.2     ┆ h25fd6f3_2           ┆ conda-forge ┆   62.14 KiB │
│ ncurses          ┆ 6.6       ┆ hdb14827_0           ┆ conda-forge ┆  897.42 KiB │
│ openssl          ┆ 3.6.2     ┆ h35e630c_0           ┆ conda-forge ┆    3.02 MiB │
│ pthread-stubs    ┆ 0.4       ┆ hb9d3cd8_1002        ┆ conda-forge ┆    8.06 KiB │
│ python           ┆ 3.14.4    ┆ habeac84_100_cp314   ┆ conda-forge ┆   35.01 MiB │
│ python_abi       ┆ 3.14      ┆ 8_cp314              ┆ conda-forge ┆    6.83 KiB │
│ readline         ┆ 8.3       ┆ h853b02a_0           ┆ conda-forge ┆  336.99 KiB │
│ tk               ┆ 8.6.15    ┆ h54e0aa7_0           ┆ main        ┆    3.44 MiB │
│ tzdata           ┆ 2026a     ┆ he532380_0           ┆ main        ┆  117.19 KiB │
│ xorg-libx11      ┆ 1.8.13    ┆ he1eb515_0           ┆ conda-forge ┆  819.97 KiB │
│ xorg-libxau      ┆ 1.0.12    ┆ hb03c661_1           ┆ conda-forge ┆   14.96 KiB │
│ xorg-libxdmcp    ┆ 1.1.5     ┆ hb03c661_1           ┆ conda-forge ┆   20.11 KiB │
│ zlib             ┆ 1.3.2     ┆ h25fd6f3_2           ┆ conda-forge ┆   93.68 KiB │
│ zstd             ┆ 1.5.7     ┆ hb78ec9c_6           ┆ conda-forge ┆  587.28 KiB │
╰──────────────────┴───────────┴──────────────────────┴─────────────┴─────────────╯
   Downloading repodata [00:00:00] Done
   Downloading repodata [00:00:01] Done
   Downloading repodata [00:00:00] Done
   Downloading repodata [00:00:01] Done
   Downloading repodata [00:00:01] Done
   Downloading repodata [00:00:00] Done

╭───────────────┬─────────┬────────────┬───────────┬──────────╮
│ Package       ┆ Version ┆ Build      ┆ Channel   ┆     Size │
╞═══════════════╪═════════╪════════════╪═══════════╪══════════╡
│ myproject-lib ┆ 2.0.0   ┆ hb0f4dca_0 ┆ conda-bld ┆ 5.50 KiB │
╰───────────────┴─────────┴────────────┴───────────┴──────────╯

Finalized run dependencies: this output has no run dependencies

   validate cache       31 packages in 6ms
   installing packages  took 340ms                                                                                                                                                                                                                                                                                                                                                                                                             Successfully updated the build environment
   validate cache       1 package in 0s
   installing packages  took 4ms                                                                                                                                                                                                                                                                                                                                                                                                               Successfully updated the host environment
Build script created at /home/jakov/miniforge3/conda-bld/bld/rattler-build_myproject-tools/work/conda_build.sh
Host dependencies available in /home/jakov/miniforge3/conda-bld/bld/rattler-build_myproject-tools/host_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold

To run the actual build, use:
rattler-build build --recipe-dir /home/jakov/test/test-recipe
Or run the build script directly with:
cd /home/jakov/miniforge3/conda-bld/bld/rattler-build_myproject-tools/work && ./conda_build.sh

I'll add a test for debug to this PR shortly

@jaimergp

Copy link
Copy Markdown
Member
To run the actual build, use:
rattler-build build --recipe-dir /home/jakov/test/test-recipe
Or run the build script directly with:
cd /home/jakov/miniforge3/conda-bld/bld/rattler-build_myproject-tools/work && ./conda_build.sh

Should we use rattler-build there or conda build /home/jakov/test/test-recipe? conda-build users may be confused about those tools mentioned here.

@jsmolic

jsmolic commented Apr 29, 2026

Copy link
Copy Markdown
Contributor Author
To run the actual build, use:
rattler-build build --recipe-dir /home/jakov/test/test-recipe
Or run the build script directly with:
cd /home/jakov/miniforge3/conda-bld/bld/rattler-build_myproject-tools/work && ./conda_build.sh

Should we use rattler-build there or conda build /home/jakov/test/test-recipe? conda-build users may be confused about those tools mentioned here.

oh yes, I was going to use conda-build there, it makes sense to recommend it now that it supports v1 recipes, but rattler ended up somehow, will fix that up

@jsmolic

jsmolic commented Apr 30, 2026

Copy link
Copy Markdown
Contributor Author

Hmm there is a newly added v1 recipe test on windows that seems to be flaky, need to investigate why is that

@jsmolic
jsmolic force-pushed the v1-integration-debug branch 2 times, most recently from 4a6bc1d to b6b9268 Compare May 5, 2026 09:02
@jsmolic
jsmolic requested a review from jaimergp May 5, 2026 15:59
Comment thread conda_build/_rattler_build/compat.py Outdated
Comment thread conda_build/_rattler_build/compat.py Outdated
Comment thread conda_build/_rattler_build/compat.py Outdated
Comment thread conda_build/_rattler_build/compat.py Outdated
Comment thread news/5950-conda-debug-v1.md Outdated
Comment thread tests/cli/test_main_debug.py
Comment thread tests/cli/test_main_debug.py
@github-project-automation github-project-automation Bot moved this from 👀 In Review to ✅ Approved in 🔎 Review Jul 7, 2026
jsmolic added 20 commits July 8, 2026 16:30
This commit introduces support for debugging v1 recipes using
py-rattler-build's debug API [1].

While py-rattler-build provides more functionality, we are currently
using it only to setup debug environment and scripts, to match
`conda-debug`'s behavior with v0 recipes.

The process loads and renders the recipe, and invokes
`DebugSession.create()` method to setup the environment before printing
debugging instructions to the console.

[1] https://rattler-build.prefix.dev/dev/py-rattler-build/reference/debug/
- Reword the prompt when multiple outputs are found
- Properly raise an error when no recipe files are found in the
  directory
- Error out when `recipe.yaml` and `meta.yaml` are found in the same dir
- Drop redundant recipe path from the debug failure report
- Drop redundant check for commands in process_recipe()
@jsmolic
jsmolic force-pushed the v1-integration-debug branch from 51048b1 to 213cb88 Compare July 8, 2026 14:31
@jaimergp
jaimergp merged commit 53862cf into conda:main Jul 11, 2026
26 checks passed
@github-project-automation github-project-automation Bot moved this from ✅ Approved to 🏁 Done in 🔎 Review Jul 11, 2026
@github-project-automation github-project-automation Bot moved this from In review 🔍 to Done 💪🏾 in conda Roadmap and Sprint Planning Jul 11, 2026
@jsmolic
jsmolic deleted the v1-integration-debug branch July 13, 2026 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed [bot] added once the contributor has signed the CLA

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants