Thanks a lot for the lead, it seems indeed that this bash profile is not loaded. You're right that the GUIX_PYTHONPATH is properly defined in the profile file. Although I don't know yet where the current python2 path comes from if the bash profile is not loaded.

I'll try to look at how it's handled in the docker format.

On 03/06/2025 19:55, Rutherther wrote:

Hi Alexis,

I don't know what apptainer is, and I don't currently have time to
investigate it or test it, so just what I found so far:

apptainer is the new name of singularity, a container platform mainly used on HPC clusters. So very much like docker.


Alexis Simon <[email protected]> writes:

a little addition to this, to reproduce you can do

```
guix pack -f squashfs bash python | \
xargs -I % sh -c 'apptainer exec % bash -c "echo \$GUIX_PYTHONPATH"'

guix pack -f squashfs bash python python2 | \
xargs -I % sh -c 'apptainer exec % bash -c "echo \$GUIX_PYTHONPATH"'
```

First one gives
/gnu/store/rxfshmxwk8pas52lpmhhnqys8apwynpr-profile/lib/python3.11/site-packages

Second one gives
/gnu/store/rxfshmxwk8pas52lpmhhnqys8apwynpr-profile/lib/python2.7/site-packages

My initial guess is that this is problem of apptainer / its
configuration, not Guix. Guix puts the export of GUIX_PYTHONPATH to
etc/profile of the used profile in store.

```
ruther:/tmp/b/squashfs-root]└2 %
cat gnu/store/99p9q3g8g7gri8klhkj983hjxn6fi215-profile/etc/profile
# Source this file to define all the relevant environment variables in Bash
# for this profile.  You may want to define the 'GUIX_PROFILE' environment
# variable to point to the "visible" name of the profile, like this:
#
#  GUIX_PROFILE=/path/to/profile ; \
#  source /path/to/profile/etc/profile
#
# When GUIX_PROFILE is undefined, the various environment variables refer
# to this specific profile generation.

export 
PATH="${GUIX_PROFILE:-/gnu/store/99p9q3g8g7gri8klhkj983hjxn6fi215-profile}/bin${PATH:+:}$PATH"
export 
BASH_LOADABLES_PATH="${GUIX_PROFILE:-/gnu/store/99p9q3g8g7gri8klhkj983hjxn6fi215-profile}/lib/bash${BASH_LOADABLES_PATH:+:}$BASH_LOADABLES_PATH"
export 
GUIX_PYTHONPATH="${GUIX_PROFILE:-/gnu/store/99p9q3g8g7gri8klhkj983hjxn6fi215-profile}/lib/python3.11/site-packages${GUIX_PYTHONPATH:+:}$GUIX_PYTHONPATH"
export 
GUIX_PYTHONPATH="${GUIX_PROFILE:-/gnu/store/99p9q3g8g7gri8klhkj983hjxn6fi215-profile}/lib/python2.7/site-packages${GUIX_PYTHONPATH:+:}$GUIX_PYTHONPATH"
```

As can be observed, both are exported, and they should be appended if
this file was sourced by bash, as can be seen with:

```
unset GUIX_PYTHONPATH
[ruther:/tmp/b/squashfs-root]└2 %
source gnu/store/99p9q3g8g7gri8klhkj983hjxn6fi215-profile/etc/profile
[ruther:/tmp/b/squashfs-root]└2 %
printenv GUIX_PYTHONPATH
/gnu/store/99p9q3g8g7gri8klhkj983hjxn6fi215-profile/lib/python2.7/site-packages:/gnu/store/99p9q3g8g7gri8klhkj983hjxn6fi215-profile/lib/python3.11/site-packages
```

So it seems to me apptainer is doing something strange here with the
etc/profile file.

Rutherther


Reply via email to