2

I am writing a python module and need to install a directory along with the module. This is what my file tree looks like:

├── module
│   └── temp
│   |   └── __init.py__
|   |       file2.yaml
|   |       file.yaml
│   └── module.py
|       __init__.py
├── setup.py

As you can see, module.py is the main module with all my functions, but it needs to access what is in the temp directory. When I use setup tools to install my module locally, using pip, it installs the module.py perfectly, but it won't install the temp directory.

Here is my setup.py:

setup(name='module',
      packages=find_packages(),
      version=VERSION,
      description=DESCRIPTION,
      long_description=LONG_DESCRIPTION,
      license=LICENSE,
      author=AUTHORS,
      install_requires=[
          ],
      include_package_data=False
      )

My theory is that I need to pass something through find packages().

Side note: I am running setup.py as python setup.py bdist_wheel. To clarify, everything is working fine, my directory is just not being installed with the package.

When I go to where the package is stored, __init__.py and module.py are the only things that are installed in my module package directory.

How can I make sure that the temp directory is installed as well?

Any help is appreciated.

EDIT: My first file tree was wrong. The temp directory is inside the directory with the module.

deepballer
  • 37
  • 3
  • 1
    See [How to read a (static) file from inside a Python package?](https://stackoverflow.com/q/6028000/674039) – wim Oct 15 '20 at 01:57
  • 2
    That’s exactly what the other question describes how to do. Follow the instructions. I can see you didn’t follow those instructions because you have include_package_data=False. – wim Oct 15 '20 at 05:28
  • Thank you wim, you pointed me in the right direction. – deepballer Oct 15 '20 at 14:26

1 Answers1

0

When python install packages, the module directory will be copied to the directory like /usr/local/lib/python3.6/dist-packages/module. If you add the extra tmp directory, it may conflict with other module.
How about considering moving the tmp directory to the module directory. like this:

├── module
│   └── temp
│   |   └── __init.py__
|   |       file2.yaml
|   |       file.yaml
│   └── module.py
|       __init__.py
├── setup.py
ramwin
  • 5,803
  • 3
  • 27
  • 29
  • So sorry, my directory actually looks like that, I will update it. So to clarify, my directory looks like that, but I am still having the issue. – deepballer Oct 15 '20 at 01:59
  • 1
    Since you changed your question and moved the tmp directory to module directory. My Answer no longer fit your question. Like wim commented, https://stackoverflow.com/questions/6028000/how-to-read-a-static-file-from-inside-a-python-package is what your are looking for. – ramwin Oct 15 '20 at 02:45
  • I saw this feed, but it doesn't answer my question. I just need to install the temp directory along with everything else I install when I install my module. – deepballer Oct 15 '20 at 03:35