diff options
author | Antoine Beaupré <anarcat@debian.org> | 2018-07-30 10:50:18 -0400 |
---|---|---|
committer | Antoine Beaupré <anarcat@debian.org> | 2018-07-30 10:50:18 -0400 |
commit | 8b136df8c340d1e1ee1874ef60850aa9bd153d49 (patch) | |
tree | 79224158005471028278eb4ddd66a73a2e43294c /upgrade.py | |
parent | e93ead0a34c25ef37904e0dc9634cdd045f05e64 (diff) | |
parent | baec34cc51c5822c002b22072a9e99d662dce465 (diff) |
Upstream version 0.9.10
# gpg: Signature faite le lun 30 jui 2018 10:50:17 EDT
# gpg: avec la clef RSA 7B164204D096723B019635AB3EA1DDDDB261D97B
# gpg: Bonne signature de « Antoine Beaupré <anarcat@orangeseeds.org> » [ultime]
# gpg: alias « Antoine Beaupré <anarcat@debian.org> » [ultime]
# gpg: alias « Antoine Beaupré <anarcat@koumbit.org> » [ultime]
# gpg: alias « Antoine Beaupré <anarcat@anarc.at> » [ultime]
Diffstat (limited to 'upgrade.py')
-rw-r--r-- | upgrade.py | 40 |
1 files changed, 33 insertions, 7 deletions
@@ -39,7 +39,7 @@ at the script level i.e. in __name__ == '__main__' # subfolder, available in the online Rapid Photo Downloader source repository. __author__ = 'Damon Lynch' -__copyright__ = "Copyright 2017, Damon Lynch" +__copyright__ = "Copyright 2017-2018, Damon Lynch" import sys import os @@ -210,7 +210,7 @@ class RunInstallProcesses: or package in ('pymediainfo')): requirements = '{}\n{}'.format(requirements, line) if self.need_pyqt5(pip_list): - requirements = '{}\nPyQt5\n'.format(requirements) + requirements = '{}\n{}\n'.format(requirements, self.pypi_pyqt5_version()) if requirements: with tempfile.NamedTemporaryFile(delete=False) as temp_requirements: temp_requirements.write(requirements.encode()) @@ -291,11 +291,39 @@ class RunInstallProcesses: return StrictVersion(pip.__version__) - def need_pyqt5(self, pip_list) -> bool: - if platform.machine() == 'x86_64' and platform.python_version_tuple()[1] in ('5', '6'): - return not 'PyQt5' in pip_list + def package_in_pip_output(self, package: str, output: str) -> bool: + """ + Determine if a package is found in the output of packages installed by pip + :param package: + :param output: + :return: True if found, False otherwise + """ + return re.search('^{}\s'.format(package), output, re.IGNORECASE | re.MULTILINE) is not None + + def need_pyqt5(self, pip_list: str) -> bool: + if platform.machine() == 'x86_64' and StrictVersion(platform.python_version()) >= StrictVersion('3.5.0'): + return not self.package_in_pip_output('PyQt5', pip_list) return False + def pyqt_511_2_compatible(self) -> bool: + """ + Python 3.5.3 or older fail to run with PyQt 5.11.2 + + :return: True if this python version is compatible with PyQt 5.11.2 + """ + + return StrictVersion(platform.python_version()) > StrictVersion('3.5.3') + + def pypi_pyqt5_version(self) -> str: + """ + :return: bytes containing correct version of PyQt5 to install from PyPi + """ + + if not self.pyqt_511_2_compatible(): + return 'PyQt5==5.10' + else: + return 'PyQt5>=5.11' + def make_pip_command(self, args: str, split: bool=True): """ Construct a call to python's pip @@ -310,7 +338,6 @@ class RunInstallProcesses: else: return cmd_line - def python_package_version(self, package: str) -> str: """ Determine the version of an installed Python package, according to pip @@ -327,7 +354,6 @@ class RunInstallProcesses: except subprocess.CalledProcessError: return '' - def match_pyqt5_and_sip(self) -> bool: if self.python_package_version('PyQt5') == '5.9' and \ StrictVersion(self.python_package_version('sip')) == StrictVersion('4.19.4'): |