0

When I'm developing a project, and a script script.py needs access to some data file data.txt, I will usually write something like this:

path = Path(__file__).parent.parent / "resources" / "text" / "data.txt"

I then commit data.txt to source control, and when people clone the repo, everything will work. This works nicely until the project matures to the point that I want to write a setup.py to let people just install it straight from the repo with pip. At this point, I can't figure out how to tell setup.py to just put the resources folder in the "same place" in the package as it is in my repository. I've looked into package_data, data_files and MANIFEST.in but I haven't been able to get any solution working. How can I do this?

Jack M
  • 4,769
  • 6
  • 43
  • 67
  • 1
    Does this answer your question? [Managing resources in a Python project](https://stackoverflow.com/questions/1395593/managing-resources-in-a-python-project) – Sören May 21 '22 at 11:16
  • @Sören No. It's still not clear from those answers how to access the file from my code, given only its relative path. – Jack M May 21 '22 at 11:31

0 Answers0