-
Notifications
You must be signed in to change notification settings - Fork 75.3k
Expand file tree
/
Copy pathpython_version.bzl
More file actions
51 lines (45 loc) · 1.81 KB
/
python_version.bzl
File metadata and controls
51 lines (45 loc) · 1.81 KB
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
"""
A much simplified version of third_party/py/python_repo.bzl, which generates the "python_version_repo" repo.
This is just to keep the current build compatible with both WORKSPACE and Bzlmod, we may not need this in future.
"""
_PY_VERSION_BZL = """
HERMETIC_PYTHON_VERSION = "{version}"
HERMETIC_PYTHON_VERSION_KIND = "{py_kind}"
USE_PYWRAP_RULES = {use_pywrap_rules}
MACOSX_DEPLOYMENT_TARGET = "{macosx_deployment_target}"
WHEEL_COLLAB = "{wheel_collab}"
WHEEL_NAME = "{wheel_name}"
# TODO(pcloudy): Figure out how to support requirements_lock in Bzlmod.
REQUIREMENTS = "//:requirements.txt"
"""
def _python_version_repo_impl(repository_ctx):
version = repository_ctx.os.environ.get("HERMETIC_PYTHON_VERSION", "3.11")
wheel_name = repository_ctx.os.environ.get("WHEEL_NAME", "tensorflow")
wheel_collab = repository_ctx.os.environ.get("WHEEL_COLLAB", False)
macosx_deployment_target = repository_ctx.os.environ.get("MACOSX_DEPLOYMENT_TARGET", "")
use_pywrap_rules = bool(
repository_ctx.os.environ.get("USE_PYWRAP_RULES", False),
)
repository_ctx.file("BUILD.bazel", "")
repository_ctx.file(
"py_version.bzl",
_PY_VERSION_BZL.format(
version = version,
py_kind = "", # TODO(pcloudy): introduce this value properly.
use_pywrap_rules = use_pywrap_rules,
wheel_name = wheel_name,
wheel_collab = wheel_collab,
macosx_deployment_target = macosx_deployment_target,
),
)
python_version_repo = repository_rule(
implementation = _python_version_repo_impl,
environ = [
"HERMETIC_PYTHON_VERSION",
"HERMETIC_PYTHON_VERSION_KIND",
"USE_PYWRAP_RULES",
],
)
python_version_ext = module_extension(
implementation = lambda mctx: python_version_repo(name = "python_version_repo"),
)