From 63a0c8c4bfbc1fb17e782fed1284bc36fb30e201 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Sok=C3=B3=C5=82?= Date: Mon, 4 Nov 2024 10:04:50 +0000 Subject: [PATCH] Revert directory move logic --- pyproject.toml | 3 +- python/CMakeLists.txt | 34 +++++--------------- python/mlir_finch/dialects/finch.py | 2 +- setup.py | 48 ++++++++++++++--------------- 4 files changed, 33 insertions(+), 54 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2264c31..5fb21e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,7 @@ build = "cp310-* cp311-* cp312-* cp313-*" build-verbosity = 1 test-requires = ["pytest", "pytest-cov", "PyYAML", "scipy"] before-test = "pip install --no-deps sparse@git+https://github.com/pydata/sparse@updated-llvm-nightly-test" -test-command = "pytest --pyargs sparse.mlir_backend" +test-command = "pytest --pyargs sparse/mlir_backend" [tool.cibuildwheel.linux] skip = ["*-manylinux_i686", "*-musllinux*"] @@ -40,4 +40,3 @@ before-build = [ "pip install delvewheel", "pip install -r {project}\\Finch-mlir\\requirements\\requirements.txt", ] -test-command = "python -c \"import mlir_finch\"" \ No newline at end of file diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 6deb356..1280c5b 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -29,37 +29,17 @@ declare_mlir_python_extension(FinchPythonSources.Extension LLVMSupport EMBED_CAPI_LINK_LIBS FinchCAPI - # MLIRCAPIConversion - # MLIRCAPITransforms - # MLIRCAPIRegisterEverything ) -# EMBED_CAPI_LINK_LIBS -# MLIRCAPIDebug -# MLIRCAPIIR -# MLIRCAPIInterfaces -# declare_mlir_python_extension(FinchPythonSources.RegisterWhatWeNeed -# MODULE_NAME _finchRegisterWhatWeNeed -# ADD_TO_PARENT FinchPythonSources -# SOURCES -# RegisterEverything.cpp -# PRIVATE_LINK_LIBS -# LLVMSupport -# EMBED_CAPI_LINK_LIBS -# MLIRCAPIConversion -# MLIRCAPITransforms -# MLIRCAPIRegisterEverything -# ) - ################################################################################ # Common CAPI ################################################################################ -add_mlir_python_common_capi_library(FPCAPI +add_mlir_python_common_capi_library(FinchPythonCAPI INSTALL_COMPONENT FinchPythonModules - INSTALL_DESTINATION mlir_finch/_ms - OUTPUT_DIRECTORY "${MLIR_BINARY_DIR}/mlir_finch/_ms" - RELATIVE_INSTALL_ROOT "../.." + INSTALL_DESTINATION python_packages/finch/mlir_finch/_mlir_libs + OUTPUT_DIRECTORY "${MLIR_BINARY_DIR}/python_packages/finch/mlir_finch/_mlir_libs" + RELATIVE_INSTALL_ROOT "../../../.." DECLARED_SOURCES FinchPythonSources # TODO: Remove this in favor of showing fine grained registration once @@ -81,8 +61,8 @@ add_mlir_python_common_capi_library(FPCAPI ################################################################################ add_mlir_python_modules(FinchPythonModules - ROOT_PREFIX "${MLIR_BINARY_DIR}/mlir_finch" - INSTALL_PREFIX "mlir_finch" + ROOT_PREFIX "${MLIR_BINARY_DIR}/python_packages/finch/mlir_finch" + INSTALL_PREFIX "python_packages/finch/mlir_finch" DECLARED_SOURCES FinchPythonSources # TODO: Remove this in favor of showing fine grained registration once @@ -93,6 +73,6 @@ add_mlir_python_modules(FinchPythonModules MLIRPythonExtension.RegisterEverything MLIRPythonSources COMMON_CAPI_LINK_LIBS - FPCAPI + FinchPythonCAPI MLIRCAPIRegisterEverything ) diff --git a/python/mlir_finch/dialects/finch.py b/python/mlir_finch/dialects/finch.py index f46551b..933c732 100644 --- a/python/mlir_finch/dialects/finch.py +++ b/python/mlir_finch/dialects/finch.py @@ -3,4 +3,4 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception from ._finch_ops_gen import * -from .._ms._finchDialects.finch import * +from .._mlir_libs._finchDialects.finch import * diff --git a/setup.py b/setup.py index d5d538a..0cfb510 100644 --- a/setup.py +++ b/setup.py @@ -25,12 +25,12 @@ def __init__( class CMakeBuild(build_ext): def build_extension(self, ext: CMakeExtension) -> None: - p1 = os.fspath(Path("/tmp/st").absolute()) - shutil.move(ext.llvm_source_dir, p1) - ext.llvm_source_dir = os.fspath(Path("/tmp/st/llvm").absolute()) - p2 = os.fspath(Path("/tmp/sf").absolute()) - shutil.move(ext.finch_source_dir, p2) - ext.finch_source_dir = p2 + # p1 = os.fspath(Path("/tmp/st").absolute()) + # shutil.move(ext.llvm_source_dir, p1) + # ext.llvm_source_dir = os.fspath(Path("/tmp/st/llvm").absolute()) + # p2 = os.fspath(Path("/tmp/sf").absolute()) + # shutil.move(ext.finch_source_dir, p2) + # ext.finch_source_dir = p2 ext_fullpath = Path.cwd() / self.get_ext_fullpath(ext.name) extdir = ext_fullpath.parent.resolve() @@ -83,17 +83,17 @@ def build_extension(self, ext: CMakeExtension) -> None: llvm_lit = "llvm-lit.py" if platform.system() == "Windows" else "llvm-lit" - subprocess.run( - ["dir", llvm_build_dir / 'bin'], - cwd=finch_build_dir, - check=True, - ) + # subprocess.run( + # ["dir", llvm_build_dir / 'bin'], + # cwd=finch_build_dir, + # check=True, + # ) - subprocess.run( - ["dir", str(llvm_build_dir)], - cwd=finch_build_dir, - check=True, - ) + # subprocess.run( + # ["dir", str(llvm_build_dir)], + # cwd=finch_build_dir, + # check=True, + # ) # if platform.system() == "Windows": # # fatal error LNK1170: line in command file contains 131071 or more characters @@ -129,9 +129,9 @@ def build_extension(self, ext: CMakeExtension) -> None: ) # Move Python package out of nested directories. - # python_package_dir = install_dir / "python_packages" / "finch" / "mlir_finch" - # shutil.copytree(python_package_dir, install_dir / "mlir_finch") - # shutil.rmtree(install_dir / "python_packages") + python_package_dir = install_dir / "python_packages" / "finch" / "mlir_finch" + shutil.copytree(python_package_dir, install_dir / "mlir_finch") + shutil.rmtree(install_dir / "python_packages") subprocess.run( [ @@ -152,15 +152,15 @@ def build_extension(self, ext: CMakeExtension) -> None: def create_dir(name: str) -> Path: - path = Path("/tmp").absolute() / name + path = Path.cwd() / "build" / name # Path("/tmp").absolute() if not path.exists(): path.mkdir(parents=True) return path -llvm_build_dir = create_dir("ub") -llvm_install_dir = create_dir("ui") -finch_build_dir = create_dir("fb") +llvm_build_dir = create_dir("llvm-build") +llvm_install_dir = create_dir("llvm-install") +finch_build_dir = create_dir("finch-build") setup( @@ -172,7 +172,7 @@ def create_dir(name: str) -> Path: long_description_content_type="text/markdown", ext_modules=[CMakeExtension( "mlir_finch_ext", - llvm_source_dir=f"./llvm-project", # /llvm + llvm_source_dir=f"./llvm-project/llvm", # /llvm finch_source_dir="./Finch-mlir", )], cmdclass={"build_ext": CMakeBuild},