diff options
Diffstat (limited to 'build/plugins')
-rw-r--r-- | build/plugins/pybuild.py | 25 | ||||
-rw-r--r-- | build/plugins/ytest.py | 8 |
2 files changed, 27 insertions, 6 deletions
diff --git a/build/plugins/pybuild.py b/build/plugins/pybuild.py index 744449d109..229d4b1665 100644 --- a/build/plugins/pybuild.py +++ b/build/plugins/pybuild.py @@ -8,7 +8,6 @@ import ymake from _common import stripext, rootrel_arc_src, listid, pathid, lazy, get_no_lint_value, ugly_conftest_exception -YA_IDE_VENV_VAR = 'YA_IDE_VENV' PY_NAMESPACE_PREFIX = 'py/namespace' BUILTIN_PROTO = 'builtin_proto' DEFAULT_FLAKE8_FILE_PROCESSING_TIME = "1.5" # in seconds @@ -37,8 +36,8 @@ def is_extended_source_search_enabled(path, unit): return False if unit.get('NO_EXTENDED_SOURCE_SEARCH') == 'yes': return False - # contrib is unfriendly to extended source search - if unit.resolve_arc_path(path).startswith('$S/contrib/'): + # Python itself and contrib/python are unfriendly to extended source search + if unit.resolve_arc_path(path).startswith(('$S/contrib/python', '$S/contrib/tools/python3')): return False return True @@ -252,7 +251,7 @@ def onpy_srcs(unit, *args): 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) + external_py_files_mode = unit.get('EXTERNAL_PY_FILES') or unit.get('YA_IDE_VENV') need_gazetteer_peerdir = False trim = 0 @@ -542,10 +541,21 @@ def onpy_srcs(unit, *args): if py3: mod_list_md5 = md5() compress = False + resfs_mocks = [] + for path, mod in pys: mod_list_md5.update(six.ensure_binary(mod)) - if not (venv and is_extended_source_search_enabled(path, unit)): - dest = 'py/' + mod.replace('.', '/') + '.py' + dest = 'py/' + mod.replace('.', '/') + '.py' + # In external_py_files mode we want to build python binaries without embedded python files. + # The application will still be able to load them from the file system. + # However, the import hook still needs meta information about the file locations to work correctly. + # That's why we manually register the files in resfs/src/resfs/file, but don't provide any actual files. + # For more info see: + # - library/python/runtime_py3 + # - https://docs.yandex-team.ru/ya-make/manual/python/vars + if external_py_files_mode and is_extended_source_search_enabled(path, unit): + resfs_mocks += ['-', 'resfs/src/resfs/file/' + dest + '=' + rootrel_arc_src(path, unit)] + else: if with_py: res += ['DEST', dest, path] if with_pyc: @@ -556,6 +566,9 @@ def onpy_srcs(unit, *args): if not compress and ugly_conftest_exception(path): compress = True + if resfs_mocks: + unit.onresource(['DONT_COMPRESS'] + resfs_mocks) + 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 = ['DONT_COMPRESS'] diff --git a/build/plugins/ytest.py b/build/plugins/ytest.py index 4911034877..ef47c32835 100644 --- a/build/plugins/ytest.py +++ b/build/plugins/ytest.py @@ -790,13 +790,21 @@ def onadd_check_py_imports(fields, unit, *args): if unit.get("TIDY") == "yes": # graph changed for clang_tidy tests return + if unit.get('NO_CHECK_IMPORTS_FOR_VALUE').strip() == "": return + unit.onpeerdir(['library/python/testing/import_test']) dart_record = create_dart_record(fields, unit, (), {}) dart_record[df.TestName.KEY] = 'pyimports' dart_record[df.ScriptRelPath.KEY] = 'py.imports' + # Import tests work correctly in this mode, but can slow down by 2-3 times, + # due to the fact that files need to be read from the file system. + # Therefore, we disable them, since the external-py-files mode is designed exclusively + # to speed up the short cycle of developing regular tests. + if unit.get('EXTERNAL_PY_FILES'): + dart_record[df.SkipTest.KEY] = 'Import tests disabled in external-py-files mode' data = dump_test(unit, dart_record) if data: |