Configuration best practices

Hi all

I am working on a project that will require several user editable entries in a TOML file. Currently the TOML file is stored at the root level of the package and I am handling all the edits in the app.

Is there a defined best practice for storing config files that can be edited by the user? Any links or comments would be appreciated.

Generally you’ll want the user editable file location to be
somewhere outside the package directory so that uninstallation,
reinstallation or upgrading doesn’t blow away their changes. What
you can do is have your application, when run, copy the default
config your package ships to the expected location if no file exists
there yet, otherwise leave it untouched.

Alternatively you can display instructions for the user and/or
supply a separate tool to do the config copying, since they may want
the file to be restricted in such a way that it’s read-only for your
application’s process, which makes runtime copying into place
otherwise challenging (requiring privilege elevation request
mechanisms which vary widely between platforms).

I recommend the platformdirs library to help you find appropriate locations on disk where to store such runtime files.

That is a good idea. Thanks

I will check that out.