[Git][NTPsec/ntpsec][master] On FFI pylib change .so path, print no traceback

Hal Murray (@hal.murray) gitlab at mg.gitlab.com
Mon Feb 3 00:17:36 UTC 2025



Hal Murray pushed to branch master at NTPsec / ntpsec


Commits:
e6aa7768 by James Browning at 2025-02-03T00:14:19+00:00
On FFI pylib change .so path, print no traceback

- - - - -


2 changed files:

- libntp/wscript
- pylib/ntpc.py


Changes:

=====================================
libntp/wscript
=====================================
@@ -63,7 +63,7 @@ def build(ctx):
             features="c cshlib",
             includes=[ctx.bldnode.parent.abspath(), "../include"],
             source=["ntp_c.c", "pymodule-mac.c"] + libntp_source_sharable,
-            target="../pylib/ntpc",  # Put the output in the pylib directory
+            target="../ntpc",  # Put the output in the parent directory
             use="M RT CRYPTO",
             vnum=ctx.env['ntpcver'],
         )


=====================================
pylib/ntpc.py
=====================================
@@ -29,11 +29,18 @@ def _fmt():
 
 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]))
-
+    mod_path_bits = __file__.split(os.sep)
+    library_basename = _fmt() % LIB  # like libntpc.so
+    ntpc_paths = [
+        # look in grandparent folder for plain bin_test,
+        # great-grandparent for pylib tests, and LIBDIR
+        # for the testers under /usr/local/lib running.
+        os.sep.join(mod_path_bits[:-3] + [library_basename]),
+        os.sep.join(mod_path_bits[:-4] + [library_basename]),
+        "@LIBDIR@" + os.sep + library_basename,
+    ]
+
+    # Finally, check in ordinary library folders for production use.
     ntpc_path = ctypes.util.find_library(LIB)
     if ntpc_path:
         ntpc_paths.append(ntpc_path)



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

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/e6aa7768e7c2e371f8a2d5d15d81a999e69cd7cd
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/20250203/68480687/attachment-0001.htm>


More information about the vc mailing list