dslosky
dslosky

Reputation: 1067

Packing a Python web app for pip distribution

I'm running into an issue with my view directory that contains many subdirectories and non-python files (.html, .css, .ts, .js). Here is a diagram for you...

- 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

These files need to maintain their directory structure in order to be served correctly. I've looked into using MANIFEST.in and including the documents as data files, but neither of these seem like real solutions.

My best idea is to zip the directory before creating my distribution package, then unzip it during the pip install... somehow. Any better ideas?

Upvotes: 2

Views: 108

Answers (1)

Flurin
Flurin

Reputation: 679

I have a web app with a similar structure. You can find the code on Github.

The following MANIFEST.IN and setup.py worked for me:

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,
      ...
)

I used ... to mark that the actual setup.py contains a bit more but this should not be relevant here.

Upvotes: 2

Related Questions