def __init__(self) -> None: """ Creates a new HostDistribution instance. """ try: import distro self._id = distro.id() self._name = distro.name(pretty=False) self._fullname = distro.name(pretty=True) try: self._major = int(distro.major_version()) except ValueError: self._major = -1 try: self._minor = int(distro.minor_version()) except ValueError: self._minor = -1 try: self._build = int(distro.build_number()) except ValueError: self._build = -1 self._versionstring = distro.version(pretty=False) self._codename = distro.codename() self._like = distro.like() except ImportError: from suisei.murasame.exceptions import MissingRequirementError raise MissingRequirementError( 'HostDistribution requires the distro package.', requirement='distro')
def get_minor_version(): minor_version = distro.minor_version() if not minor_version: if SystemInfo.get_major_version != "UNKNOWN": minor_version = "0" else: minor_version = "UNKNOWN" return minor_version
def get_os_distribution(): try: return platform.dist() except Exception: import distro return [ distro.name(), distro.major_version() + '.' + distro.minor_version(), distro.codename() ]
def get_os_version(): """ Check OS version and return it :return: OS version :rtype: tuple | Exception if it is not supported """ if os_type_is_linux(): return distro.major_version(), distro.minor_version() if os_type_is_windows(): return sys.getwindowsversion().major, sys.getwindowsversion().minor if os_type_is_darwin(): return tuple(platform.mac_ver()[0].split(".")[:2]) raise UnsupportedOsError()
def infer_platform(edition=None, version=None): """Infer platform for popular OS.""" syst = platform.system() pltf = None if syst == 'Darwin': pltf = 'osx' elif syst == 'Windows': pltf = 'windows' if edition == 'base' and version == "4.2": pltf += '_x86_64-2012plus' elif syst == 'Linux': id_name = distro.id() if id_name in ('ubuntu', 'rhel'): pltf = id_name + distro.major_version() + distro.minor_version() if pltf is None: raise ValueError( "Platform cannot be inferred. Please specify platform explicitly with -p. " f"Available platforms can be found in {config.SETUP_MULTIVERSION_CONFIG}." ) else: return pltf
def _detect_os(): id = distro.id() name = distro.name() major = distro.major_version() minor = distro.minor_version() if name.startswith('Scientific'): return 'sl' + major if name.startswith('Red Hat Enterprise'): return 'rhel' + major if id == 'centos': return 'centos' + major if id == 'debian': return 'debian' + major if id == 'arch': return 'arch' if id == 'gentoo': return 'gentoo' + major + '.' + minor if id == 'ubuntu': return 'ubuntu' + major + minor if id == 'fedora': return 'fedora' + major if name.startswith('openSUSE'): return 'opensuse' + major return 'unknown'
def __init__(self, args): self.args = args self.configFilePath = os.path.join(args.build_root, 'qt.cmake') self.version = os.getenv('VIRCADIA_USE_QT_VERSION', '5.12.3') self.assets_url = hifi_utils.readEnviromentVariableFromFile( args.build_root, 'EXTERNAL_BUILD_ASSETS') defaultBasePath = os.path.expanduser('~/hifi/qt') self.basePath = os.getenv('HIFI_QT_BASE', defaultBasePath) if (not os.path.isdir(self.basePath)): os.makedirs(self.basePath) self.path = os.path.join(self.basePath, self.version) self.fullPath = os.path.join(self.path, 'qt5-install') self.cmakePath = os.path.join(self.fullPath, 'lib/cmake') print("Using qt path {}".format(self.path)) lockDir, lockName = os.path.split(self.path) lockName += '.lock' if not os.path.isdir(lockDir): os.makedirs(lockDir) self.lockFile = os.path.join(lockDir, lockName) if (os.getenv('VIRCADIA_USE_PREBUILT_QT')): print("Using pre-built Qt5") return # OS dependent information system = platform.system() if 'Windows' == system: self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.12.3-windows3.tar.gz%3FversionId=5ADqP0M0j5ZfimUHrx4zJld6vYceHEsI' elif 'Darwin' == system: self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.12.3-macos.tar.gz%3FversionId=bLAgnoJ8IMKpqv8NFDcAu8hsyQy3Rwwz' elif 'Linux' == system: import distro dist = distro.linux_distribution() if distro.id() == 'ubuntu': u_major = int(distro.major_version()) u_minor = int(distro.minor_version()) if u_major == 16: self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.12.3-ubuntu-16.04-with-symbols.tar.gz' elif u_major == 18: self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.12.3-ubuntu-18.04.tar.gz' elif u_major == 19 and u_minor == 10: self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.12.6-ubuntu-19.10.tar.xz' elif u_major > 18 and (u_major != 19 and u_minor != 4): print("We don't support " + distro.name(pretty=True) + " yet. Perhaps consider helping us out?") raise Exception('LINUX DISTRO IS NOT SUPPORTED YET!!!') else: print( "Sorry, " + distro.name(pretty=True) + " is old and won't be officially supported. Please consider upgrading." ) raise Exception('UNKNOWN LINUX DISTRO VERSION!!!') else: print("Sorry, " + distro.name(pretty=True) + " is not supported. Please consider helping us out.") print( "It's also possible to build Qt for your distribution, please see the documentation at:" ) print( "https://github.com/kasenvr/project-athena/tree/kasen/core/tools/qt-builder" ) raise Exception('UNKNOWN LINUX VERSION!!!') else: print("System : " + platform.system()) print("Architecture: " + platform.architecture()) print("Machine : " + platform.machine()) raise Exception('UNKNOWN OPERATING SYSTEM!!!')
def get_minor_version(): minor_version = distro.minor_version() if not minor_version: minor_version = "UNKNOWN" return minor_version
def __init__(self, args): self.args = args self.configFilePath = os.path.join(args.build_root, 'qt.cmake') self.version = os.getenv('VIRCADIA_USE_QT_VERSION', '5.15.2') self.assets_url = hifi_utils.readEnviromentVariableFromFile(args.build_root, 'EXTERNAL_BUILD_ASSETS') defaultBasePath = os.path.expanduser('~/hifi/qt') self.basePath = os.getenv('HIFI_QT_BASE', defaultBasePath) if (not os.path.isdir(self.basePath)): os.makedirs(self.basePath) self.path = os.path.join(self.basePath, self.version) self.fullPath = os.path.join(self.path, 'qt5-install') self.cmakePath = os.path.join(self.fullPath, 'lib/cmake') print("Using qt path {}".format(self.path)) lockDir, lockName = os.path.split(self.path) lockName += '.lock' if not os.path.isdir(lockDir): os.makedirs(lockDir) self.lockFile = os.path.join(lockDir, lockName) if (os.getenv('VIRCADIA_USE_PREBUILT_QT')): print("Using pre-built Qt5") return # OS dependent information system = platform.system() cpu_architecture = platform.machine() if 'Windows' == system: self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.15.2-windows.tar.gz' elif 'Darwin' == system: self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.15.2-macos.tar.gz' elif 'Linux' == system: import distro dist = distro.linux_distribution() if 'x86_64' == cpu_architecture: if distro.id() == 'ubuntu': u_major = int( distro.major_version() ) u_minor = int( distro.minor_version() ) if u_major == 18: self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.15.2-ubuntu-18.04-amd64.tar.xz' elif u_major > 19: print("We don't support " + distro.name(pretty=True) + " yet. Perhaps consider helping us out?") raise Exception('LINUX DISTRO IS NOT SUPPORTED YET!!!') else: print("Sorry, " + distro.name(pretty=True) + " is old and won't be officially supported. Please consider upgrading."); raise Exception('UNKNOWN LINUX DISTRO VERSION!!!') else: print("Sorry, " + distro.name(pretty=True) + " is not supported on x86_64. Please consider helping us out.") print("It's also possible to build Qt for your distribution, please see the documentation at:") print("https://github.com/vircadia/vircadia/tree/master/tools/qt-builder") raise Exception('UNKNOWN LINUX VERSION!!!') elif 'aarch64' == cpu_architecture: if distro.id() == 'ubuntu': u_major = int( distro.major_version() ) u_minor = int( distro.minor_version() ) if u_major == 18: self.qtUrl = 'http://motofckr9k.ddns.net/vircadia_packages/qt5-install-5.15.2-ubuntu-18.04-aarch64_test.tar.xz' elif u_major > 19: print("We don't support " + distro.name(pretty=True) + " on aarch64 yet. Perhaps consider helping us out?") raise Exception('LINUX DISTRO IS NOT SUPPORTED YET!!!') else: print("Sorry, " + distro.name(pretty=True) + " is old and won't be officially supported. Please consider upgrading."); raise Exception('UNKNOWN LINUX DISTRO VERSION!!!') elif distro.id() == 'debian': u_major = int( distro.major_version() ) u_minor = int( distro.minor_version() ) if u_major == 10: #self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.12.3-ubuntu-16.04-with-symbols.tar.gz' print("We don't support " + distro.name(pretty=True) + " on aarch64 yet. Perhaps consider helping us out?") raise Exception('LINUX DISTRO IS NOT SUPPORTED YET!!!') elif u_major > 10: print("We don't support " + distro.name(pretty=True) + " on aarch64 yet. Perhaps consider helping us out?") raise Exception('LINUX DISTRO IS NOT SUPPORTED YET!!!') else: print("Sorry, " + distro.name(pretty=True) + " is old and won't be officially supported. Please consider upgrading."); raise Exception('UNKNOWN LINUX DISTRO VERSION!!!') else: print("Sorry, " + distro.name(pretty=True) + " is not supported on aarch64. Please consider helping us out.") print("It's also possible to build Qt for your distribution, please see the documentation at:") print("https://github.com/vircadia/vircadia/tree/master/tools/qt-builder") raise Exception('UNKNOWN LINUX VERSION!!!') else: raise Exception('UNKNOWN CPU ARCHITECTURE!!!') else: print("System : " + platform.system()) print("Architecture: " + platform.architecture()) print("Machine : " + platform.machine()) raise Exception('UNKNOWN OPERATING SYSTEM!!!')
from __future__ import print_function from pprint import pformat import distro def pprint(obj): for line in pformat(obj).split("\n"): print(4 * " " + line) print("os_release_info:") pprint(distro.os_release_info()) print("lsb_release_info:") pprint(distro.lsb_release_info()) print("distro_release_info:") pprint(distro.distro_release_info()) print("id: {0}".format(distro.id())) print("name: {0}".format(distro.name())) print("name_pretty: {0}".format(distro.name(True))) print("version: {0}".format(distro.version())) print("version_pretty: {0}".format(distro.version(True))) print("like: {0}".format(distro.like())) print("codename: {0}".format(distro.codename())) print("linux_distribution_full: {0}".format(distro.linux_distribution())) print("linux_distribution: {0}".format(distro.linux_distribution(False))) print("major_version: {0}".format(distro.major_version())) print("minor_version: {0}".format(distro.minor_version())) print("build_number: {0}".format(distro.build_number()))
def __init__(self, args): self.args = args self.configFilePath = os.path.join(args.build_root, 'qt.cmake') self.version = os.getenv('VIRCADIA_USE_QT_VERSION', '5.15.2') self.assets_url = hifi_utils.readEnviromentVariableFromFile(args.build_root, 'EXTERNAL_BUILD_ASSETS') # OS dependent information system = platform.system() qt_found = False system_qt = False # Here we handle the 3 possible cases of dealing with Qt: if os.getenv('VIRCADIA_USE_SYSTEM_QT', "") != "": # 1. Using the system provided Qt. This is only recommended for Qt 5.15.0 and above, # as it includes a required fix on Linux. # # This path only works on Linux as neither Windows nor OSX ship Qt. if system != "Linux": raise Exception("Using the system Qt is only supported on Linux") self.path = None self.cmakePath = None qt_found = True system_qt = True print("Using system Qt") elif os.getenv('VIRCADIA_QT_PATH', "") != "": # 2. Using an user-provided directory. # VIRCADIA_QT_PATH must point to a directory with a Qt install in it. self.path = os.getenv('VIRCADIA_QT_PATH') self.fullPath = self.path self.cmakePath = os.path.join(self.fullPath, 'lib', 'cmake') qt_found = True print("Using Qt from " + self.fullPath) else: # 3. Using a pre-built Qt. # # This works somewhat differently from above, notice how path and fullPath are # used differently in this case. # # In the case of an user-provided directory, we just use the user-supplied directory. # # For a pre-built qt, however, we have to unpack it. The archive is required to contain # a qt5-install directory in it. self.path = os.path.expanduser("~/vircadia-files/qt") self.fullPath = os.path.join(self.path, 'qt5-install') self.cmakePath = os.path.join(self.fullPath, 'lib', 'cmake') if (not os.path.isdir(self.path)): os.makedirs(self.path) qt_found = os.path.isdir(self.fullPath) print("Using a packaged Qt") if not system_qt: if qt_found: # Sanity check, ensure we have a good cmake directory qt5_dir = os.path.join(self.cmakePath, "Qt5") if not os.path.isdir(qt5_dir): raise Exception("Failed to find Qt5 directory under " + self.cmakePath + ". There should be a " + qt5_dir) else: print("Qt5 check passed, found " + qt5_dir) # I'm not sure why this is needed. It's used by hifi_singleton. # Perhaps it stops multiple build processes from interferring? lockDir, lockName = os.path.split(self.path) lockName += '.lock' if not os.path.isdir(lockDir): os.makedirs(lockDir) self.lockFile = os.path.join(lockDir, lockName) if qt_found: print("Found pre-built Qt5") return if 'Windows' == system: self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.15.2-windows.tar.gz' elif 'Darwin' == system: self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.15.2-macos.tar.gz' elif 'Linux' == system: import distro cpu_architecture = platform.machine() if 'x86_64' == cpu_architecture: if distro.id() == 'ubuntu': u_major = int( distro.major_version() ) u_minor = int( distro.minor_version() ) if u_major == 18: self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.15.2-ubuntu-18.04-amd64.tar.xz' elif u_major > 19: self.__no_qt_package_error() else: self.__unsupported_error() else: self.__no_qt_package_error() elif 'aarch64' == cpu_architecture: if distro.id() == 'ubuntu': u_major = int( distro.major_version() ) u_minor = int( distro.minor_version() ) if u_major == 18: self.qtUrl = 'http://motofckr9k.ddns.net/vircadia_packages/qt5-install-5.15.2-ubuntu-18.04-aarch64_test.tar.xz' elif u_major > 19: self.__no_qt_package_error() else: self.__unsupported_error() elif distro.id() == 'debian': u_major = int( distro.major_version() ) if u_major == 10: self.qtUrl = 'https://data.moto9000.moe/vircadia_packages/qt5-install-5.15.2-debian-10-aarch64.tar.xz' elif u_major > 10: self.__no_qt_package_error() else: self.__unsupported_error() else: self.__no_qt_package_error() else: raise Exception('UNKNOWN CPU ARCHITECTURE!!!') else: print("System : " + platform.system()) print("Architecture: " + platform.architecture()) print("Machine : " + platform.machine()) raise Exception('UNKNOWN OPERATING SYSTEM!!!')
# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import distro print 'os_release_info: {0}'.format(distro.os_release_info()) print 'lsb_release_info: {0}'.format(distro.lsb_release_info()) print 'distro_release_info: {0}'.format(distro.distro_release_info()) print 'id: {0}'.format(distro.id()) print 'name: {0}'.format(distro.name()) print 'name_pretty: {0}'.format(distro.name(True)) print 'version: {0}'.format(distro.version()) print 'version_pretty: {0}'.format(distro.version(True)) print 'like: {0}'.format(distro.like()) print 'codename: {0}'.format(distro.codename()) print 'linux_distribution_full: {0}'.format(distro.linux_distribution()) print 'linux_distribution: {0}'.format(distro.linux_distribution(False)) print 'major_version: {0}'.format(distro.major_version()) print 'minor_version: {0}'.format(distro.minor_version()) print 'build_number: {0}'.format(distro.build_number())
def get_os_version(): if os_type_is_linux(): return distro.major_version(), distro.minor_version() raise UnsupportedOsError(f'The platform is not Linux')