Skip to content

Commit

Permalink
Use a hermetic python and install lit
Browse files Browse the repository at this point in the history
  • Loading branch information
j2kun committed Aug 7, 2023
1 parent b0e529a commit aac8490
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 3 deletions.
5 changes: 5 additions & 0 deletions BUILD
@@ -0,0 +1,5 @@
# An MLIR tutorial

package(
default_visibility = ["//visibility:public"],
)
36 changes: 34 additions & 2 deletions WORKSPACE
@@ -1,5 +1,6 @@
workspace(name = "mlir_tutorial")

load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")

Expand Down Expand Up @@ -68,9 +69,40 @@ maybe(
# https://github.com/hedronvision/bazel-compile-commands-extractor
http_archive(
name = "hedron_compile_commands",
url = "https://github.com/hedronvision/bazel-compile-commands-extractor/archive/3dddf205a1f5cde20faf2444c1757abe0564ff4c.tar.gz",
strip_prefix = "bazel-compile-commands-extractor-3dddf205a1f5cde20faf2444c1757abe0564ff4c",
sha256 = "3cd0e49f0f4a6d406c1d74b53b7616f5e24f5fd319eafc1bf8eee6e14124d115",
strip_prefix = "bazel-compile-commands-extractor-3dddf205a1f5cde20faf2444c1757abe0564ff4c",
url = "https://github.com/hedronvision/bazel-compile-commands-extractor/archive/3dddf205a1f5cde20faf2444c1757abe0564ff4c.tar.gz",
)

load("@hedron_compile_commands//:workspace_setup.bzl", "hedron_compile_commands_setup")

hedron_compile_commands_setup()

# Depend on a hermetic python version
new_git_repository(
name = "rules_python",
commit = "9ffb1ecd9b4e46d2a0bca838ac80d7128a352f9f", # v0.23.1
remote = "https://github.com/bazelbuild/rules_python.git",
)

load("@rules_python//python:repositories.bzl", "python_register_toolchains")

python_register_toolchains(
name = "python3_10",
# Available versions are listed at
# https://github.com/bazelbuild/rules_python/blob/main/python/versions.bzl
python_version = "3.10",
)

load("@python3_10//:defs.bzl", "interpreter")
load("@rules_python//python:pip.bzl", "pip_parse")

pip_parse(
name = "mlir_tutorial_pip_deps",
python_interpreter_target = interpreter,
requirements_lock = "//:requirements.txt",
)

load("@mlir_tutorial_pip_deps//:requirements.bzl", "install_deps")

install_deps()
3 changes: 2 additions & 1 deletion bazel/lit.bzl
@@ -1,6 +1,7 @@
"""Macros for defining lit tests."""

load("@bazel_skylib//lib:paths.bzl", "paths")
load("@rules_python//python:py_test.bzl", "py_test")

_DEFAULT_FILE_EXTS = ["mlir"]

Expand Down Expand Up @@ -44,7 +45,7 @@ def lit_test(name = None, src = None, size = "small", tags = None):
srcs = [src],
)

native.py_test(
py_test(
name = name,
size = size,
# -v ensures lit outputs useful info during test failures
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
@@ -0,0 +1 @@
lit==16.0.6
1 change: 1 addition & 0 deletions tests/BUILD
Expand Up @@ -12,6 +12,7 @@ filegroup(
"@llvm-project//llvm:not",
"@llvm-project//mlir:mlir-cpu-runner",
"@llvm-project//mlir:mlir-opt",
"@mlir_tutorial_pip_deps_lit//:pkg",
],
)

Expand Down

0 comments on commit aac8490

Please sign in to comment.