def run(self): with syspath(PACKAGEDIR, MODULE_NAME == 'snakeoil'): from snakeoil.pickling import dump, load # try to load the cached results try: with open(self.cache_path, 'rb') as f: cache_db = load(f) except (OSError, IOError): cache_db = {} else: if self._cache_env_key() == cache_db.get('env_key'): sys.stderr.write(f'-- Using cache: {self.cache_path}\n') else: sys.stderr.write( '-- Build environment changed, discarding cache\n') cache_db = {} self.cache = cache_db.get('cache', {}) self.check_defines = {} if not self._sanity_check(): sys.stderr.write( 'The C toolchain is unable to compile & link a simple C program!\n' ) sys.exit(1) # run all decorated methods for k in dir(self): if k.startswith('_'): continue if hasattr(getattr(self, k), 'pkgdist_config_decorated'): getattr(self, k)() # store results in Distribution instance self.distribution.check_defines = self.check_defines # store updated cache cache_db = { 'cache': self.cache, 'env_key': self._cache_env_key(), } self.mkpath(os.path.dirname(self.cache_path)) with open(self.cache_path, 'wb') as f: dump(cache_db, f)
def run(self): with syspath(PACKAGEDIR, MODULE_NAME == 'snakeoil'): from snakeoil.pickling import dump, load # try to load the cached results try: with open(self.cache_path, 'rb') as f: cache_db = load(f) except (OSError, IOError): cache_db = {} else: if self._cache_env_key() == cache_db.get('env_key'): sys.stderr.write('-- Using cache from %s\n' % self.cache_path) else: sys.stderr.write('-- Build environment changed, discarding cache\n') cache_db = {} self.cache = cache_db.get('cache', {}) self.check_defines = {} if not self._sanity_check(): sys.stderr.write('The C toolchain is unable to compile & link a simple C program!\n') sys.exit(1) # run all decorated methods for k in dir(self): if k.startswith('_'): continue if hasattr(getattr(self, k), 'pkgdist_config_decorated'): getattr(self, k)() # store results in Distribution instance self.distribution.check_defines = self.check_defines # store updated cache cache_db = { 'cache': self.cache, 'env_key': self._cache_env_key(), } self.mkpath(os.path.dirname(self.cache_path)) with open(self.cache_path, 'wb') as f: dump(cache_db, f)