打包用于pip分发的python web应用程序

2024-09-28 20:16:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我的视图目录遇到了一个问题,它包含许多子目录和非python文件(.html, .css, .ts, .js)。这是给你的图表

- 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期间解压缩它。。。不知怎么的。有更好的主意吗


Tags: 文件py目录视图webappinitmain
1条回答
网友
1楼 · 发布于 2024-09-28 20:16:23

我有一个类似结构的web应用程序。您可以在Github上找到代码

以下MANIFEST.IN和setup.py对我有效:

清单。在中:

recursive-include omxremote/static *

设置.py

#!/usr/bin/env python

from setuptools import setup

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

我使用...来标记实际setup.py包含了更多的内容,但这在这里应该不相关

相关问题 更多 >