Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix linting issues
  • Loading branch information
DmitriyShepelev committed Oct 6, 2025
commit 4c22980ddcd864bcb80d9b89db7881cb0b8d3b0e
6 changes: 4 additions & 2 deletions clr_loader/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def get_coreclr_command_line(
*,
entry_dll: StrOrPath,
dotnet_root: Optional[StrOrPath] = None,
properties: Optional[Dict[str, str]] = None
properties: Optional[Dict[str, str]] = None,
) -> Runtime:
"""Get a CoreCLR (.NET Core) runtime instance
The returned ``DotnetCoreRuntimeCommandLine`` also acts as a mapping of the config
Expand All @@ -178,7 +178,9 @@ def get_coreclr_command_line(
if dotnet_root is None:
dotnet_root = find_dotnet_root()

impl = DotnetCoreCommandRuntime(entry_dll=_maybe_path(entry_dll), dotnet_root=dotnet_root)
impl = DotnetCoreCommandRuntime(
entry_dll=_maybe_path(entry_dll), dotnet_root=dotnet_root
)
if properties:
for key, value in properties.items():
impl[key] = value
Expand Down
20 changes: 13 additions & 7 deletions clr_loader/hostfxr.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ def info(self):
class DotnetCoreRuntime(DotnetCoreRuntimeBase):
def __init__(self, runtime_config: Path, dotnet_root: Path, **params: str):
super().__init__(dotnet_root)
self._handle = _get_handle_for_runtime_config(self._dll, self._dotnet_root, runtime_config)
self._handle = _get_handle_for_runtime_config(
self._dll, self._dotnet_root, runtime_config
)

for key, value in params.items():
self[key] = value
Expand All @@ -132,7 +134,9 @@ def __init__(self, runtime_config: Path, dotnet_root: Path, **params: str):
class DotnetCoreCommandRuntime(DotnetCoreRuntimeBase):
def __init__(self, entry_dll: Path, dotnet_root: Path, **params: str):
super().__init__(dotnet_root)
self._handle = _get_handle_for_dotnet_command_line(self._dll, self._dotnet_root, entry_dll)
self._handle = _get_handle_for_dotnet_command_line(
self._dll, self._dotnet_root, entry_dll
)

for key, value in params.items():
self[key] = value
Expand All @@ -141,7 +145,9 @@ def __init__(self, entry_dll: Path, dotnet_root: Path, **params: str):
self._version = "<undefined>"


def _get_handle_for_runtime_config(dll, dotnet_root: StrOrPath, runtime_config: StrOrPath):
def _get_handle_for_runtime_config(
dll, dotnet_root: StrOrPath, runtime_config: StrOrPath
):
params = ffi.new("hostfxr_initialize_parameters*")
params.size = ffi.sizeof("hostfxr_initialize_parameters")
# params.host_path = ffi.new("char_t[]", encode(sys.executable))
Expand All @@ -159,7 +165,9 @@ def _get_handle_for_runtime_config(dll, dotnet_root: StrOrPath, runtime_config:
return handle_ptr[0]


def _get_handle_for_dotnet_command_line(dll, dotnet_root: StrOrPath, entry_dll: StrOrPath):
def _get_handle_for_dotnet_command_line(
dll, dotnet_root: StrOrPath, entry_dll: StrOrPath
):
params = ffi.new("hostfxr_initialize_parameters*")
params.size = ffi.sizeof("hostfxr_initialize_parameters")
params.host_path = ffi.NULL
Expand All @@ -172,9 +180,7 @@ def _get_handle_for_dotnet_command_line(dll, dotnet_root: StrOrPath, entry_dll:
arg_ptr = ffi.new("char_t[]", encode(str(Path(entry_dll))))
args_ptr[0] = arg_ptr
res = dll.hostfxr_initialize_for_dotnet_command_line(
1,
args_ptr,
params, handle_ptr
1, args_ptr, params, handle_ptr
)

check_result(res)
Expand Down
Loading