diff options
author | Florian Bruhin <git@the-compiler.org> | 2017-02-17 12:00:16 +0100 |
---|---|---|
committer | Florian Bruhin <git@the-compiler.org> | 2017-02-17 12:00:16 +0100 |
commit | abded2470a764d43afd1f367c493590065c501f9 (patch) | |
tree | c42c0ed6e9e391e07b8fe87d123f300e95829adc /scripts/link_pyqt.py | |
parent | 79d22f25050c9c37a0a64cbc7d40838ba59314c9 (diff) | |
download | qutebrowser-abded2470a764d43afd1f367c493590065c501f9.tar.gz qutebrowser-abded2470a764d43afd1f367c493590065c501f9.zip |
Reenable PyQt 5.6 PyPI tests
To avoid segfaults we need to hardcode the sip version.
We also need to write a Qt.conf as it was missing with PyQt 5.6 and QtWebEngine
can't find its resources.
Diffstat (limited to 'scripts/link_pyqt.py')
-rw-r--r-- | scripts/link_pyqt.py | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/scripts/link_pyqt.py b/scripts/link_pyqt.py index fffe27fb3..c93449b47 100644 --- a/scripts/link_pyqt.py +++ b/scripts/link_pyqt.py @@ -154,6 +154,15 @@ def link_pyqt(executable, venv_path): copy_or_link(path, dest) +def patch_pypi_pyqt(venv_path): + executable = get_venv_executable(venv_path) + pyqt_dir = os.path.dirname(get_lib_path(executable, 'PyQt5.QtCore')) + qt_conf = os.path.join(pyqt_dir, 'Qt', 'libexec', 'qt.conf') + with open(qt_conf, 'w', encoding='utf-8') as f: + f.write('[Paths]\n') + f.write('Prefix = ..\n') + + def copy_or_link(source, dest): """Copy or symlink source to dest.""" if os.name == 'nt': @@ -177,11 +186,15 @@ def remove(filename): os.unlink(filename) +def get_venv_executable(path): + """Get the Python executable in a virtualenv.""" + subdir = 'Scripts' if os.name == 'nt' else 'bin' + return os.path.join(path, subdir, 'python') + + def get_venv_lib_path(path): """Get the library path of a virtualenv.""" - subdir = 'Scripts' if os.name == 'nt' else 'bin' - executable = os.path.join(path, subdir, 'python') - return run_py(executable, + return run_py(get_venv_executable(path), 'from distutils.sysconfig import get_python_lib', 'print(get_python_lib())') @@ -200,15 +213,19 @@ def main(): parser.add_argument('path', help="Base path to the venv.") parser.add_argument('--tox', help="Add when called via tox.", action='store_true') + parser.add_argument('--pypi', help="Patch a PyPI-installed PyQt 5.6", + action='store_true') args = parser.parse_args() - if args.tox: - executable = get_tox_syspython(args.path) + if args.pypi: + patch_pypi_pyqt(args.path) else: - executable = sys.executable - - venv_path = get_venv_lib_path(args.path) - link_pyqt(executable, venv_path) + if args.tox: + executable = get_tox_syspython(args.path) + else: + executable = sys.executable + venv_path = get_venv_lib_path(args.path) + link_pyqt(executable, venv_path) if __name__ == '__main__': |