A project I’m trying to build has Fedora Rawhide (added by clicking “Add from a distribution”) as target.
I need python3 <= 3.10 to build source but get “unresolvable” error message (nothing provides python3 < 3.11 got 3.11.0…).
How can I add for example python3.10 to the build environment?
There is only one RPM with the name python3 - which is the version 3.11. There are RPMs python3.10 etc.
ok, understand.
Is it possible to blacklist python3.11 from being installed or perhaps set python3 to use 3.10? (from .spec-file or other obs-file)?
Now I seem to get both 3.10 and 3.11 if I interpret the log correct. Closer to where I think I want to be.
Should be possible to define it in your spec file:
Requires: python3 = 3.10
But it seems like that Fedora Rawhide only has python3-3.11.0 in the repos…
Ok, is it somehow possible to use use ‘sudo update-alternatives …’ in the %prep-phase?
Right now I get sudo: a password is required
sudo since running w/o result in
failed to create /var/lib/alternatives/python3.new: Permission denied
And why exactly is it bad?
Is it possible to blacklist python3.11 from being installed or perhaps set python3 to use 3.10? (from .spec-file or other obs-file)?
This question should be directed to Fedora lists/forums, not here. OBS is just a tool to automate package building. It can do only what target distribution supports. If Fedora offers some settings to switch between Python versions, they can then be integrated in OBS.
But I doubt very much it is possible. It most certainly would not be possible in openSUSE. While multiple Python versions are available in distribution, at any given point there is one version that is default system version, that provides /usr/bin/python3 link and that is implicit dependency of any other Python based tool built in this distribution. As far as I know RedHat traditionally used a lot Python-based tools which means default Python is pulled in.
Closer to where I think I want to be.
As you did not describe what you are trying to achieve, it is rather hard to give any advice.
But let’s assume you somehow managed to fake /usr/bin/python3 to be version 3.10 and built package for Fedora. This package won’t work on any real system because on all real systems out there /usr/bin/python3 will be version 3.11 and presumably your software fails to work with this version. If your software absolutely needs Python 3.10 (or any lower version) then you must build your software to explicitly use Python 3.10 and require python3.10 package.
“Should be” as in “I do not know and I did not even look what Fedora RPM provides but it sounds like easy question”?
If you believe so…
True i’m not 100% sure how Fedora specs look like but in most distributions you define a specific version with "requires = x.xx.
Any other smart-ass comments that don’t contribute to the topic?
Reading Python Packaging Guidelines :: Fedora Docs, that is probably not possible:
In Fedora, Python libraries are packaged for a single version of Python, called python3. For example, in Fedora 32, python3 is Python 3.8.
Uhm it’s not. No idea what has lead you to this question. Obviously I have gone from impossible to maybe possible to do what I want. From not having 3.10 in the build environment to actually there. Just need to get the build environment to switch python3 version globally during build.
python - How to make python3.7 default - Unix & Linux Stack Exchange update-alternatives is available in fedora thru Alternatives :: Fedora Docs (fedoraproject.org) . How do I use this in obs workflow?
Just need python3 <= 3.10 at build time. The output is a “c-library” without any connection to python what so ever.
E-h-h …
Is it possible to blacklist python3.11 from being installed
Just need to get the build environment to switch python3 version globally during build.
We are going in circles. OBS starts Fedora Rawhide instance to build your package. You cannot “switch python to 3.10” globally, because this means - any Fedora tool that needs python 3.11 stops working.
update-alternatives is available in fedora
Of course update-alternatives is available. What you seem to miss - this is again just a tool, and each package must be explicitly built to use alternatives. Python packages in Fedora are not.
If you insist, you can create your own package that runs whatever magic you need as postinstall script and BuildRequire this package. You do not even need update-alternatives, just run “rm /usr/bin/python3; ln -s python3.10 /usr/bin/python3”.
Just need python3 <= 3.10 at build time. The output is a “c-library” without any connection to python what so ever.
Can you simply patch shebang to explicitly use python3.10? Or use virtualenv?
Virtualenv looks interesting. Thx for trying to help and increase my understanding, we should definitely have coffee.
I would still recommend asking on Fedora lists/forums. The problem is unrelated to OBS, Fedora packagers using native tools would face exactly the same issue.