How do I allow a package installed with 'python setup.py install' to access external configuration files?
I am currently trying to use distutils/setuptools to install a Python package for RHEL. This Python package was originally written in such a way that it operated as a set of scripts, which needed filesystem access to a variety of configuration files, logs, etc. Now that I am trying to create an installable package out of this setup, I'm having difficulties interacting with the filesystem for the necessary files.
These files should be editable. In addition to the base question, what are the best practices for this type of behavior? I.e. what are the best practices for managing the configuration of Python packages that are installed via setuptools
or distutils
, and for these packages to interact with the filesystem. I assume there are two halves of this coin: configuring the locations for the files on the install side, and accessing the information on the code implementation side. Any advice for optimizing both of these aspects would be greatly appreciated.
Additional Information:
I essentially need to access the "config" directory, once the package is installed. The location of the 'config' directory can be anywhere (that the user has privileges to) on the filesystem, and should, in itself, be configurable before installing the package. The project looks like this:
- project/
- main/
- __init__.py
- script1.py
- script2.py
- service.py (Flask web service runner)
- ...other python files that interact with above
- config/
- sub-directory/
- sub-directory/
- config_file.ini
- sub-directory/
- sub-directory/
- ...
- ...
- sub-directory/
- logs/
- log_file.log
- main/