You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2020/09/27 19:34:45 UTC

[GitHub] [incubator-mxnet] szha commented on a change in pull request #19236: [BUGFIX]fix python 3.8 ctypes dll load with windows

szha commented on a change in pull request #19236:
URL: https://github.com/apache/incubator-mxnet/pull/19236#discussion_r495607149



##########
File path: python/mxnet/base.py
##########
@@ -276,7 +276,15 @@ class MXCallbackList(ctypes.Structure):
 def _load_lib():
     """Load library by searching possible path."""
     lib_path = libinfo.find_lib_path()
-    lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_LOCAL)
+    if sys.version_info >= (3, 8):
+        if os.name == "nt":
+            # use LOAD_WITH_ALTERED_SEARCH_PATH, For simplicity, let's just fill the numbers.
+            # pylint: disable=E1123
+            lib = ctypes.CDLL(lib_path[0], winmode=0x00000008)
+        else:
+            lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_LOCAL)
+    else:
+        lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_LOCAL)

Review comment:
       nit:
   ```suggestion
       if sys.version_info >= (3, 8) and os.name == "nt":
           # use LOAD_WITH_ALTERED_SEARCH_PATH, For simplicity, let's just fill the numbers.
           # pylint: disable=E1123
           lib = ctypes.CDLL(lib_path[0], winmode=0x00000008)
       else:
           lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_LOCAL)
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org