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)
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
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)
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
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
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
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')
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)
def _python_version_to_brew_formula(clazz, version): version = python_version.check_version(version) return 'python@{}'.format(version)