However, the tools/mlir/python_packages/mlir_core/ directory is not present in my build, and when I run with python bindings enabled I’m given an error saying that the cmake option is ignored. How do I enable the python bindings when the cmake is being ignored? Do I have to add the cmake variables at the top elsewehere? I’m trying to use the MLIR python bindings and I’m at a bit of a loss, any help would be greatly appreciated.
MLIR_BINDINGS_PYTHON_ENABLED was renamed MLIR_ENABLE_BINDINGS_PYTHON about two months ago as part of a cleanup to make all these variable names consistent (using the imperative form). Those instructions would need an update.
Great, so I’ve replaced the outdated variable names with the correct ones. I no longer get Cmake warnings about manually-specified variables. I am, however, now getting a new error:
-- Configuring done
-- Generating done
-- Build files have been written to: /media/machel/74D6207BD6203FAA/AAAAAAAAAAAAAA/mlir-py-release/build/llvm
-- Running cmake (build/install): cmake --build /media/machel/74D6207BD6203FAA/AAAAAAAAAAAAAA/mlir-py-release/build/llvm --target install-mlir-headers install-MLIRBindingsPythonSources install-MLIRBindingsPythonDialects install-MLIRPublicAPI-stripped install-MLIRTransformsBindingsPythonExtension-stripped install-MLIRCoreBindingsPythonExtension-stripped
ninja: error: unknown target 'install-MLIRBindingsPythonSources'
Traceback (most recent call last):
File "./setup.py", line 302, in <module>
subprocess.check_call(cmake_build_args)
File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '/media/machel/74D6207BD6203FAA/AAAAAAAAAAAAAA/mlir-py-release/build/llvm', '--target', 'install-mlir-headers', 'install-MLIRBindingsPythonSources', 'install-MLIRBindingsPythonDialects', 'install-MLIRPublicAPI-stripped', 'install-MLIRTransformsBindingsPythonExtension-stripped', 'install-MLIRCoreBindingsPythonExtension-stripped']' returned non-zero exit status 1.
I’m on mobile for a few days and can’t check. Can I suggest just doing a global “ninja install” for the moment. There is a discrete target for just installing this part but I can’t remember it off hand. Also, we still need to add a setup.py to the upstream project (similar to the one in mlir-npcomp). I haven’t done so because of the additional work to enable a CI for it, etc.
For upstream MLIR, if you install with python bindings enabled, the resultant python_packages/mlir_core is a standalone python package that you can copy to site-packages, etc.
We don’t (yet) distribute the bindings for the core project and are missing setup.py, which would make this more canonical. Downstreams have been working that out and when it stabilizes, we should do the same upsteam.