Skip to content

Commit

Permalink
Modernize build
Browse files Browse the repository at this point in the history
  • Loading branch information
hameerabbasi committed Feb 4, 2025
1 parent 9921991 commit 295b2bb
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 24 deletions.
11 changes: 1 addition & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,7 @@ jobs:
- name: Checkout Finch-mlir
uses: actions/checkout@v4
with:
path: 'Finch-mlir'

- name: Checkout LLVM
uses: actions/checkout@v4
with:
repository: llvm/llvm-project
ref: 'bb59eb8ed534da2bd03117cfde594321add4d60c' # Latest commit as of 2025-01-22
path: 'llvm-project'
submodules: 'recursive'

- name: Setup Developer Command Prompt
uses: ilammy/msvc-dev-cmd@v1.4.1
Expand Down Expand Up @@ -105,8 +98,6 @@ jobs:
env:
SPARSE_BACKEND: MLIR
run: |
mv ./Finch-mlir/setup.py .
mv ./Finch-mlir/pyproject.toml .
cibuildwheel --output-dir ./wheelhouse
ccache -s
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.vscode/
build/
*.egg_info
*.egg-info
dist/
5 changes: 5 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[submodule "llvm-project"]
path = llvm-project
url = https://github.com/llvm/llvm-project.git
branch = bb59eb8ed534da2bd03117cfde594321add4d60c
shallow = true
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ find_package(Python3 COMPONENTS Interpreter Development.Module NumPy REQUIRED)
# nanobind uses Python_EXECUTABLE
find_package(Python COMPONENTS Interpreter Development.Module NumPy REQUIRED)


if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
find_package(MLIR REQUIRED CONFIG)

Expand Down
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
recursive-include llvm-project **/*
recursive-exclude llvm-project/.git **/*
1 change: 1 addition & 0 deletions llvm-project
Submodule llvm-project added at bb59eb
19 changes: 18 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,24 @@ requires = [
"PyYAML",
"nanobind",
"delvewheel; platform_system=='Windows'",
"setuptools-scm>=8",
]
build-backend = "setuptools.build_meta"

[project]
name = "finch-mlir"
dynamic = ["version"]
description = "Finch MLIR distribution as wheel."
readme = "README.md"
dependencies = [
"PyYAML>=6",
"numpy>=1.17",
]

[tool.setuptools.packages.find]
include = ["mlir_finch", "mlir_finch.*"]

[tool.setuptools_scm]

[tool.cibuildwheel]
build = "cp310-* cp311-* cp312-* cp313-*"
Expand All @@ -22,7 +39,7 @@ test-command = "python -m pytest --pyargs sparse.mlir_backend"
skip = ["*-manylinux_i686", "*-musllinux*"]
environment = { PATH = "/usr/lib/ccache:/usr/lib64/ccache:/usr/lib/ccache/bin:$PATH" }
before-build = [
"{project}/Finch-mlir/scripts/docker_prepare_ccache.sh"
"{project}/scripts/docker_prepare_ccache.sh"
]
environment-pass = ["HOST_CCACHE_DIR", "SPARSE_BACKEND"]

Expand Down
15 changes: 4 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext


class CMakeExtension(Extension):
def __init__(
self,
Expand All @@ -19,7 +18,7 @@ def __init__(
finch_source_dir: str,
) -> None:
super().__init__(name, sources=[])
self.llvm_source_dir = os.fspath(Path(llvm_source_dir).resolve())
self.llvm_source_dir = os.fspath((Path(llvm_source_dir) / "llvm").resolve())
self.finch_source_dir = os.fspath(Path(finch_source_dir).resolve())


Expand Down Expand Up @@ -98,6 +97,7 @@ def build_extension(self, ext: CMakeExtension) -> None:
f"-B{finch_build_dir}",
f"-DMLIR_DIR={llvm_install_dir / 'lib' / 'cmake' / 'mlir'}",
f"-DLLVM_EXTERNAL_LIT={llvm_build_dir / 'bin' / llvm_lit}",
f"-DLLVM_MAIN_SRC_DIR={ext.llvm_source_dir}"
"-DCMAKE_PLATFORM_NO_VERSIONED_SONAME=ON",
f"-DCMAKE_MAKE_PROGRAM:FILEPATH={ninja_executable_path}",
"-DLLVM_ENABLE_ZLIB=OFF",
Expand Down Expand Up @@ -158,18 +158,11 @@ def create_dir(name: str) -> Path:


setup(
name="finch-mlir",
version="0.0.2",
include_package_data=True,
description="Finch MLIR distribution as wheel.",
long_description="Finch MLIR distribution as wheel.",
long_description_content_type="text/markdown",
ext_modules=[CMakeExtension(
"mlir_finch_ext",
llvm_source_dir=f"./llvm-project/llvm",
finch_source_dir="./Finch-mlir",
llvm_source_dir="./llvm-project",
finch_source_dir=".",
)],
install_requires=["PyYAML>=6", "numpy>=1.17"],
cmdclass={"build_ext": CMakeBuild},
zip_safe=False,
)

0 comments on commit 295b2bb

Please sign in to comment.