From 9a1ce0d52db45c2f320202ad949f37185a491216 Mon Sep 17 00:00:00 2001 From: Roman Lacko Date: Fri, 7 Sep 2012 15:39:28 +0200 Subject: Don't use custom popenasync module on linux to run commands. This fixes following error: can't concatenate bytes to None --- qtinfo.py | 15 +++++---------- setup.py | 18 ++++++++++++------ utils.py | 13 ++++++++++++- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/qtinfo.py b/qtinfo.py index e638f90af..0cf132863 100644 --- a/qtinfo.py +++ b/qtinfo.py @@ -1,6 +1,6 @@ +import sys import subprocess from distutils.spawn import find_executable -from popenasync import Popen class QtInfo(object): def __init__(self, qmake_path=None): @@ -32,18 +32,13 @@ class QtInfo(object): def getProperty(self, prop_name): cmd = [self._qmake_path, "-query", prop_name] - proc = Popen(cmd, - stdin = subprocess.PIPE, - stdout = subprocess.PIPE, - stderr = subprocess.STDOUT, - universal_newlines = 1, - shell=False) - prop = '' - while proc.poll() is None: - prop += proc.read_async(wait=0.1, e=0) + proc = subprocess.Popen(cmd, stdout = subprocess.PIPE, shell=False) + prop = proc.communicate()[0] proc.wait() if proc.returncode != 0: return None + if sys.version_info >= (3,): + return str(prop, 'ascii').strip() return prop.strip() version = property(getVersion) diff --git a/setup.py b/setup.py index ea3beb06f..f81892c9f 100644 --- a/setup.py +++ b/setup.py @@ -224,7 +224,7 @@ class pyside_build(_build): # Prepare parameters build_type = OPTION_DEBUG and "Debug" or "Release" - + py_executable = sys.executable py_version = "%s.%s" % (sys.version_info[0], sys.version_info[1]) py_include_dir = get_config_var("INCLUDEPY") py_libdir = get_config_var("LIBDIR") @@ -234,17 +234,22 @@ class pyside_build(_build): py_libdir = os.path.join(py_prefix, "libs") else: py_libdir = os.path.join(py_prefix, "lib") - py_executable = sys.executable dbgPostfix = "" if build_type == "Debug": dbgPostfix = "_d" - py_executable = py_executable[:-4] + "_d.exe" if sys.platform == "win32": py_library = os.path.join(py_libdir, "python%s%s.lib" % \ (py_version.replace(".", ""), dbgPostfix)) else: - py_library = os.path.join(py_libdir, "libpython%s%s.so" % \ - (py_version, dbgPostfix)) + if sys.version_info[0] > 2: + py_abiflags = getattr(sys, 'abiflags', None) + py_library = os.path.join(py_libdir, "libpython%s%s.so" % \ + (py_version, py_abiflags)) + else: + py_library = os.path.join(py_libdir, "libpython%s%s.so" % \ + (py_version, dbgPostfix)) + if not os.path.exists(py_library): + py_library = py_library + ".1" if not os.path.exists(py_library): raise DistutilsSetupError( "Failed to locate the Python library %s" % py_library) @@ -301,6 +306,7 @@ class pyside_build(_build): log.info("Python library: %s" % self.py_library) log.info("-" * 3) log.info("Qt qmake: %s" % self.qmake_path) + log.info("Qt version: %s" % qtinfo.version) log.info("Qt bins: %s" % qtinfo.bins_dir) log.info("Qt plugins: %s" % qtinfo.plugins_dir) log.info("-" * 3) @@ -405,7 +411,7 @@ class pyside_build(_build): raise DistutilsSetupError("Error configuring " + extension) log.info("Compiling module %s..." % extension) - if run_process(make_cmd, log) != 0: + if run_process([make_cmd], log) != 0: raise DistutilsSetupError("Error compiling " + extension) log.info("Installing module %s..." % extension) diff --git a/utils.py b/utils.py index 81deedd51..c03f31f7c 100644 --- a/utils.py +++ b/utils.py @@ -5,9 +5,13 @@ import errno import time import shutil import subprocess -import popenasync import fnmatch +from distutils.spawn import spawn +from distutils.spawn import DistutilsExecError + +import popenasync + def has_option(name): try: @@ -162,6 +166,13 @@ def rmtree(dirname): def run_process(args, logger=None): + if sys.platform != "win32": + try: + spawn(args) + return 0 + except DistutilsExecError: + return -1 + def log(buffer, checkNewLine): endsWithNewLine = False if buffer.endswith('\n'): -- cgit v1.2.3