0

I created an pip module and installed the module in jupyter notebook.

There is one function that is not working because of the following.

I created a pip module and within this module I also have one text file with some information that is needed for the toolbox.

But when I create the pypi module, this txt file is not converted into the python wheel and now after installing this txt file cannot be found.

Is there a way to include a txt file within this module, or do I need to convert this txt file into another format (.csv?).

Rauph
  • 13
  • 1
  • 2
  • Share your function which isn't working – FortyTwo Mar 26 '19 at 08:23
  • 2
    Possible duplicate of [How to include package data with setuptools/distribute?](https://stackoverflow.com/questions/7522250/how-to-include-package-data-with-setuptools-distribute) – AzMoo Mar 26 '19 at 08:26
  • 1
    Possible duplicate of [How include static files to setuptools - python package](https://stackoverflow.com/questions/11848030/how-include-static-files-to-setuptools-python-package) – SuperShoot Mar 26 '19 at 08:27

1 Answers1

9

You're probably calling setuptools.setup in your setup.py file to package your code. The logic by which setup decides which files to include in the wheel is, while it mostly works out of the box, a little complicated.

In your case, it should be enough to add the file path of your .csv to a package_data-list:

from setuptools import setup

setup(
    ...                                      # "name" and stuff
    packages=['mypkg'],                      # root folder of your package
    package_dir={'mypkg': 'src/mypkg'},      # directory which contains the python code
    package_data={'mypkg': ['data/*.csv']},  # directory which contains your csvs
)

Concerning the use MANIFEST, not package_data argument the doc pages talk about, since you use wheel to build the package you should be fine. wheel uses bdist by default, which works well with package_data.

Arne
  • 17,706
  • 5
  • 83
  • 99