I am trying to create one distributable package in Python.So in my package I need to access a file from the root of the project for which my package is installed inside. I am trying to do that like this,
Path(__file__).parents[1] / Path(self.file_name)
But is is just returning '.' which means it indicating my package's root folder. For example my package directory structure looks like this,
mypackage
- lib
- myfile.py
- __init__.py
So when I convert that package to installable wheel format I can install that using pip command.If now I create project like this,
myproject
- __init__.py
- config.json
- main.py
- venv
Now see I want to use/install mypackage
in myproject
. All the packages are installed inside the venv
folder. So now my question is how I can access the config.json
file inside my mypackage
. So to do that I require to access the root folder of myproject
.I hope this is clear to understand.
Any help would be appreciated.