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
As one can see, when I ran python3.7 directly, I don't get the __pypackages__ folder in my sys.path. However, when I ran pdm run python3.7, __pypackages__ is in my sys.path.
#645 made the project's max depth a configurable parameter. This works well when I invoke the python interpreter with pdm run python3. However, when I enabled PEP582 globally and then ran python3, I found that the project depth is still at its default value (5). This is due to pep582/sitecustomize.py does not take the configured value of project_max_depth.
Expected behavior
I expect the project_max_depth is respected when I enable PEP582 globally.
Environment Information
# Paste the output of `pdm info && pdm info --env` below:
$ pdm info
PDM version:
2.1.4
Python Interpreter:
/usr/bin/python3 (3.10)
Project Root:
/home/oulongwu/tmp/project
Project Packages:
/home/oulongwu/tmp/project/__pypackages__/3.10
$ pdm info --env
{
"implementation_name": "cpython",
"implementation_version": "3.10.6",
"os_name": "posix",
"platform_machine": "x86_64",
"platform_release": "5.15.68-218.current",
"platform_system": "Linux",
"platform_version": "#1 SMP PREEMPT Sat Sep 17 01:51:42 UTC 2022",
"python_full_version": "3.10.6",
"platform_python_implementation": "CPython",
"python_version": "3.10",
"sys_platform": "linux"
}
The text was updated successfully, but these errors were encountered:
This is just for convenience, the original specification of PEP 582 doesn't even allow looking for the parent directories. Moreover, the PDM configuration can't be easily passed to the Python interpreter.
Therefore, stick to pdm run if the depth exceeds 5. We will not improve this, unless the PEP 582 is revised to suggest so.
I think it sounds fair that it is not easy to pass PDM config to the python interpreter. However, I do have two suggestions:
Since PDM will read the PROJECT_MAX_DEPTH environment variable, can we let the sitecustomize.py read the same environment variable so that there is one way to sync the maximum depth between the two?
If the above is still impossible, can we set the default depth in sitecustomize.py to a larger value so that it is less likely that people will run into this issue. After all, 5 is a really low value here, and I believe there is a decent chance that a project has more than 5 levels of sub folders.
Make sure you run commands with
-v
flag before pasting the output.Steps to reproduce
$ mkdir -p project/1/2/3/4/5 $ cd project $ pdm init
I chose python3.7 as the interpreter for this demonstration.
PEP582
is enabled globallyproject_max_depth
is set to a big valueI set
project_max_depth
to 20.sys.path
Actual behavior
As one can see, when I ran
python3.7
directly, I don't get the__pypackages__
folder in mysys.path
. However, when I ranpdm run python3.7
,__pypackages__
is in mysys.path
.#645 made the project's max depth a configurable parameter. This works well when I invoke the python interpreter with
pdm run python3
. However, when I enabled PEP582 globally and then ranpython3
, I found that the project depth is still at its default value (5). This is due topep582/sitecustomize.py
does not take the configured value ofproject_max_depth
.Expected behavior
I expect the project_max_depth is respected when I enable PEP582 globally.
Environment Information
The text was updated successfully, but these errors were encountered: