aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2016-09-24 11:33:36 +0200
committerChristian Tismer <tismer@stackless.com>2016-10-18 14:43:32 +0000
commit8c090690a206e83eba88fcf785b95932f7ad9203 (patch)
treea7239c1e182124da230418c42df8ba30417ffb6e
parent52f4ed0829bf8a47ad3cc16d7679d31ae645f17b (diff)
Make paths absolute in setup.py
The paths for "qmake" and "cmake" will not work when they are relative paths. This problem is pretty subtle, when setup.py breaks because it cannot create the simple list at line 712, variable "cmake_cmd". This innocent looking list is causing problems, because it uses qtinfo.py, and this is dependent on properties which call back into the subprocess module! The properties in qtinfo.py are now real properties, because their values are early computed in __init__. The problem is solved by this patch. Change-Id: I877b6644fa2909ca9ac1f23d4ce5accfc869716b Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--qtinfo.py11
-rw-r--r--setup.py7
2 files changed, 16 insertions, 2 deletions
diff --git a/qtinfo.py b/qtinfo.py
index 6f81cca7a..1e3f278e0 100644
--- a/qtinfo.py
+++ b/qtinfo.py
@@ -8,6 +8,10 @@ class QtInfo(object):
self._qmake_command = qmake_command
else:
self._qmake_command = [find_executable("qmake"),]
+ self._dict = {}
+ # bind all variables early at __init__ time.
+ for thing in self.__class__.__dict__:
+ getattr(self, thing)
def getQMakeCommand(self):
qmake_command_string = self._qmake_command[0]
@@ -39,7 +43,7 @@ class QtInfo(object):
def getDocsPath(self):
return self.getProperty("QT_INSTALL_DOCS")
- def getProperty(self, prop_name):
+ def _getProperty(self, prop_name):
cmd = self._qmake_command + ["-query", prop_name]
proc = subprocess.Popen(cmd, stdout = subprocess.PIPE, shell=False)
prop = proc.communicate()[0]
@@ -50,6 +54,11 @@ class QtInfo(object):
return str(prop, 'ascii').strip()
return prop.strip()
+ def getProperty(self, prop_name):
+ if prop_name not in self._dict:
+ self._dict[prop_name] = self._getProperty(prop_name)
+ return self._dict[prop_name]
+
version = property(getVersion)
bins_dir = property(getBinsPath)
libs_dir = property(getLibsPath)
diff --git a/setup.py b/setup.py
index 722710edb..27df50a28 100644
--- a/setup.py
+++ b/setup.py
@@ -233,6 +233,12 @@ if OPTION_QMAKE is None:
if OPTION_QMAKE is None:
OPTION_QMAKE = find_executable("qmake")
+# make qtinfo.py independent of relative paths.
+if OPTION_QMAKE is not None and os.path.exists(OPTION_QMAKE):
+ OPTION_QMAKE = os.path.abspath(OPTION_QMAKE)
+if OPTION_CMAKE is not None and os.path.exists(OPTION_CMAKE):
+ OPTION_CMAKE = os.path.abspath(OPTION_CMAKE)
+
QMAKE_COMMAND = None
if OPTION_QMAKE is not None and os.path.exists(OPTION_QMAKE): # Checking whether qmake executable exists
if os.path.islink(OPTION_QMAKE) and os.path.lexists(OPTION_QMAKE): # Looking whether qmake path is a link and whether the link exists
@@ -247,7 +253,6 @@ if len(QMAKE_COMMAND) == 0 or QMAKE_COMMAND[0] is None:
if not os.path.exists(QMAKE_COMMAND[0]):
print("'%s' does not exist." % QMAKE_COMMAND[0])
sys.exit(1)
-
if OPTION_CMAKE is None:
OPTION_CMAKE = find_executable("cmake")