tmporaries
tmporaries

Reputation: 1553

Cannot include non-python files with setup.py

I read a lot of answers on this question, but no solution works for me.

Project layout:

generators_data\
    en_family_names.txt
    en_female_names.txt
__init__.py
generators.py
setup.py

I want include "generators_data" with it's content into installation. My setup.py:

from distutils.core import setup

setup(name='generators',
      version='1.0',
      package_data={'generators': ['generators_data/*']}
      )

I tried

python setup.py install

got

running install
running build
running install_egg_info
Removing c:\Python27\Lib\site-packages\generators-1.0-py2.7.egg-info
Writing c:\Python27\Lib\site-packages\generators-1.0-py2.7.egg-info

but generators_data directory doesn't appear in "c:\Python27\Lib\site-packages\". Why?

Upvotes: 2

Views: 1561

Answers (1)

merwok
merwok

Reputation: 6907

The code you posted contains two issues: setup.py should be sibling to the package you want to distribute, not inside it, and you need to list packages in setup.py.

Try with this this layout:

generators/       # project root, the directory you get from git clone or equivalent
    setup.py
    generators/   # Python package
        __init__.py
        # other modules
        generators_data/
            names.txt

And this setup.py:

setup(name='generators',
      version='1.0',
      packages=['generators'],
      package_data={'generators': ['generators_data/*']},
)

Upvotes: 2

Related Questions