2013-03-29 59 views
0

将Python应用程序作为rpm/deb软件包安装到系统时,如何构建python应用程序的最佳实践是什么? 应用程序代码主要是用Python编写的,并且有一些shell脚本,配置文件和日志文件。Python应用程序目录结构(Linux)

我在想如下的结构。

  • 何处放Python包?
  • 我需要配置应用程序的配置文件,但它会被Python包使用。在哪里把配置文件?

/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 

回答

1

你可以把在主目录中的配置文件,许多应用程序做到这一点(如bash中,VIM ...)

+0

是的,这也可以,我猜。 – user921176

0

把python代码放到标准的python dir中是最好的(例如/usr/local/lib/pythonX.Y/site-packages)。 不幸的是,我有要求将源代码放入应用程序目录,所以我会把它放在我认为是第二好的地方: /opt/.../app_name-1.0.0/lib/python/app_name/

和配置文件去等/

好了,我不知道这是如何符合标准,但似乎对我不够好。