Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PyCDE] Move build and publishing pipeline into repo #7062

Merged
merged 58 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
e701fbd
pipeline debug
teqdruid May 17, 2024
c359a78
pipeline debug
teqdruid May 17, 2024
9ba9747
pipeline debug
teqdruid May 17, 2024
74c38e6
pipeline debug
teqdruid May 17, 2024
c490e4d
pipeline debug
teqdruid May 17, 2024
3f5d765
pipeline debug
teqdruid May 17, 2024
3a2dafb
pipeline debug
teqdruid May 17, 2024
96d99a5
pipeline debug
teqdruid May 17, 2024
d6f26f5
pipeline debug
teqdruid May 17, 2024
a6c18c5
pipeline debug
teqdruid May 17, 2024
aac2d79
pipeline debug
teqdruid May 17, 2024
777d4b5
pipeline debug
teqdruid May 17, 2024
1ef3884
pipeline debug
teqdruid May 17, 2024
4173efd
pipeline debug
teqdruid May 17, 2024
e37ce8f
pipeline debug
teqdruid May 17, 2024
0966949
pipeline debug
teqdruid May 17, 2024
feab610
pipeline debug
teqdruid May 18, 2024
c2b1b18
pipeline debug
teqdruid May 18, 2024
1203a13
pipeline debug
teqdruid May 18, 2024
896990d
pipeline debug
teqdruid May 18, 2024
a04c3d3
pipeline debug
teqdruid May 18, 2024
e903cc1
pipeline debug
teqdruid May 18, 2024
906aaac
pipeline debug
teqdruid May 18, 2024
3813e28
pipeline debug
teqdruid May 18, 2024
8716a0e
pipeline debug
teqdruid May 18, 2024
281a86d
pipeline debug
teqdruid May 18, 2024
14670f5
pipeline debug
teqdruid May 18, 2024
9b54d99
pipeline debug
teqdruid May 18, 2024
3f8f025
pipeline debug
teqdruid May 18, 2024
57cde60
pipeline debug
teqdruid May 18, 2024
38a205b
pipeline debug
teqdruid May 18, 2024
ff653b3
pipeline debug
teqdruid May 18, 2024
e1b0b6f
pipeline debug
teqdruid May 18, 2024
1fe890c
pipeline debug
teqdruid May 18, 2024
9297397
pipeline debug
teqdruid May 18, 2024
cecf9c9
pipeline debug
teqdruid May 18, 2024
f4fe6a3
pipeline debug
teqdruid May 18, 2024
19a95e3
pipeline debug
teqdruid May 18, 2024
6c74661
pipeline debug
teqdruid May 18, 2024
8ddf8c7
pipeline debug
teqdruid May 18, 2024
39ab44c
pipeline debug
teqdruid May 18, 2024
f94a869
pipeline debug
teqdruid May 18, 2024
6f7717f
pipeline debug
teqdruid May 18, 2024
ad010ba
pipeline debug
teqdruid May 18, 2024
f55a0c1
pipeline debug
teqdruid May 18, 2024
0862505
Merge branch 'main' into teqdruid/pycde-publish
teqdruid May 18, 2024
e3e8f22
pipeline debug
teqdruid May 18, 2024
fc6b506
pipeline debug
teqdruid May 18, 2024
3724296
pipeline debug
teqdruid May 19, 2024
e0780f9
pipeline debug
teqdruid May 19, 2024
ace88e2
done!
teqdruid May 20, 2024
42089ec
clean up workflow
teqdruid May 20, 2024
e4ee582
Merge branch 'main' into teqdruid/pycde-publish
teqdruid May 20, 2024
93018a5
Merge branch 'main' into teqdruid/pycde-publish
teqdruid May 20, 2024
5d1e45a
typo
teqdruid May 20, 2024
a0b4f77
Merge branch 'main' into teqdruid/pycde-publish
teqdruid May 20, 2024
650fbf7
Disable sccache.
teqdruid May 20, 2024
9e6cc01
Since I disabled caching, use my runners
teqdruid May 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
195 changes: 165 additions & 30 deletions .github/workflows/pycdePublish.yml
Original file line number Diff line number Diff line change
@@ -1,60 +1,195 @@
name: PyCDE Test and Publish

