0

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
user921176
  • 91
  • 1
  • 12

2 Answers2

1

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

xuanji
  • 5,007
  • 2
  • 26
  • 35
0

Putting python code to standard python dir would be the best.(e.g. /usr/local/lib/pythonX.Y/site-packages). Unfortunately I have the requirement to put the source insde tha app dir, so I will put to what I think is the second best place: /opt/.../app_name-1.0.0/lib/python/app_name/

and config file goes to etc/

Well, I am not sure how this conforms to standard, but seemingly good enough for me.

user921176
  • 91
  • 1
  • 12