Skip to content

Allow overriding configuration options #115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 25 additions & 15 deletions nsist/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,12 +502,31 @@ def run(self, makensis=True):
if not exitcode:
logger.info('Installer written to %s', pjoin(self.build_dir, self.installer_name))

def main(argv=None):
"""Make an installer from the command line.

This parses command line arguments and a config file, and calls
:func:`all_steps` with the extracted information.
def run_installer_builder(config_file, makensis=True, **kwargs):
"""Make an installer

:param str config_file: Path to the configuration file
:param bool makensis: Call makensis or not
:param **kwargs: Override options specified in the configuration file

This instantiates an :class:`InstallerBuilder` using the options set in the
configuration file. Keyword arguments can be specified to override some of
these options. Finally :meth:`InstallerBuilder.run` is called.
"""
dirname, config_file = os.path.split(config_file)
if dirname:
os.chdir(dirname)

from . import configreader
cfg = configreader.read_and_validate(config_file)
args = get_installer_builder_args(cfg)
args.update(kwargs)
InstallerBuilder(**args).run(makensis=makensis)


def main(argv=None):
"""Make an installer from the command line."""
logger.setLevel(logging.INFO)
logger.handlers = [logging.StreamHandler()]

Expand All @@ -519,22 +538,13 @@ def main(argv=None):
)
options = argp.parse_args(argv)

dirname, config_file = os.path.split(options.config_file)
if dirname:
os.chdir(dirname)

from . import configreader
try:
cfg = configreader.read_and_validate(config_file)
run_installer_builder(options.config_file,
makensis=(not options.no_makensis))
except configreader.InvalidConfig as e:
logger.error('Error parsing configuration file:')
logger.error(str(e))
sys.exit(1)

args = get_installer_builder_args(cfg)

try:
InstallerBuilder(**args).run(makensis=(not options.no_makensis))
except InputError as e:
logger.error("Error in config values:")
logger.error(str(e))
Expand Down