Closed dilawar closed 3 years ago
Hi @dilawar - thanks for flagging this. I've just merged #118, which uses the __file__
builtin (when available) to construct a directory in the same location as the script. When that builtin is not available, we default to what pathlib.Path.cwd()
provides.
We don't expect /usr/bin
to be the default location for data; our intention was to create directories in the same folder as the client script. We do expect that client code calling this library will be run from a user-writable location, which I think is reasonable.
My testing indicates that argv[0]
picks up the script location rather than the binary location. As an example, consider this following test script (test.py
), located in my home directory:
from sys import argv
from pathlib import Path
print(argv[0])
print(Path(argv[0]).resolve().parent)
try:
print(Path(__file__).resolve().parent)
except NameError:
print("__file__ variable not available")
print(Path.cwd())
When I run /usr/bin/python3 test.py
, I get:
test.py
/Users/satej
/Users/satej
/Users/satej
Does that make sense? Let me know if I've misunderstood something or have assumed something too specific about users' set ups.
https://github.com/openjournals/joss-reviews/issues/3464
Permission issues at the very first run.
After
pip3 install epimargin
on a Linux box. I ran the following snippets in python console.I hit by permission issues when application tried to create default directory. Is is necessary to use
/usr/bin/
to save data. In line 44 below, may beroot
can be set to someplace in user's$HOME
?On Linux and OSX, https://github.com/COVID-IWG/epimargin /blob/1a8094ae8173a9f09f2efc5b872ac56d67a86c6f/epimargin/utils.py#L18 most likely to return
/usr/bin
sinceargv0
is/usr/bin/python3
.Another solution is to check if the
cwd()
is writable by the user. If not, default to a user-writable directory in user's$HOME
? If not, the application needs to be run as root orsudo
user which is not advisable.