fromsetuptools.command.setoptimportedit_config,option_baseclasssaveopts(option_base):"""Save command-line options to a file"""description="save supplied options to setup.cfg or other config file"defrun(self):dist=self.distributionsettings={}forcmdindist.command_options:ifcmd=='saveopts':continue# don't save our own options!
foropt, (src,val) indist.get_option_dict(cmd).items():ifsrc=="command line":settings.setdefault(cmd,{})[opt]=valedit_config(self.filename,settings,self.dry_run)