[PATCH v2 1/1] rt-tests: Makefile: Use sysconfig instead of distutils for PYLIB

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use sysconfig instead of distutils for PYLIB
Version 2 takes into consideration that different versions of python
produce different results.

Signed-off-by: John Kacur <jkacur@xxxxxxxxxx>
---
 Makefile     |  2 +-
 get_pylib.py | 16 ++++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)
 create mode 100755 get_pylib.py

diff --git a/Makefile b/Makefile
index 4df61ece123b..32a9f41198a4 100644
--- a/Makefile
+++ b/Makefile
@@ -34,7 +34,7 @@ CFLAGS ?= -Wall -Wno-nonnull -Wextra
 CPPFLAGS += -D_GNU_SOURCE -Isrc/include
 LDFLAGS ?=
 
-PYLIB  ?= $(shell python3 -c 'import distutils.sysconfig;  print (distutils.sysconfig.get_python_lib())')
+PYLIB ?= $(shell python3 -m get_pylib)
 
 # Check for errors, such as python3 not available
 ifeq (${PYLIB},)
diff --git a/get_pylib.py b/get_pylib.py
new file mode 100755
index 000000000000..56253d589fe4
--- /dev/null
+++ b/get_pylib.py
@@ -0,0 +1,16 @@
+#!/usr/bin/python3
+
+# This file is used during the make process
+
+import sysconfig
+
+# Older versions of python don't have this scheme
+# but produce the answer we expect with 'posix_prefix'
+# Newer versions of python insert 'local' in the path unless we use rpm_prefix
+SCHEME = 'rpm_prefix'
+
+if not SCHEME in sysconfig.get_scheme_names():
+    SCHEME = 'posix_prefix'
+
+PYLIB = sysconfig.get_path('purelib', SCHEME)
+print(PYLIB)
-- 
2.39.1




[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux