2024-06-05 15:53:02 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
buildPythonPackage,
|
|
|
|
llvmPackages,
|
|
|
|
setuptools,
|
|
|
|
writeText,
|
2023-11-16 04:20:00 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
libclang = llvmPackages.libclang;
|
|
|
|
|
|
|
|
pyproject_toml = writeText "pyproject.toml" ''
|
|
|
|
[build-system]
|
|
|
|
requires = ["setuptools>=42", "wheel"]
|
|
|
|
build-backend = "setuptools.build_meta"
|
|
|
|
'';
|
|
|
|
|
|
|
|
setup_cfg = writeText "setup.cfg" ''
|
|
|
|
[metadata]
|
|
|
|
name = clang
|
|
|
|
version = ${libclang.version}
|
|
|
|
|
|
|
|
[options]
|
|
|
|
packages = clang
|
|
|
|
'';
|
2024-06-05 15:53:02 +00:00
|
|
|
in
|
|
|
|
buildPythonPackage {
|
2023-11-16 04:20:00 +00:00
|
|
|
pname = "libclang";
|
|
|
|
format = "pyproject";
|
|
|
|
|
|
|
|
inherit (libclang) version src;
|
|
|
|
|
|
|
|
buildInputs = [ setuptools ];
|
|
|
|
|
|
|
|
postUnpack = ''
|
|
|
|
# set source root to python bindings
|
|
|
|
if [ -e "$sourceRoot/clang/bindings/python" ]; then
|
|
|
|
# LLVM 13+ puts clang sources in subdirectory instead of plain tarball
|
|
|
|
sourceRoot="$sourceRoot/clang/bindings/python"
|
|
|
|
else
|
|
|
|
sourceRoot="$sourceRoot/bindings/python"
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
# link in our own build info to build as a python package
|
|
|
|
ln -s ${pyproject_toml} ./pyproject.toml
|
|
|
|
ln -s ${setup_cfg} ./setup.cfg
|
|
|
|
|
|
|
|
# set passed libclang for runtime
|
|
|
|
echo 'Config.set_library_path("${lib.getLib libclang}/lib")' >>./clang/cindex.py
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = libclang.meta // {
|
|
|
|
description = "Python bindings for the C language family frontend for LLVM";
|
2024-07-31 10:19:44 +00:00
|
|
|
maintainers = [ ];
|
2023-11-16 04:20:00 +00:00
|
|
|
};
|
|
|
|
}
|