Include the current working directory in PYTHONPATH#152
Include the current working directory in PYTHONPATH#152ritchie46 merged 3 commits intopola-rs:mainfrom
Conversation
|
Just out of curiosity, when did this trigger a problem? I've never encountered one whilst running |
|
I think the issue is likely a bug in either CPython that is due to some subtle interplay with build options. I reported python/cpython#107353 a couple of years ago, and the problem appears to be similar, but in this case occurs even without PYTHONPATH set (hence why I am suspecting build options). If I ❯ python -c "import sys; print('' in sys.path)"
True # Sometimes this is False
One possible root cause is that I see different results for |
|
It might be (@vyasr) that your environment has |
|
@wence- good call! It didn't occur to me to check that. It seems like if run directly, but it does not work if I change the |
|
@ritchie46 how would you like me to proceed here? If I do figure out how to get PYTHONSAFEPATH unset, would you be open to adding that into the benchmark suite? If so, any ideas on what I might be doing wrong above? |
Including This patch is sufficient for me (against diff --git a/Makefile b/Makefile
index 848dc31..d5304ba 100644
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,7 @@ SHELL=/bin/bash
VENV=.venv
VENV_BIN=$(VENV)/bin
+export PYTHONSAFEPATH =
.venv: ## Set up Python virtual environment and install dependencies
python3 -m venv $(VENV)
$(MAKE) install-deps |
I tested that exact diff earlier and it did not work for me. Let me test again just in case I missed something. |
|
The issue is that
|
|
Any thoughts on how best to proceed with this PR? |
|
Sorry for the delay on my part. Seeing the discussion, I agree on
Can you add a comment on why we do this on the location where we append current directory? (e.g. the PYTHONSAFEPATH discussion above). After a rebase, I think it is good to merge. |
4315473 to
4955b1b
Compare
The commands in the makefile all run via
python -m .... Such commands will not properly find the desired modules unless the current directory is on the PYTHONPATH. Furthermore, since these commands all internally launch subshells that runpython -m...(viaexecute_all) the PYTHONPATH must also be propagated to those subshells. For that, we must export.The old code wiped the PYTHONPATH. If that is still desirable, I can just set it to be the PWD instead of prepending PWD to the existing PYTHONPATH.
Split out of #146