gentoo/dev-python/pycxx/pycxx-7.1.10.ebuild
Mark Wright 761b274649
dev-python/pycxx: Fix SRC_URI bug 961959
Thanks to ulm for reporting. The original source for the snapshot
should have been:
https://sourceforge.net/code-snapshots/svn/c/cx/cxx/code/cxx-code-r464-trunk-CXX.zip

but I had to make a local copy as the hash changes when fetching it again.

Closes: https://bugs.gentoo.org/show_bug.cgi?id=961959
Signed-off-by: Mark Wright <gienah@gentoo.org>
2025-08-25 15:06:13 +10:00

116 lines
3.0 KiB
Bash

# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI="8"
PYTHON_COMPAT=( python3_{10..14} )
DISTUTILS_USE_PEP517=setuptools
inherit distutils-r1 toolchain-funcs
DESCRIPTION="Set of facilities to extend Python with C++"
HOMEPAGE="https://cxx.sourceforge.net"
SRC_URI="https://dev.gentoo.org/~gienah/snapshots/${P}.zip"
S="${WORKDIR}"/cxx-code-r464-trunk/CXX
LICENSE="BSD"
SLOT="0"
KEYWORDS="~amd64 ~arm ~ppc ~ppc64 ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos"
IUSE="doc examples test"
RESTRICT="!test? ( test )"
BDEPEND="
$(python_gen_cond_dep '
dev-python/setuptools[${PYTHON_USEDEP}]
' 3.12)
app-arch/unzip
"
python_prepare_all() {
rm -R Src/Python2/ || die
# Without this, pysvn fails.
# Src/Python3/cxxextensions.c: No such file or directory
sed -e "/^#include/s:Src/::" -i Src/*.{c,cxx} || die "sed failed"
distutils-r1_python_prepare_all
}
python_compile() {
distutils-r1_python_compile
if use test; then
pushd Src || die
local S_SRCS="cxx_exceptions.cxx cxxextensions.c cxx_extensions.cxx cxxsupport.cxx IndirectPythonInterface.cxx"
local S_OBJS=""
for i in ${S_SRCS}; do
local S_O="${BUILD_DIR}/${i%%.c*}.o"
local c_cmd=(
$(tc-getCXX) \
${CPPFLAGS} ${CFLAGS} ${ASFLAGS} \
-I"${S}" -I"${EPREFIX}/usr/include/${EPYTHON}" \
-fPIC -c ${i} -o "${S_O}"
)
printf '%s\n' "${c_cmd[*]}"
"${c_cmd[@]}" || die "compile test ${i} failed"
S_OBJS+="${S_O} "
done
popd || die
pushd Demo/Python3 || die
cp -p test_example.py "${BUILD_DIR}" || die
local D_SRCS="example.cxx range.cxx rangetest.cxx"
local D_OBJS=""
for i in ${D_SRCS}; do
local D_O="${BUILD_DIR}/${i%%.c*}.o"
local c_cmd=(
$(tc-getCXX) \
${CPPFLAGS} ${CFLAGS} ${ASFLAGS} \
-I"${S}" -I"${S}"/Demo/Python3 -I"${EPREFIX}/usr/include/${EPYTHON}" \
-fPIC -c ${i} -o "${D_O}"
)
printf '%s\n' "${c_cmd[*]}"
"${c_cmd[@]}" || die "compile test ${i} failed"
S_OBJS+="${D_O} "
done
local l_example_cmd=(
$(tc-getCXX) \
${CPPFLAGS} ${CFLAGS} ${ASFLAGS} \
-I$"{S}" -I"${S}"/Demo/Python3 -I$"{EPREFIX}/usr/include/${EPYTHON}" \
-shared -fPIC -o "${BUILD_DIR}"/example.so ${S_OBJS} ${D_OBJS} -l${EPYTHON} -ldl
)
printf '%s\n' "${l_example_cmd[*]}"
"${l_example_cmd[@]}" || die "link test example.so failed"
popd || die
fi
}
python_test() {
pushd "${BUILD_DIR}" || die
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${BUILD_DIR}"
local cmd=(
"${EPYTHON}" test_example.py
)
printf '%s\n' "${cmd[*]}"
"${cmd[@]}" || die "test_example failed"
popd || die
}
python_install() {
distutils-r1_python_install
# Move misplaced files into place
dodir "/usr/share/${EPYTHON}"
mv "${D}/usr/CXX" "${D}/usr/share/${EPYTHON}/CXX" || die
mv "${D}/usr/include/${EPYTHON}"/{cxx,CXX} || die
}
python_install_all() {
use doc && local HTML_DOCS=( Doc/. )
if use examples ; then
docinto examples
dodoc -r Demo/Python3/.
docompress -x /usr/share/doc/${PF}/examples
fi
distutils-r1_python_install_all
}