From b18c65f6d5aca4149c87c62e2b82d529adebadda Mon Sep 17 00:00:00 2001 From: Marek Szuba Date: Wed, 7 Sep 2022 12:40:14 +0100 Subject: net-libs/xrootd: use distutils-r1 to handle Python bindings Now we can finally install the bindings for multiple Python implementations! Signed-off-by: Marek Szuba --- .../files/xrootd-5.4.3-cmake_no_python.patch | 15 ++ .../files/xrootd-5.4.3-python_tests_py3.patch | 169 ++++++++++++++++++++ net-libs/xrootd/xrootd-5.4.3-r2.ebuild | 173 +++++++++++++++++++++ 3 files changed, 357 insertions(+) create mode 100644 net-libs/xrootd/files/xrootd-5.4.3-cmake_no_python.patch create mode 100644 net-libs/xrootd/files/xrootd-5.4.3-python_tests_py3.patch create mode 100644 net-libs/xrootd/xrootd-5.4.3-r2.ebuild (limited to 'net-libs/xrootd') diff --git a/net-libs/xrootd/files/xrootd-5.4.3-cmake_no_python.patch b/net-libs/xrootd/files/xrootd-5.4.3-cmake_no_python.patch new file mode 100644 index 000000000000..04607cdd7b04 --- /dev/null +++ b/net-libs/xrootd/files/xrootd-5.4.3-cmake_no_python.patch @@ -0,0 +1,15 @@ +--- a/bindings/python/CMakeLists.txt ++++ b/bindings/python/CMakeLists.txt +@@ -32,6 +32,7 @@ + + configure_file(${SETUP_PY_IN} ${SETUP_PY}) + ++if (0) + string(FIND "${PIP_OPTIONS}" "--prefix" PIP_OPTIONS_PREFIX_POSITION) + if( "${PIP_OPTIONS_PREFIX_POSITION}" EQUAL "-1" ) + string(APPEND PIP_OPTIONS " --prefix \$ENV{DESTDIR}/${CMAKE_INSTALL_PREFIX}") +@@ -100,3 +101,4 @@ + )" + ) + endif() ++endif() diff --git a/net-libs/xrootd/files/xrootd-5.4.3-python_tests_py3.patch b/net-libs/xrootd/files/xrootd-5.4.3-python_tests_py3.patch new file mode 100644 index 000000000000..e20e45309e39 --- /dev/null +++ b/net-libs/xrootd/files/xrootd-5.4.3-python_tests_py3.patch @@ -0,0 +1,169 @@ +--- a/bindings/python/tests/test_copy.py ++++ b/bindings/python/tests/test_copy.py +@@ -61,15 +61,15 @@ + + class TestProgressHandler(object): + def begin(self, id, total, source, target): +- print '+++ begin(): %d, total: %d' % (id, total) +- print '+++ source: %s' % source +- print '+++ target: %s' % target ++ print('+++ begin(): %d, total: %d' % (id, total)) ++ print('+++ source: %s' % source) ++ print('+++ target: %s' % target) + + def end(self, jobId, status): +- print '+++ end(): jobId: %s, status: %s' % (jobId, status) ++ print('+++ end(): jobId: %s, status: %s' % (jobId, status)) + + def update(self, jobId, processed, total): +- print '+++ update(): jobid: %s, processed: %d, total: %d' % (jobId, processed, total) ++ print('+++ update(): jobid: %s, processed: %d, total: %d' % (jobId, processed, total)) + + def test_copy_progress_handler(): + c = client.CopyProcess() +--- a/bindings/python/tests/test_file.py ++++ b/bindings/python/tests/test_file.py +@@ -289,9 +289,9 @@ + for i, l in enumerate(lines): + total += len(l) + if l != pylines[i]: +- print '!!!!!', total, i +- print '+++++ py: %r' % pylines[i] +- print '+++++ me: %r' % l ++ print('!!!!!', total, i) ++ print('+++++ py: %r' % pylines[i]) ++ print('+++++ me: %r' % l) + break + if pylines[i].endswith('\n'): + assert l.endswith('\n') +--- a/bindings/python/tests/test_filesystem.py ++++ b/bindings/python/tests/test_filesystem.py +@@ -37,20 +37,20 @@ + status, response = f.open(smallfile, OpenFlags.NEW) + + for func, args, hasReturnObject in funcspecs: +- async(func, args, hasReturnObject) ++ run_async(func, args, hasReturnObject) + + def sync(func, args, hasReturnObject): + status, response = func(*args) +- print status ++ print(status) + assert status.ok + if hasReturnObject: +- print response ++ print(response) + assert response + +-def async(func, args, hasReturnObject): ++def run_async(func, args, hasReturnObject): + handler = AsyncResponseHandler() + status = func(callback=handler, *args) +- print status ++ print(status) + assert status.ok + status, response, hostlist = handler.wait() + +@@ -60,7 +60,7 @@ + + for host in hostlist: + assert host.url +- print host.url ++ print(host.url) + + if hasReturnObject: + assert response +@@ -79,7 +79,7 @@ + + try: + os.remove('/tmp/eggs') +- except OSError, __: ++ except OSError as __: + pass + + def test_locate_sync(): +@@ -127,7 +127,7 @@ + + for item in response: + assert item.name +- print item.statinfo ++ print(item.statinfo) + assert item.statinfo + assert item.hostaddr + +@@ -143,11 +143,11 @@ + assert status.ok + + for h in hostlist: +- print h.url ++ print(h.url) + + for item in response: + assert item.name +- print item.statinfo ++ print(item.statinfo) + assert item.statinfo + assert item.hostaddr + +@@ -158,7 +158,7 @@ + status, response = c.query(QueryCode.STATS, 'a') + assert status.ok + assert response +- print response ++ print(response) + + def test_query_async(): + c = client.FileSystem(SERVER_URL) +@@ -169,7 +169,7 @@ + status, response, hostlist = handler.wait() + assert status.ok + assert response +- print response ++ print(response) + + def test_mkdir_flags(): + c = client.FileSystem(SERVER_URL) +--- a/bindings/python/tests/test_glob.py ++++ b/bindings/python/tests/test_glob.py +@@ -2,7 +2,7 @@ + import os + import glob as norm_glob + import XRootD.client.glob_funcs as glob +-from pathlib2 import Path ++from pathlib import Path + + + @pytest.fixture +@@ -13,7 +13,7 @@ + subdir2.mkdir() + for i in range(3): + dummy = subdir1 / ("a_file_%d.txt" % i) +- dummy.write_text(u"This is file %d\n" % i, encoding="utf-8") ++ dummy.write_text("This is file %d\n" % i, encoding="utf-8") + return tmpdir + + +--- a/bindings/python/tests/test_threads.py ++++ b/bindings/python/tests/test_threads.py +@@ -15,10 +15,10 @@ + s, _ = self.file.write(smallbuffer) + assert s.ok + +- print '+++ thread %d says: %s' % (self.id, self.file.read()) ++ print('+++ thread %d says: %s' % (self.id, self.file.read())) + + for line in self.file: +- print '+++ thread %d says: %s' % (self.id, line) ++ print('+++ thread %d says: %s' % (self.id, line)) + + self.file.close() + +@@ -28,7 +28,7 @@ + # assert f.is_open() + # f.write(smallbuffer) + +- for i in xrange(3): ++ for i in range(3): + tt = TestThread(f, i) + tt.start() + tt.join() diff --git a/net-libs/xrootd/xrootd-5.4.3-r2.ebuild b/net-libs/xrootd/xrootd-5.4.3-r2.ebuild new file mode 100644 index 000000000000..e0c005ecfcb9 --- /dev/null +++ b/net-libs/xrootd/xrootd-5.4.3-r2.ebuild @@ -0,0 +1,173 @@ +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +PYTHON_COMPAT=( python3_{8..11} ) +DISTUTILS_OPTIONAL=1 +DISTUTILS_USE_PEP571="setuptools" + +inherit cmake distutils-r1 + +DESCRIPTION="Extended ROOT remote file server" +HOMEPAGE="https://xrootd.slac.stanford.edu/" +SRC_URI="https://xrootd.slac.stanford.edu/download/v${PV}/${P}.tar.gz" + +LICENSE="LGPL-3" +SLOT="0" +KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux" +IUSE="doc examples fuse http kerberos +libxml2 python readline +server systemd test test-suite" + +# Python tests currently require manual configuration and start-up of an xrootd server. +# No actual build-time test suite for native code. +RESTRICT="test" + +CDEPEND="acct-group/xrootd + acct-user/xrootd + dev-libs/openssl:0= + sys-libs/zlib + virtual/libcrypt:= + fuse? ( sys-fs/fuse:0= ) + http? ( net-misc/curl:= ) + kerberos? ( virtual/krb5 ) + libxml2? ( dev-libs/libxml2:2= ) + python? ( ${PYTHON_DEPS} ) + readline? ( sys-libs/readline:0= ) + systemd? ( sys-apps/systemd:= ) + test-suite? ( dev-util/cppunit ) +" +DEPEND="${CDEPEND}" +BDEPEND=" + doc? ( + app-doc/doxygen[dot] + virtual/latex-base + python? ( dev-python/sphinx ) + ) + python? ( + ${PYTHON_DEPS} + ${DISTUTILS_DEPS} + test? ( >=dev-python/pytest-7.1.2[${PYTHON_USEDEP}] ) + ) +" +RDEPEND="${CDEPEND} + dev-lang/perl +" +REQUIRED_USE=" + http? ( kerberos ) + python? ( ${PYTHON_REQUIRED_USE} ) + test? ( server ) + test-suite? ( server ) +" + +PATCHES=( + "${FILESDIR}"/${PN}-4.8.3-crc32.patch + "${FILESDIR}"/${PN}-5.4.3-no_automagic.patch + "${FILESDIR}"/${PN}-5.4.3-cmake_no_python.patch + "${FILESDIR}"/${PN}-5.4.3-python_tests_py3.patch +) + +# xrootd plugins are not intended to be linked with, +# they are to be loaded at runtime by xrootd, +# see https://github.com/xrootd/xrootd/issues/447 +QA_SONAME="/usr/lib.*/libXrd.*-$(ver_cut 1)\.so + /usr/lib.*/libXrdClTests\.so" + +pkg_setup() { + use python && python_setup +} + +src_prepare() { + cmake_src_prepare + + if use python; then + pushd "${S}"/bindings/python > /dev/null || die + distutils-r1_src_prepare + popd > /dev/null || die + fi +} + +# FIXME: support xrdec - currently only builds against bundled isa-l +src_configure() { + local mycmakeargs=( + -DENABLE_FUSE=$(usex fuse) + -DENABLE_HTTP=$(usex http) + -DENABLE_KRB5=$(usex kerberos) + -DENABLE_LIBXML2=$(usex libxml2) + -DENABLE_PYTHON=$(usex python) + -DENABLE_READLINE=$(usex readline) + -DENABLE_TESTS=$(usex test-suite) + -DENABLE_VOMS=no + -DFORCE_ENABLED=yes + -DXRDCL_ONLY=$(usex server "no" "yes") + ) + cmake_src_configure + + if use python; then + pushd "${BUILD_DIR}"/bindings/python > /dev/null || die + distutils-r1_src_configure + popd > /dev/null || die + fi +} + +src_compile() { + cmake_src_compile + if use doc; then + doxygen Doxyfile || die + if use python; then + emake -C bindings/python/docs html + fi + fi + if use python; then + pushd "${BUILD_DIR}"/bindings/python > /dev/null || die + distutils-r1_src_compile + popd > /dev/null || die + fi +} + +python_test() { + epytest +} + +src_test() { + use python && distutils-r1_src_test +} + +src_install() { + use doc && HTML_DOCS=( doxydoc/html/. ) + dodoc docs/ReleaseNotes.txt + cmake_src_install + find "${D}" \( -iname '*.md5' -o -iname '*.map' \) -delete || die + + # base configs + insinto /etc/xrootd + doins packaging/common/*.cfg + + fowners root:xrootd /etc/xrootd + keepdir /var/log/xrootd + fowners xrootd:xrootd /var/log/xrootd + + if use server; then + local i + for i in cmsd frm_purged frm_xfrd xrootd; do + newinitd "${FILESDIR}"/${i}.initd ${i} + done + # all daemons MUST use single master config file + newconfd "${FILESDIR}"/xrootd.confd xrootd + fi + + if use python; then + pushd "${BUILD_DIR}"/bindings/python > /dev/null || die + distutils-r1_src_install + popd > /dev/null || die + + if use doc; then + docinto python + docompress -x "/usr/share/doc/${PF}/python/html" + dodoc -r bindings/python/docs/build/html + fi + if use examples; then + docinto python + dodoc -r bindings/python/examples + fi + fi +} -- cgit v1.2.3-65-gdbad