Patch python path on CLI for logconfig (#667)
Some checks are pending
test / linux (3.10) (push) Waiting to run
test / linux (3.11) (push) Waiting to run
test / windows (3.13) (push) Waiting to run
test / linux (3.12) (push) Waiting to run
test / linux (3.13) (push) Waiting to run
test / linux (3.14) (push) Waiting to run
test / linux (3.9) (push) Waiting to run
test / linux (pypy3.11) (push) Waiting to run
test / linux (3.13t) (push) Waiting to run
test / linux (3.14t) (push) Waiting to run
test / macos (3.10) (push) Waiting to run
test / macos (3.11) (push) Waiting to run
test / macos (3.12) (push) Waiting to run
test / macos (3.13) (push) Waiting to run
test / macos (3.14) (push) Waiting to run
test / macos (3.14t) (push) Waiting to run
test / windows (3.11) (push) Waiting to run
test / windows (3.12) (push) Waiting to run
test / windows (3.13t) (push) Waiting to run
test / windows (3.14) (push) Waiting to run
test / windows (3.14t) (push) Waiting to run
test / macos (3.9) (push) Waiting to run
test / macos (3.13t) (push) Waiting to run
test / windows (3.10) (push) Waiting to run
test / windows (3.9) (push) Waiting to run

This commit is contained in:
Giovanni Barillari 2025-08-25 19:41:19 +02:00 committed by GitHub
parent a5ff7910cd
commit 84feb42e8b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View file

@ -9,6 +9,10 @@ from typing import Callable, List, Optional
from ._imports import dotenv
def patch_pypath(wd: Optional[Path] = None):
sys.path.insert(0, str(wd.resolve()) if wd else '')
def get_import_components(path: str) -> List[Optional[str]]:
return (re.split(r':(?![\\/])', path, maxsplit=1) + [None])[:2]
@ -54,7 +58,7 @@ def load_module(module_name: str, raise_on_failure: bool = True) -> Optional[Mod
def load_target(target: str, wd: Optional[Path] = None, factory: bool = False) -> Callable[..., None]:
sys.path.insert(0, str(wd.resolve()) if wd else '')
patch_pypath(wd)
path, name = get_import_components(target)
path = prepare_import(path) if path else None
name = name or 'app'

View file

@ -458,6 +458,10 @@ def cli(
print('Unable to parse provided logging config.')
raise click.exceptions.Exit(1)
from ._internal import patch_pypath
patch_pypath(working_dir)
server = Server(
app,
address=host,