[+] fix pr34 build: exclude archlinux from ruff/pyrefly, import overload from typing

1. exclude archlinux namespace from pr34 ruff and pyrefly configs;
  2. import overload from typing (available since py3.5) instead of typing_extensions;
  3. add --no-annotate --no-header to uv pip compile;
  4. read version from pyproject.toml in archlinux meson.build;
  5. exclude archlinux from pr34 meson.build find;
This commit is contained in:
LLM 2026-04-06 07:43:37 +00:00
parent 46d951afab
commit 2c013d6be4
6 changed files with 162 additions and 102 deletions

@ -21,20 +21,15 @@ from typing import (
Type, Type,
TypeVar, TypeVar,
Callable, Callable,
overload,
) )
if typing.TYPE_CHECKING: if typing.TYPE_CHECKING:
from typing_extensions import ( from typing_extensions import (
Self, Self,
BinaryIO, BinaryIO,
overload,
) )
else:
try:
from typing_extensions import overload
except ModuleNotFoundError:
def overload(f: Any) -> Any:
return f
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -383,15 +378,9 @@ class BootstrapSettings:
'--no-index -U', '--no-index -U',
).split(), ).split(),
) )
whl_cache_update: Optional[bool] = dataclasses.field( whl_cache_update: Optional[bool] = dataclasses.field(default_factory=lambda: os.environ.get('WHL_CACHE_UPDATE', json.dumps(False)) in [json.dumps(True)])
default_factory=lambda: os.environ.get('WHL_CACHE_UPDATE', json.dumps(False)) in [json.dumps(True)] uv_compile_allow_index: bool = dataclasses.field(default_factory=lambda: os.environ.get('UV_COMPILE_ALLOW_INDEX', json.dumps(False)) in [json.dumps(True)])
) venv_partial: bool = dataclasses.field(default_factory=lambda: os.environ.get('VENV_PARTIAL', json.dumps(False)) in [json.dumps(True)])
uv_compile_allow_index: bool = dataclasses.field(
default_factory=lambda: os.environ.get('UV_COMPILE_ALLOW_INDEX', json.dumps(False)) in [json.dumps(True)]
)
venv_partial: bool = dataclasses.field(
default_factory=lambda: os.environ.get('VENV_PARTIAL', json.dumps(False)) in [json.dumps(True)]
)
@classmethod @classmethod
def get( def get(
@ -537,10 +526,17 @@ def whl_cache_download(
try: try:
cmd = [ cmd = [
sys.executable, '-m', 'pip', 'download', '--only-binary=:all:', sys.executable,
*uv_python_version, *pip_find_links_args, '-m',
'-r', missing_req_path, 'pip',
'-d', str(whl_cache_path), 'download',
'--only-binary=:all:',
*uv_python_version,
*pip_find_links_args,
'-r',
missing_req_path,
'-d',
str(whl_cache_path),
] ]
logger.info(dict(cmd=cmd)) logger.info(dict(cmd=cmd))
subprocess.check_call(cmd) subprocess.check_call(cmd)
@ -664,17 +660,20 @@ def env_bootstrap(
cache_find_links_args = ['-f', str(bootstrap_settings.whl_cache_path)] cache_find_links_args = ['-f', str(bootstrap_settings.whl_cache_path)]
if needs_compile: if needs_compile:
with tempfile.NamedTemporaryFile( with (
mode='w', tempfile.NamedTemporaryFile(
prefix='requirements', mode='w',
suffix='.in', prefix='requirements',
) as f_in, tempfile.NamedTemporaryFile( suffix='.in',
mode='w', ) as f_in,
prefix='requirements', tempfile.NamedTemporaryFile(
suffix='.txt', mode='w',
dir=requirements_path.parent, prefix='requirements',
delete=False, suffix='.txt',
) as f_out: dir=requirements_path.parent,
delete=False,
) as f_out,
):
f_in.write('\n'.join(requirements_in)) f_in.write('\n'.join(requirements_in))
f_in.flush() f_in.flush()
@ -687,15 +686,20 @@ def env_bootstrap(
cmd = [ cmd = [
'uv', 'uv',
'--cache-dir', bootstrap_settings.uv_cache_dir, '--cache-dir',
'pip', 'compile', bootstrap_settings.uv_cache_dir,
'pip',
'compile',
*uv_python_version, *uv_python_version,
'--generate-hashes', '--generate-hashes',
'--no-annotate',
'--no-header',
*pip_find_links_args, *pip_find_links_args,
*cache_find_links_args, *cache_find_links_args,
*constraint_args, *constraint_args,
*uv_compile_args, *uv_compile_args,
'-o', f_out.name, '-o',
f_out.name,
f_in.name, f_in.name,
] ]
logger.info(dict(cmd=cmd)) logger.info(dict(cmd=cmd))
@ -720,26 +724,33 @@ def env_bootstrap(
if bootstrap_settings.venv_partial and bootstrap_settings.env_path.exists(): if bootstrap_settings.venv_partial and bootstrap_settings.env_path.exists():
logger.info('[bootstrap] VENV_PARTIAL: skipping venv creation (already exists)') logger.info('[bootstrap] VENV_PARTIAL: skipping venv creation (already exists)')
else: else:
subprocess.check_call([ subprocess.check_call(
'uv', [
'--cache-dir', bootstrap_settings.uv_cache_dir, 'uv',
*[o for o in bootstrap_settings.uv_args if o not in ['-U', '--upgrade', '--no-index']], '--cache-dir',
'venv', bootstrap_settings.uv_cache_dir,
*venv_python_version, *[o for o in bootstrap_settings.uv_args if o not in ['-U', '--upgrade', '--no-index']],
*cache_find_links_args, 'venv',
str(bootstrap_settings.env_path), *venv_python_version,
]) *cache_find_links_args,
str(bootstrap_settings.env_path),
]
)
cmd = [ cmd = [
'uv', 'uv',
'--cache-dir', bootstrap_settings.uv_cache_dir, '--cache-dir',
'pip', 'install', bootstrap_settings.uv_cache_dir,
'pip',
'install',
*uv_python_version, *uv_python_version,
*cache_find_links_args, *cache_find_links_args,
'-p', str(bootstrap_settings.python_path), '-p',
str(bootstrap_settings.python_path),
'--require-hashes', '--require-hashes',
*bootstrap_settings.uv_args, *bootstrap_settings.uv_args,
'-r', str(requirements_path), '-r',
str(requirements_path),
] ]
logger.info(dict(cmd=cmd)) logger.info(dict(cmd=cmd))
subprocess.check_call(cmd) subprocess.check_call(cmd)

@ -3,7 +3,10 @@ project(
'.venv/bin/toml', 'get', '--toml-path', 'pyproject.toml', 'project.name', '.venv/bin/toml', 'get', '--toml-path', 'pyproject.toml', 'project.name',
check: true check: true
).stdout().strip('\n'), ).stdout().strip('\n'),
version: '0.1.5.17+27.23', version: run_command(
'.venv/bin/toml', 'get', '--toml-path', 'pyproject.toml', 'project.version',
check: true
).stdout().strip('\n'),
) )
install_path = get_option('install_path') install_path = get_option('install_path')

@ -44,7 +44,9 @@ if mode == 'pyproject'
module_root = install_root / namespace_path module_root = install_root / namespace_path
python_sources = run_command( python_sources = run_command(
'find', namespace_path, '-iname', '*.py', 'find', namespace_path,
'-path', namespace_path / 'commands_typed' / 'archlinux', '-prune',
'-o', '-iname', '*.py', '-print',
check: true check: true
).stdout().strip().split('\n') ).stdout().strip().split('\n')

@ -21,20 +21,15 @@ from typing import (
Type, Type,
TypeVar, TypeVar,
Callable, Callable,
overload,
) )
if typing.TYPE_CHECKING: if typing.TYPE_CHECKING:
from typing_extensions import ( from typing_extensions import (
Self, Self,
BinaryIO, BinaryIO,
overload,
) )
else:
try:
from typing_extensions import overload
except ModuleNotFoundError:
def overload(f: Any) -> Any:
return f
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -383,15 +378,9 @@ class BootstrapSettings:
'--no-index -U', '--no-index -U',
).split(), ).split(),
) )
whl_cache_update: Optional[bool] = dataclasses.field( whl_cache_update: Optional[bool] = dataclasses.field(default_factory=lambda: os.environ.get('WHL_CACHE_UPDATE', json.dumps(False)) in [json.dumps(True)])
default_factory=lambda: os.environ.get('WHL_CACHE_UPDATE', json.dumps(False)) in [json.dumps(True)] uv_compile_allow_index: bool = dataclasses.field(default_factory=lambda: os.environ.get('UV_COMPILE_ALLOW_INDEX', json.dumps(False)) in [json.dumps(True)])
) venv_partial: bool = dataclasses.field(default_factory=lambda: os.environ.get('VENV_PARTIAL', json.dumps(False)) in [json.dumps(True)])
uv_compile_allow_index: bool = dataclasses.field(
default_factory=lambda: os.environ.get('UV_COMPILE_ALLOW_INDEX', json.dumps(False)) in [json.dumps(True)]
)
venv_partial: bool = dataclasses.field(
default_factory=lambda: os.environ.get('VENV_PARTIAL', json.dumps(False)) in [json.dumps(True)]
)
@classmethod @classmethod
def get( def get(
@ -537,10 +526,17 @@ def whl_cache_download(
try: try:
cmd = [ cmd = [
sys.executable, '-m', 'pip', 'download', '--only-binary=:all:', sys.executable,
*uv_python_version, *pip_find_links_args, '-m',
'-r', missing_req_path, 'pip',
'-d', str(whl_cache_path), 'download',
'--only-binary=:all:',
*uv_python_version,
*pip_find_links_args,
'-r',
missing_req_path,
'-d',
str(whl_cache_path),
] ]
logger.info(dict(cmd=cmd)) logger.info(dict(cmd=cmd))
subprocess.check_call(cmd) subprocess.check_call(cmd)
@ -664,17 +660,20 @@ def env_bootstrap(
cache_find_links_args = ['-f', str(bootstrap_settings.whl_cache_path)] cache_find_links_args = ['-f', str(bootstrap_settings.whl_cache_path)]
if needs_compile: if needs_compile:
with tempfile.NamedTemporaryFile( with (
mode='w', tempfile.NamedTemporaryFile(
prefix='requirements', mode='w',
suffix='.in', prefix='requirements',
) as f_in, tempfile.NamedTemporaryFile( suffix='.in',
mode='w', ) as f_in,
prefix='requirements', tempfile.NamedTemporaryFile(
suffix='.txt', mode='w',
dir=requirements_path.parent, prefix='requirements',
delete=False, suffix='.txt',
) as f_out: dir=requirements_path.parent,
delete=False,
) as f_out,
):
f_in.write('\n'.join(requirements_in)) f_in.write('\n'.join(requirements_in))
f_in.flush() f_in.flush()
@ -687,15 +686,20 @@ def env_bootstrap(
cmd = [ cmd = [
'uv', 'uv',
'--cache-dir', bootstrap_settings.uv_cache_dir, '--cache-dir',
'pip', 'compile', bootstrap_settings.uv_cache_dir,
'pip',
'compile',
*uv_python_version, *uv_python_version,
'--generate-hashes', '--generate-hashes',
'--no-annotate',
'--no-header',
*pip_find_links_args, *pip_find_links_args,
*cache_find_links_args, *cache_find_links_args,
*constraint_args, *constraint_args,
*uv_compile_args, *uv_compile_args,
'-o', f_out.name, '-o',
f_out.name,
f_in.name, f_in.name,
] ]
logger.info(dict(cmd=cmd)) logger.info(dict(cmd=cmd))
@ -720,26 +724,33 @@ def env_bootstrap(
if bootstrap_settings.venv_partial and bootstrap_settings.env_path.exists(): if bootstrap_settings.venv_partial and bootstrap_settings.env_path.exists():
logger.info('[bootstrap] VENV_PARTIAL: skipping venv creation (already exists)') logger.info('[bootstrap] VENV_PARTIAL: skipping venv creation (already exists)')
else: else:
subprocess.check_call([ subprocess.check_call(
'uv', [
'--cache-dir', bootstrap_settings.uv_cache_dir, 'uv',
*[o for o in bootstrap_settings.uv_args if o not in ['-U', '--upgrade', '--no-index']], '--cache-dir',
'venv', bootstrap_settings.uv_cache_dir,
*venv_python_version, *[o for o in bootstrap_settings.uv_args if o not in ['-U', '--upgrade', '--no-index']],
*cache_find_links_args, 'venv',
str(bootstrap_settings.env_path), *venv_python_version,
]) *cache_find_links_args,
str(bootstrap_settings.env_path),
]
)
cmd = [ cmd = [
'uv', 'uv',
'--cache-dir', bootstrap_settings.uv_cache_dir, '--cache-dir',
'pip', 'install', bootstrap_settings.uv_cache_dir,
'pip',
'install',
*uv_python_version, *uv_python_version,
*cache_find_links_args, *cache_find_links_args,
'-p', str(bootstrap_settings.python_path), '-p',
str(bootstrap_settings.python_path),
'--require-hashes', '--require-hashes',
*bootstrap_settings.uv_args, *bootstrap_settings.uv_args,
'-r', str(requirements_path), '-r',
str(requirements_path),
] ]
logger.info(dict(cmd=cmd)) logger.info(dict(cmd=cmd))
subprocess.check_call(cmd) subprocess.check_call(cmd)

@ -82,6 +82,7 @@ include = [
] ]
exclude = [ exclude = [
'.venv', '.venv',
'online/fxreader/pr34/commands_typed/archlinux',
] ]
[tool.ruff.format] [tool.ruff.format]
@ -252,7 +253,7 @@ project-includes = [
] ]
project-excludes = [ project-excludes = [
'.venv', '.venv',
'online/fxreader/pr34/commands_typed/archlinux/tests/res', 'online/fxreader/pr34/commands_typed/archlinux',
] ]
search-path = [ search-path = [
'.', '.',

@ -8,7 +8,7 @@ classifiers = [
'Programming Language :: Python', 'Programming Language :: Python',
] ]
name = 'online.fxreader.pr34' name = "online.fxreader.pr34"
# version = '0.1.5.16+27.7' # version = '0.1.5.16+27.7'
dynamic = [ dynamic = [
'version', 'version',
@ -21,6 +21,7 @@ dependencies = [
'pydantic', 'pydantic',
'pydantic-settings', 'pydantic-settings',
'tomlkit', 'tomlkit',
'pip==23.3.2',
] ]
[project.optional-dependencies] [project.optional-dependencies]
@ -31,28 +32,41 @@ crypto = [
early = [ early = [
'numpy', 'numpy',
'cryptography', 'cryptography',
'yq',
'toml-cli',
'ninja',
'patchelf',
# 'tomlkit', # 'tomlkit',
] ]
archlinux = [
'solv==0.7.35',
]
lint = [ lint = [
'tomli', 'tomli',
# 'tomllib', # 'tomllib',
'mypy', 'mypy',
'pyright', 'pyright',
'pyrefly',
'ruff', 'ruff',
# 'tomlkit', # 'tomlkit',
] ]
[project.scripts]
online-fxreader-pr34-commands = 'online.fxreader.pr34.commands:commands_cli'
[tool.online-fxreader-pr34] [tool.online-fxreader-pr34]
early_features = ['default', 'early', 'lint',] early_features = ["default", "early", "lint"]
modules = [
{ name = 'online.fxreader.pr34', tool = { 'online-fxreader-pr34' = { early_features = ['default', 'early', 'lint'] } } },
]
[build-system] [build-system]
requires = ["meson-python", "pybind11"] requires = ["meson-python", "pybind11"]
build-backend = "mesonpy" build-backend = "mesonpy"
[project.scripts]
online-fxreader-pr34-commands = 'online.fxreader.pr34.commands:commands_cli'
[tool.ruff] [tool.ruff]
line-length = 160 line-length = 160
@ -68,6 +82,7 @@ include = [
] ]
exclude = [ exclude = [
'.venv', '.venv',
'online/fxreader/pr34/commands_typed/archlinux',
] ]
[tool.ruff.format] [tool.ruff.format]
@ -128,6 +143,7 @@ extraPaths = [
'.', '.',
'../mypy-stubs', '../mypy-stubs',
'../mypy-stubs/types-debugpy', '../mypy-stubs/types-debugpy',
'../mypy-stubs/types-solv',
'../mypy-stubs/marisa-trie-types', '../mypy-stubs/marisa-trie-types',
# '../../../../../', # '../../../../../',
] ]
@ -230,3 +246,19 @@ reportShadowedImports = "none"
reportUninitializedInstanceVariable = "none" reportUninitializedInstanceVariable = "none"
reportUnnecessaryTypeIgnoreComment = "none" reportUnnecessaryTypeIgnoreComment = "none"
reportUnusedCallResult = "none" reportUnusedCallResult = "none"
[tool.pyrefly]
project-includes = [
'online/fxreader/pr34/commands_typed/**/*.py',
]
project-excludes = [
'.venv',
'online/fxreader/pr34/commands_typed/archlinux',
]
search-path = [
'.',
'../mypy-stubs/types-debugpy',
'../mypy-stubs/types-solv',
'../mypy-stubs/marisa-trie-types',
]
python-version = '3.13'