Getting Directory of Command Line Entry Point For Packages

Abdur-Rahmaan Janhangeer arj.python at gmail.com
Sat Nov 13 01:23:57 EST 2021


Greetings,

Well since sometimes i have this: https://github.com/shopyo/shopyo
Old versions worked as we are using it for FlaskCon
<https://github.com/flaskcon/traveller>, even newer versions
until sometimes ago.

shopyo has a copy of the project which is a flask app in site-packages.
upon using shopyo new, it creates a copy of the project in the current
folder
then on running say shopyo run, it just passes commandline args flask run
under the hood

Only thing is that os.getcwd is giving the path of site-packages and not
the directory from
which the command is run from. See the run command's source here:
https://github.com/shopyo/shopyo/blob/19dc2ee03ff0a6a0dca3237f80a11478ee2dbe46/shopyo/api/cmd_helper.py#L313

Same goes for other commands. I wanted to know how to get the directory
from which the
command is called from. Thanks


Else i assume you are the author of this article
<https://python-history.blogspot.com/2009/04/and-snake-attacks.html> as i
was compiling a list of articles
<https://www.pythonkitchen.com/python-engineering-articles/>
and guess that it might be.

Kind Regards,

Abdur-Rahmaan Janhangeer
about <https://compileralchemy.github.io/> | blog
<https://www.pythonkitchen.com>
github <https://github.com/Abdur-RahmaanJ>
Mauritius


More information about the Python-list mailing list