Enable Python bindings
Create package python3-mlir that distributes all the MLIR Python bindings.
This commit is contained in:
parent
037ead5935
commit
d5802648fa
|
@ -0,0 +1,72 @@
|
|||
From d8d712c632e925139a6e5e53ee64749301358b25 Mon Sep 17 00:00:00 2001
|
||||
From: Tulio Magno Quites Machado Filho <tuliom@redhat.com>
|
||||
Date: Tue, 5 Sep 2023 10:35:37 -0300
|
||||
Subject: [PATCH] [mlir][python] Reuse the library directory
|
||||
|
||||
Prefer to get the path to the shared libraries from config.llvm_shlib_dir.
|
||||
Fallback to the previous path only if config.llvm_shlib_dir is not
|
||||
defined.
|
||||
|
||||
This ensures the test will pass regardless of the build configuration
|
||||
used downstream.
|
||||
---
|
||||
mlir/test/lit.cfg.py | 1 +
|
||||
mlir/test/python/execution_engine.py | 12 +++++++-----
|
||||
2 files changed, 8 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/mlir/test/lit.cfg.py b/mlir/test/lit.cfg.py
|
||||
index 3a8bdbfcec28..eb8e66a2491c 100644
|
||||
--- a/mlir/test/lit.cfg.py
|
||||
+++ b/mlir/test/lit.cfg.py
|
||||
@@ -130,6 +130,7 @@ tools.extend(
|
||||
ToolSubst("toyc-ch7", unresolved="ignore"),
|
||||
ToolSubst('transform-opt-ch2', unresolved='ignore'),
|
||||
ToolSubst('transform-opt-ch3', unresolved='ignore'),
|
||||
+ ToolSubst("%llvm_shlib_dir", config.llvm_shlib_dir, unresolved="ignore"),
|
||||
ToolSubst("%mlir_lib_dir", config.mlir_lib_dir, unresolved="ignore"),
|
||||
ToolSubst("%mlir_src_dir", config.mlir_src_root, unresolved="ignore"),
|
||||
]
|
||||
diff --git a/mlir/test/python/execution_engine.py b/mlir/test/python/execution_engine.py
|
||||
index e8b47007a890..0cb78dd0bac6 100644
|
||||
--- a/mlir/test/python/execution_engine.py
|
||||
+++ b/mlir/test/python/execution_engine.py
|
||||
@@ -1,4 +1,4 @@
|
||||
-# RUN: %PYTHON %s 2>&1 | FileCheck %s
|
||||
+# RUN: env LLVM_SHLIB_DIR=%llvm_shlib_dir %PYTHON %s 2>&1 | FileCheck %s
|
||||
# REQUIRES: host-supports-jit
|
||||
import gc, sys, os, tempfile
|
||||
from mlir.ir import *
|
||||
@@ -6,6 +6,8 @@ from mlir.passmanager import *
|
||||
from mlir.execution_engine import *
|
||||
from mlir.runtime import *
|
||||
|
||||
+_DEFAULT_LIB_DIR = "../../../../lib"
|
||||
+LIB_DIR = os.getenv("LLVM_SHLIB_DIR", _DEFAULT_LIB_DIR)
|
||||
|
||||
# Log everything to stderr and flush so that we have a unified stream to match
|
||||
# errors/info emitted by MLIR to stderr.
|
||||
@@ -540,8 +542,8 @@ def testSharedLibLoad():
|
||||
]
|
||||
else:
|
||||
shared_libs = [
|
||||
- "../../../../lib/libmlir_runner_utils.so",
|
||||
- "../../../../lib/libmlir_c_runner_utils.so",
|
||||
+ LIB_DIR + "/libmlir_runner_utils.so",
|
||||
+ LIB_DIR + "/libmlir_c_runner_utils.so",
|
||||
]
|
||||
|
||||
execution_engine = ExecutionEngine(
|
||||
@@ -583,8 +585,8 @@ def testNanoTime():
|
||||
]
|
||||
else:
|
||||
shared_libs = [
|
||||
- "../../../../lib/libmlir_runner_utils.so",
|
||||
- "../../../../lib/libmlir_c_runner_utils.so",
|
||||
+ LIB_DIR + "/libmlir_runner_utils.so",
|
||||
+ LIB_DIR + "/libmlir_c_runner_utils.so",
|
||||
]
|
||||
|
||||
execution_engine = ExecutionEngine(
|
||||
--
|
||||
2.41.0
|
||||
|
37
mlir.spec
37
mlir.spec
|
@ -12,7 +12,7 @@
|
|||
|
||||
Name: mlir
|
||||
Version: %{mlir_version}%{?rc_ver:~rc%{rc_ver}}
|
||||
Release: 2%{?dist}
|
||||
Release: 3%{?dist}
|
||||
Summary: Multi-Level Intermediate Representation Overview
|
||||
|
||||
License: Apache-2.0 WITH LLVM-exception
|
||||
|
@ -21,6 +21,8 @@ Source0: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{maj_ve
|
|||
Source1: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{maj_ver}.%{min_ver}.%{patch_ver}%{?rc_ver:-rc%{rc_ver}}/%{mlir_srcdir}.tar.xz.sig
|
||||
Source2: release-keys.asc
|
||||
|
||||
Patch1: 0001-mlir-python-Reuse-the-library-directory.patch
|
||||
|
||||
# Support for i686 upstream is unclear with lots of tests failling.
|
||||
ExcludeArch: i686
|
||||
|
||||
|
@ -33,6 +35,10 @@ BuildRequires: llvm-cmake-utils = %{version}
|
|||
BuildRequires: llvm-googletest = %{version}
|
||||
BuildRequires: llvm-test = %{version}
|
||||
BuildRequires: python3-lit
|
||||
BuildRequires: python3-devel
|
||||
BuildRequires: python3-numpy
|
||||
BuildRequires: python3-pybind11
|
||||
BuildRequires: python3-pyyaml
|
||||
|
||||
# For origin certification
|
||||
BuildRequires: gnupg2
|
||||
|
@ -59,6 +65,14 @@ Requires: %{name}-static%{?_isa} = %{version}-%{release}
|
|||
%description devel
|
||||
MLIR development files.
|
||||
|
||||
%package -n python3-%{name}
|
||||
Summary: MLIR python bindings
|
||||
Requires: python3
|
||||
Requires: python3-numpy
|
||||
|
||||
%description -n python3-%{name}
|
||||
%{summary}
|
||||
|
||||
%prep
|
||||
%{gpgverify} --keyring='%{SOURCE2}' --signature='%{SOURCE1}' --data='%{SOURCE0}'
|
||||
%autosetup -n %{mlir_srcdir} -p2
|
||||
|
@ -109,6 +123,7 @@ MLIR development files.
|
|||
%ifarch %ix86
|
||||
-DMLIR_RUN_X86VECTOR_TESTS:BOOL=OFF \
|
||||
%endif
|
||||
-DMLIR_ENABLE_BINDINGS_PYTHON:BOOL=ON \
|
||||
%if 0%{?__isa_bits} == 64
|
||||
-DLLVM_LIBDIR_SUFFIX=64
|
||||
%else
|
||||
|
@ -120,11 +135,22 @@ export LD_LIBRARY_PATH=%{_builddir}/%{mlir_srcdir}/%{name}/%{_build}/%{_lib}
|
|||
|
||||
%install
|
||||
%cmake_install
|
||||
mkdir -p %{buildroot}/%{python3_sitearch}
|
||||
mv %{buildroot}/usr/python_packages/mlir_core/mlir %{buildroot}/%{python3_sitearch}
|
||||
# These directories should be empty now.
|
||||
rmdir %{buildroot}/usr/python_packages/mlir_core %{buildroot}/usr/python_packages
|
||||
# Unneeded files.
|
||||
rm -rf %{buildroot}/usr/src/python
|
||||
|
||||
%check
|
||||
# Remove tablegen tests, as they rely on includes from llvm/.
|
||||
rm -rf test/mlir-tblgen
|
||||
|
||||
%ifarch s390x
|
||||
# s390x does not support half-float
|
||||
rm test/python/execution_engine.py
|
||||
%endif
|
||||
|
||||
%ifarch %{ix86}
|
||||
# TODO: Test currently fails on i686.
|
||||
rm test/IR/file-metadata-resources.mlir
|
||||
|
@ -165,7 +191,8 @@ rm -rf test/mlir-pdll-lsp-server/view-output.test
|
|||
%endif
|
||||
|
||||
# Test execution normally relies on RPATH, so set LD_LIBRARY_PATH instead.
|
||||
export LD_LIBRARY_PATH=%{buildroot}/%{_libdir}
|
||||
export LD_LIBRARY_PATH=%{buildroot}/%{_libdir}:%{buildroot}/%{python3_sitearch}/mlir/_mlir_libs
|
||||
export PYTHONPATH=%{buildroot}/%{python3_sitearch}
|
||||
%cmake_build --target check-mlir
|
||||
|
||||
%files
|
||||
|
@ -199,7 +226,13 @@ export LD_LIBRARY_PATH=%{buildroot}/%{_libdir}
|
|||
%{_includedir}/mlir-c
|
||||
%{_libdir}/cmake/mlir
|
||||
|
||||
%files -n python3-%{name}
|
||||
%{python3_sitearch}/mlir/
|
||||
|
||||
%changelog
|
||||
* Tue Sep 05 2023 Tulio Magno Quites Machado Filho <tuliom@redhat.com> - 17.0.0~rc3-3
|
||||
- Enable python bindings. Fixes rhbz#2221241
|
||||
|
||||
* Mon Aug 28 2023 Tulio Magno Quites Machado Filho <tuliom@redhat.com> - 17.0.0~rc3-2
|
||||
- Restrict link jobs on x86_64
|
||||
|
||||
|
|
Loading…
Reference in New Issue