Yo Hal!

On Wed, 27 Sep 2017 23:35:23 -0700
Hal Murray <hmur...@megapathdsl.net> wrote:

> > Once again, I think pip has the answer: edit the sys.path.  
> 
> Why is editing sys.path better than using PYTHONPATH?

Editing the config file that stores sys.path is persistent, and used
by all python  that uses that path.

PYTHONPATH must be in the current environment, thus no available, by default,
to cron jobs.  And when you change from python2 to python3 the PYTHONPATH
will need to be change.

In contrast, when you change from python2 to python3, the correct 
config file for the current version is read so the right ntp is used.

For example, I have NTpsec installed for Python2.7 and Python 3.5:

/usr/local/lib64/python2.7/site-packages/ntp/
/usr/local/lib64/python3.4/site-packages/ntp/

To run from python 2, using PYTHONPATH, I need to do:

export PYTHONPATH=/usr/local/lib64/python2.7/site-packages/ntp/
python2 ntpq

To run Python3:

export PYTHONPATH=/usr/local/lib64/python3.4/site-packages/ntp/
python3 ntpq

By contrast, if the config file that is read by the current python
has the correct paths, like pip does, then I only need to do:

python2 ntpq
python3 ntpq

This works for the dozens of pip packages I have installed,  Are the
pip coders smarter then us?  We even have the pip code to steal from.

For further info, you'll find much interesting reading here:

/usr/lib64/python3.4/site.py
/usr/lib64/python2.7/site.py
/usr/lib64/python3.5/site.py

As a teaser, here is the top line:

"""Append module search paths for third-party packages to sys.path.


Seems apropos?


RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
        g...@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

Attachment: pgpHBOYle4PDF.pgp
Description: OpenPGP digital signature

_______________________________________________
devel mailing list
devel@ntpsec.org
http://lists.ntpsec.org/mailman/listinfo/devel

Reply via email to