blob: 411f334671856aafa8af97414deb75a0eda86ed3 [file] [log] [blame]
"""Starlark representation of locked requirements.
@generated by rules_python pip_parse repository rule
from %%REQUIREMENTS_LOCK%%
"""
%%IMPORTS%%
all_requirements = %%ALL_REQUIREMENTS%%
all_whl_requirements = %%ALL_WHL_REQUIREMENTS%%
all_data_requirements = %%ALL_DATA_REQUIREMENTS%%
_packages = %%PACKAGES%%
_config = %%CONFIG%%
_annotations = %%ANNOTATIONS%%
def _clean_name(name):
return name.replace("-", "_").replace(".", "_").lower()
def requirement(name):
return "@%%NAME%%_" + _clean_name(name) + "//:pkg"
def whl_requirement(name):
return "@%%NAME%%_" + _clean_name(name) + "//:whl"
def data_requirement(name):
return "@%%NAME%%_" + _clean_name(name) + "//:data"
def dist_info_requirement(name):
return "@%%NAME%%_" + _clean_name(name) + "//:dist_info"
def entry_point(pkg, script = None):
if not script:
script = pkg
return "@%%NAME%%_" + _clean_name(pkg) + "//:rules_python_wheel_entry_point_" + script
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):
whl_config = dict(_config)
whl_config.update(whl_library_kwargs)
for name, requirement in _packages:
whl_library(
name = name,
requirement = requirement,
annotation = _get_annotation(requirement),
**whl_config
)