0

I know roughly similar questions have already been asked, but I can't seem to find the solution to my particular problem (or my error!).

I am building a small Python package for myself, so I can use several functions without caring about folders and paths. For some of these functions (e.g., for interpolation), I need additional files which should also be copied when installing the package. I can't get this to work no matter what I try. I am also puzzled about how to add these files without explicitly specifying their paths once installed.

Here is the structure of my package

my_package
├── setup.py
├── README.rst
├── MANIFEST.in
├── my_package
│   ├── __init__.py
│   └── some_stuff.py
├── tables
│   ├── my_table.txt

my_Table.txt is the additional file that I need to install, so I have set my MANIFEST.in to

include README.rst
recursive-include tables *

And my setup.py looks like this (including the include_package_data=True statement)

from setuptools import setup

setup(name='my_package',
      version='0.1',
      description='Something',
      url='http://something.com',
      author='me',
      author_email='an_email',
      license='MIT',
      packages=['my_package'],
      include_package_data=True,
      zip_safe=False)

However, after running python setup.py install, I can't find my_table.txt anywhere. What am I doing wrong? Where/how are these files copied? And after installing the package, how would you get the path of my_table.txt without explicitly writing it?

Thanks a lot!

Community
  • 1
  • 1
Álvaro
  • 1,219
  • 2
  • 12
  • 20
  • I think [this answer](http://stackoverflow.com/a/3597263/353839) is the closest thing that would help. – bbayles Jan 15 '16 at 17:53

1 Answers1

1

I took the time to try your code/structure. As it is, with packages=['my_package'], it only install the content of "my_package" (the subfolder).

You could use "find_packages" in your setup.py, I made it works with your structure.

from setuptools import setup, find_packages

setup(name='my_package',
  version='0.1',
  description='Something',
  url='http://something.com',
  author='me',
  author_email='an_email',
  license='MIT',
  packages=find_packages(),
  include_package_data=True,
  zip_safe=False)

You can read more on "find_packages" here: https://pythonhosted.org/setuptools/setuptools.html#using-find-packages

Hope this help.

  • Thanks a lot for your help! I could't make it work with this structure though. I managed to make if work by changing the location of `tables` inside the `my_package` folder and specifying it in the MANIFEST.in file. Could this be a python 2-3 issue? – Álvaro Jan 16 '16 at 04:53
  • I installed python3.4 to make sure, and the file/folder structure + the code I pasted above are still working great (the result gets installed inside my python folder\lib\site-packages directory and does contain the subfolder tables, with the file my_table.txt. (whether or not I used the MANIFEST). I'm relatively new to this site but would like to be able to test with your files... Could you share them somehow? Thanks. – Olivier Painchaud Jan 19 '16 at 19:50