[+] 0.1.4.7, improve os module
1. add runtime initialization; works for .so files; linux platform only at the moment;
This commit is contained in:
parent
22f5f0fba3
commit
6599115a68
2
deps/com.github.aiortc.aiortc
vendored
2
deps/com.github.aiortc.aiortc
vendored
@ -1 +1 @@
|
|||||||
Subproject commit e6422d353cda8ff688ceff7036b91d2a0de0d277
|
Subproject commit f94ded8fbfe62bea6e96827312eb25853990ecd3
|
@ -18,6 +18,8 @@ class PyProject:
|
|||||||
dependencies: dict[str, list[str]]
|
dependencies: dict[str, list[str]]
|
||||||
early_features: Optional[list[str]] = None
|
early_features: Optional[list[str]] = None
|
||||||
pip_find_links: Optional[list[pathlib.Path]] = None
|
pip_find_links: Optional[list[pathlib.Path]] = None
|
||||||
|
runtime_libdirs: Optional[list[pathlib.Path]] = None
|
||||||
|
runtime_preload: Optional[list[pathlib.Path]] = None
|
||||||
|
|
||||||
def pyproject_load(
|
def pyproject_load(
|
||||||
d: pathlib.Path,
|
d: pathlib.Path,
|
||||||
@ -68,10 +70,24 @@ def pyproject_load(
|
|||||||
|
|
||||||
if 'pip_find_links' in content['tool'][tool_name]:
|
if 'pip_find_links' in content['tool'][tool_name]:
|
||||||
res.pip_find_links = [
|
res.pip_find_links = [
|
||||||
pathlib.Path(o)
|
d.parent / pathlib.Path(o)
|
||||||
for o in content['tool'][tool_name]['pip_find_links']
|
for o in content['tool'][tool_name]['pip_find_links']
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if 'runtime_libdirs' in content['tool'][tool_name]:
|
||||||
|
res.runtime_libdirs = [
|
||||||
|
d.parent / pathlib.Path(o)
|
||||||
|
# pathlib.Path(o)
|
||||||
|
for o in content['tool'][tool_name]['runtime_libdirs']
|
||||||
|
]
|
||||||
|
|
||||||
|
if 'runtime_preload' in content['tool'][tool_name]:
|
||||||
|
res.runtime_preload = [
|
||||||
|
d.parent / pathlib.Path(o)
|
||||||
|
# pathlib.Path(o)
|
||||||
|
for o in content['tool'][tool_name]['runtime_preload']
|
||||||
|
]
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@dataclasses.dataclass
|
@dataclasses.dataclass
|
||||||
|
@ -1,7 +1,17 @@
|
|||||||
import shutil
|
import shutil
|
||||||
|
import glob
|
||||||
|
import pathlib
|
||||||
|
import ctypes
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import logging
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
from typing import (overload, Optional, Literal,)
|
from typing import (overload, Optional, Literal,)
|
||||||
|
|
||||||
|
from .cli_bootstrap import PyProject
|
||||||
|
|
||||||
@overload
|
@overload
|
||||||
def shutil_which(
|
def shutil_which(
|
||||||
name: str,
|
name: str,
|
||||||
@ -23,3 +33,60 @@ def shutil_which(
|
|||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
else:
|
else:
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def runtime_libdirs_init(
|
||||||
|
project: PyProject,
|
||||||
|
) -> None:
|
||||||
|
if sys.platform == 'linux':
|
||||||
|
ld_library_path : list[pathlib.Path] = [
|
||||||
|
o
|
||||||
|
for o in [
|
||||||
|
*[
|
||||||
|
o.absolute()
|
||||||
|
for o in (
|
||||||
|
project.runtime_libdirs
|
||||||
|
if project.runtime_libdirs
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
],
|
||||||
|
*[
|
||||||
|
pathlib.Path(o)
|
||||||
|
for o in os.environ.get(
|
||||||
|
'LD_LIBRARY_PATH',
|
||||||
|
''
|
||||||
|
).split(os.path.pathsep)
|
||||||
|
if o != ''
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
ld_library_path_present : list[pathlib.Path] = []
|
||||||
|
|
||||||
|
for o in ld_library_path:
|
||||||
|
if not o.exists():
|
||||||
|
logger.warning(dict(
|
||||||
|
ld_library_path=o,
|
||||||
|
msg='not found',
|
||||||
|
))
|
||||||
|
|
||||||
|
ld_library_path_present.append(o)
|
||||||
|
|
||||||
|
os.environ.update(
|
||||||
|
LD_LIBRARY_PATH=os.path.pathsep.join([
|
||||||
|
str(o) for o in ld_library_path_present
|
||||||
|
])
|
||||||
|
)
|
||||||
|
|
||||||
|
for preload_path in (project.runtime_preload or []):
|
||||||
|
for preload_found in glob.glob(str(
|
||||||
|
preload_path.parent / ('lib%s.so' % preload_path.name)
|
||||||
|
)):
|
||||||
|
logger.info(dict(
|
||||||
|
preload_path=preload_path, preload_found=preload_found,
|
||||||
|
# lib_path=o,
|
||||||
|
msg='load_library',
|
||||||
|
))
|
||||||
|
|
||||||
|
ctypes.cdll.LoadLibrary(preload_found)
|
||||||
|
else:
|
||||||
|
raise NotImplementedError
|
@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = 'online.fxreader.pr34'
|
name = 'online.fxreader.pr34'
|
||||||
version = '0.1.4.1'
|
version = '0.1.4.7'
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
#"-r requirements.txt",
|
#"-r requirements.txt",
|
||||||
@ -38,8 +38,8 @@ include-package-data = false
|
|||||||
#exclude = ['*']
|
#exclude = ['*']
|
||||||
#include = ['*.py']
|
#include = ['*.py']
|
||||||
|
|
||||||
[tool.setuptools.exclude-package-data]
|
# [tool.setuptools.exclude-package-data]
|
||||||
'online.fxreader.pr34' = ['online/fxreader/pr34/py.typed']
|
# 'online.fxreader.pr34' = ['online/fxreader/pr34/py.typed']
|
||||||
|
|
||||||
#[tool.setuptools.package-data]
|
#[tool.setuptools.package-data]
|
||||||
#'online_fxreader.vpn' = ['requirements.txt']
|
#'online_fxreader.vpn' = ['requirements.txt']
|
||||||
|
Loading…
Reference in New Issue
Block a user