Compare commits

..

5 Commits

Author SHA1 Message Date
7d1d887692 [+] update keybindigs 2025-01-02 10:42:58 +03:00
212c8c8086 [+] improve deploy:wheel command 2025-01-01 02:19:40 +03:00
6599115a68 [+] 0.1.4.7, improve os module
1. add runtime initialization;
    works for .so files;
    linux platform only at the moment;
2024-12-30 15:03:45 +03:00
22f5f0fba3 [+] raise 0.1.4.1 2024-12-29 14:44:07 +03:00
c9382162de [+] update cli logic
1. add pip_sync method;
  1.1. rely on -f flag
    of pip to use a custom cache dir;
2024-12-29 14:36:30 +03:00
8 changed files with 267 additions and 21 deletions

@ -1 +1 @@
Subproject commit 857be4a1fb1c07e2a239b61ce49b34cdd1698467
Subproject commit f94ded8fbfe62bea6e96827312eb25853990ecd3

@ -133,5 +133,24 @@
"key": "ctrl+b",
"command": "-extension.vim_ctrl+b",
"when": "editorTextFocus && vim.active && vim.use<C-b> && !inDebugRepl && vim.mode != 'Insert'"
},
{
"key": "ctrl+w",
"command": "-workbench.action.closeActiveEditor"
},
{
"key": "ctrl+w",
"command": "-workbench.action.closeGroup",
"when": "activeEditorGroupEmpty && multipleEditorGroups"
},
{
"key": "ctrl+w",
"command": "-extension.vim_ctrl+w",
"when": "editorTextFocus && vim.active && vim.use<C-w> && !inDebugRepl"
},
{
"key": "ctrl+w",
"command": "workbench.action.closeActiveEditor",
"when": "editorTextFocus"
}
]

@ -47,5 +47,42 @@
"workbench.preferredHighContrastColorTheme": "Monokai",
"workbench.preferredHighContrastLightColorTheme": "Monokai",
"workbench.preferredLightColorTheme": "Monokai",
"mesonbuild.downloadLanguageServer": false
"mesonbuild.downloadLanguageServer": false,
// "vim.easymotion": true,
// "vim.incsearch": true,
"vim.useSystemClipboard": true,
// "vim.useCtrlKeys": true,
"vim.hlsearch": true,
// "vim.insertModeKeyBindings": [
// {
// "before": ["j", "j"],
// "after": ["<Esc>"]
// }
// ],
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["<leader>", "w"],
"after": ["<C-w>"],
// "after": ["d", "d"]
},
// {
// "before": ["<C-n>"],
// "commands": [":nohl"]
// },
// {
// "before": ["K"],
// "commands": ["lineBreakInsert"],
// "silent": true
// }
],
"vim.leader": "\\",
// "vim.handleKeys": {
// "<C-a>": false,
// "<C-f>": false
// },
"// To improve performance",
"extensions.experimental.affinity": {
"vscodevim.vim": 1
},
}

