lief: fix python bindings

This commit is contained in:
Anton Bolshakov 2024-01-25 13:05:21 +08:00
parent 7010513f96
commit 321ab22adb
No known key found for this signature in database
GPG key ID: 32BDCED870788F04
7 changed files with 76 additions and 42 deletions

View file

@ -0,0 +1 @@
DIST robin-map-1.0.1.tar.gz 69160 BLAKE2B 0830b7a44d69269d8adff4c57af1b8603ed96aeca5d158e67322afcdea4013757eac5fd198771d001a2c42992d7be97daf5a3b0a93d4461ef69fbb52e73673b1 SHA512 5741049287fdb9c3316e1eb84b99343efc7b35f492e1db8166d65c2d16c7905f51b11cf164bedae9e44d4b6000bbea3c49012acf725a977e665a8dc23e89b1fb

View file

@ -0,0 +1,20 @@
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
inherit cmake
DESCRIPTION="C++ fast hash map and hash set using robin hood hashing"
HOMEPAGE="https://github.com/Tessil/robin-map"
if [[ ${PV} == 9999 ]] ; then
inherit git-r3
EGIT_REPO_URI="https://github.com/Tessil/robin-map"
else
SRC_URI="https://github.com/Tessil/robin-map/archive/v${PV}.tar.gz -> ${P}.tar.gz"
KEYWORDS="amd64 ~arm ~arm64 ~ppc64 ~riscv x86"
fi
LICENSE="MIT"
SLOT="0"

View file

@ -1 +1,2 @@
DIST nanobind-1.7.0.r7.gfd1f04b.zip 936501 BLAKE2B 36865e778fc2ebe6e011fa5f3f090eca7afe9f68b98f788904bdf01930c54029023b5b17ff7e4b5b6c02ea9414ced734adc1fd60e47df4fd3f87d7fa0981930d SHA512 3095706fac8e735acd36f4d41b0505b8036233543d2a72592e488da9e6541da38bc7413c277a01daf58958d4979f22644e4407e780af7bb604c27f97fcc5148b
DIST nanobind-1.8.0.gh.tar.gz 778020 BLAKE2B 0374d8380a9de88e9ef0551f2a26eecaa7ea934f4b233f0976159245de80d24768f589010c52cb63f68e53e64509907135854acfca4c468cb19ef05652bd3520 SHA512 72bb066f6884c0ceb2672f26087daf4eb6453a339b7bc81d8abc6b52a0380663d69797193d863979118a5fbc29487a9f6aed4b0e60a53be297ab6b4e0f7f828c

View file

@ -0,0 +1,27 @@
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
DISTUTILS_USE_PEP517=setuptools
PYTHON_COMPAT=( python3_{10..12} )
inherit distutils-r1
DESCRIPTION="tiny and efficient C++/Python bindings"
HOMEPAGE="https://github.com/wjakob/nanobind"
#this fork is specifically required by LIEF project
SRC_URI="https://github.com/lief-project/LIEF/raw/bb2bd6c679644f075d1dc92b8c2c2a222d4154ed/third-party/nanobind-1.7.0.r7.gfd1f04b.zip"
LICENSE="BSD"
SLOT="0"
KEYWORDS="amd64 ~arm64 x86"
RDEPEND="dev-cpp/robin-map"
DEPEND="${RDEPEND}"
REQUIRED_USE="${PYTHON_REQUIRED_USE}"
RESTRICT="test"
#distutils_enable_tests pytest
S="${WORKDIR}"

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python
import lief
import zipfile

View file

