summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlávek Banko <[email protected]>2024-01-28 20:25:10 +0100
committerSlávek Banko <[email protected]>2024-01-31 13:17:59 +0100
commite266e8f8bcac221b5d547601cf6decf4ce920dd8 (patch)
treee8a0ed8b1b03100e5f00efac7f5504008a270d19
parente864982d59c8004ff41e59882a36ae8d2565bc44 (diff)
downloadpytdeextensions-e266e8f8bcac221b5d547601cf6decf4ce920dd8.tar.gz
pytdeextensions-e266e8f8bcac221b5d547601cf6decf4ce920dd8.zip
Fix detection of SIP-TQt, PyTQt and PyTDE modules in tdedistutils
with multiple Python3 installed in parallel. This solves FTBFS when building tde-guidance. Remove import of 'imp' module that is no longer needed. Sysconfig from Python is now used instead of sysconfig from distutils. Signed-off-by: Slávek Banko <[email protected]> (cherry picked from commit 9f0eefe9d37963ff414f24e20e84709f41d01596)
-rw-r--r--src/tdedistutils.py72
1 files changed, 40 insertions, 32 deletions
diff --git a/src/tdedistutils.py b/src/tdedistutils.py
index afb1600..0ba543d 100644
--- a/src/tdedistutils.py
+++ b/src/tdedistutils.py
@@ -26,15 +26,15 @@ from distutils.command.install_data import install_data
from distutils.command.install_lib import install_lib
from distutils.util import change_root, convert_path
from distutils.spawn import find_executable,spawn
-from distutils import sysconfig
from distutils import log
from distutils import file_util
from distutils import dir_util
from distutils.util import byte_compile
import tqtuicompiler
import stat
-import os,os.path,imp,glob
+import os,os.path,glob
import sys
+import sysconfig
from types import *
INSTALL_LIST = 'install_log.txt'
@@ -619,39 +619,43 @@ class BuildKControlModule(Command):
# Python dir
if self.python_dir is None:
- self.python_dir = os.path.split(sysconfig.get_config_var("LIBPL"))[0]
+ self.python_dir = sysconfig.get_path('platstdlib')
self.announce("Using %s for the python directory" % self.python_dir)
# Python include dir.
if self.python_inc_dir is None:
# Find the Python include directory.
- self.python_inc_dir = sysconfig.get_config_var("INCLUDEPY")
+ self.python_inc_dir = sysconfig.get_path('include')
self.announce("Using %s for Python header files" % self.python_inc_dir)
# PyTQt dir
if self.pytqt_dir is None:
- self.pytqt_dir = FindFileInPaths("PyTQt", sys.path)
- if self.pytqt_dir is None:
- self.pytqt_dir = os.path.join(sysconfig.get_python_lib(), 'PyTQt')
- if (FindFileInPaths("libtqtcmodule*",[self.pytqt_dir]) is None) and (FindFileInPaths("tqt*",[self.pytqt_dir]) is None):
+ pytqt_dirs = sys.path
+ pytqt_dirs.insert(0, sysconfig.get_path('platstdlib'))
+ self.pytqt_dir = FindFileInPaths("PyTQt/tqt*.so", pytqt_dirs)
+ if not self.pytqt_dir is None:
+ self.pytqt_dir = os.path.join(self.pytqt_dir, 'PyTQt')
+ if (FindFileInPaths("tqt*", self.pytqt_dir) is None):
raise SystemExit("Failed to find the PyTQt directory: %s" % self.pytqt_dir)
self.announce("Using %s for PyTQt modules" % self.pytqt_dir)
# PyTDE dir
if self.pytde_dir is None:
- self.pytde_dir = sysconfig.get_python_lib()
- if (FindFileInPaths("libtdecorecmodule*",[self.pytde_dir]) is None) and (FindFileInPaths("tdecore*",[self.pytde_dir]) is None):
+ pytde_dirs = sys.path
+ pytde_dirs.insert(0, sysconfig.get_path('platstdlib'))
+ self.pytde_dir = FindFileInPaths("tdecore*.so", pytde_dirs)
+ if (FindFileInPaths("tdecore*", self.pytde_dir) is None):
raise SystemExit("Failed to find the PyTDE directory: %s" % self.pytde_dir)
self.announce("Using %s for PyTDE modules" % self.pytde_dir)
# Sip dir
if self.sip_dir is None:
- self.sip_dir = os.path.dirname(FindFileInPaths("sip_tqt*", sys.path))
- if self.sip_dir is None:
- self.sip_dir = sysconfig.get_python_lib()
- if (FindFileInPaths("libsip_tqt*", [self.sip_dir]) is None) and (FindFileInPaths("sip_tqt*", [self.sip_dir]) is None):
- raise SystemExit("Failed to find libsip files in directory: %s" % self.sip_dir)
- self.announce("Using %s for libsip files" % self.sip_dir)
+ sip_dirs = sys.path
+ sip_dirs.insert(0, sysconfig.get_path('platstdlib'))
+ self.sip_dir = FindFileInPaths("sip_tqt*.so", sip_dirs)
+ if (FindFileInPaths("sip_tqt*", [self.sip_dir]) is None):
+ raise SystemExit("Failed to find sip-tqt directory: %s" % self.sip_dir)
+ self.announce("Using %s for sip-tqt files" % self.sip_dir)
# Find the C library (libgcc, libgcc_s or some other variation).
if self.clib is None:
@@ -692,7 +696,7 @@ class BuildKControlModule(Command):
libraryname = None
cmodulecategory = None
try:
- fhandle = open(moduletuple[0],'r')
+ fhandle = open(moduletuple[0], 'r', encoding='utf-8')
for line in fhandle.readlines():
parts = line.strip().split('=')
try:
@@ -1068,7 +1072,7 @@ class InstallKControlModule(Command):
libraryname = None
cmodulecategory = None
try:
- fhandle = open(moduletuple[0],'r')
+ fhandle = open(moduletuple[0], 'r', encoding='utf-8')
for line in fhandle.readlines():
parts = line.strip().split('=')
try:
@@ -1564,39 +1568,43 @@ class BuildTdeioslave(Command):
# Python dir
if self.python_dir is None:
- self.python_dir = os.path.split(sysconfig.get_config_var("LIBPL"))[0]
+ self.python_dir = sysconfig.get_path('platstdlib')
self.announce("Using %s for the python directory" % self.python_dir)
# Python include dir.
if self.python_inc_dir is None:
# Find the Python include directory.
- self.python_inc_dir = sysconfig.get_config_var("INCLUDEPY")
+ self.python_inc_dir = sysconfig.get_path('include')
self.announce("Using %s for Python header files" % self.python_inc_dir)
# PyTQt dir
if self.pytqt_dir is None:
- self.pytqt_dir = FindFileInPaths("PyTQt", sys.path)
- if self.pytqt_dir is None:
- self.pytqt_dir = os.path.join(sysconfig.get_python_lib(), 'PyTQt')
- if (FindFileInPaths("libtqtcmodule*",[self.pytqt_dir]) is None) and (FindFileInPaths("tqt*",[self.pytqt_dir]) is None):
+ pytqt_dirs = sys.path
+ pytqt_dirs.insert(0, sysconfig.get_path('platstdlib'))
+ self.pytqt_dir = FindFileInPaths("PyTQt/tqt*.so", pytqt_dirs)
+ if not self.pytqt_dir is None:
+ self.pytqt_dir = os.path.join(self.pytqt_dir, 'PyTQt')
+ if (FindFileInPaths("tqt*", self.pytqt_dir) is None):
raise SystemExit("Failed to find the PyTQt directory: %s" % self.pytqt_dir)
self.announce("Using %s for PyTQt modules" % self.pytqt_dir)
# PyTDE dir
if self.pytde_dir is None:
- self.pytde_dir = sysconfig.get_python_lib()
- if (FindFileInPaths("libtdecorecmodule*",[self.pytde_dir]) is None) and (FindFileInPaths("tdecore*",[self.pytde_dir]) is None):
+ pytde_dirs = sys.path
+ pytde_dirs.insert(0, sysconfig.get_path('platstdlib'))
+ self.pytde_dir = FindFileInPaths("tdecore*.so", pytde_dirs)
+ if (FindFileInPaths("tdecore*", self.pytde_dir) is None):
raise SystemExit("Failed to find the PyTDE directory: %s" % self.pytde_dir)
self.announce("Using %s for PyTDE modules" % self.pytde_dir)
# Sip dir
if self.sip_dir is None:
- self.sip_dir = os.path.dirname(FindFileInPaths("sip_tqt*", sys.path))
- if self.sip_dir is None:
- self.sip_dir = sysconfig.get_python_lib()
- if (FindFileInPaths("libsip_tqt*", [self.sip_dir]) is None) and (FindFileInPaths("sip_tqt*", [self.sip_dir]) is None):
- raise SystemExit("Failed to find libsip files in directory: %s" % self.sip_dir)
- self.announce("Using %s for libsip files" % self.sip_dir)
+ sip_dirs = sys.path
+ sip_dirs.insert(0, sysconfig.get_path('platstdlib'))
+ self.sip_dir = FindFileInPaths("sip_tqt*.so", sip_dirs)
+ if (FindFileInPaths("sip_tqt*", [self.sip_dir]) is None):
+ raise SystemExit("Failed to find sip-tqt directory: %s" % self.sip_dir)
+ self.announce("Using %s for sip-tqt files" % self.sip_dir)
# Find the C library (libgcc, libgcc_s or some other variation).
if self.clib is None: