From: Antonio Valentino <antonio.valentino@tiscali.it>
Date: Mon, 31 Dec 2018 09:07:28 +0000
Subject: Robust definition list generation

Forwarded: not-needed
---
 libtiff/libtiff_ctypes.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/libtiff/libtiff_ctypes.py b/libtiff/libtiff_ctypes.py
index 4928646..5202747 100644
--- a/libtiff/libtiff_ctypes.py
+++ b/libtiff/libtiff_ctypes.py
@@ -148,12 +148,13 @@ if tiff_h is None:
         lst.append('%s = %s' % (name, value))
     f.close()
 
-    fn = os.path.join(os.path.dirname(os.path.abspath(__file__)),
-                      tiff_h_name + '.py')
-    print('Generating %r from %r' % (fn, include_tiff_h))
-    f = open(fn, 'w')
-    f.write('\n'.join(lst) + '\n')
-    f.close()
+    if os.environ.get('PYLIBRIFF_WRITE_DEFINITION_FILE', 'NO') == 'YES':
+        fn = os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                          tiff_h_name + '.py')
+        print('Generating %r from %r' % (fn, include_tiff_h))
+        f = open(fn, 'w')
+        f.write('\n'.join(lst) + '\n')
+        f.close()
 else:
     d = tiff_h.__dict__
 
