Skip to content

Commit

Permalink
fix: Make sitecustomize.py respect the PDM_PROJECT_MAX_DEPTH envi…
Browse files Browse the repository at this point in the history
…ronment variable. Resolves #1413. (#1480)

* Make sitecustomize.py respect PDM_PROJECT_MAX_DEPTH

* Add a news entry
  • Loading branch information
xulongwu4 authored Nov 1, 2022
1 parent b32030d commit c5dd305
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions news/1471.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make `sitecustomize.py` respect the `PDM_PROJECT_MAX_DEPTH` environment variable
4 changes: 2 additions & 2 deletions src/pdm/pep582/sitecustomize.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import sys


def get_pypackages_path(maxdepth=5):
def get_pypackages_path():
def find_pypackage(path, version):
if not os.path.exists(path):
return None

packages_name = f"__pypackages__/{version}/lib"
for _ in range(maxdepth):
for _ in range(int(os.getenv("PDM_PROJECT_MAX_DEPTH", "5"))):
if os.path.exists(os.path.join(path, packages_name)):
return os.path.join(path, packages_name)
if os.path.dirname(path) == path:
Expand Down

0 comments on commit c5dd305

Please sign in to comment.