As promised, here is a patch containing the changes I made while packaging PyScrabble for Debian. Initially I thought that OptionManager, ScrabbleServerFactory and ServerConsole should look for configuration files both in a system-wide location and in a user-specific location, but then I changed my mind and decided that it's enough if the client options and the server configuration can be in separate places, with the server log (pyscrabble.log, not server_history) and database further separated. So the patch does the following:
- Moves getLocaleDirs(), getResourceDirs(), getDataFiles(), and the distutils command subclasses InstallScripts and InstallLib from dist.py to setup.py. They are only used by setup.py at installation time so I can't see why they would be needed outside it.
- Defines class Install(distutils.command.install) in order to add three more options to setup.py: --logdir, --dbdir, and --confdir. InstallLib.generate_template() writes these to __installed__.py together with RESOURCE_PREFIX (hint: use %r instead of '%s' to get a representation rather than a string presentation).
- Defines class InstallData(distutils.command.install) because fix_path() needs the --confdir option value (instead of dist.get_app_data_dir()).
- Adds a resource "serverconfig" which ScrabbleServerFactory and ServerConsole looks for their config in. Doesn't use ResourceManager to find the location of the server DB or log - what's the point?
At least one problem remains: --confdir, --logdir, and --dbdir all have to be supplied currently, otherwise SERVER_CONFIG_DIR. SERVER_LOG_DIR, and SERVER_DB_DIR are set to None in __installed__.py, and there is no check for that in dist.py. Some default should be provided, either in setup.py or in dist.py, or both.