guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 03/163: build/python: Add a new guix-pythonpath procedure.


From: Maxim Cournoyer
Subject: Re: 03/163: build/python: Add a new guix-pythonpath procedure.
Date: Fri, 29 Jan 2021 09:25:03 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

Hi Ludo,

Ludovic Courtès <ludo@gnu.org> writes:

> Hi Maxim,
>
> Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
>
>>>> +(define (guix-pythonpath inputs)
>>>> +  "Derive the GUIX_PYTHONPATH_X_Y string , with the major and minor 
>>>> version
>>>> +numbers substituted for X and Y, respectively."
>>>> +  (let ((python (assoc-ref inputs "python")))
>>>> +    (string-append "GUIX_PYTHONPATH_"
>>>> +                   (string-replace-substring (python-version python) "." 
>>>> "_"))))
>>>
>>> One pattern used elsewhere, notably for ‘GUIX_LOCPATH’, is to still keep
>>> a single environment variable (that’d be ‘GUIX_PYTHONPATH’ here) but to
>>> ensure that only MAJOR.MINOR sub-directories are taken into
>>> consideration.
>>>
>>> IOW, instead of having GUIX_PYTHONPATH_3_8 and GUIX_PYTHONPATH_2_7,
>>> you’d have just GUIX_PYTHONPATH but Python 3.8 would only care about
>>> 3.8/ sub-directories while 2.7 would only care about 2.7/
>>> sub-directories.
>>>
>>> That’s perhaps easier to document and to deal with generally (you only
>>> need to look at one specific environment variable).
>>>
>>> Does that make sense?  I don’t know if it’s applicable in this case
>>> though.
>>
>> One of the limitations lifted by this change is the limitation of
>> running a single version of Python per profile.  As mentioned in past
>> discussions, it's not trivial ensuring that packages installed won't end
>> up pulling various versions of Python in a same profile, so it's better
>> to prepared for it :-).
>>
>> Using a non-versioned GUIX_PYTHONPATH would not allow for this, unless
>> I'm missing something.
>
> Sure, I definitely agree.
>
> I’m advocating for a versioned environment variable too, but I’m
> suggesting that versioning should not be part of the variable name.
>
> In the ‘GUIX_LOCPATH’ example I gave, locale data is looked up not
> directly in the search path entries, but instead in those entries
> prefixed by the libc version.  See ‘glibc-versioned-locpath.patch’.
>
> If possible, the proposed ‘GUIX_PYTHONPATH’ variable could work
> similarly: “/MAJOR.MINOR” would automatically be appended to each search
> path entry.
>
> That way, both Python 2.7 and 3.8 can populate the same ‘GUIX_LOCPATH’
> variable, and eventually 2.7 only picks 2.7 packages and 3.8 only picks
> 3.8 packages.
>
> Does that make more sense?

Indeed, I thought about the possibility to filter the GUIX_PYTHONPATH
entries based on their version at runtime after I wrote my initial
reply.  It makes life easier.  I've updated the
cu/farewell-to-pythonpath branch with this new way of doing things.

Thanks for the suggestion!

Maxim



reply via email to

[Prev in Thread] Current Thread [Next in Thread]