Skip to content

Commit

Permalink
ctypesgen patches needed for mac
Browse files Browse the repository at this point in the history
  • Loading branch information
nilason committed Jun 17, 2021
1 parent 8c93979 commit d1e52db
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
1 change: 1 addition & 0 deletions python/grass/ctypes/ctypesgen/libraryloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def getdirs(self, libname):
dyld_fallback_library_path = _environ_path("DYLD_FALLBACK_LIBRARY_PATH")
if not dyld_fallback_library_path:
dyld_fallback_library_path = [os.path.expanduser("~/lib"), "/usr/local/lib", "/usr/lib"]
dyld_fallback_library_path.extend(_environ_path('LD_RUN_PATH'))

dirs = []

Expand Down
27 changes: 23 additions & 4 deletions python/grass/ctypes/ctypesgen/parser/preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,29 @@ def parse(self, filename):

self.cparser.handle_status(cmd)

pp = subprocess.Popen(
cmd, shell=True, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
ppout, pperr = pp.communicate()
pp = subprocess.Popen(cmd,
shell=True,
universal_newlines=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
try:
ppout, pperr = pp.communicate()
except UnicodeError:
# Fix for https://trac.osgeo.org/grass/ticket/3883,
# handling file(s) encoded with mac_roman
if sys.platform == 'darwin':
pp = subprocess.Popen(cmd,
shell=True,
universal_newlines=False, # read as binary
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
ppout, pperr = pp.communicate()

data = ppout.decode('utf8', errors='replace')
ppout = data.replace('\r\n', '\n').replace('\r', '\n')
pperr = pperr.decode('utf8', errors='replace')
else:
raise UnicodeError

for line in pperr.split("\n"):
if line:
Expand Down

0 comments on commit d1e52db

Please sign in to comment.