32

I am trying to create a Python package, and I have a directory structure like this:

mypkg/
├── __init__.py
├── module1
│   ├── x.py
│   ├── y.py
│   └── z.txt
└── module2
    ├── a.py
    └── b.py

Then I added all the files in MANIFEST.in and when I check the created archive, it had all the files.

When I do python setup.py install in the dist-packages/mypkg/module1. I see only the Python files and not z.txt.

I have z.txt in both MANIFEST.in and setup.py:

setup (
    packages = [
        'mypkg',
        'mypkg.module1',
        'mypkg.module2',
    ],
    package_data = {
        'mypkg': ['module1/z.txt']
    },
    include_package_data = True, 
    ...
)

I tried adding the file as data_files as well but that created a directory in /usr/local. I want to keep it inside the source code directory as the code uses that data.

I have read the posts listed below but I keep getting confused about what is the right way to keep z.txt in the right location after setup.py install.

jnns
  • 5,148
  • 4
  • 47
  • 74
Sourabh
  • 1,091
  • 11
  • 13
  • Update: It got fixed when I started using setuptools instead of distutils.core. I think it was some problem with distutils not agreeing with manifest while setuptools worked without any changes in the code. I recommend using setuptools in the future. Using the link [here][1]. [1]: http://peak.telecommunity.com/DevCenter/setuptools#developer-s-guide – Sourabh Jan 20 '13 at 08:21
  • Minimal runnable published working example at: https://stackoverflow.com/questions/3596979/manifest-in-ignored-on-python-setup-py-install-no-data-files-installed/60735402#60735402 – Ciro Santilli OurBigBook.com Mar 18 '20 at 07:54

2 Answers2

14

Try using setuptools instead of distutils.

CJH
  • 1,295
  • 1
  • 11
  • 15
2

Update: It got fixed when I started using setuptools instead of distutils.core. I think it was some problem with distutils not agreeing with manifest while setuptools worked without any changes in the code. I recommend using setuptools in the future. Using the link here : setup tools- developers guide

Sourabh
  • 1,091
  • 11
  • 13