python3Packages.libclang: init
This commit is contained in:
parent
a0923a3f14
commit
09ab507c16
3 changed files with 62 additions and 4 deletions
pkgs
56
pkgs/development/python-modules/libclang/default.nix
Normal file
56
pkgs/development/python-modules/libclang/default.nix
Normal file
|
@ -0,0 +1,56 @@
|
|||
{ lib
|
||||
, buildPythonPackage
|
||||
, llvmPackages
|
||||
, setuptools
|
||||
, writeText
|
||||
}:
|
||||
|
||||
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
|
||||
'';
|
||||
in buildPythonPackage {
|
||||
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";
|
||||
maintainers = with lib.maintainers; [ lilyinstarlight ];
|
||||
};
|
||||
}
|
|
@ -22,7 +22,7 @@
|
|||
, setuptools
|
||||
, toposort
|
||||
, wheezy-template
|
||||
, libclang
|
||||
, llvmPackages
|
||||
, gst_all_1
|
||||
}:
|
||||
|
||||
|
@ -100,9 +100,9 @@ buildPythonApplication rec {
|
|||
postPatch = ''
|
||||
substituteInPlace hotdoc/extensions/c/c_extension.py \
|
||||
--replace "shutil.which('llvm-config')" 'True' \
|
||||
--replace "subprocess.check_output(['llvm-config', '--version']).strip().decode()" '"${libclang.version}"' \
|
||||
--replace "subprocess.check_output(['llvm-config', '--prefix']).strip().decode()" '"${libclang.lib}"' \
|
||||
--replace "subprocess.check_output(['llvm-config', '--libdir']).strip().decode()" '"${libclang.lib}/lib"'
|
||||
--replace "subprocess.check_output(['llvm-config', '--version']).strip().decode()" '"${llvmPackages.libclang.version}"' \
|
||||
--replace "subprocess.check_output(['llvm-config', '--prefix']).strip().decode()" '"${llvmPackages.libclang.lib}"' \
|
||||
--replace "subprocess.check_output(['llvm-config', '--libdir']).strip().decode()" '"${llvmPackages.libclang.lib}/lib"'
|
||||
'';
|
||||
|
||||
# Make pytest run from a temp dir to have it pick up installed package for cmark
|
||||
|
|
|
@ -6121,6 +6121,8 @@ self: super: with self; {
|
|||
inherit (pkgs) libasyncns;
|
||||
};
|
||||
|
||||
libclang = callPackage ../development/python-modules/libclang { };
|
||||
|
||||
libcloud = callPackage ../development/python-modules/libcloud { };
|
||||
|
||||
libcst = callPackage ../development/python-modules/libcst { };
|
||||
|
|
Loading…
Reference in a new issue