2017-04-25 44 views
2

我遇到了包含許多子目錄和非python文件(.html, .css, .ts, .js)的我的視圖目錄的問題。這裏是你的圖...打包用於點分佈的Python web應用程序

- my_python_web_app 
    - __init__.py 
    - python_app 
     - __init__.py 
     - a.py 
     - few.py 
     - python.py 
     - modules.py 
    - view 
     - index.html 
     - main.css 
     - script.js 
     - web_app 
      - main_app.ts 
      - components 
       - component1 
        - component1.html 
        - component1.css 
        - component1.ts 
       - component2 
        - component2.html 
        - component2.css 
        - component2.ts 

這些文件需要維護其目錄結構,以便正確服務。我研究過使用MANIFEST.in並將文檔包含爲數據文件,但這些都不是真正的解決方案。

我最好的想法是在創建我的分發包之前壓縮目錄,然後在pip install期間將它解壓縮......不知何故。任何更好的想法?

回答

2

我有一個類似結構的web應用程序。您可以在Github上找到代碼。

以下MANIFEST.IN和setup.py爲我工作:

MANIFEST.IN

recursive-include omxremote/static *

setup.py

#!/usr/bin/env python 

from setuptools import setup 

setup(name='omxremote', 
     ... 
     packages=['omxremote'], 
     include_package_data=True, 
     zip_safe=False, 
     ... 
) 

我使用...來標記實際的se tup.py包含更多,但這不應該在這裏相關。