Closed Nuc1eoN closed 5 months ago
@Nuc1eoN
the python3
executable looks for it's libraries and modules in the associated /lib/pythonMAJOR.MINOR
folder, so version 3.8.x
will use /lib/python3.8
, while 3.11.x
will use /lib/python3.11
. It appears that pre_link()
tries to rename the source's module folder to match the MAJOR.MINOR of the installed python executable.
Commenting the line out means that Freshen will only install if python3.8 is used, but wont for any other version.
I'm not at a gobo machine right now, but I'd noticed, on Arch python_path
isn't defined? I assume it points to /Programs/Python/MAJOR.MINOR.PATCH
and is defined by Gobo?
Based on the error description it looks like you just need to wrap the mv
line in an if
block.
pre_link() {
python_release=$(basename $python_path) # get version number "MAJOR.MINOR.PATCH"
python_version=${python_release%.*} # remove ".PATCH"
# check if the MAJOR.MINOR differs from that of source
# if it does, rename the folder
if [[ "3.8" != "$python_version" ]]; then
mv $target/lib/python3.8 $target/lib/python$python_version
fi
}
With that being said, though the above should work, it may be more reliable to determine the version using the output of python3 --version
. If python_path
is defined by Gobo, then the actual python3
executable couldn't care less about what the variable told us, it's going to use whatever version it thinks it is (i.e. what we see when use --version
).
pre_link() {
python_output=$(python3 --version) # Get version output "Python MAJOR.MINOR.PATCH"
python_release=${python_output/Python /} # remove "Python "
python_version=${python_release%.*} # remove ".PATCH"
# ...
}
then for future proofing, you can remove the 3.8
version number like this, also optional, but should make less maintenance
pre_link() {
# ...
# check if the source/current folder differs from that expected by python
# if it does, rename the current folder
python_folder="python$python_version" # get python expected folder
source_folder=$(basename $target/lib/python*) # get source folder
if [[ "$source_folder" != "$python_folder" ]]; then
mv $target/lib/$current_folder $target/lib/$module_folder
fi
}
Both approaches should work though
Thanks @sage-etcher that helps a lot! I find the added comments also very neat.
The python_path
variable is not available system wide, but generated by Compile
for its sandbox environment during build time. Yes you are correct, it points to /Programs/Python/MAJOR.MINOR.PATCH
. I believe it is being generated in this function. Every Dependency (as far as I understand it), will have a corresponding _path
, _settings_path
, _variable_path
variable inside the sandbox.
Personally I lean towards utilizing python_path
, I think in this case it is safe and a little simpler.. But if it breaks it could also be a good learning experience^^ So let's just keep it:)
The Recipe works for me now, merging.
@sage-etcher need your help here. Let's fix the freshen git recipe so upgrade path is easy.
I have fixed the dependencies, but the last line on the recipe file makes no sense to me, please read the commit description. Replacing 2.5 with 3.8 but it has an issue, not sure what it was meant for, since commenting out the line seemed to work 🤷