Search code examples
pythoninstallationpackagedir

Python application directory strucuture (Linux)


What is the best practice to structure the python application when installed to the system as a rpm/deb package? The app code is mostly written in Python, and there are some shell scripts, configuration files and log files.

I was thinking to have the structure as below.

  • Where to put the Python package?
  • I need to have the config file for the app, but it would be used by the Python package. Where to put the config file?

/opt/.../app_name-1.0.0/

                  bin/
                      /*Here would be few shell scripts I need*/
                      shell_script_1.sh
                      shell_script_2.sh

                   var/
                       log/
                          /* Log files */
                          app_name.log
                       notifications/
                                    /* notifications, generated by app,
                                       temporarily kept */
                                    alert_1.tmp
                                    alert_2.tmp 

                   etc/
                       /*python package configuration*/
                       /*is it better to put this in package dir?*/
                       app_name.config 

                   app_name/
                           /*Python package, the main content*/
                            __init__.py
                            app_name.py
                            a.py
                            b.py
                            config_file_reader.py

                            subpackage_1/                  
                                          __init__.py
                                          c.py
                            subpackage_2/                  
                                          __init__.py
                                          d.py

Solution

  • You could put the config file in the home directory, many applications do this (eg bash, vim...)