You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not entirely sure what the specific root cause of this issue, but I feel like the behavior here is not quite right.
So basic setup, there is a virtualenv located at /opt/warehouse, and inside of that a directory called /opt/warehouse/src which has a git checkout of the Warehouse code, which is added to sys.path using PYTHONPATH.
Now, it just so happens that when inside of a virtual environment, the root of the virtual environment is set to be the "data" path (sysconfig.get_paths()["data"]). This means that /opt/warehouse gets detected as a "system path" by #40, and because the project files are in an unrelated directory within that directory, it detects the entire project as an installed project and doesn't monitor it.
It seems to me, the easiest fix would be to not use all of the paths returned by sysconfig.get_paths(). There are 8 keys that can exist in the dictionary returned by that API:
data
include
platinclude
platlib
platstdlib
purelib
scripts
stdlib
It seems to me, like installed packages are not going to exist in data, include, platinclude, and maybescripts, so it would make sense to exclude those directories from the paths you get from sysconfig.get_paths().
Another option would be, instead of doing a simple startswith, is to figure out which sys.path entry this file is imported from (by comparing the filename to every entry in sys.path, and making it "owned" by whichever sys.pathentry is longer *and* is a prefix match), and then only ignore files whosesys.path`` entry matches on the system paths.
The text was updated successfully, but these errors were encountered:
I hadn't considered the case that the virtualenv would be at the root (something like python3 -m venv .) which is certainly a valid configuration. I'll update to only include purelib, stdlib, platlib and platstdlib. Do you see any others I should add?
I'm not entirely sure what the specific root cause of this issue, but I feel like the behavior here is not quite right.
So basic setup, there is a virtualenv located at
/opt/warehouse
, and inside of that a directory called/opt/warehouse/src
which has a git checkout of the Warehouse code, which is added tosys.path
usingPYTHONPATH
.Now, it just so happens that when inside of a virtual environment, the root of the virtual environment is set to be the "data" path (
sysconfig.get_paths()["data"]
). This means that/opt/warehouse
gets detected as a "system path" by #40, and because the project files are in an unrelated directory within that directory, it detects the entire project as an installed project and doesn't monitor it.It seems to me, the easiest fix would be to not use all of the paths returned by
sysconfig.get_paths()
. There are 8 keys that can exist in the dictionary returned by that API:It seems to me, like installed packages are not going to exist in
data
,include
,platinclude
, and maybescripts
, so it would make sense to exclude those directories from the paths you get fromsysconfig.get_paths()
.Another option would be, instead of doing a simple startswith, is to figure out which
sys.path
entry this file is imported from (by comparing the filename to every entry insys.path, and making it "owned" by whichever
sys.pathentry is longer *and* is a prefix match), and then only ignore files whose
sys.path`` entry matches on the system paths.The text was updated successfully, but these errors were encountered: