简体   繁体   English

Flask 蓝图为 package | 安装工具

[英]Flask blueprint as a package | setuptools

I have a flask blueprint that I'm pushing to GitHub as a separate repo.我有一个 flask 蓝图,我将其作为单独的回购推送到 GitHub。 Then I install it via然后我通过安装它

pip install git@httpps://.... pip 安装 git@httpps://....

I get the package in my venv and it's all good I can import code etc.我在我的 venv 中得到了 package,这一切都很好,我可以导入代码等。

However there is an issue.但是有一个问题。 I don't see HTML/CSS/js files that are visible on GitHub.我没有看到 GitHub 上可见的 HTML/CSS/js 文件。

I found similar errors on here but the solutions that I tested don't work.我在这里发现了类似的错误,但我测试的解决方案不起作用。 Maybe there is an error in my folder structure (if so how to do it correctly? flask needs to see them too) maybe it's something different.也许我的文件夹结构有错误(如果是这样如何正确执行?flask 也需要查看它们)也许是不同的东西。

Here is my folder structure all of the folders have init .py这是我的文件夹结构,所有文件夹都有init .py

src
   updater
      SWupdater
      templates
        static
           js
             *.js
           css
             external_css
                  *.css
             *.css
           images
            *.jpg 
        SWupdater
            *.html

This is my setup without names/descriptions etc这是我的设置,没有名称/描述等

setuptools.setup(
    packages=setuptools.find_packages(where='src', exclude=["*.tests", "*.tests.*"]),
    package_dir={"updater": "src/updater"},
    zip_safe=False,
    include_package_data=True,
    install_requires=[],
    classifiers=[],
    python_requires='>=3.7'
)

What I've tried to do in my setup.py我在 setup.py 中尝试做的事情

-added package_data - 添加了 package_data

package_data={"updater/SWupdater/templates": ["SWUpdater/*"],
               "updater/SWupdater/templates/static":["css/*", "images/*", "js/*"]},

-added include_package_data - 添加了 include_package_data

include_package_data=True,

-a combination of package_data/include -line order combination (one higher one lower) - 组合 package_data/include - 行顺序组合(高一低)

I do not build this package, I only push it to GitHub and install it into my venv我不构建这个 package,我只将它推送到 GitHub 并将其安装到我的 venv

For anyone looking for answers.对于任何寻找答案的人。

  • you don't need package_data in setup.py你不需要 setup.py 中的 package_data
  • you need manifest.in你需要 manifest.in

In my case I've created manifest with this line在我的例子中,我用这一行创建了清单

recursive-include src\updater\SWupdater\templates\* .

to include all html/css/js files包含所有 html/css/js 文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM