0

I have the following files:

setup.py
problems/
    __init__.py
    sometimes_included/
        file.txt

__init__.py simply contains:

import os
with open(os.path.join(os.path.join(os.path.dirname(__file__), "sometimes_included"), "file.txt")) as f:
    print(f.read())

And file.txt is just some dummy text.

The file is in a repo at https://github.com/ysangkok/packaging-problems

When I pip3 install https://github.com/ysangkok/packaging-problems/archive/master.zip

and then python3 -c 'import problems' it doesn't work, (the txt file was not installed).

But if I clone the git repo and python3 setup.py install --user, it works.

How can I achieve consistent behaviour without listing problems/sometimes_included as a package in setup.py. This directory is not a package, it shouldn't need a __init__.py. And given that it works when not using wheels, I am wondering if there is a way.

Janus Troelsen
  • 20,267
  • 14
  • 135
  • 196

1 Answers1

0

Create a file MANIFEST.in with include problems/sometimes_included/file.txt

joeforker
  • 40,459
  • 37
  • 151
  • 246
  • That would ensure the file is included in the sdist but not in the wheel, and the wheel is what pip uses. – jwodder Jul 24 '18 at 14:47
  • 1
    It's seems like this is not necessary. If I change `package_data` to reference `sometimes_included/file.txt` instead of `problems/sometimes_included/file.txt`, I can install using wheels, or the old way. – Janus Troelsen Jul 24 '18 at 14:48
  • I tested it on his repository and it included the file in the wheel. – joeforker Jul 24 '18 at 14:48