aboutsummaryrefslogtreecommitdiffstats
path: root/c_extension.c
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2022-02-09 19:53:06 +0100
committerJonas Schmid <schmid@stettbacher.ch>2022-02-09 21:22:48 +0100
commit1cfdf5c198f1c74c2f894067baf4670f5bca8e70 (patch)
tree76fb251f56b75733db65fbc010826cf536ecb6b1 /c_extension.c
parentAdd operator / linux username to the annotation file. (diff)
downloado3000-python-binding-1cfdf5c198f1c74c2f894067baf4670f5bca8e70.tar.gz
o3000-python-binding-1cfdf5c198f1c74c2f894067baf4670f5bca8e70.zip
Fix arrayobject.h path on Debian based distros
On Debian Linux and its derivatives such as Ubuntu and LinuxMint, Python packages installed through the package manager are kept in a different non-standard directory called 'dist-packages' instead of the normal 'site-packages' [1]. To detect the Linux distribution the 'platform' library (part of the Python stdlib) provides a function 'platform.freedesktop_os_release()' that parses a standard file '/etc/os-release' available in most Linux distributions [2]. However this function is rather new (Python >= 3.10) and unavailable in most python installations, so the core of its functionaly was reimplemented here. [1]: https://wiki.debian.org/Python#Deviations_from_upstream [2]: https://docs.python.org/3/library/platform.html#linux-platforms Signed-off-by: Jonas Schmid <schmid@stettbacher.ch>
Diffstat (limited to 'c_extension.c')
-rw-r--r--c_extension.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/c_extension.c b/c_extension.c
index 00da503..6cfadba 100644
--- a/c_extension.c
+++ b/c_extension.c
@@ -42,8 +42,17 @@ POSSIBILITY OF SUCH DAMAGE.
#include "helpers.h"
-#include </usr/lib64/python3.6/site-packages/numpy/core/include/numpy/arrayobject.h>
-
+/* On Debian Linux and its derivatives (such as ubuntu), Python libraries
+ * installed through the package manager are kept in a non-standard directory
+ * 'dist-packages' instead of 'site-packages'. Why? Who knows.
+ *
+ * https://wiki.debian.org/Python#Deviations_from_upstream
+ */
+#ifdef DEBIAN_LINUX
+ #include </usr/lib/python3/dist-packages/numpy/core/include/numpy/arrayobject.h>
+#else
+ #include </usr/lib64/python3.6/site-packages/numpy/core/include/numpy/arrayobject.h>
+#endif
#define DEFAULT_FRAME_RATE 10 ///< default frame rate