blob: 9c58d72e44d16e3e573c44002e73374cf78d639c [file] [log] [blame]
Phillip J. Eby069159b2006-04-18 04:05:34 +00001import distutils, os
2from setuptools import Command
3from setuptools.command.setopt import edit_config, option_base
4
5class saveopts(option_base):
6 """Save command-line options to a file"""
7
8 description = "save supplied options to setup.cfg or other config file"
9
10 def run(self):
11 dist = self.distribution
12 commands = dist.command_options.keys()
13 settings = {}
14
15 for cmd in commands:
16
17 if cmd=='saveopts':
18 continue # don't save our own options!
19
20 for opt,(src,val) in dist.get_option_dict(cmd).items():
21 if src=="command line":
22 settings.setdefault(cmd,{})[opt] = val
23
24 edit_config(self.filename, settings, self.dry_run)