zstd: hack include order to ensure that our zstd.h is found
authorJoerg Sonnenberger <joerg@bec.de>
Mon, 21 Feb 2022 14:44:22 +0100
changeset 50531 9d1c56a79bb8
parent 50530 b361e9da3c3b
child 50532 116da6bb7e3b
zstd: hack include order to ensure that our zstd.h is found If the regular Python CFLAGS include directories that already have the zstd headers available, a different and possible incompatible version can be picked up otherwise. Sadly, it seems like Python has no easy way to prefix flags before the rest.
contrib/python-zstandard/setup_zstd.py
--- a/contrib/python-zstandard/setup_zstd.py	Thu May 18 17:07:43 2023 -0700
+++ b/contrib/python-zstandard/setup_zstd.py	Mon Feb 21 14:44:22 2022 +0100
@@ -145,8 +145,16 @@
 
     include_dirs = set([os.path.join(actual_root, d) for d in ext_includes])
     if not system_zstd:
-        include_dirs.update(
-            [os.path.join(actual_root, d) for d in zstd_includes]
+        from distutils import sysconfig
+        from shlex import quote
+
+        includes = []
+        for incdir in [os.path.join(actual_root, d) for d in zstd_includes]:
+            includes.append('-I' + quote(incdir))
+            include_dirs.add(incdir)
+        config_vars = sysconfig.get_config_vars()
+        config_vars['CFLAGS'] = ' '.join(
+            includes + [config_vars.get('CFLAGS', '')]
         )
         if support_legacy:
             include_dirs.update(