From 295b2bb57f119764df64af3646740c6e0481c459 Mon Sep 17 00:00:00 2001 From: Hameer Abbasi <2190658+hameerabbasi@users.noreply.github.com> Date: Tue, 4 Feb 2025 13:39:03 +0100 Subject: [PATCH] Modernize build --- .github/workflows/ci.yml | 11 +---------- .gitignore | 2 +- .gitmodules | 5 +++++ CMakeLists.txt | 1 - MANIFEST.in | 2 ++ llvm-project | 1 + pyproject.toml | 19 ++++++++++++++++++- setup.py | 15 ++++----------- 8 files changed, 32 insertions(+), 24 deletions(-) create mode 100644 .gitmodules create mode 100644 MANIFEST.in create mode 160000 llvm-project diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 37964c5..3798439 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 diff --git a/.gitignore b/.gitignore index f37f84e..a85b15b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ .vscode/ build/ -*.egg_info +*.egg-info dist/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..e9ec63c --- /dev/null +++ b/.gitmodules @@ -0,0 +1,5 @@ +[submodule "llvm-project"] + path = llvm-project + url = https://github.com/llvm/llvm-project.git + branch = bb59eb8ed534da2bd03117cfde594321add4d60c + shallow = true diff --git a/CMakeLists.txt b/CMakeLists.txt index d6f7800..3a0d8cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..d449899 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +recursive-include llvm-project **/* +recursive-exclude llvm-project/.git **/* diff --git a/llvm-project b/llvm-project new file mode 160000 index 0000000..bb59eb8 --- /dev/null +++ b/llvm-project @@ -0,0 +1 @@ +Subproject commit bb59eb8ed534da2bd03117cfde594321add4d60c diff --git a/pyproject.toml b/pyproject.toml index 0e82f1a..49bba26 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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-*" @@ -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"] diff --git a/setup.py b/setup.py index 39cbf55..4752202 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,6 @@ from setuptools import Extension, setup from setuptools.command.build_ext import build_ext - class CMakeExtension(Extension): def __init__( self, @@ -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()) @@ -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", @@ -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, )