Skip to content

Commit

Permalink
[BUILD:env] Changes that seem to get Ubuntu 22.04 working.
Browse files Browse the repository at this point in the history
* sysconfig module is no longer in distutils in Python 3.10 -- it was
  introduced in Python 3.2 so we can use it for all our platforms of interest.
* Allow a version of scipy that supports Python 3.10

PiperOrigin-RevId: 452125866
  • Loading branch information
cdleary authored and copybara-github committed May 31, 2022
1 parent f9185fb commit dec3462
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 5 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/nightly-ubuntu-22.04.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
# See also: https://github.com/marketplace/actions/bazel-action

name: Nightly Ubuntu 22.04
on:
schedule:
# Nightly at midnight -- uses UTC, so 7am.
- cron: '0 7 * * *'
# This lets us trigger manually from the UI.
workflow_dispatch:

jobs:
build:
name: Nightly Ubuntu 22.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v3
with:
path: "~/.cache/bazel"
# Create/use a cache called bazel-cache-22_04-<commit hash>
# and read the latest cache with prefix bazel-cache-22_04-
# if it doesn't already exist.
key: bazel-cache-22_04-${{ github.sha }}
restore-keys: bazel-cache-22_04-
- name: Install bazelisk
run: |
curl -LO "https://github.com/bazelbuild/bazelisk/releases/download/v1.1.0/bazelisk-linux-amd64"
mkdir -p "${GITHUB_WORKSPACE}/bin/"
mv bazelisk-linux-amd64 "${GITHUB_WORKSPACE}/bin/bazel"
chmod +x "${GITHUB_WORKSPACE}/bin/bazel"
# Note: xlscc is excluded because it builds Clang, and that can make
# builds time out.
- name: Bazel Test All (opt)
run: |
"${GITHUB_WORKSPACE}/bin/bazel" test -c opt -- //xls/... -//xls/contrib/xlscc/...
11 changes: 7 additions & 4 deletions dependency_support/load_external.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,13 @@ def load_external_repositories():
shallow_since = "1635790430 +0000",
)

# Commit on 2021-12-03, current as of 2022-05-04
# Commit on 2021-12-03, current as of 2022-05-31
http_archive(
name = "pybind11_bazel",
strip_prefix = "pybind11_bazel-72cbbf1fbc830e487e3012862b7b720001b70672",
urls = ["https://github.com/pybind/pybind11_bazel/archive/72cbbf1fbc830e487e3012862b7b720001b70672.tar.gz"],
sha256 = "516c1b3a10d87740d2b7de6f121f8e19dde2c372ecbfe59aef44cd1872c10395",
patches = ["@com_google_xls//dependency_support/pybind11_bazel:sysconfig_fix.patch"],
)

http_archive(
Expand Down Expand Up @@ -162,11 +163,13 @@ def load_external_repositories():
build_file = "@com_google_xls//dependency_support/linenoise:bundled.BUILD.bazel",
)

# Released on 2022-05-20, current as of 2022-05-31.
# https://github.com/grpc/grpc/releases/tag/v1.46.3
http_archive(
name = "com_github_grpc_grpc",
urls = ["https://github.com/grpc/grpc/archive/v1.43.0.tar.gz"],
sha256 = "9647220c699cea4dafa92ec0917c25c7812be51a18143af047e20f3fb05adddc",
strip_prefix = "grpc-1.43.0",
urls = ["https://github.com/grpc/grpc/archive/v1.46.3.tar.gz"],
sha256 = "d6cbf22cb5007af71b61c6be316a79397469c58c82a942552a62e708bce60964",
strip_prefix = "grpc-1.46.3",
# repo_mapping = {"@com_github_google_re2": "@com_googlesource_code_re2"},
# Note: repo mapping doesn't seem to work for gRPC because it
# explicitly binds the re2 name to the com_googlesource_code_re2 repo.
Expand Down
2 changes: 1 addition & 1 deletion dependency_support/pip_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ portpicker==1.3.1
# versions that we want to support (e.g. 18.04 vs 20.04), so we accept a
# range that makes successful installation on those platforms possible.
numpy>=1.21
scipy>=1.5.4,<=1.6.0
scipy>=1.5.4,<=1.8.1
15 changes: 15 additions & 0 deletions dependency_support/pybind11_bazel/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2022 The XLS Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Needed to make this a package.
15 changes: 15 additions & 0 deletions dependency_support/pybind11_bazel/sysconfig_fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git python_configure.bzl python_configure.bzl
index 1f5bffa..4225255 100644
--- python_configure.bzl
+++ python_configure.bzl
@@ -252,8 +252,8 @@ def _get_python_include(repository_ctx, python_bin):
python_bin,
"-c",
"from __future__ import print_function;" +
- "from distutils import sysconfig;" +
- "print(sysconfig.get_python_inc())",
+ "import sysconfig; import os; " +
+ "print(os.path.dirname(sysconfig.get_config_h_filename()))",
],
error_msg = "Problem getting python include path.",
error_details = ("Is the Python binary path set up right? " +
37 changes: 37 additions & 0 deletions xls/oss/Dockerfile-ubuntu-22.04
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# NOTE: We try to support Ubuntu 22.04 environment as it is the latest Ubuntu
LTS release.

# Download base image ubuntu 22.04
FROM ubuntu:22.04

# LABEL about the custom image
LABEL version="0.1"
LABEL description="Docker Image for Building/Testing XLS on Ubuntu 22.04 x86-64"

# Update package info
RUN apt-get update -y

# Install Bazel
RUN apt-get install -y curl gnupg && \
curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg && \
mv bazel.gpg /etc/apt/trusted.gpg.d/ && \
echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list && \
apt-get update -y && apt-get install -y bazel

# Install dependencies
RUN apt-get -y install python3-distutils python3-dev python-is-python3 libtinfo5 build-essential liblapack-dev libblas-dev gfortran

# Install development tools
RUN apt-get install -y git vim

RUN useradd -m xls-developer
USER xls-developer

# Map the project contents in.
ADD --chown=xls-developer . /home/xls-developer/xls/
WORKDIR /home/xls-developer/xls/


# Test everything (opt), exclude xlscc for now due to increased build time when
# we add Clang.
RUN bazel test -c opt -- //xls/... -//xls/contrib/xlscc/...

0 comments on commit dec3462

Please sign in to comment.