Skip to content

Commit

Permalink
Merge pull request #1202 from cliveverghese:python_versions
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 713802079
  • Loading branch information
copybara-github committed Jan 9, 2025
2 parents 9857c7d + 0563db1 commit d11ffb8
Show file tree
Hide file tree
Showing 5 changed files with 1,356 additions and 5 deletions.
3 changes: 2 additions & 1 deletion BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
load("@python//:defs.bzl", "compile_pip_requirements")
load("@python_deps//:requirements.bzl", "requirement")
load("@repository_configuration//:repository_config.bzl", "PROFILER_REQUIREMENTS_FILE")

# Description
# Xprof, ML Performance Toolbox (for TPU, GPU, CPU).
Expand Down Expand Up @@ -33,5 +34,5 @@ compile_pip_requirements(
],
generate_hashes = True,
requirements_in = "requirements.in",
requirements_txt = "requirements_lock_3_10.txt",
requirements_txt = PROFILER_REQUIREMENTS_FILE,
)
4 changes: 2 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ load("//:config.bzl", "repository_configuration")

repository_configuration(name = "repository_configuration")

load("@repository_configuration//:repository_config.bzl", "PROFILER_PYTHON_VERSION")
load("@repository_configuration//:repository_config.bzl", "PROFILER_PYTHON_VERSION", "PROFILER_REQUIREMENTS_FILE")

print("Using Python Version = {}".format(PROFILER_PYTHON_VERSION))

Expand Down Expand Up @@ -47,7 +47,7 @@ load("@rules_python//python:pip.bzl", "pip_parse")
pip_parse(
name = "python_deps",
python_interpreter_target = interpreter,
requirements_lock = "//:requirements_lock_3_10.txt",
requirements_lock = PROFILER_REQUIREMENTS_FILE,
)

load("@python_deps//:requirements.bzl", "install_deps")
Expand Down
5 changes: 3 additions & 2 deletions config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
def _repository_configuration(repository_ctx):
python_version = repository_ctx.os.environ.get("PROFILER_PYTHON_VERSION", "3.11")
repository_ctx.file("BUILD")

requirements_file = "//:requirements_lock_{version}.txt".format(version = python_version.replace(".", "_"))
repository_ctx.file("repository_config.bzl", content = """
PROFILER_PYTHON_VERSION={python_version}
""".format(python_version = repr(python_version)))
PROFILER_REQUIREMENTS_FILE={requirements_file}
""".format(python_version = repr(python_version), requirements_file = repr(requirements_file)))

repository_configuration = repository_rule(
implementation = _repository_configuration,
Expand Down
Loading

0 comments on commit d11ffb8

Please sign in to comment.