Skip to content

Commit

Permalink
Update rules_python and rules_proto, along with bazel_rules_hdl
Browse files Browse the repository at this point in the history
NOTE: Due to the changes in how `rules_python` handles pip dependencies, we've had to add a new step to the startup instructions; users not on Python 3.11 (or not on a similar-enough Linux release) may need to run `bazel run //dependency_support:pip_requirements.update` before building the rest of the code.

As a side effect, lets us remove `xls_py_proto_library` wrapper, since internal & external `py_proto_library` rules have converged.

PiperOrigin-RevId: 571329808
  • Loading branch information
ericastor authored and copybara-github committed Oct 6, 2023
1 parent 6c01982 commit 3d27437
Show file tree
Hide file tree
Showing 21 changed files with 319 additions and 127 deletions.
2 changes: 2 additions & 0 deletions Dockerfile-ubuntu-20.04
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ USER xls-developer
ADD --chown=xls-developer . /home/xls-developer/xls/
WORKDIR /home/xls-developer/xls/

# Update pip dependencies
RUN bazel run -c opt //dependency_support:pip_requirements.update

# Build everything (opt)
RUN bazel build -c opt ...
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile-ubuntu-20.10
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ USER xls-developer
ADD --chown=xls-developer . /home/xls-developer/xls/
WORKDIR /home/xls-developer/xls/

# Update pip dependencies
RUN bazel run -c opt //dependency_support:pip_requirements.update


# Test everything (opt), exclude xlscc for now due to increased build time when
# we add Clang.
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile-ubuntu-22.04
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ USER xls-developer
ADD --chown=xls-developer . /home/xls-developer/xls/
WORKDIR /home/xls-developer/xls/

# Update pip dependencies
RUN bazel run -c opt //dependency_support:pip_requirements.update


# Test everything (opt), exclude xlscc for now due to increased build time when
# we add Clang.
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ bazel 5.2.0
~/xls$ # This is important. Without this step, you may experience cryptic error messages:
~/xls$ sudo apt install python3-distutils python3-dev libtinfo5 python-is-python3

~/xls$ # We're also going to update the Python/pip dependency lock file for your Python
~/xls$ # version, since it's locked to one version by default. Without this, you may
~/xls$ # also experience cryptic error messages.
~/xls$ bazel run -c opt -- //xls/dependency_support:pip_requirements.update

~/xls$ # Now build/test in optimized build mode.
~/xls$ # If you don't plan on using the C++ frontend, which is not needed to get started,
~/xls$ # use this command line:
Expand Down
10 changes: 9 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,16 @@ load("//dependency_support:initialize_external.bzl", "initialize_external_reposi

initialize_external_repositories()

load("@rules_hdl_pip_deps//:requirements.bzl", rules_hdl_pip_install_deps = "install_deps")

rules_hdl_pip_install_deps()

load("@xls_pip_deps//:requirements.bzl", xls_pip_install_deps = "install_deps")

xls_pip_install_deps()

# Loading the extra deps must be called after initialize_eternal_repositories or
# the call to pip_install fails.
# the call to pip_parse fails.
load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")

grpc_extra_deps()
8 changes: 7 additions & 1 deletion dependency_support/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Needed to make this a package.
load("@rules_python//python:pip.bzl", "compile_pip_requirements")

compile_pip_requirements(
name = "pip_requirements",
requirements_in = "pip_requirements.in",
requirements_txt = "pip_requirements_lock.txt",
)
21 changes: 14 additions & 7 deletions dependency_support/initialize_external.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,34 @@

"""Provides helper that initializes external repositories with third-party code."""

load("//dependency_support/boost:initialize.bzl", initialize_boost = "initialize")
load("//dependency_support/llvm:initialize.bzl", initialize_llvm = "initialize")
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
load("@com_grail_bazel_compdb//:deps.bzl", "bazel_compdb_deps")
load("@io_bazel_rules_closure//closure:repositories.bzl", "rules_closure_dependencies", "rules_closure_toolchains")
load("@rules_hdl//dependency_support:dependency_support.bzl", rules_hdl_dependency_support = "dependency_support")
load("@rules_hdl//:init.bzl", rules_hdl_init = "init")
load("@rules_python//python:pip.bzl", "pip_install")
load("//dependency_support/boost:initialize.bzl", initialize_boost = "initialize")
load("//dependency_support/llvm:initialize.bzl", initialize_llvm = "initialize")
load("@com_grail_bazel_compdb//:deps.bzl", "bazel_compdb_deps")
load("@rules_hdl//dependency_support:dependency_support.bzl", rules_hdl_dependency_support = "dependency_support")
load("@rules_hdl//toolchains/cpython:cpython_toolchain.bzl", rules_hdl_register_cpython_repository = "register_cpython_repository")
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
load("@rules_python//python:pip.bzl", "pip_parse")
load("@rules_python//python:repositories.bzl", "py_repositories")

def initialize_external_repositories():
"""Calls set-up methods for external repositories that require that."""
bazel_skylib_workspace()
protobuf_deps()
rules_hdl_register_cpython_repository()
rules_hdl_init()
rules_hdl_dependency_support()
rules_closure_dependencies()
rules_closure_toolchains()
pip_install(
rules_proto_dependencies()
rules_proto_toolchains()
py_repositories()
pip_parse(
name = "xls_pip_deps",
requirements = "@com_google_xls//dependency_support:pip_requirements.txt",
requirements_lock = "@com_google_xls//dependency_support:pip_requirements_lock.txt",
python_interpreter = "python3",
timeout = 600000,
)
Expand Down
21 changes: 16 additions & 5 deletions dependency_support/load_external.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,24 @@ def load_external_repositories():
],
)

# Released on 2022-04-22, current as of 2022-05-27
# https://github.com/bazelbuild/rules_python/releases/tag/0.8.1
# Released on 2022-12-27, current as of 2023-09-27
# https://github.com/bazelbuild/rules_proto/releases/tag/5.3.0-21.7
http_archive(
name = "rules_proto",
sha256 = "dc3fb206a2cb3441b485eb1e423165b231235a1ea9b031b4433cf7bc1fa460dd",
strip_prefix = "rules_proto-5.3.0-21.7",
urls = [
"https://github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.7.tar.gz",
],
)

# Released on 2023-08-22, current as of 2023-09-26
# https://github.com/bazelbuild/rules_python/releases/tag/0.25.0
http_archive(
name = "rules_python",
sha256 = "cdf6b84084aad8f10bf20b46b77cb48d83c319ebe6458a18e9d2cebf57807cdd",
strip_prefix = "rules_python-0.8.1",
url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.8.1.tar.gz",
sha256 = "5868e73107a8e85d8f323806e60cad7283f34b32163ea6ff1020cf27abef6036",
strip_prefix = "rules_python-0.25.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.25.0/rules_python-0.25.0.tar.gz",
)

http_archive(
Expand Down
File renamed without changes.
Loading

0 comments on commit 3d27437

Please sign in to comment.