diff options
author | say <say@yandex-team.ru> | 2022-02-10 16:48:19 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:19 +0300 |
commit | 2096e85a73bb6b3b20ae25a92943992717fe4167 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /build/plugins | |
parent | a6a6f6e1e77c7d7d0cdfad61c093e061d6fb5782 (diff) | |
download | ydb-2096e85a73bb6b3b20ae25a92943992717fe4167.tar.gz |
Restoring authorship annotation for <say@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'build/plugins')
-rw-r--r-- | build/plugins/pybuild.py | 108 |
1 files changed, 54 insertions, 54 deletions
diff --git a/build/plugins/pybuild.py b/build/plugins/pybuild.py index 62cd89b51c..f32a2d39a0 100644 --- a/build/plugins/pybuild.py +++ b/build/plugins/pybuild.py @@ -1,15 +1,15 @@ import os import collections -from hashlib import md5 +from hashlib import md5 import ymake from _common import stripext, rootrel_arc_src, tobuilddir, listid, resolve_to_ymake_path, generate_chunks, pathid -YA_IDE_VENV_VAR = 'YA_IDE_VENV' -PY_NAMESPACE_PREFIX = 'py/namespace' +YA_IDE_VENV_VAR = 'YA_IDE_VENV' +PY_NAMESPACE_PREFIX = 'py/namespace' BUILTIN_PROTO = 'builtin_proto' - + def is_arc_src(src, unit): return ( src.startswith('${ARCADIA_ROOT}/') or @@ -17,13 +17,13 @@ def is_arc_src(src, unit): unit.resolve_arc_path(src).startswith('$S/') ) -def is_extended_source_search_enabled(path, unit): - if not is_arc_src(path, unit): - return False - if unit.get('NO_EXTENDED_SOURCE_SEARCH') == 'yes': - return False - return True - +def is_extended_source_search_enabled(path, unit): + if not is_arc_src(path, unit): + return False + if unit.get('NO_EXTENDED_SOURCE_SEARCH') == 'yes': + return False + return True + def to_build_root(path, unit): if is_arc_src(path, unit): return '${ARCADIA_BUILD_ROOT}/' + rootrel_arc_src(path, unit) @@ -147,10 +147,10 @@ def is_py3(unit): return unit.get("PYTHON3") == "yes" -def on_py_program(unit, *args): - py_program(unit, is_py3(unit)) - - +def on_py_program(unit, *args): + py_program(unit, is_py3(unit)) + + def py_program(unit, py3): """ Documentation: https://wiki.yandex-team.ru/devtools/commandsandvars/py_srcs/#modulpyprogramimakrospymain @@ -194,11 +194,11 @@ def onpy_srcs(unit, *args): upath = unit.path()[3:] py3 = is_py3(unit) - py_main_only = unit.get('PROCESS_PY_MAIN_ONLY') + py_main_only = unit.get('PROCESS_PY_MAIN_ONLY') with_py = not unit.get('PYBUILD_NO_PY') with_pyc = not unit.get('PYBUILD_NO_PYC') in_proto_library = unit.get('PY_PROTO') or unit.get('PY3_PROTO') - venv = unit.get(YA_IDE_VENV_VAR) + venv = unit.get(YA_IDE_VENV_VAR) need_gazetteer_peerdir = False trim = 0 @@ -235,7 +235,7 @@ def onpy_srcs(unit, *args): protos = [] evs = [] fbss = [] - py_namespaces = {} + py_namespaces = {} dump_dir = unit.get('PYTHON_BUILD_DUMP_DIR') dump_output = None @@ -304,25 +304,25 @@ def onpy_srcs(unit, *args): if arg.startswith('/'): ymake.report_configure_error('PY_SRCS item starts with "/": {!r}'.format(arg)) continue - mod_name = stripext(arg).replace('/', '.') - if py3 and path.endswith('.py') and is_extended_source_search_enabled(path, unit): - # Dig out real path from the file path. Unit.path is not enough because of SRCDIR and ADDINCL - root_rel_path = rootrel_arc_src(path, unit) - mod_root_path = root_rel_path[:-(len(path) + 1)] - py_namespaces.setdefault(mod_root_path, set()).add(ns if ns else '.') - mod = ns + mod_name + mod_name = stripext(arg).replace('/', '.') + if py3 and path.endswith('.py') and is_extended_source_search_enabled(path, unit): + # Dig out real path from the file path. Unit.path is not enough because of SRCDIR and ADDINCL + root_rel_path = rootrel_arc_src(path, unit) + mod_root_path = root_rel_path[:-(len(path) + 1)] + py_namespaces.setdefault(mod_root_path, set()).add(ns if ns else '.') + mod = ns + mod_name if main_mod: py_main(unit, mod + ":main") elif py3 and unit_needs_main and main_py: py_main(unit, mod) - if py_main_only: - continue - - if py3 and mod == '__main__': - ymake.report_configure_error('TOP_LEVEL __main__.py is not allowed in PY3_PROGRAM') - + if py_main_only: + continue + + if py3 and mod == '__main__': + ymake.report_configure_error('TOP_LEVEL __main__.py is not allowed in PY3_PROGRAM') + pathmod = (path, mod) if dump_output is not None: @@ -441,28 +441,28 @@ def onpy_srcs(unit, *args): res = [] if py3: - mod_list_md5 = md5() + mod_list_md5 = md5() for path, mod in pys: - mod_list_md5.update(mod) - if not (venv and is_extended_source_search_enabled(path, unit)): - dest = 'py/' + mod.replace('.', '/') + '.py' - if with_py: - res += ['DEST', dest, path] - if with_pyc: - root_rel_path = rootrel_arc_src(path, unit) - dst = path + uniq_suffix(path, unit) - unit.on_py3_compile_bytecode([root_rel_path + '-', path, dst]) - res += ['DEST', dest + '.yapyc3', dst + '.yapyc3'] - - if py_namespaces: - # Note: Add md5 to key to prevent key collision if two or more PY_SRCS() used in the same ya.make - ns_res = [] - for path, ns in sorted(py_namespaces.items()): - key = '{}/{}/{}'.format(PY_NAMESPACE_PREFIX, mod_list_md5.hexdigest(), path) - namespaces = ':'.join(sorted(ns)) - ns_res += ['-', '{}="{}"'.format(key, namespaces)] - unit.onresource(ns_res) - + mod_list_md5.update(mod) + if not (venv and is_extended_source_search_enabled(path, unit)): + dest = 'py/' + mod.replace('.', '/') + '.py' + if with_py: + res += ['DEST', dest, path] + if with_pyc: + root_rel_path = rootrel_arc_src(path, unit) + dst = path + uniq_suffix(path, unit) + unit.on_py3_compile_bytecode([root_rel_path + '-', path, dst]) + res += ['DEST', dest + '.yapyc3', dst + '.yapyc3'] + + if py_namespaces: + # Note: Add md5 to key to prevent key collision if two or more PY_SRCS() used in the same ya.make + ns_res = [] + for path, ns in sorted(py_namespaces.items()): + key = '{}/{}/{}'.format(PY_NAMESPACE_PREFIX, mod_list_md5.hexdigest(), path) + namespaces = ':'.join(sorted(ns)) + ns_res += ['-', '{}="{}"'.format(key, namespaces)] + unit.onresource(ns_res) + unit.onresource_files(res) add_python_lint_checks(unit, 3, [path for path, mod in pys] + unit.get(['_PY_EXTRA_LINT_FILES_VALUE']).split()) else: @@ -583,8 +583,8 @@ def onpy_register(unit, *args): def py_main(unit, arg): - if unit.get('IGNORE_PY_MAIN'): - return + if unit.get('IGNORE_PY_MAIN'): + return unit_needs_main = unit.get('MODULE_TYPE') in ('PROGRAM', 'DLL') if unit_needs_main: py_program(unit, is_py3(unit)) |