[~] Refactor

This commit is contained in:
Siarhei Siniak 2024-11-10 12:32:27 +03:00
parent 81bf066e82
commit eb310ceef7
2 changed files with 15 additions and 7 deletions

@ -1,3 +1,6 @@
import distutils.command import distutils.command
from typing import (Any,)
def _get_build_extension() -> distutils.command.build_ext: ... def _get_build_extension() -> distutils.command.build_ext: ...
def load_dynamic(name: str, path: str) -> Any: ...

@ -10,7 +10,7 @@ import threading
import cython import cython
import datetime import datetime
from typing import (Any, Optional,) from typing import (Any, Optional, TypeVar, Type, cast)
# from scoping import scoping as s # from scoping import scoping as s
def test( def test(
@ -31,7 +31,9 @@ def test(
print(['done', started_at, elapsed(), a[_id]]) print(['done', started_at, elapsed(), a[_id]])
def build(content: str) -> Any: M = TypeVar('M', bound=Type[Any])
def build(content: str, module: M) -> M:
import pathlib import pathlib
import tempfile import tempfile
import hashlib import hashlib
@ -58,12 +60,15 @@ def build(content: str) -> Any:
#) #)
t1.run() t1.run()
return Cython.Build.Inline.load_dynamic( return cast(
M,
Cython.Build.Inline.load_dynamic(
'_%s' % sha256sum, '_%s' % sha256sum,
glob.glob( glob.glob(
str(output_dir / ('_%s*.so' % sha256sum)) str(output_dir / ('_%s*.so' % sha256sum))
)[0] )[0]
) )
)
raise NotImplementedError raise NotImplementedError