diff options
author | zaverden <zaverden@yandex-team.com> | 2024-10-17 09:07:08 +0300 |
---|---|---|
committer | zaverden <zaverden@yandex-team.com> | 2024-10-17 09:23:20 +0300 |
commit | 68f2bcc600fc15fb8400346624c43d6be3ec81b2 (patch) | |
tree | d68f5ff3b9413a3026e6364bf41d13739b8d9511 /build | |
parent | fe7dabb9c4f211cb4ba4884d0c323e77873800c3 (diff) | |
download | ydb-68f2bcc600fc15fb8400346624c43d6be3ec81b2.tar.gz |
feat(conf+builder): remove contrib-related code
commit_hash:cfbd74bf877107b5db0cb2ea60977b4849e15af5
Diffstat (limited to 'build')
-rw-r--r-- | build/conf/ts/node_modules.conf | 51 | ||||
-rw-r--r-- | build/conf/ts/ts.conf | 1 | ||||
-rw-r--r-- | build/plugins/lib/nots/package_manager/base/package_manager.py | 5 | ||||
-rw-r--r-- | build/plugins/lib/nots/package_manager/npm/npm_package_manager.py | 4 | ||||
-rw-r--r-- | build/plugins/lib/nots/package_manager/pnpm/package_manager.py | 23 | ||||
-rw-r--r-- | build/plugins/nots.py | 48 | ||||
-rw-r--r-- | build/scripts/fetch_from_npm.py | 113 | ||||
-rw-r--r-- | build/scripts/ya.make | 1 |
8 files changed, 1 insertions, 245 deletions
diff --git a/build/conf/ts/node_modules.conf b/build/conf/ts/node_modules.conf index f33668db45..719aceb578 100644 --- a/build/conf/ts/node_modules.conf +++ b/build/conf/ts/node_modules.conf @@ -7,59 +7,10 @@ NPM_SCRIPT=$NPM_ROOT/node_modules/npm/bin/npm-cli.js PM_SCRIPT= PM_TYPE= -NPM_CONTRIBS_PATH=- -# combined input/outputs records as list of directives ${hide;input:<path>} ${hide;output:<path>}, used in builders +# combined input/outputs records as list of directives ${input;hide:<path>} ${output;hide:<path>}, used in builders _NODE_MODULES_INOUTS= _YATOOL_PREBUILDER_ARG= -macro CUSTOM_CONTRIB_TYPESCRIPT(P) { - SET(NPM_CONTRIBS_PATH -) -} - -macro NO_CONTRIB_TYPESCRIPT() { - SET(NPM_CONTRIBS_PATH -) -} - -### @usage: NPM_CONTRIBS() # internal -### -### Defines special module that provides contrib tarballs from internal npm registry. -### -### @see [FROM_NPM_LOCKFILES()](#macro_FROM_NPM_LOCKFILES) -module NPM_CONTRIBS: _BARE_UNIT { - .CMD=TOUCH_UNIT - .PEERDIR_POLICY=as_build_from - .FINAL_TARGET=no - .ALLOWED=FROM_NPM_LOCKFILES - .RESTRICTED=PEERDIR - .EXTS=_ # Ignore all files, so module is not affected by FROM_NPM output (.EXTS=* is inherited from _BARE_UNIT) - - SET(MODULE_TAG NPM_CONTRIBS) - SET(MODULE_LANG TS) - - # .fake tells builder to not materialize it in results - SET(MODULE_SUFFIX .fake) -} - -### @usage: FROM_NPM_LOCKFILES(LOCKFILES...) # internal -### -### Defines lockfile list for `NPM_CONTRIBS` module. -### -### @see [NPM_CONTRIBS()](#module_NPM_CONTRIBS) -macro FROM_NPM_LOCKFILES(LOCKFILES...) { - # SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS $LOCKFILES) - # See implementation in build/plugins/nots.py - # _FROM_NPM_LOCKFILES($LOCKFILES) - MESSAGE("NPM_CONTRIBS and FROM_NPM_LOCKFILES are disabled. Please exclude them from your build process") -} - -FROM_NPM_CWD=$ARCADIA_BUILD_ROOT/$NPM_CONTRIBS_PATH -macro _FROM_NPM(TARBALL_URL, SKY_ID, INTEGRITY, INTEGRITY_ALGO, TARBALL_PATH) { - .CMD=${cwd:FROM_NPM_CWD} $YMAKE_PYTHON ${input:"build/scripts/fetch_from_npm.py"} ${hide;input:"build/scripts/fetch_from.py"} ${hide;input:"build/scripts/sky.py"} --tarball-url $TARBALL_URL --sky-id $SKY_ID --integrity $INTEGRITY --integrity-algorithm $INTEGRITY_ALGO --copy-to ${noauto;output:TARBALL_PATH} ${requirements;hide:"network:full"} ${hide;kv:"p TS_FNPM"} ${hide;kv:"pc magenta"} - # we want output to be available for other modules without affecting NPM_CONTRIBS - # we need to expose it (some details in https://st.yandex-team.ru/YMAKE-34) - _EXPOSE($TARBALL_PATH) -} - macro _TS_ADD_NODE_MODULES_FOR_BUILDER() { # Calculate inputs and outputs of node_modules, fill `_NODE_MODULES_INOUTS` variable _NODE_MODULES_CONFIGURE() diff --git a/build/conf/ts/ts.conf b/build/conf/ts/ts.conf index d793b6a7bd..0fb8cba30d 100644 --- a/build/conf/ts/ts.conf +++ b/build/conf/ts/ts.conf @@ -33,7 +33,6 @@ NOTS_TOOL_BASE_ARGS=\ --nodejs-bin $NODEJS_BIN \ --pm-script $PM_SCRIPT \ --pm-type $PM_TYPE \ - --contribs $NPM_CONTRIBS_PATH \ --trace $TS_TRACE \ --verbose $TS_LOG \ $_YATOOL_PREBUILDER_ARG diff --git a/build/plugins/lib/nots/package_manager/base/package_manager.py b/build/plugins/lib/nots/package_manager/base/package_manager.py index 8805c94013..efd5038d27 100644 --- a/build/plugins/lib/nots/package_manager/base/package_manager.py +++ b/build/plugins/lib/nots/package_manager/base/package_manager.py @@ -34,7 +34,6 @@ class BasePackageManager(object): sources_path, nodejs_bin_path, script_path, - contribs_path, module_path=None, sources_root=None, ): @@ -45,7 +44,6 @@ class BasePackageManager(object): self.sources_root = sources_path[: -len(self.module_path) - 1] if sources_root is None else sources_root self.nodejs_bin_path = nodejs_bin_path self.script_path = script_path - self.contribs_path = contribs_path @classmethod def load_package_json(cls, path): @@ -150,9 +148,6 @@ class BasePackageManager(object): def _nm_path(self, *parts): return os.path.join(build_nm_path(self.build_path), *parts) - def _contrib_tarball_path(self, pkg): - return os.path.join(self.contribs_path, pkg.tarball_path) - def _tarballs_store_path(self, pkg, store_path): return os.path.join(self.module_path, store_path, pkg.tarball_path) diff --git a/build/plugins/lib/nots/package_manager/npm/npm_package_manager.py b/build/plugins/lib/nots/package_manager/npm/npm_package_manager.py index 72abcd43eb..3de14b1d7c 100644 --- a/build/plugins/lib/nots/package_manager/npm/npm_package_manager.py +++ b/build/plugins/lib/nots/package_manager/npm/npm_package_manager.py @@ -50,9 +50,6 @@ class NpmPackageManager(BasePackageManager): if errors: raise PackageManagerError("Unable to process some lockfiles:\n{}".format("\n".join(errors))) - def calc_prepare_deps_inouts(self, store_path: str, has_deps: bool) -> tuple[list[str], list[str]]: - raise NotImplementedError("NPM does not support contrib/typescript flow.") - def calc_prepare_deps_inouts_and_resources( self, store_path: str, has_deps: bool ) -> tuple[list[str], list[str], list[str]]: @@ -147,7 +144,6 @@ class NpmPackageManager(BasePackageManager): sources_path=dep_source_path, nodejs_bin_path=self.nodejs_bin_path, script_path=self.script_path, - contribs_path=self.contribs_path, module_path=module_path, sources_root=self.sources_root, ) diff --git a/build/plugins/lib/nots/package_manager/pnpm/package_manager.py b/build/plugins/lib/nots/package_manager/pnpm/package_manager.py index 43e6cbfe15..8be7a2dddb 100644 --- a/build/plugins/lib/nots/package_manager/pnpm/package_manager.py +++ b/build/plugins/lib/nots/package_manager/pnpm/package_manager.py @@ -117,29 +117,6 @@ class PnpmPackageManager(BasePackageManager): return ins, outs, resources # TODO: FBP-1254 - # def calc_prepare_deps_inouts(self, store_path: str, has_deps: bool) -> (list[str], list[str]): - def calc_prepare_deps_inouts(self, store_path, has_deps): - ins = [ - s_rooted(build_pj_path(self.module_path)), - s_rooted(build_lockfile_path(self.module_path)), - ] - outs = [ - b_rooted(build_ws_config_path(self.module_path)), - b_rooted(build_pre_lockfile_path(self.module_path)), - ] - - if has_deps: - for dep_path in self.get_local_peers_from_package_json(): - ins.append(b_rooted(build_ws_config_path(dep_path))) - ins.append(b_rooted(build_pre_lockfile_path(dep_path))) - - for pkg in self.extract_packages_meta_from_lockfiles([build_lockfile_path(self.sources_path)]): - ins.append(b_rooted(self._contrib_tarball_path(pkg))) - outs.append(b_rooted(self._tarballs_store_path(pkg, store_path))) - - return ins, outs - - # TODO: FBP-1254 # def calc_node_modules_inouts(self, local_cli=False) -> (list[str], list[str]): def calc_node_modules_inouts(self, local_cli=False): """ diff --git a/build/plugins/nots.py b/build/plugins/nots.py index f5a199bb07..f6824b67e7 100644 --- a/build/plugins/nots.py +++ b/build/plugins/nots.py @@ -345,7 +345,6 @@ def _create_pm(unit: NotsUnitType) -> 'BasePackageManager': sources_path=unit.resolve(sources_path), build_root="$B", build_path=unit.path().replace("$S", "$B", 1), - contribs_path=unit.get("NPM_CONTRIBS_PATH"), nodejs_bin_path=None, script_path=None, module_path=module_path, @@ -387,31 +386,6 @@ def on_set_append_with_directive(unit: NotsUnitType, var_name: str, directive: s __set_append(unit, var_name, " ".join(wrapped)) -@_with_report_configure_error -def on_from_npm_lockfiles(unit, *args): - from lib.nots.package_manager.base import PackageManagerError - - # This is contrib with pnpm-lock.yaml files only - # Force set to pnpm - unit.set(["PM_TYPE", "pnpm"]) - pm = _create_pm(unit) - lf_paths = [] - - for lf_path in args: - abs_lf_path = unit.resolve(unit.resolve_arc_path(lf_path)) - if abs_lf_path: - lf_paths.append(abs_lf_path) - elif unit.get("TS_STRICT_FROM_NPM_LOCKFILES") == "yes": - ymake.report_configure_error("lockfile not found: {}".format(lf_path)) - - try: - for pkg in pm.extract_packages_meta_from_lockfiles(lf_paths): - unit.on_from_npm([pkg.tarball_url, pkg.sky_id, pkg.integrity, pkg.integrity_algorithm, pkg.tarball_path]) - except PackageManagerError as e: - logger.warn(str(e)) - pass - - def _check_nodejs_version(unit: NotsUnitType, major: int) -> None: if major < 14: raise Exception( @@ -800,28 +774,6 @@ def _select_matching_version( @_with_report_configure_error def on_prepare_deps_configure(unit: NotsUnitType) -> None: - contrib_path = unit.get("NPM_CONTRIBS_PATH") - if contrib_path == '-': - unit.on_prepare_deps_configure_no_contrib() - return - unit.onpeerdir(contrib_path) - pm = _create_pm(unit) - pj = pm.load_package_json_from_dir(pm.sources_path) - has_deps = pj.has_dependencies() - ins, outs = pm.calc_prepare_deps_inouts(unit.get("_TARBALLS_STORE"), has_deps) - - if has_deps: - unit.onpeerdir(pm.get_local_peers_from_package_json()) - __set_append(unit, "_PREPARE_DEPS_INOUTS", _build_directives("input", ["hide"], sorted(ins))) - __set_append(unit, "_PREPARE_DEPS_INOUTS", _build_directives("output", ["hide"], sorted(outs))) - - else: - __set_append(unit, "_PREPARE_DEPS_INOUTS", _build_directives("output", [], sorted(outs))) - unit.set(["_PREPARE_DEPS_CMD", "$_PREPARE_NO_DEPS_CMD"]) - - -@_with_report_configure_error -def on_prepare_deps_configure_no_contrib(unit: NotsUnitType) -> None: pm = _create_pm(unit) pj = pm.load_package_json_from_dir(pm.sources_path) has_deps = pj.has_dependencies() diff --git a/build/scripts/fetch_from_npm.py b/build/scripts/fetch_from_npm.py deleted file mode 100644 index d8f0c41f26..0000000000 --- a/build/scripts/fetch_from_npm.py +++ /dev/null @@ -1,113 +0,0 @@ -from __future__ import print_function -from future.utils import raise_ -import os -import sys -import time -import logging -import argparse -import hashlib -import base64 - -import sky -import fetch_from - - -NPM_BASEURL = "http://npm.yandex-team.ru" - - -def parse_args(): - parser = argparse.ArgumentParser() - fetch_from.add_common_arguments(parser) - - parser.add_argument("--tarball-url", required=True) - parser.add_argument("--sky-id", required=True) - parser.add_argument("--integrity", required=True) - parser.add_argument("--integrity-algorithm", required=True) - - return parser.parse_args() - - -def fetch(tarball_url, sky_id, integrity, integrity_algorithm, file_name, tries=5): - """ - :param name: package name - :type name: str - :param version: package version - :type version: str - :param sky_id: sky id of tarball - :type sky_id: str - :param integrity: tarball integrity (hex) - :type integrity: str - :param integrity_algorithm: integrity algorithm (known for openssl) - :type integrity_algorithm: str - :param tries: tries count - :type tries: int - :return: path to fetched file - :rtype: str - """ - # if sky.is_avaliable() and 'NOTS_FETCH_FROM_HTTP_ONLY' not in os.environ: - # fetcher = lambda: sky.fetch(sky_id, file_name) - # else: - # Отключаем походы через скай - # TODO: https://st.yandex-team.ru/FBP-351 - if 'NOTS_FETCH_FROM_SKY' in os.environ and sky.is_avaliable(): - fetcher = lambda: sky.fetch(sky_id, file_name) - else: - fetcher = lambda: _fetch_via_http(tarball_url, integrity, integrity_algorithm, file_name) - - fetched_file = None - exc_info = None - - for i in range(0, tries): - try: - fetched_file = fetcher() - exc_info = None - break - except Exception as e: - logging.exception(e) - exc_info = exc_info or sys.exc_info() - time.sleep(i) - - if exc_info: - raise_(exc_info[0], exc_info[1], exc_info[2]) - - return fetched_file - - -def _fetch_via_http(tarball_url, integrity, integrity_algorithm, file_name): - is_abs_url = tarball_url.startswith("https://") or tarball_url.startswith("http://") - url_delim = "" if tarball_url.startswith("/") else "/" - url = tarball_url if is_abs_url else NPM_BASEURL + url_delim + tarball_url - - hashobj = hashlib.new(integrity_algorithm) - fetched_file = fetch_from.fetch_url(url, False, file_name, tries=1, writers=[hashobj.update]) - checksum = base64.b64encode(hashobj.digest()).decode('utf-8') - - if checksum != integrity: - raise fetch_from.BadChecksumFetchError("Expected {}, but got {} for {}".format( - integrity, - checksum, - file_name, - )) - - return fetched_file - - -def main(args): - file_name = os.path.basename(args.copy_to) - fetched_file = fetch(args.tarball_url, args.sky_id, args.integrity, args.integrity_algorithm, file_name) - fetch_from.process(fetched_file, file_name, args) - - -if __name__ == "__main__": - args = parse_args() - fetch_from.setup_logging(args, os.path.basename(__file__)) - - try: - main(args) - except Exception as e: - logging.exception(e) - print(open(args.abs_log_path).read(), file=sys.stderr) - sys.stderr.flush() - - import error - sys.exit(error.ExitCodes.INFRASTRUCTURE_ERROR if fetch_from.is_temporary(e) else 1) diff --git a/build/scripts/ya.make b/build/scripts/ya.make index 43cda7dc0d..3941fa1fb8 100644 --- a/build/scripts/ya.make +++ b/build/scripts/ya.make @@ -15,7 +15,6 @@ IF (PY2) fetch_from.py fetch_from_archive.py fetch_from_mds.py - fetch_from_npm.py fetch_from_sandbox.py fetch_resource.py fix_py2_protobuf.py |