Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include package sub-folders in my project distribution?

I have a project with this structure:

SomeProject/
    bin/
    CHANGES.txt
    docs/
    LICENSE.txt
    MANIFEST.in
    README.txt
    setup.py
    someproject/
        __init__.py
        location.py
        utils.py
        static/
            javascript/
                somescript.js

And a "setup.py" as follows:

#!/usr/bin/env python

import someproject
from os.path import exists
try:
    from setuptools import setup, find_packages
except ImportError:
    from distutils.core import setup, find_packages

setup(
    name='django-some-project',
    version=someproject.__version__,
    maintainer='Some maintainer',
    maintainer_email='[email protected]',
    packages=find_packages(),
    include_package_data=True,
    scripts=[],
    url='https://github.com/xxx/some-project',
    license='LICENSE',
    description='Some project description.',
    long_description=open('README.markdown').read() if exists("README.markdown") else "",
    install_requires=[
        "Django >= 1.4.0"
    ],
)

Then, when I upload it using the command:

python setup.py sdist upload

It seems ok, but there is no "static" folder with this "javascript" subfolder in the package. My "setup.py" was inspired on github.com/maraujop/django-crispy-forms that has a similar structure. Any hint on what is wrong on uploading this subfolders?

like image 494
staticdev Avatar asked Mar 27 '13 01:03

staticdev


2 Answers

You should be able to add those files to source distributions by editing the MANIFEST.in file to add a line like:

recursive-include someproject/static *.js

or just:

include someproject/static/javascript/*.js

This will be enough to get the files included in source distributions. If the setuptools include_package_data option you're using isn't enough to get the files installed, you can ask for them to be installed explicitly with something like this in your setup.py:

package_data={'someproject': ['static/javascript/*.js']},
like image 188
James Henstridge Avatar answered Sep 17 '22 11:09

James Henstridge


Use following

packages = ['.','templates','static','docs'],

package_data={'templates':['*'],'static':['*'],'docs':['*'],},
like image 21
Dadaso Zanzane Avatar answered Sep 19 '22 11:09

Dadaso Zanzane