Skip to content

Commit cb5c07d

Browse files
committed
fix: merge local poetry.toml configuration in PoetryPythonPathProvider if available
1 parent 472bd04 commit cb5c07d

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/poetry/utils/env/python/providers.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import contextlib
34
import dataclasses
45
import shutil
56
import sysconfig
@@ -12,6 +13,7 @@
1213
from findpython.providers.path import PathProvider
1314

1415
from poetry.config.config import Config
16+
from poetry.toml import TOMLFile
1517
from poetry.utils._compat import WINDOWS
1618

1719

@@ -43,7 +45,19 @@ def find_python_by_name(cls, name: str) -> findpython.PythonVersion | None:
4345
class PoetryPythonPathProvider(PathProvider): # type: ignore[misc]
4446
@classmethod
4547
def base_installation_dir(cls) -> Path:
46-
return Config.create().python_installation_dir
48+
from poetry.factory import Factory
49+
50+
config = Config.create()
51+
52+
# Let's check if there is a local config file.
53+
with contextlib.suppress(RuntimeError):
54+
pyproject = Factory.locate()
55+
56+
local_config_file = TOMLFile(pyproject.parent / "poetry.toml")
57+
if local_config_file.exists():
58+
config.merge(local_config_file.read())
59+
60+
return config.python_installation_dir
4761

4862
@classmethod
4963
def installation_dir(cls, version: Version, implementation: str) -> Path:

0 commit comments

Comments
 (0)