Example project structure:
|-setup.toml
|-README.md
|-tests/...
|-data/...
|-src/
|-package1
|-package2
|-module1.py
|-package3
|-subpackage4
|-module2.py
In reality, I have many more folders and files scattered around them and I need to be able to access $ROOT/data/... from most of them. Ideally, I wouldn't have to update numerous strings across the project every time I decide to move the file from one folder to another.
I can think of a number of solutions but none of them seem clean.
For example, I could pip install -e the package and have a module at the top level (just under src/) which would import os so I would just need to add ../data/ on top of that root. Then, I would import this module in all the other py files throughout the directory structure.
I think it would do the job but it feels very clumsy, surely there is a better way?
Looked through lots of documentation for setuptools, poetry etc. but none of the tutorials cover this trivial scenario. They are mostly concerned with dependencies and publishing to PyPi.
Is this still the way to do this in 2023? Python - Get path of root project structure