def make_cache(fn): if os.path.exists(fn): os.remove(fn) with DelayedInterrupt([signal.SIGTERM, signal.SIGINT]): ar = tarfile.open(fn, 'w|bz2') if os.path.exists('src/'): ar.add('src/') if os.path.exists('test/'): ar.add('test/') ar.close() print('... successfully made olean cache.')
def fetch_mathlib(asset): mathlib_dir = os.path.join(os.environ['HOME'], '.mathlib') if not os.path.isdir(mathlib_dir): os.mkdir(mathlib_dir) if not os.path.isfile(os.path.join(mathlib_dir, asset.name)): print("Downloading nightly...") cd = os.getcwd() os.chdir(mathlib_dir) http = urllib3.PoolManager(cert_reqs='CERT_REQUIRED', ca_certs=certifi.where()) req = http.request('GET', asset.browser_download_url) with DelayedInterrupt([signal.SIGTERM, signal.SIGINT]): with open(asset.name, 'wb') as f: f.write(req.data) os.chdir(cd) else: print("Reusing cached olean archive") with DelayedInterrupt([signal.SIGTERM, signal.SIGINT]): ar = tarfile.open(os.path.join(mathlib_dir, asset.name)) ar.extractall('.') print("... successfully extracted olean archive.")
if x.name.startswith('mathlib-olean-nightly-')) except StopIteration: print("Error: Release " + release.tag_name + " does not contains a olean " "archive (this shouldn't happen...)") sys.exit(1) # Get archive if needed mathlib_dir = os.path.join(os.environ['HOME'], '.mathlib') if not os.path.isdir(mathlib_dir): os.mkdir(mathlib_dir) if not os.path.isfile(os.path.join(mathlib_dir, asset.name)): print("Downloading nightly...") cd = os.getcwd() os.chdir(mathlib_dir) http = urllib3.PoolManager(cert_reqs='CERT_REQUIRED', ca_certs=certifi.where()) req = http.request('GET', asset.browser_download_url) with open(asset.name, 'wb') as f: f.write(req.data) os.chdir(cd) else: print("Reusing cached olean archive") # Extract archive print("Extracting nightly...") with DelayedInterrupt([signal.SIGTERM, signal.SIGINT]): ar = tarfile.open(os.path.join(mathlib_dir, asset.name)) ar.extractall('_target/deps/mathlib')