[Git][NTPsec/ntpsec][20k-Nov22-install-test-fix] nyp.ntpc, bin_test: (ab)use CTYPESDIR when testing install.

James Browning gitlab at mg.gitlab.com
Wed Nov 25 15:06:57 UTC 2020



James Browning pushed to branch 20k-Nov22-install-test-fix at NTPsec / ntpsec


Commits:
327152cd by James Browning at 2020-11-25T07:05:03-08:00
nyp.ntpc, bin_test: (ab)use CTYPESDIR when testing install.


- - - - -


2 changed files:

- pylib/ntpc.py
- wafhelpers/bin_test.py


Changes:

=====================================
pylib/ntpc.py
=====================================
@@ -11,29 +11,38 @@ import sys
 import ntp.poly
 
 LIB = 'ntpc'
+CTD = 'CTYPESDIR'
 
 
-def _fmt():
+def _libname():
     """Produce library naming scheme."""
-    if sys.platform.startswith('darwin'):
-        return 'lib%s.dylib'
-    if sys.platform.startswith('win32'):
-        return '%s.dll'
-    if sys.platform.startswith('cygwin'):
-        return 'lib%s.dll'
-    return 'lib%s.so'
+    _format = 'lib%s.so'
+    _templates = {
+        'darwin': 'lib%s.dylib',
+        'win32': '%s.dll',
+        'cygwin': 'lib%s.dll'
+        }
+    for key in _templates:
+        if sys.platform.startswith(key):
+            _format = _templates[key]
+            break
+    return _format % LIB
 
 
 def _importado():
     """Load the ntpc library or throw an OSError trying."""
     ntpc_paths = []         # places to look
 
-    j = __file__.split(os.sep)[:-1]
-    ntpc_paths.append(os.sep.join(j + [_fmt() % LIB]))
+    if CTD in os.environ:  # and not sys.platform.startswith('linux'):
+        ntpc_paths.append(os.environ[CTD] +
+                          os.sep + _libname())
+    else:
+        j = __file__.split(os.sep)[:-1]
+        ntpc_paths.append(os.sep.join(j + [_libname()]))
 
-    ntpc_path = ctypes.util.find_library(LIB)
-    if ntpc_path:
-        ntpc_paths.append(ntpc_path)
+        ntpc_path = ctypes.util.find_library(LIB)
+        if ntpc_path:
+            ntpc_paths.append(ntpc_path)
 
     return _dlo(ntpc_paths)
 


=====================================
wafhelpers/bin_test.py
=====================================
@@ -104,8 +104,10 @@ def cmd_bin_test(ctx):
     path = spath = None
 
     if ctx.cmd == 'install':
-        pypath = destdir + ctx.env.PYTHONARCHDIR  # + os.sep + 'ntp'
-        env = {'PYTHONPATH': pypath} if destdir != '/' else {}
+        pypath = destdir + ctx.env.PYTHONARCHDIR
+        libpath = destdir + ctx.env.LIBDIR
+        env = {'PYTHONPATH': pypath,
+               'CTYPESDIR': libpath }
         path = destdir + os.sep if destdir != '/' else '/'
         spath = path + ctx.env.SBINDIR[1:] + os.sep
         path = path + ctx.env.BINDIR[1:] + os.sep



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/327152cd25f1367baece6b3f73bd63be52a02c22

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/327152cd25f1367baece6b3f73bd63be52a02c22
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20201125/99203e25/attachment-0001.htm>


More information about the vc mailing list