@ -1,53 +1,43 @@
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
#fails to compile with 8
EAPI=8
#fails to compile with setuptools
#DISTUTILS_USE_PEP517=no
DISTUTILS_USE_PEP517=setuptools
DISTUTILS_OPTIONAL=1
#DISTUTILS_USE_PEP517=scikit-build-core
DISTUTILS_USE_PEP517=standalone
DISTUTILS_EXT=1
PYTHON_COMPAT=( python3_{10..12} )
inherit cmake distutils-r1
inherit distutils-r1 cmake
DESCRIPTION="Library to instrument executable formats"
HOMEPAGE="https://lief.quarkslab.com/"
SRC_URI="https://github.com/lief-project/LIEF/archive/${PV}.tar.gz -> ${P}.tar.gz"
# https://files.pythonhosted.org/packages/cp311/${P:0:1}/${PN}/${P}-cp311-cp311-manylinux_2_28_x86_64.manylinux_2_27_x86_64.whl -> ${P}_x86_64.zip"
# whl: https://pypi.org/pypi/lief/json
LICENSE="Apache-2.0"
SLOT="0"
#wait for https://github.com/lief-project/LIEF/issues/1015
KEYWORDS="~amd64 ~x86"
KEYWORDS="amd64 x86"
IUSE="examples python static-libs"
IUSE="examples +python static-libs"
RDEPEND="python? ( ${PYTHON_DEPS}
dev-python/xtract[${PYTHON_USEDEP}]
dev-python/nanobind[${PYTHON_USEDEP}]
~dev-python/nanobind-1.7.0_p20231019[${PYTHON_USEDEP}]
)"
DEPEND="${RDEPEND}
python? ( dev-python/setuptools[${PYTHON_USEDEP}] )"
python? ( dev-python/scikit-build-core[${PYTHON_USEDEP}] )"
BDEPEND="${DISTUTILS_DEPS}"
REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
#FIXME: LIEF_TESTS
RESTRICT="test"
# linxon: WHY??
#CMAKE_BUILD_TYPE=
S=${WORKDIR}/LIEF-${PV}
wrap_python() {
if use python; then
ewarn
ewarn "Unable to compile python bindings, see:"
ewarn "https://github.com/lief-project/LIEF/issues/1015"
ewarn "Please disable python USE flag for now, or use a previous version"
ewarn
die "Please disable python USE flag for now, or use a previous version"
#pushd "${BUILD_DIR}"/api/python >/dev/null || die
pushd "./api/python" >/dev/null || die
distutils-r1_${1} "$@"
popd >/dev/null
@ -57,8 +47,11 @@ wrap_python() {
src_prepare() {
#fix multilib
sed -i "s|CMAKE_INSTALL_LIBDIR \"lib\"|CMAKE_INSTALL_LIBDIR \"$(get_libdir)\"|" CMakeLists.txt || die
# sed -i "s|\"setup\"|\"scikit_build_core.build\"|" api/python/pyproject.toml || die
cmake_src_prepare
wrap_python ${FUNCNAME}
eapply_user
}
src_configure() {
@ -67,44 +60,33 @@ src_configure() {
use x86 && FORCE32=YES
local PYTHON_API=NO
use python && PYTHON_API=YES
local NANOBIND_DIR
set_nano(){
# We just need any sitdir, it exist for all
if use python; then
#set EPYTHON variable for python_get_sitedir
python_setup
PYTHON_API=YES
NANOBIND_DIR=$(python_get_sitedir)/nanobind/cmake
}
python_foreach_impl set_nano
fi
#Do not install python using cmake
local mycmakeargs=(
-DBUILD_SHARED_LIBS="$(usex static-libs OFF ON)"
-DLIEF_EXAMPLES="$(usex examples ON OFF)"
-DLIEF_PYTHON_API="$PYTHON_API"
# -DLIEF_INSTALL_PYTHON="OFF"
-DLIEF_FORCE32="$FORCE32"
)
use python && mycmakeargs+=(
-DLIEF_EXTERNAL_NANOBINDS=1
-DLIEF_OPT_NANOBIND_EXTERNAL=1
-Dnanobind_DIR="${NANOBIND_DIR}"
)
cmake_src_configure
wrap_python ${FUNCNAME}
}
src_compile() {
cmake_src_compile
# wrap_python ${FUNCNAME}
compile_python() {
# ${EPYTHON} setup.py build_ext
distutils-r1_python_compile build_ext
}
pushd "./api/python" >/dev/null || die
python_foreach_impl compile_python
popd >/dev/null
wrap_python ${FUNCNAME}
}
src_install() {

View file

@ -378,3 +378,6 @@ dev-python/inquirer3
#cython 3.0.x support
~dev-python/uvloop-0.19.0-r1
#required by dev-util/lief
=dev-python/scikit-build-core--0.7*