• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"""Starlark representation of locked requirements.
2
3@generated by rules_python pip_parse repository rule
4from %%REQUIREMENTS_LOCK%%
5"""
6
7%%IMPORTS%%
8
9all_requirements = %%ALL_REQUIREMENTS%%
10
11all_whl_requirements = %%ALL_WHL_REQUIREMENTS%%
12
13all_data_requirements = %%ALL_DATA_REQUIREMENTS%%
14
15_packages = %%PACKAGES%%
16_config = %%CONFIG%%
17_annotations = %%ANNOTATIONS%%
18
19def _clean_name(name):
20    return name.replace("-", "_").replace(".", "_").lower()
21
22def requirement(name):
23    return "@%%NAME%%_" + _clean_name(name) + "//:pkg"
24
25def whl_requirement(name):
26    return "@%%NAME%%_" + _clean_name(name) + "//:whl"
27
28def data_requirement(name):
29    return "@%%NAME%%_" + _clean_name(name) + "//:data"
30
31def dist_info_requirement(name):
32    return "@%%NAME%%_" + _clean_name(name) + "//:dist_info"
33
34def entry_point(pkg, script = None):
35    if not script:
36        script = pkg
37    return "@%%NAME%%_" + _clean_name(pkg) + "//:rules_python_wheel_entry_point_" + script
38
39def _get_annotation(requirement):
40    # This expects to parse `setuptools==58.2.0     --hash=sha256:2551203ae6955b9876741a26ab3e767bb3242dafe86a32a749ea0d78b6792f11`
41    # down to `setuptools`.
42    name = requirement.split(" ")[0].split("=")[0].split("[")[0]
43    return _annotations.get(name)
44
45def install_deps(**whl_library_kwargs):
46    whl_config = dict(_config)
47    whl_config.update(whl_library_kwargs)
48    for name, requirement in _packages:
49        whl_library(
50            name = name,
51            requirement = requirement,
52            annotation = _get_annotation(requirement),
53            **whl_config
54        )
55