Exemplo n.º 1
0
    def install(self, version):
        'Install the major.minor.revision or major.minor version of python.'
        version = python_version.check_version(version)

        package_name = self._python_version_to_brew_formula(version)
        self._log.log_d('install: package_name={}'.format(package_name))
        self._brew.install(package_name)
Exemplo n.º 2
0
 def python_exe(clazz, root_dir, version):
     'Return the absolute path the python exe with major version in a virtual env.'
     version = python_version.check_version(version)
     major_version_exe_basename = 'python{}'.format(
         str(version.major_version))
     exe = path.join(root_dir, 'bin', major_version_exe_basename)
     return exe
Exemplo n.º 3
0
    def _do_needs_update(self, version):
        'Return True if python version major.minor needs update.'
        self._log.log_method_d()

        version = python_version.check_version(version)

        available_versions = self.available_versions(0)
        self._log.log_d('needs_update: available_versions: {}'.format(
            available_versions.to_string()))
        filtered_available_versions = available_versions.filter_by_version(
            version)
        self._log.log_d('needs_update: filtered_available_versions: {}'.format(
            filtered_available_versions.to_string()))

        installed_versions = self.installed_versions()
        self._log.log_d('needs_update: installed_versions: {}'.format(
            installed_versions.to_string()))
        filtered_installed_versions = installed_versions.filter_by_version(
            version)
        self._log.log_d('needs_update: filtered_installed_versions: {}'.format(
            filtered_installed_versions.to_string()))

        if not filtered_installed_versions:
            return self._needs_update_result(True, filtered_available_versions)
        assert len(filtered_installed_versions) == 1
        installed_version = filtered_installed_versions[0]
        latest_available_version = filtered_available_versions[-1]
        self._log.log_d(
            'needs_update: installed_version={} latest_available_version={}'.
            format(installed_version, latest_available_version))
        return self._needs_update_result(
            installed_version < latest_available_version,
            filtered_available_versions)
Exemplo n.º 4
0
    def needs_update(self, version):
        'Return True if python version major.minor needs update.'
        self._log.log_method_d()

        version = python_version.check_version(version)

        needs_update, _ = self._do_needs_update(version)
        return needs_update
Exemplo n.º 5
0
    def update(self, version):
        'Update to the latest major.minor version of python.'
        version = python_version.check_version(version)

        needs_update, available_versions = self._do_needs_update(version)
        if not needs_update:
            return False
        self.install(available_versions[-1])
        return True
Exemplo n.º 6
0
    def needs_update(self, version):
        'Return True if python version major.minor needs update.'
        version = python_version.check_version(version)

        self._log.log_method_d()

        package_name = self._python_version_to_brew_formula(version)
        self._log.log_d('needs_update: package_name={}'.format(package_name))
        result = self._brew.needs_update(package_name)
        return result.needs_update
Exemplo n.º 7
0
 def python_exe(clazz, root_dir, version):
     'Return the absolute path the python exe with major version in a virtual env.'
     version = python_version.check_version(version)
     return path.join(root_dir, 'Scripts', 'python.exe')
Exemplo n.º 8
0
    def update(self, version):
        'Update to the latest major.minor version of python.'
        python_version.check_version(version)

        if not self.is_installed(version):
            self.install(version)
Exemplo n.º 9
0
 def _python_version_to_brew_formula(clazz, version):
     version = python_version.check_version(version)
     return 'python@{}'.format(version)