rattler-build icon indicating copy to clipboard operation
rattler-build copied to clipboard

`SP_DIR` not set during build and test time

Open hadim opened this issue 6 months ago • 2 comments

See the below recipe:

package:
  name: test-sp-dir
  version: 0.0.1

build:
  number: 0
  noarch: python
  script:
    - echo "hello world"
    - echo "SP_DIR 1 = $SP_DIR"
    - echo "SP_DIR 2 = ${{ SP_DIR }}"
    - export SP_DIR=$(python -c "import site; print(site.getsitepackages()[0])")
    - echo "SP_DIR 3 = $SP_DIR"
requirements:
  build:
    - python
  run:
    - python

tests:
  - script:
      - echo "hello world"
      - echo "SP_DIR 1 = $SP_DIR"
      - echo "SP_DIR 2 = ${{ SP_DIR }}"
      - export SP_DIR=$(python -c "import site; print(site.getsitepackages()[0])")
      - echo "SP_DIR 3 = $SP_DIR"

and the relevant logs

 │ Installing build environment
 │ ✔ Successfully updated the build environment
 │ 
 │ Installing host environment
 │ ✔ Successfully updated the host environment
 │
 │ ╭─ Running build script
 │ │ hello world
 │ │ SP_DIR 1 = 
 │ │ SP_DIR 2 = 
 │ │ SP_DIR 3 = $BUILD_PREFIX/lib/python3.13/site-packages
 │ │
 │ ╰─────────────────── (took 0 seconds)

#####

 │ Installing test environment
 │ ✔ Successfully updated the test environment
 │ Testing commands:
 │ hello world
 │ SP_DIR 1 = 
 │ SP_DIR 2 = 
 │ SP_DIR 3 = $SRC_DIR_run_env/lib/python3.13/site-packages

hadim avatar Jun 21 '25 17:06 hadim

You need

requirements:
  host:
    - python
  run:
    - python

instead of

requirements:
  build:
    - python
  run:
    - python

to host to work.

isuruf avatar Sep 24 '25 19:09 isuruf

Yeah the SP_DIR is a bit of a weird one. Currently we try to get all env variables from the variant and not from the resolved environment, so SP_DIR is empty when not directly adding python into the variants.

I think we could consider setting SP_DIR (and possibly other Python variables) when dependening transitively on Python (whenever Python is part of the solution). Or at least we could do that for SP_DIR? Would love additional thoughts on this.

wolfv avatar Sep 25 '25 09:09 wolfv