i packaging python 3 application in executable want distribute different environments: dev, test, staging , production.
while binaries same environments (within same release of course) keeping external config file in each environment set host names, environment, credentials etc.
this script parsing config file:
import argparse import configparser import os import sys parser = argparse.argumentparser(description = 'my awesome python app') parser.add_argument('-c', '--config', default='/etc/myapp.conf', help='configuration file path.') args = parser.parse_args() config_file = args.config if not os.path.isfile(config_file): raise ioerror('could not read config file: {}' .format(config_file)) config = configparser.configparser() config.read(config_file) the problem when run executable, python throws exception set because not finding config file, if exists , user running app has permissions read it.
if run uncompiled script, runs expected.
is issue cxfreeze? if yes, how can read config file without hardcoding in cxfreeze options, since there no guarantee file have same path in hosts?
thanks,
gm
Comments
Post a Comment