@ -65,6 +65,46 @@ class CLI(abc.ABC):
argv,
)
def pip_sync(
self,
project: str,
features: list[str],
) -> None:
from . import cli_bootstrap
pyproject = cli_bootstrap.pyproject_load(
self.projects[project].source_dir / 'pyproject.toml'
)
dependencies = sum([
pyproject.dependencies[o]
for o in features
], [])
pip_find_links : list[pathlib.Path] = []
if not pyproject.pip_find_links is None:
pip_find_links.extend(pyproject.pip_find_links)
logger.info(dict(
dependencies=dependencies,
))
if len(dependencies) > 0:
subprocess.check_call([
self.dist_settings.python_path,
'-m',
'uv', 'pip', 'install',
*sum([
['-f', str(o),]
for o in pip_find_links
], []),
# '-f', str(pathlib.Path(__file__).parent / 'deps' / 'dist'),
'--offline',
*dependencies,
])
def deploy_fetch_dist(
self,
force: bool,
@ -138,6 +178,16 @@ class CLI(abc.ABC):
latest_file['path'],
])
@property
def pkg_config_path(self,) -> set[pathlib.Path]:
return {
pathlib.Path(o)
for o in glob.glob(
str(self.dist_settings.env_path / 'lib' / 'python*' / '**' / 'pkgconfig'),
recursive=True,
)
}
def deploy_wheel(
self,
project_name: str,
@ -156,7 +206,10 @@ class CLI(abc.ABC):
# Command.meson_setup.value,
# ])
assert argv is None or len(argv) == 0
if argv is None:
argv = []
# assert argv is None or len(argv) == 0
if not project.meson_path is None:
self.meson_install(
@ -170,16 +223,28 @@ class CLI(abc.ABC):
if env is None:
env = dict()
extra_args: list[str] = []
if len(self.third_party_roots) > 0:
extra_args.extend([
'-Csetup-args=%s' % (
'-Dthird_party_roots=%s' % str(o.absolute())
)
for o in self.third_party_roots
])
cmd = [
sys.executable,
'-m',
'build',
'-w', '-n',
*extra_args,
'-Csetup-args=-Dmodes=pyproject',
'-Cbuild-dir=%s' % str(project.build_dir / 'pyproject'),
'-Csetup-args=-Dinstall_path=%s' % str(project.dest_dir),
# '-Cbuild-dir=%s' % str(project.build_dir),
str(project.source_dir),
*argv,
]
if not output_dir is None:
@ -269,11 +334,16 @@ class CLI(abc.ABC):
*argv,
])
@property
def third_party_roots(self) -> list[pathlib.Path]:
return []
def meson_setup(
self,
project_name: str,
force: bool,
argv: Optional[list[str]] = None,
# third_party_roots: Optional[list[pathlib.Path]] = None,
) -> None:
project = self.projects[project_name]
@ -285,12 +355,21 @@ class CLI(abc.ABC):
logger.info(dict(action='removing build dir', path=project.build_dir / 'meson'))
shutil.rmtree(project.build_dir / 'meson')
extra_args : list[str] = []
if len(self.third_party_roots) > 0:
extra_args.extend([
'-Dthird_party_roots=%s' % str(o.absolute())
for o in self.third_party_roots
])
cmd = [
shutil_which('meson', True,),
'setup',
str(project.source_dir),
str(project.build_dir / 'meson'),
'-Dmodes=["meson"]',
*extra_args,
# '-Dpkgconfig.relocatable=true',
'-Dprefix=/',
*argv,

@ -17,6 +17,9 @@ logger = logging.getLogger(__name__)
class PyProject:
dependencies: dict[str, list[str]]
early_features: Optional[list[str]] = 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(
d: pathlib.Path,
@ -42,7 +45,7 @@ def pyproject_load(
assert isinstance(v, list)
assert isinstance(k, str)
dependencies[k] = v
dependencies[k] = v
res = PyProject(
@ -65,6 +68,26 @@ def pyproject_load(
if 'early_features' in content['tool'][tool_name]:
res.early_features = content['tool'][tool_name]['early_features']
if 'pip_find_links' in content['tool'][tool_name]:
res.pip_find_links = [
d.parent / pathlib.Path(o)
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
@dataclasses.dataclass
@ -115,20 +138,25 @@ def env_bootstrap(
'build', 'setuptools', 'meson-python', 'pybind11',
])
early_wheels = glob.glob(
str(
pathlib.Path(__file__).parent / 'deps' / 'dist' / 'early' / '*.whl'
)
)
# early_wheels = glob.glob(
# str(
# pathlib.Path(__file__).parent / 'deps' / 'dist' / 'early' / '*.whl'
# )
# )
if len(early_wheels) > 0:
subprocess.check_call([
bootstrap_settings.python_path,
'-m',
'uv', 'pip', 'install',
'--offline',
*early_wheels,
])
# if len(early_wheels) > 0:
# subprocess.check_call([
# bootstrap_settings.python_path,
# '-m',
# 'uv', 'pip', 'install',
# '--offline',
# *early_wheels,
# ])
pip_find_links : list[pathlib.Path] = []
if not pyproject.pip_find_links is None:
pip_find_links.extend(pyproject.pip_find_links)
if pyproject.early_features:
early_dependencies = sum([
@ -139,11 +167,17 @@ def env_bootstrap(
logger.info(dict(
early_dependencies=early_dependencies,
))
if len(early_dependencies) > 0:
subprocess.check_call([
bootstrap_settings.python_path,
'-m',
'uv', 'pip', 'install',
*sum([
['-f', str(o),]
for o in pip_find_links
], []),
# '-f', str(pathlib.Path(__file__).parent / 'deps' / 'dist'),
'--offline',
*early_dependencies,
])

@ -1,7 +1,17 @@
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 .cli_bootstrap import PyProject
@overload
def shutil_which(
name: str,
@ -22,4 +32,61 @@ def shutil_which(
if res is None and raise_on_failure:
raise NotImplementedError
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

@ -0,0 +1,10 @@
import pip._internal.commands.show
def pip_show(
argv: list[str],
) -> list[pip._internal.commands.show._PackageInfo]:
return list(
pip._internal.commands.show.search_packages_info(
argv,
)
)

@ -1,6 +1,6 @@
[project]
name = 'online.fxreader.pr34'
version = '0.1.1'
version = '0.1.4.8'
dependencies = [
#"-r requirements.txt",
@ -38,8 +38,8 @@ include-package-data = false
#exclude = ['*']
#include = ['*.py']
[tool.setuptools.exclude-package-data]
'online.fxreader.pr34' = ['online/fxreader/pr34/py.typed']
# [tool.setuptools.exclude-package-data]
# 'online.fxreader.pr34' = ['online/fxreader/pr34/py.typed']
#[tool.setuptools.package-data]
#'online_fxreader.vpn' = ['requirements.txt']