# Build the wheels for a series of Python versions and OSes and publish them to
# PyPI.

on:
push:
tags:
- pycde-*
workflow_dispatch:

jobs:
# Build CIRCT and run its tests using a Docker container with all the
# integration testing prerequisite installed.
build-circt:

# ---------------------------------------------------------------------------
# Build and test Linux wheels. Run the CIRCT tests also.
# ---------------------------------------------------------------------------

build-linux:
name: Build
runs-on: ubuntu-latest
# Run on an internal MSFT subscription. Please DO NOT use this for any other
# workflows without talking to John Demme (john.demme@microsoft.com, GH
# teqdruid) first. We may lose funding for this if it ends up costing too
# much.
# If individual jobs fail due to timeouts or disconnects, please report to
# John and re-run the job.
runs-on:
- self-hosted
- 1ES.Pool=1ES-CIRCT-builds
- 1ES.ImageOverride=CIRCT-StdUbuntu2204
strategy:
# Keep the 'matrix' strategy with one data point to make it obvious that
# this is one point in the overall matrix.
matrix:
python-env:
- cp38-win_amd64
- cp38-manylinux_x86_64
- cp39-manylinux_x86_64
- cp310-manylinux_x86_64
- cp311-manylinux_x86_64
- cp312-manylinux_x86_64
steps:
# Clone the CIRCT repo and its submodules. Do shallow clone to save clone
# time.
- name: Get CIRCT
uses: actions/checkout@v3
- name: Get CIRCT (no submodules)
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
fetch-tags: true
submodules: false

- name: Get shallow LLVM submodule
run: |
git submodule update --init --recursive --recommend-shallow --depth 1

# --------
# Build and test CIRCT
# --------
- name: Install dependencies
run: |
set -o errexit
sudo apt install -y python3-pip
python3 -m pip install --upgrade pip
python3 -m pip install cibuildwheel twine

# Build CIRCT and run its tests using a Docker container with all the
# integration testing prerequisite installed.
- name: Build wheel
env:
CC: clang
CXX: clang++
CIBW_BUILD: ${{ matrix.python-env }}
CIBW_ENVIRONMENT: CMAKE_GENERATOR=Ninja
CMAKE_GENERATOR: Ninja
SETUPTOOLS_SCM_DEBUG: True
BUILD_TYPE: RelWithAsserts
BUILD_TYPE: Release
RUN_TESTS: True
run: |
set -o errexit
export PATH=$PATH:$HOME/.local/bin
cd $(Pipeline.Workspace)/circt

echo "Fetching history and tags from CIRCT repo"
git fetch --depth=1000000 --tags --no-recurse-submodules

echo "Building wheel"
cibuildwheel --output-dir wheelhouse frontends/PyCDE
- name: Upload Binary (Non-Tag)
uses: actions/upload-artifact@v3

- name: Get wheel name
shell: bash
id: whl-name
run: |
cd wheelhouse
echo WHL=`ls *.whl` >> "$GITHUB_OUTPUT"

- name: Upload wheels as artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ steps.whl-name.outputs.WHL }}
path: wheelhouse/${{ steps.whl-name.outputs.WHL }}
retention-days: 7
if-no-files-found: error


# ---------------------------------------------------------------------------
# Build and test Windows wheels.
# ---------------------------------------------------------------------------

