From fc14b5b6b2595ce59bbecde36da03332874b7c1f Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 26 Mar 2015 13:16:48 +0100 Subject: [PATCH] Fix link_pyqt.py on Debian/Windows. --- scripts/link_pyqt.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/scripts/link_pyqt.py b/scripts/link_pyqt.py index 4e0c725fd..3d584127b 100644 --- a/scripts/link_pyqt.py +++ b/scripts/link_pyqt.py @@ -27,6 +27,7 @@ import os.path import sys import glob import subprocess +import platform class Error(Exception): @@ -95,9 +96,23 @@ def link_pyqt(sys_path, venv_path): def get_python_lib(executable): """Get the python site-packages directory for the given executable.""" - return subprocess.check_output( - [executable, '-c', 'from distutils.sysconfig import get_python_lib\n' - 'print(get_python_lib())'], universal_newlines=True).rstrip() + distribution = platform.linux_distribution(full_distribution_name=False) + if os.name == 'nt': + # For some reason, we get an empty string from get_python_lib() on + # Windows when running via tox, and sys.prefix is empty too... + return os.path.join(os.path.dirname(executable), '..', 'Lib', + 'site-packages') + elif distribution[0].lower() in ('debian', 'ubuntu'): + # For some reason, we get '/usr/lib/python3.4/site-packages' instead of + # '/usr/lib/python3/dist-packages' on debian with tox... + cmd = [executable, '-c', 'import sys\nprint(sys.prefix)'] + prefix = subprocess.check_output(cmd, universal_newlines=True).rstrip() + return os.path.join(prefix, 'lib', 'python3', 'dist-packages') + else: + cmd = [executable, '-c', + 'from distutils.sysconfig import get_python_lib\n' + 'print(get_python_lib())'] + return subprocess.check_output(cmd, universal_newlines=True).rstrip() def get_tox_syspython(venv_path):