Python libs on Debian/Raspbian

Gary E. Miller gem at rellim.com
Wed Dec 20 01:50:05 UTC 2017


Yo Richard!

On Tue, 19 Dec 2017 18:42:52 -0600
Richard Laager <rlaager at wiktel.com> wrote:

> On 12/19/2017 06:30 PM, Gary E. Miller via devel wrote:
> > On Tue, 19 Dec 2017 18:22:11 -0600
> > Richard Laager <rlaager at wiktel.com> wrote:
> >   
> >> On 12/19/2017 05:48 PM, Gary E. Miller via devel wrote:  
> >>> I never, ever, ever, considered PYTHONPATH == sys.path.    
> >>
> >> Do you agree that sys.path is the authoritative list of directories
> >> that are actually searched at run-time, by the python
> >> interpreter?  
> > 
> > Never doubted it  
> Excellent. Do you agree with each of the following (substituting the
> actual version for X.Y):
> 
> A) By default, NTPsec should install to /usr/local.

Yup.

> B) If NTPsec's wafhelpers/fix_python_config.py is removed, when NTPsec
> is configured with --prefix=/usr/local, the Python modules will
> (excluding Debian) install to:
> /usr/local/pythonX.Y/site-packages/ntp

Dunno, never looked at that script.  Now I'm worried about what
should happen, not ways to get there, or hypotheticals.


> C) For a stock upstream Python installed to the normal location
> of /usr, /usr/local/pythonX.Y/site-packages/ntp is not in sys.path by
> default.

Yup.  Although I'm not sure why all the conditionals.  So many undefined
words used in nonstandard ways.  Like 'upstream'?  Upstream to what?
'normal'?  Normal for what?  Normal for distro isntalled, normal for
user installed, or?

Stock may mean from upstream (python.org), or from distro (downstream
from python.prg), or??

How about we just say:  "plain vanilla distro installed Python"?


> D) The combination of B + C means that NTPsec's python utilities (e.g.
> ntpq) will not work out-of-the-box, because they can't find the ntp
> module.

Correct.  As mandated by FHS, Gentoo policy, and policy of pretty much
every distro I've ever looked at.

> E) If the user sets PYTHONPATH=/usr/local/pythonX.Y/site-packages/ntp
> in their environment, NTPsec's python utilities will then work.

Of course, that is what I always do.  Our waf used to tell users to
do that.  I'm not sure current status, that has been removed, added,
changed, etc...

> F) If the user unsets PYTHONPATH in their environment and creates
> /usr/lib/pythonX.Y/site-packages/local.pth with the contents (no
> quotes) "/usr/local/pythonX.Y/site-packages/ntp", NTPsec's python
> utilities will then work.

Maybe.  Not looked much into how .pth files work, yet.

One glitch, Debian does not have any /usr/lib/pythonX.Y/site-packages/
and their policies discourage nonstandard directories in /usr/lib.

Another glitch, some distros use /usr/lib for 32-bit and /usr/lib64
for 64-bit.  So some 64 bit distros would need the .pth in /usr/lib64.
If someone built a 32-bit ntpd on a 64-bit Gentoo, then it would
need to be in /usr/lib32.

In any case, the FHS, Gentoo policy, and the policy of pretty much
every distro I have ever seen, is that we can NOT install anything into
/usr.  But we can recommend when waf is run, and in our doc.

For completeness, other options, not recommendations:

G) ntpsec Python programs could notice they are being run from
/usr/local/bin/ and edit sys.path to look in /usr/local/lib/ for the
ntpd modules.

H) waf could put the --prefix value inside ntpsec Python programs. So
the programs know where to find their modules.

I) waf could install a file in /usr/local/etc to tell ntpsec Python
programs where to look.

And with that, I think we are pretty much right back to where we
were a week ago.  If more people get it now, then worth the effort.

RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
	gem at rellim.com  Tel:+1 541 382 8588

	    Veritas liberabit vos. -- Quid est veritas?
    "If you can’t measure it, you can’t improve it." - Lord Kelvin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <https://lists.ntpsec.org/pipermail/devel/attachments/20171219/28713c4c/attachment.bin>


More information about the devel mailing list