build-windows:
name: Build
# Run on an internal MSFT subscription. Please DO NOT use this for any other
# workflows without talking to John Demme (john.demme@microsoft.com, GH
# teqdruid) first. We may lose funding for this if it ends up costing too
# much.
# If individual jobs fail due to timeouts or disconnects, please report to
# John and re-run the job.
runs-on:
- self-hosted
- 1ES.Pool=1ES-CIRCT-builds
- 1ES.ImageOverride=1esMMSWindows2022
strategy:
matrix:
python-env:
- cp38-win_amd64
- cp39-win_amd64
- cp310-win_amd64
- cp311-win_amd64
- cp312-win_amd64
steps:
# Since we don't use docker on Windows, we need to install the dependencies.
- name: Build additional c++ deps
shell: pwsh
run: |
& "${env:VCPKG_INSTALLATION_ROOT}/vcpkg" --triplet x64-windows install zlib capnproto

- name: Get CIRCT
uses: actions/checkout@v4
with:
path: wheelhouse/*.whl
fetch-depth: 0
fetch-tags: true
submodules: false

- name: Get shallow LLVM submodule
run: |
git submodule update --init --recursive --recommend-shallow --depth 1

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install cibuildwheel twine
choco install ninja

- name: Build wheel
shell: cmd
env:
CIBW_BUILD: ${{ matrix.python-env }}
CMAKE_GENERATOR: Ninja
SETUPTOOLS_SCM_DEBUG: True
BUILD_TYPE: Release
# PyCDE integration tests are not yet implemented on Windows.
RUN_TESTS: False
run: |
echo "Building wheel"
"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" -arch=x64 -host_arch=x64 && python3 -m cibuildwheel --output-dir wheelhouse frontends/PyCDE

- name: Get wheel name
shell: bash
id: whl-name
run: |
cd wheelhouse
echo WHL=`ls *.whl` >> "$GITHUB_OUTPUT"

- name: Upload wheels as artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ steps.whl-name.outputs.WHL }}
path: wheelhouse/${{ steps.whl-name.outputs.WHL }}
retention-days: 7
if-no-files-found: error


# ---------------------------------------------------------------------------
# If both the Linux and Windows builds are successful, push the wheels to
# pypi. Only do this on the main branch or a tag.
# ---------------------------------------------------------------------------

push_wheels:
name: Push wheels (Tag or Weekly)
runs-on: ubuntu-20.04
if: github.repository == 'llvm/circt' && ( github.ref == 'refs/heads/main' || github.ref_type == 'tag' )
needs:
- build-linux
- build-windows
environment:
name: pypi
url: https://pypi.org/p/esiaccel
permissions:
id-token: write

steps:
- name: Download wheels
uses: actions/download-artifact@v4
with:
path: ./wheelhouse/
merge-multiple: true

- name: List downloaded wheels
run: ls -laR
working-directory: ./wheelhouse/

- name: Upload wheels to pypi
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: wheelhouse/
verify-metadata: false
10 changes: 10 additions & 0 deletions frontends/PyCDE/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ manylinux-x86_64-image = "ghcr.io/circt/images/pycde-build"
[tool.cibuildwheel.linux]
# Use our internal auditwheel script so as to not mess up the collateral.
repair-wheel-command = "frontends/PyCDE/auditwheel.sh {dest_dir} {wheel}"
environment-pass = [
"SCCACHE_GHA_ENABLED",
"ACTIONS_CACHE_URL",
"ACTIONS_RUNTIME_TOKEN",
"CMAKE_GENERATOR",
"SETUPTOOLS_SCM_DEBUG",
"BUILD_TYPE",
"RUN_TESTS",
"COMPILER_LAUNCHER"
]

[project]
name = "pycde"
Expand Down
38 changes: 25 additions & 13 deletions frontends/PyCDE/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class CMakeBuild(build_py):

def run(self):
target_dir = self.build_lib
test = os.getenv("RUN_TESTS")
cmake_build_dir = os.getenv("PYCDE_CMAKE_BUILD_DIR")
if not cmake_build_dir:
cmake_build_dir = os.path.join(target_dir, "..", "cmake_build")
Expand All @@ -54,6 +53,8 @@ def run(self):
os.environ.get("CIRCT_DIRECTORY", os.path.join(_thisdir, "..", "..")))
src_dir = os.path.abspath(os.path.join(circt_dir, "llvm", "llvm"))
cfg = "Release"
if "BUILD_TYPE" in os.environ:
cfg = os.environ["BUILD_TYPE"]
cmake_args = [
"-DCMAKE_INSTALL_PREFIX={}".format(os.path.abspath(cmake_install_dir)),
"-DPython3_EXECUTABLE={}".format(sys.executable.replace("\\", "/")),
Expand All @@ -66,9 +67,23 @@ def run(self):
"-DCIRCT_ENABLE_FRONTENDS=PyCDE",
"-DLLVM_EXTERNAL_PROJECTS=circt",
"-DLLVM_EXTERNAL_CIRCT_SOURCE_DIR={}".format(circt_dir),
"-DESI_RUNTIME=ON",
]
if "COMPILER_LAUNCHER" in os.environ:
cmake_args += [
f"-DCMAKE_C_COMPILER_LAUNCHER={os.environ['COMPILER_LAUNCHER']}",
f"-DCMAKE_CXX_COMPILER_LAUNCHER={os.environ['COMPILER_LAUNCHER']}"
]
if "CC" in os.environ:
cmake_args += [f"-DCMAKE_C_COMPILER={os.environ['CC']}"]
if "CXX" in os.environ:
cmake_args += [f"-DCMAKE_CXX_COMPILER={os.environ['CXX']}"]
if "CIRCT_EXTRA_CMAKE_ARGS" in os.environ:
cmake_args += os.environ["CIRCT_EXTRA_CMAKE_ARGS"].split(" ")
if "VCPKG_INSTALLATION_ROOT" in os.environ:
cmake_args += [
f"-DCMAKE_TOOLCHAIN_FILE={os.environ['VCPKG_INSTALLATION_ROOT']}/scripts/buildsystems/vcpkg.cmake"
]
build_args = []
build_parallelism = os.getenv("CMAKE_PARALLELISM")
if build_parallelism:
Expand All @@ -81,25 +96,22 @@ def run(self):
cmake_cache_file = os.path.join(cmake_build_dir, "CMakeCache.txt")
if os.path.exists(cmake_cache_file):
os.remove(cmake_cache_file)
print(f"Running cmake with args: {cmake_args}", file=sys.stderr)
subprocess.check_call(["echo", "Running: cmake", src_dir] + cmake_args)
subprocess.check_call(["cmake", src_dir] + cmake_args, cwd=cmake_build_dir)
targets = ["check-pycde"]
if "RUN_TESTS" in os.environ and os.environ["RUN_TESTS"] != "false":
# The pycde integration tests test both PyCDE and the ESIRuntime so
# failure shouldn't gate publishing PyCDE.
# targets.append("check-pycde-integration")
targets.append("check-circt")
subprocess.check_call([
"cmake",
"--build",
".",
"--target",
"check-pycde",
] + build_args,
] + targets + build_args,
cwd=cmake_build_dir)
if test.lower() == "true":
subprocess.check_call([
"cmake",
"--build",
".",
"--target",
"check-pycde-integration",
"check-circt",
] + build_args,
cwd=cmake_build_dir)
install_cmd = ["cmake", "--build", ".", "--target", "install-PyCDE"]
subprocess.check_call(install_cmd + build_args, cwd=cmake_build_dir)
shutil.copytree(os.path.join(cmake_install_dir, "python_packages"),
Expand Down
4 changes: 3 additions & 1 deletion lib/Dialect/ESI/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,9 @@ if (WHEEL_BUILD)
endif()

# Pybind11 is used to wrap the ESIRuntime APIs.
find_package(Python3 COMPONENTS Interpreter Development)
if(NOT DEFINED Python3_FOUND)
find_package(Python3 COMPONENTS Interpreter Development)
endif()
if(Python3_FOUND)
IF(MSVC)
# Work around an issue with pybind11 and cmake incompatibility on Windows in debug mode.
Expand Down
Loading