Skip to content

Commit

Permalink
Revert directory move logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsokol committed Nov 4, 2024
1 parent 32fa2b2 commit 63a0c8c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 54 deletions.
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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*"]
Expand All @@ -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\""
34 changes: 7 additions & 27 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -93,6 +73,6 @@ add_mlir_python_modules(FinchPythonModules
MLIRPythonExtension.RegisterEverything
MLIRPythonSources
COMMON_CAPI_LINK_LIBS
FPCAPI
FinchPythonCAPI
MLIRCAPIRegisterEverything
)
2 changes: 1 addition & 1 deletion python/mlir_finch/dialects/finch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
48 changes: 24 additions & 24 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
[
Expand All @@ -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(
Expand All @@ -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},
Expand Down

0 comments on commit 63a0c8c

Please sign in to comment.