aboutsummaryrefslogtreecommitdiffstats
path: root/build/plugins/pybuild.py
diff options
context:
space:
mode:
authoriaz1607 <iaz1607@yandex-team.com>2023-11-27 13:50:15 +0300
committeriaz1607 <iaz1607@yandex-team.com>2023-11-27 14:20:03 +0300
commitf2bebe45e16d892b620cc073279faaa1bf550a92 (patch)
treef8b87603f9c7f8372a7e4d49b352e1ab1b8fc61f /build/plugins/pybuild.py
parent9b07404a4c0075cda0fcf2ee078cf81c51c05fd2 (diff)
downloadydb-f2bebe45e16d892b620cc073279faaa1bf550a92.tar.gz
`build/plugins` ya style --py
Diffstat (limited to 'build/plugins/pybuild.py')
-rw-r--r--build/plugins/pybuild.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/build/plugins/pybuild.py b/build/plugins/pybuild.py
index c6a8662742..b9a4343acf 100644
--- a/build/plugins/pybuild.py
+++ b/build/plugins/pybuild.py
@@ -16,11 +16,12 @@ DEFAULT_FLAKE8_FILE_PROCESSING_TIME = "1.5" # in seconds
def _split_macro_call(macro_call, data, item_size, chunk_size=1024):
index = 0
length = len(data)
- offset = item_size*chunk_size
+ offset = item_size * chunk_size
while index + 1 < length:
- macro_call(data[index:index+offset])
+ macro_call(data[index : index + offset])
index += offset
+
def is_arc_src(src, unit):
return (
src.startswith('${ARCADIA_ROOT}/')
@@ -82,7 +83,8 @@ def mangle(name):
def parse_pyx_includes(filename, path, source_root, seen=None):
- normpath = lambda *x: os.path.normpath(os.path.join(*x))
+ def normpath(*args):
+ return os.path.normpath(os.path.join(*args))
abs_path = normpath(source_root, filename)
seen = seen or set()
@@ -145,7 +147,6 @@ def add_python_lint_checks(unit, py_ver, files):
no_lint_value = get_no_lint_value(unit)
if no_lint_value == "none":
-
no_lint_allowed_paths = (
"contrib/",
"devtools/",
@@ -195,9 +196,7 @@ def add_python_lint_checks(unit, py_ver, files):
if files and unit.get('STYLE_PYTHON_VALUE') == 'yes' and is_py3(unit):
resolved_files = get_resolved_files()
if resolved_files:
- black_cfg = (
- unit.get('STYLE_PYTHON_PYPROJECT_VALUE') or 'build/config/tests/py_style/config.toml'
- )
+ black_cfg = unit.get('STYLE_PYTHON_PYPROJECT_VALUE') or 'build/config/tests/py_style/config.toml'
params = ['black', 'tools/black_linter/black_linter']
params += ['FILES'] + resolved_files
params += ['CONFIGS', black_cfg]
@@ -233,11 +232,14 @@ def onpy_srcs(unit, *args):
"""
@usage PY_SRCS({| CYTHONIZE_PY} {| CYTHON_C} { | TOP_LEVEL | NAMESPACE ns} Files...)
- PY_SRCS() - is rule to build extended versions of Python interpreters and containing all application code in its executable file. It can be used to collect only the executables but not shared libraries, and, in particular, not to collect the modules that are imported using import directive.
+ PY_SRCS() - is rule to build extended versions of Python interpreters and containing all application code in its executable file.
+ It can be used to collect only the executables but not shared libraries, and, in particular, not to collect the modules that are imported using import directive.
The main disadvantage is the lack of IDE support; There is also no readline yet.
The application can be collect from any of the sources from which the C library, and with the help of PY_SRCS .py , .pyx,.proto and .swg files.
- At the same time extensions for Python on C language generating from .pyx and .swg, will be registered in Python's as built-in modules, and sources on .py are stored as static data: when the interpreter starts, the initialization code will add a custom loader of these modules to sys.meta_path.
- You can compile .py files as Cython sources with CYTHONIZE_PY directive (Use carefully, as build can get too slow). However, with it you won't have profiling info by default. To enable it, add "# cython: profile=True" line to the beginning of every cythonized source.
+ At the same time extensions for Python on C language generating from .pyx and .swg, will be registered in Python's as built-in modules, and sources on .py are stored as static data:
+ when the interpreter starts, the initialization code will add a custom loader of these modules to sys.meta_path.
+ You can compile .py files as Cython sources with CYTHONIZE_PY directive (Use carefully, as build can get too slow). However, with it you won't have profiling info by default.
+ To enable it, add "# cython: profile=True" line to the beginning of every cythonized source.
By default .pyx files are collected as C++-extensions. To collect them as C (similar to BUILDWITH_CYTHON_C, but with the ability to specify namespace), you must specify the Directive CYTHON_C.
Building with pyx automatically registers modules, you do not need to call PY_REGISTER for them
__init__.py never required, but if present (and specified in PY_SRCS), it will be imported when you import package modules with __init__.py Oh.