Skip to content

Commit

Permalink
Merge pull request #843 from DLR-SC/842-ctypes-dll-policy-py38
Browse files Browse the repository at this point in the history
Respect new dll loading policy of ctypes starting in Python 3.8
  • Loading branch information
rainman110 authored Oct 26, 2021
2 parents 29e1a44 + 5d35685 commit e866b7b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions bindings/bindings_generator/python_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def create_wrapper(self, cparser):
if self.license:
string += self.license

string += 'import sys, ctypes\n\n'
string += 'import sys, ctypes, ctypes.util\n\n'
for enumname, values in cparser.enums.items():
string += self.create_enum(enumname, values) + '\n\n'

Expand Down Expand Up @@ -120,7 +120,8 @@ def create_constructor(self):

string += indent + 'try:\n'
string += indent + ' if sys.platform == \'win32\':\n'
string += indent + ' lib = ctypes.cdll.%s\n' % self.libname
string += indent + ' name = ctypes.util.find_library("%s")\n' % self.libname
string += indent + ' lib = ctypes.cdll.LoadLibrary(name)\n'
string += indent + ' elif sys.platform == \'darwin\':\n'
string += indent + ' lib = ctypes.CDLL("lib%s.dylib")\n' % self.libname
string += indent + ' else:\n'
Expand Down

0 comments on commit e866b7b

Please sign in to comment.