"""Starlark representation of locked requirements. @generated by rules_python pip_parse repository rule. """ %%IMPORTS%% all_requirements = %%ALL_REQUIREMENTS%% all_whl_requirements_by_package = %%ALL_WHL_REQUIREMENTS_BY_PACKAGE%% all_whl_requirements = all_whl_requirements_by_package.values() all_data_requirements = %%ALL_DATA_REQUIREMENTS%% _packages = %%PACKAGES%% _config = %%CONFIG%% _annotations = %%ANNOTATIONS%% def requirement(name): return "%%MACRO_TMPL%%".format(pip_utils.normalize_name(name), "pkg") def whl_requirement(name): return "%%MACRO_TMPL%%".format(pip_utils.normalize_name(name), "whl") def data_requirement(name): return "%%MACRO_TMPL%%".format(pip_utils.normalize_name(name), "data") def dist_info_requirement(name): return "%%MACRO_TMPL%%".format(pip_utils.normalize_name(name), "dist_info") def _get_annotation(requirement): # This expects to parse `setuptools==58.2.0 --hash=sha256:2551203ae6955b9876741a26ab3e767bb3242dafe86a32a749ea0d78b6792f11` # down to `setuptools`. name = requirement.split(" ")[0].split("=")[0].split("[")[0] return _annotations.get(name) def install_deps(**whl_library_kwargs): """Repository rule macro. Install dependencies from `pip_parse`. Args: **whl_library_kwargs: Additional arguments which will flow to underlying `whl_library` calls. See pip_repository.bzl for details. """ # Set up the requirement groups all_requirement_groups = %%ALL_REQUIREMENT_GROUPS%% requirement_group_mapping = { requirement: group_name for group_name, group_requirements in all_requirement_groups.items() for requirement in group_requirements } # %%GROUP_LIBRARY%% # Install wheels which may be participants in a group whl_config = dict(_config) whl_config.update(whl_library_kwargs) for name, requirement in _packages: group_name = requirement_group_mapping.get(name.replace("%%NAME%%_", "")) group_deps = all_requirement_groups.get(group_name, []) whl_library( name = name, requirement = requirement, group_name = group_name, group_deps = group_deps, annotation = _get_annotation(requirement), **whl_config )