Python libs on Debian/Raspbian

Richard Laager rlaager at wiktel.com
Wed Dec 20 23:27:55 UTC 2017


On 12/20/2017 05:00 PM, Gary E. Miller via devel wrote:
> Neither --prefix, nor DESTDIR
> affect the generated and installed files.

I haven't checked, but I'm willing to stipulate that PREFIX is not
*currently* being embedded in any files installed by NTPsec.

The proposed "option H" is a change which would start embedding the
PREFIX or PYTHONDIR (which, by default, is based on PREFIX) inside the
installed files. It would not, however, embed DESTDIR.

In the examples below, I am embedding PYTHONDIR (again, based on PREFIX
by default), as I think that is what we really want. You'll see why when
you look at the custom --pythondir example.


The Debian packaging:

./waf configure --prefix=/usr
./waf install --destdir=debian/tmp

I will end up with a file named:
debian/tmp/bin/ntpq

which will have something like this:

PYTHONDIR='/usr/lib/python2.7/site-packages'
import sys
sys.path.insert(1, PYTHONDIR)
# current imports from ntp module



A default source install:
./waf configure
sudo ./waf install

I will end up with a file named:
/usr/local/bin/ntpq

which will contain something like:
PYTHONDIR='/usr/local/lib/python2.7/site-packages'
import sys
sys.path.insert(1, PYTHONDIR)
# current imports from ntp module



An install to custom locations:
./waf configure --prefix=/opt/ntpsec --pythondir=/opt/ntpsec/python
sudo ./waf install

I will end up with a file named:
/opt/ntpsec/bin/ntpq

which will contain something like:
PYTHONDIR='/opt/ntpsec/python'
import sys
sys.path.insert(1, PYTHONDIR)
# current imports from ntp module


Note the position of the insertion into sys.path. The result is:
['', PYTHONDIR, the rest of the default sys.path]

In this way, the PYTHONDIR overrides the default locations. This fixes
the case of distro package in /usr + source install to /usr/local.

Since the rest of the default path is kept, all of the standard Python
modules and other dependencies are still found as per usual.

Since '' is still first, the current directory is still searched first.
This allows the regression tests to work using a symlink to the "ntp"
directory. Alternatively, here are other ways that can be handled, if
needed. For example, the code could be enhanced to add PYTHONDIR *after*
the values from the environment's PYTHONPATH. Then the regression test
could set a PYTHONPATH. Or, a custom environment variable could be used
for regression tests.

-- 
Richard

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: OpenPGP digital signature
URL: <https://lists.ntpsec.org/pipermail/devel/attachments/20171220/ba41ff79/attachment.bin>


More information about the devel mailing list