rattler-build
rattler-build copied to clipboard
`SP_DIR` not set during build and test time
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
You need
requirements:
host:
- python
run:
- python
instead of
requirements:
build:
- python
run:
- python
to host to work.
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.