def main(**kwargs): """Entry point for Pyppyn CLI.""" print("Pyppyn CLI,", pyppyn.__version__) # Remove unused options empty_keys = [k for k, v in kwargs.items() if not v] for k in empty_keys: del kwargs[k] exit_val = pyppyn.__EXITOKAY__ # Create an instance pyppyn_instance = pyppyn.ConfigRep(**kwargs) if kwargs.get("display", False): if not (pyppyn_instance.read_config() and pyppyn_instance.load_config()): exit_val = 1 elif kwargs.get("auto_load", False): if not pyppyn_instance.process_config(): exit_val = 1 sys.exit(exit_val)
def __init__(self, **kwargs): """Instantiation""" if not os.environ.get('VIRTUAL_ENV'): logger.error("No virtual environment directory detected!") raise NotADirectoryError # Remove unused options empty_keys = [key for key, value in kwargs.items() if not value] for key in empty_keys: del kwargs[key] # arguments that do NOT depend on pyppyn self.flags = {} self.flags["clean"] = kwargs.get('clean', False) self.directories = {} self.directories["pkg"] = kwargs.get('pkg_dir', os.environ.get('GB_PKG_DIR', '.')) self.directories["src"] = kwargs.get('src_dir', os.environ.get('GB_SRC_DIR', '.')) self.formats = {} self.formats["name"] = kwargs.get( 'name_format', os.environ.get('GB_NAME_FORMAT', '{an}-{v}-standalone-{os}-{m}')) self.formats["sha"] = kwargs.get( 'sha_format', os.environ.get('GB_SHA_FORMAT', '{an}-{v}-sha256-{os}-{m}.json')) self.formats["label"] = kwargs.get( 'label_format', os.environ.get('GB_LABEL_FORMAT', '{An} {v} {ft} for {os} [GravityBee Build]')) self.extra = {} self.extra["data"] = kwargs.get('extra_data', None) self.extra["pkgs"] = kwargs.get('extra_pkgs', []) self.extra["modules"] = kwargs.get('extra_modules', []) self.flags["dont_write_file"] = kwargs.get('no_file', False) self.directories["work"] = kwargs.get( 'work_dir', os.environ.get( 'GB_WORK_DIR', os.path.join(FILE_DIR, 'build', uuid.uuid1().hex[:16]))) if os.path.exists(self.directories["work"]): logger.error("work_dir must not exist. It may be deleted.") raise FileExistsError self.flags["one_dir"] = kwargs.get('onedir', os.environ.get('GB_ONEDIR', False)) self.directories["staging"] = kwargs.get( 'staging_dir', os.environ.get('GB_STAGING_DIR', os.path.join(FILE_DIR, 'dist'))) self.flags["with_latest"] = kwargs.get('with_latest', False) self.info = {} self.info["sha"] = kwargs.get('sha', Arguments.OPTION_SHA_INFO) # arguments that DO depend on pyppyn self.pyppy = pyppyn.ConfigRep(setup_path=self.directories["pkg"]) self.info["console_script"] = self.pyppy.get_config_attr( 'console_scripts') self.info["app_version"] = self.pyppy.get_config_attr('version') # Initial values self.info["app_name"] = kwargs.get( 'app_name', os.environ.get('GB_APP_NAME', self.pyppy.config['app_name'])) self.info["pkg_name"] = kwargs.get( 'pkg_name', os.environ.get('GB_PKG_NAME', self.pyppy.get_config_attr('packages'))) self.info["script_path"] = kwargs.get( 'script_path', os.environ.get('GB_SCRIPT', self.find_script())) pl_sys = platform.system().lower() self.info["operating_system"] = pl_sys if pl_sys != 'darwin' else 'osx' self.info["machine_type"] = platform.machine().lower() self.run_info()