Skip to content

Instantly share code, notes, and snippets.

@celoyd
Created August 8, 2013 20:46
Show Gist options
  • Save celoyd/6188546 to your computer and use it in GitHub Desktop.
Save celoyd/6188546 to your computer and use it in GitHub Desktop.
if tiff_h is None:
include_tiff_h = os.path.join(os.path.split(lib)[0], '..', 'include', 'tiff.h')
if not os.path.isfile(include_tiff_h):
# fix me for windows:
include_tiff_h = os.path.join('/usr','include','tiff.h')
if not os.path.isfile(include_tiff_h):
raise ValueError('Failed to find TIFF header file (may be need to run: sudo apt-get install libtiff4-dev)')
# Read TIFFTAG_* constants for the header file:
f = open (include_tiff_h, 'r')
l = []
d = {}
for line in f.readlines():
if not line.startswith('#define'): continue
words = line[7:].lstrip().split()[:2]
if len (words)!=2: continue
name, value = words
i = value.find('/*')
if i!=-1: value = value[:i]
if value in d:
value = d[value]
else:
print value
value = eval(value)
d[name] = value
l.append('%s = %s' % (name, value))
f.close()
@celoyd
Copy link
Author

celoyd commented Aug 8, 2013

>>> import libtiff
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/libtiff/__init__.py", line 20, in <module>
    from .libtiff_ctypes import libtiff, TIFF
  File "/Library/Python/2.7/site-packages/libtiff/libtiff_ctypes.py", line 79, in <module>
    value = eval(value)
  File "<string>", line 1
    (1
     ^
SyntaxError: unexpected EOF while parsing
>>> well, all right then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment