LLVM python binding
Project description
LLVMPY Meow!
Note this project is still in the very early stage, not even half completed.
Installation
pip install llvmpym
Additional notes for NixOS User
If you encounter issues like ImportError: libz.so.1: cannot open shared object file: No such file or directory
when using this library
You can use the following command to inspect those shared libraries that are not founded.
ldd ./.venv/lib/python3.12/site-packages/llvmpym/llvmpym_ext.abi3.so
You can use the following command to give this library a quick run (if you miss libz.so.1
and libstdc++.so.6
):
env LD_LIBRARY_PATH="$(nix path-info nixpkgs#zlib)/lib:$(nix path-info nixpkgs#stdenv.cc.cc.lib)/lib:$LD_LIBRARY_PATH" python ./main.py
Or using a shellHook
in your devShell
:
devShells = forAllSystems ({ pkgs }: {
default = pkgs.mkShell {
packages = with pkgs; [
(python312.withPackages (ppkgs: with ppkgs; [
pip
]))
];
shellHook = ''
export LD_LIBRARY_PATH="${pkgs.zlib}/lib:${pkgs.stdenv.cc.cc.lib.outPath}/lib:$LD_LIBRARY_PATH"
'';
};
});
Currently I haven't invested into how to solve the problem from its root. If you know how to solve it, please give it a hand. It would really be appreciated.
Build
Requirements
- A C++17 compiler
- CMake 3.20.0+
- ninja (optional, if you want to follow the guide)
- Python at least 3.12
Manual Build of LLVM
- Download llvm-project 18.1.8 release source code. LLVM release page.
- Extract the source code in a random directory such as
~/proj/probe/llvm-project
. Here we set the path as<llvm-project-path>
for later reference. - Change directory into the this project (
llvmpym
). - Do the following command to manually build llvm project
mkdir ./llvm-build
cd ./llvm-build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=. -DCMAKE_INSTALL_INCLUDEDIR=include -G Ninja ~/proj/llvm/llvm-project_18.1.8/llvm/
cmake --build .
ninja install-llvm-headers
First time building this project
env SKBUILD_CMAKE_ARGS="-DLLVM_DIR=$(pwd)/llvm-build/cmake/modules/CMakeFiles" just
Enable nanobind Debug
If you are using just
, then you can create an .env
file at project root
SKBUILD_CMAKE_BUILD_TYPE=Debug
otherwise you need to expose it as an environment variable
Status
- All functions that operates on lambda functions(function pointers) is not binded
or handled correctly. Typically those parameters'(or returned value's) type name ends
with
Hanlder
orCallback
, e.g.LLVMDiagnosticHandler
,LLVMYieldCallback
.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for llvmpym-0.0.2-cp312-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 000a13ef37dc504cfbce80ba0992470cba6b796cb83a908069f68451d4f984de |
|
MD5 | 52f7042e072e1558aec8ff56e0627ad3 |
|
BLAKE2b-256 | 69e3fe95db25ea0d1c39eef05f88445240569b555f75242e9dd162e660ed1d66 |
Hashes for llvmpym-0.0.2-cp312-abi3-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f14245b8a3377c957883a40adbf1968a7868548ad58968bf00d244bf5ba7375a |
|
MD5 | e71d659b470a38d63ff8004a5a64bb5e |
|
BLAKE2b-256 | 762f30f82948d56a64e53e8296fadb6cc0ac6e730cef57c1466c0099773bcf6d |
Hashes for llvmpym-0.0.2-cp312-abi3-macosx_14_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60fadf66997649de2145781b13491159b31151fb69a7a242e6f335896c48b026 |
|
MD5 | 75e487f692665454a85b6ce04f366cc2 |
|
BLAKE2b-256 | b57ab046ae2415599845921415644134d12897c20262ee49c093a39724ebd62d |