mirror of
https://github.com/emmett-framework/granian.git
synced 2025-12-23 05:36:49 +00:00
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
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:
parent
a5ff7910cd
commit
84feb42e8b
2 changed files with 9 additions and 1 deletions
|
|
@ -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'
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue