Home > Net >  Flask blueprint as a package | setuptools
Flask blueprint as a package | setuptools

Time:01-06

I have a flask blueprint that I'm pushing to GitHub as a separate repo. Then I install it via

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

I get the package in my venv and it's all good I can import code etc.

However there is an issue. I don't see HTML/CSS/js files that are visible on GitHub.

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.

Here is my folder structure all of the folders have 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

-added package_data

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

-added include_package_data

include_package_data=True,

-a combination of package_data/include -line order combination (one higher one lower)

I do not build this package, I only push it to GitHub and install it into my venv

CodePudding user response:

For anyone looking for answers.

  • you don't need package_data in setup.py
  • you need 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

  • Related