Skip to content

Instantly share code, notes, and snippets.

@sdiehl
Created May 12, 2025 06:34
Show Gist options
  • Save sdiehl/96e014c6287ce6bb627ffd97a7027792 to your computer and use it in GitHub Desktop.
Save sdiehl/96e014c6287ce6bb627ffd97a7027792 to your computer and use it in GitHub Desktop.
Setup.py for mlir-python-bindings
from setuptools import setup, find_packages
import os
import platform
import sys
# Ensure we're using Python 3.10 or later
if sys.version_info < (3, 10):
raise RuntimeError("Python 3.10 or later required")
# Get platform-specific extension
if platform.system() == "Darwin":
lib_ext = ".dylib"
elif platform.system() == "Linux":
lib_ext = ".so"
elif platform.system() == "Windows":
lib_ext = ".dll"
else:
raise RuntimeError(f"Unsupported platform: {platform.system()}")
# Check if the _mlir_libs directory exists
mlir_libs_dir = os.path.join("mlir", "_mlir_libs")
if not os.path.exists(mlir_libs_dir):
os.makedirs(mlir_libs_dir, exist_ok=True)
setup(
name="mlir",
version="0.0.1",
author="LLVM/MLIR Team",
author_email="[email protected]",
description="MLIR Python Bindings",
long_description="Python bindings for Multi-Level IR Compiler Framework",
long_description_content_type="text/markdown",
url="https://mlir.llvm.org",
packages=find_packages(),
include_package_data=True,
package_data={
"mlir": [f"_mlir_libs/*{lib_ext}*"],
},
zip_safe=False,
python_requires=">=3.10",
classifiers=[
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"License :: OSI Approved :: Apache Software License",
"Operating System :: MacOS",
"Operating System :: POSIX :: Linux",
],
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment