Subject: Re: bug#52269: [core-updates-frozen] sitecustomize.py does not honor .pth files

From: Maxim Cournoyer <[email-masked]>
Date: Fri, 17 Dec 2021 09:41:39 -0500

Hello!

Lars-Dominik Braun <[email-masked]> writes:

> Hi Maxim,
>
>> You can test it by placing the new sitecustomize.py file in the current
>> directory, and then:
> that works, thanks!
>
>> I agree that after it's un-bundled it shouldn't be necessary anymore, but
>> let's keep this change for core-updates along work on the 517
>> python-build-system (I'll try having a look to it after the next release
>> it out -- ping me otherwise).
> Sure.
>
>> +    # Move the entries that were appended to sys.path in front of
>> +    # Python's own site-packages directory.  This enables Guix
>> +    # packages to override Python's bundled packages, such as 'pip'.
>> +    python_site_index = sys.path.index(python_site)
>> +    new_site_start_index = sys.path.index(matching_sites[0])
> One more nitpick: list.index() will raise a ValueError if the requested
> value does not exist. I believe setting GUIX_PYTHONPATH=/nonexistent
> will trigger this.

It doesn't break when I try it here:

$ PYTHONPATH=. GUIX_PYTHONPATH=/nonexistent python sample.py

Also, messing with GUIX_PYTHONPATH is something users shouldn't do
unless they really know what they are doing, in my opinion.  It's
intended as Guix's own mechanism to discover Python packages.  Users can
and should still use PYTHONPATH if they want to mess with Python's
module search path.

Thank you!

Maxim