When using pyproject.toml setuptools how can I dynamically assure that my binary finds its config enclosed in the same directory as the python code?
After pip install files are located:
:
c:\dist\venvs\ranchercli\lib\site-packages\ranchercli\ranchercli-projects.json
c:\dist\venvs\ranchercli\lib\site-packages\ranchercli\ranchercli.py
c:\dist\venvs\ranchercli\scripts\ranchercli.exe
:
But when I run:
# same dir:
ranchercli.exe --ns='keycloak' --env=prod --refresh
20240322095209.115|ERROR|C:\dist\venvs\ranchercli\Lib\site-packages\ranchercli\ranchercli.py:89|--projectfile=./ranchercli-projects.json not found
# relative:
20240322101246.345|ERROR|C:\dist\venvs\ranchercli\Lib\site-packages\ranchercli\ranchercli.py:89|--projectfile=../lib/site-packages/ranchercli/ranchercli-projects.json not found
I only got full path working but the path changes with any install:
C:\\dist\\venvs\\ranchercli\\Lib\\site-packages\\ranchercli\\ranchercli-projects.json
A workaround like @phd suggests, is to get the path from
__file__with pathlibBut I need to do this for all files, Would like to have a generic way in setuptools.