Re: Python version dependencies in pkg

From: Rainer Hurling <rhurlin_at_gwdg.de>
Date: Thu, 29 Sep 2022 04:43:49 UTC
Hi Dan,

Am 28.09.22 um 23:01 schrieb Dan Mahoney:
> 
> 
>> On Sep 26, 2022, at 20:22, Kevin Oberman <rkoberman@gmail.com 
>> <mailto:rkoberman@gmail.com>> wrote:
>>
>> On Mon, Sep 26, 2022, 18:13 Dan Mahoney <freebsd@gushi.org 
>> <mailto:freebsd@gushi.org>> wrote:
>>
>>
>>
>>>     On Sep 26, 2022, at 09:27, Kevin Oberman <rkoberman@gmail.com
>>>     <mailto:rkoberman@gmail.com>> wrote:
>>>
>>>     On Mon, Sep 26, 2022 at 2:58 AM Dan Mahoney <freebsd@gushi.org
>>>     <mailto:freebsd@gushi.org>> wrote:
>>>
>>>         All,
>>>
>>>         A quick question:
>>>
>>>         If a pkg depends on python, but not a specific version, it
>>>         will simply pick a version to install (I guess, whatever
>>>         version was the default when the pkg was built, 3.8 right
>>>         now), correct?
>>>
>>>         If you have 3.9 installed, that will satifsfy dependencies,
>>>         and it won't install python3.8, correct? Or are the dependent
>>>         versions for interpretec languages in pkg locked to whatever
>>>         the default is?
>>>
>>>         Assuming "any python will work", If you have 3.8 installed,
>>>         and later install 3.9 -- is there any easy way to point your
>>>         package at the new version as the new dependency, without
>>>         deinstalling/reinstalling it?
>>>
>>>         -Dan
>>>
>>>
>>>     It will use the version specified as default in
>>>     /usr/ports/Mk/bsd.default-versions.mk
>>>     <http://bsd.default-versions.mk/>.
>>
>>     To be clear, I'm talking about pkg install, not port building.
>>
>>     So I understand -- that value is somehow baked in to the package
>>     tree somewhere?  Because pkg alone doesn't look at the ports tree
>>     on the installing machine(you do not need to have ports extracted
>>     to install packages), nor do I believe it looks at make.conf,
>>
>>     If so, where in pkg do I find the default version?  Is it
>>     somewhere in the repository that's fetched before I install any
>>     packages?
>>
>>     -Dan
>>
>>
>> You are correct.  But the packages are built using the same Makefile 
>> and the same defaults as when built from ports for the specified 
>> version of FreeBSD as if it was built from ports. The Mk files are 
>> updated with ports, so all packages change when the change is 
>> committed to the defaults file, though they will only take effect when 
>> the quarter changes unless you're using LATEST packages.
> 
> Okay, so in either the package file, or the repo file, is there a bit 
> that says "whatever is the default" or that explicitly says "if there's 
> not a python, install 3.8"?

There is PYTHON_DEFAULT (set to 3.9 ATM) in 
ports/Mk/bsd.default-versions.mk. You can override this for example by 
an entry in /etc/make.conf:

DEFAULT_VERSIONS+= python=3.10 python3=3.10

> 
> I realize I'm asking weird minute questions, but I'm noticing that 
> across our fleet we have some blend of machines that are 3.7, 3.8, and 
> 3.9, and trying to just remove 3.7 attempts to deinstall packages that 
> would work with 3.8.

To update from one Python version to another, there are descriptions in 
/usr/ports/UPDATING, see entry from 20220626.

After changing Python itself (i.e. from 3.7 to 3.9), rebuilding 
depending py3x-packages will do this version change for you (i.e. from 
py3.7-* to py3.9-*, ...). It works via the so called flavors.

I hope I have not misunderstood your request and that these hints are 
somehow useful ;)

Best wishes,
Rainer

> 
> -Dan