Fix for Python library path problem

Gary E. Miller gem at rellim.com
Thu Sep 28 19:01:39 UTC 2017


Yo Fred!

On Wed, 27 Sep 2017 19:02:23 -0700 (PDT)
Fred Wright via devel <devel at ntpsec.org> wrote:

> First of all, in order for an import to work in Python, the directory
> containing the module needs to be in sys.path at the time of the
> import. This requirement can be met in one of two ways:

Yup.

> One of the ways to do #1 is to use the path returned by
> get_python_lib() without the prefix option.  This is what GPSD has
> done for years.

And caused subtl problems for years.

> 2.2) Make use of some sort of hook to augment sys.path, which is what
> pip appears to do.  So far, this approach doesn't look promising,
> partly because the only such mechanisms seem to require that the hook
> itself be in a "non-local" location in order to be seen by Python
> before being applied.  A chicken-and-egg problem.

Huh?  Looks simple to me.  Looks like the preferred solution.

Since pip, and many other programs do it, that is a lot of good precendent.

> 2.3) Add code to the programs to augment sys.path prior to the import.

Gack.  Breaks in a large number of ways.  It is very common for
packaers to build to one path, package the results, then install
elsewhere.

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/20170928/b3841736/attachment.bin>


More information about the devel mailing list