def run(self): """ Downloads, unzips and installs GKS, GR and GR3 binaries. """ build_py.run(self) base_path = os.path.realpath(self.build_lib) if os.environ.get('GR_FORCE_DOWNLOAD') or runtime_helper.load_runtime( silent=True) is None: version = _runtime_version operating_system = DownloadBinaryDistribution.detect_os() if operating_system is not None: arch = DownloadBinaryDistribution.detect_architecture() # check for desired build variant (e.g. -msvc) variant = os.environ.get('GR_BUILD_VARIANT', '') if variant: variant = '-' + variant # download binary distribution for system file_name = 'gr-{version}-{os}-{arch}{variant}.tar.gz'.format( version=version, os=operating_system, arch=arch, variant=variant) tar_gz_data = DownloadBinaryDistribution.get_file_from_mirrors( file_name, version, 'http') # wrap response as file-like object tar_gz_data = BytesIO(tar_gz_data) expected_hash = DownloadBinaryDistribution.get_expected_hash( version, file_name) calculated_hash = hashlib.sha512( tar_gz_data.read()).hexdigest() tar_gz_data.seek(0) if calculated_hash != expected_hash: raise RuntimeError( "Downloaded binary distribution of GR runtime does not match expected hash" ) # extract shared libraries from downloaded .tar.gz archive tar_gz_file = tarfile.open(fileobj=tar_gz_data) try: for member in tar_gz_file.getmembers(): tar_gz_file.extract(member, base_path) finally: tar_gz_file.close() if sys.platform == 'win32': search_dir = os.path.join(base_path, 'gr', 'bin') else: search_dir = os.path.join(base_path, 'gr', 'lib') if runtime_helper.load_runtime(search_dirs=[search_dir], silent=False) is None: raise RuntimeError("Unable to install GR runtime")
def run(self): """ Downloads, unzips and installs GKS, GR and GR3 binaries. """ build_py.run(self) base_path = os.path.realpath(self.build_lib) if runtime_helper.load_runtime(silent=True) is None: version = _runtime_version operating_system = DownloadBinaryDistribution.detect_os() if operating_system is not None: arch = DownloadBinaryDistribution.detect_architecture() # download binary distribution for system file_name = 'gr-{version}-{os}-{arch}.tar.gz'.format( version=version, os=operating_system, arch=arch ) distribution_url = 'http://gr-framework.org/downloads/' + file_name response = urlopen(distribution_url) if response.getcode() != 200: raise URLError('GR runtime not found on: ' + distribution_url) # wrap response as file-like object tar_gz_data = BytesIO(response.read()) expected_hash = DownloadBinaryDistribution.get_expected_hash(version, file_name) calculated_hash = hashlib.sha512(tar_gz_data.read()).hexdigest() tar_gz_data.seek(0) if calculated_hash != expected_hash: raise RuntimeError("Downloaded binary distribution of GR runtime does not match expected hash") # extract shared libraries from downloaded .tar.gz archive tar_gz_file = tarfile.open(fileobj=tar_gz_data) try: for member in tar_gz_file.getmembers(): tar_gz_file.extract(member, base_path) finally: tar_gz_file.close() if sys.platform == 'win32': search_dir = os.path.join(base_path, 'gr', 'bin') else: search_dir = os.path.join(base_path, 'gr', 'lib') if runtime_helper.load_runtime(search_dirs=[search_dir], silent=False) is None: raise RuntimeError("Unable to install GR runtime")