forked from aip-dev/site-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequirements.bzl
executable file
·53 lines (40 loc) · 3.14 KB
/
requirements.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""Starlark representation of locked requirements.
@generated by rules_python pip_parse repository rule
from //internal:requirements.txt
"""
load("@python39//:defs.bzl", "interpreter")
load("@rules_python//python/pip_install:pip_repository.bzl", "whl_library")
all_requirements = ["@pip_click//:pkg", "@pip_flask//:pkg", "@pip_itsdangerous//:pkg", "@pip_jinja2//:pkg", "@pip_markdown//:pkg", "@pip_markupsafe//:pkg", "@pip_pygments//:pkg", "@pip_pymdown_extensions//:pkg", "@pip_pyscss//:pkg", "@pip_pyyaml//:pkg", "@pip_six//:pkg", "@pip_types_markdown//:pkg", "@pip_types_pyyaml//:pkg", "@pip_werkzeug//:pkg", "@pip_importlib_metadata//:pkg", "@pip_zipp//:pkg"]
all_whl_requirements = ["@pip_click//:whl", "@pip_flask//:whl", "@pip_itsdangerous//:whl", "@pip_jinja2//:whl", "@pip_markdown//:whl", "@pip_markupsafe//:whl", "@pip_pygments//:whl", "@pip_pymdown_extensions//:whl", "@pip_pyscss//:whl", "@pip_pyyaml//:whl", "@pip_six//:whl", "@pip_types_markdown//:whl", "@pip_types_pyyaml//:whl", "@pip_werkzeug//:whl", "@pip_importlib_metadata//:whl", "@pip_zipp//:whl"]
_packages = [("pip_click", "click==8.1.3"), ("pip_flask", "flask==2.1.2"), ("pip_itsdangerous", "itsdangerous==2.1.2"), ("pip_jinja2", "jinja2==3.1.2"), ("pip_markdown", "markdown==3.3.7"), ("pip_markupsafe", "markupsafe==2.1.1"), ("pip_pygments", "pygments==2.12.0"), ("pip_pymdown_extensions", "pymdown-extensions==9.4"), ("pip_pyscss", "pyscss==1.4.0"), ("pip_pyyaml", "pyyaml==6.0"), ("pip_six", "six==1.16.0"), ("pip_types_markdown", "types-Markdown==3.3.21"), ("pip_types_pyyaml", "types-PyYAML==6.0.7"), ("pip_werkzeug", "werkzeug==2.1.2"), ("pip_importlib_metadata", "importlib-metadata==5.0.0"), ("pip_zipp", "zipp==3.10.0")]
_config = {"download_only": False, "enable_implicit_namespace_pkgs": False, "environment": {}, "extra_pip_args": [], "isolated": True, "pip_data_exclude": [], "python_interpreter": "python3", "python_interpreter_target": interpreter, "quiet": True, "repo": "pip", "repo_prefix": "pip_", "timeout": 600}
_annotations = {}
def _clean_name(name):
return name.replace("-", "_").replace(".", "_").lower()
def requirement(name):
return "@pip_" + _clean_name(name) + "//:pkg"
def whl_requirement(name):
return "@pip_" + _clean_name(name) + "//:whl"
def data_requirement(name):
return "@pip_" + _clean_name(name) + "//:data"
def dist_info_requirement(name):
return "@pip_" + _clean_name(name) + "//:dist_info"
def entry_point(pkg, script = None):
if not script:
script = pkg
return "@pip_" + _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 wo `setuptools`.
name = requirement.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
)