pistacchio
pistacchio

Reputation: 58863

Include static files in installed directory

I have the following directory structure:

/mypackage
    __init__.py
    setup.py
    code.py
    MANIFEST.in
    /static
        app.js

In setup.py I've tried any combination of MANIFEST.in, data_files, package_data, include_package_data=True.

I'm able to make the setup include static/app.js in the .tar.gz file generated by running python setup.py sdist, but I'm not able in any way to get pip install to actually distribute the static files in the installed directory.

All I want is basically to replicate the source structure into the installed directory.

The closes I could get is to have the setup to add a static directory into the root of site_packages as if the static files were another package. In short, I want to get the following structure into site_packages

/site_packages
    /mypackage
        __init__.py
        code.py
        /static
            app.js

Upvotes: 0

Views: 467

Answers (1)

phd
phd

Reputation: 94397

Your developemt directory structure is wrong. It must be the same as installed package:

/mypackage
    setup.py
    MANIFEST.in
    /mypackage
        __init__.py
        code.py
        /static
            app.js

setup.py:

setup (
    packages = ['mypackage'],
    package_data = {
        'mypackage': ['static/app.js']
    },
    ...
)

Now generate distributions: python.setup.py sdist bdist_wheel

Upvotes: 2

Related Questions