Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable py3.11 for packages in embedded@ #30423

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
89 changes: 89 additions & 0 deletions dev-embedded/libftdi/libftdi-0.20-r2.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

PYTHON_COMPAT=( python3_{9..11} )
inherit cmake python-single-r1

if [[ ${PV} == 9999* ]] ; then
inherit git-r3
EGIT_REPO_URI="git://developer.intra2net.com/${PN}"
else
SRC_URI="https://www.intra2net.com/en/developer/${PN}/download/${P}.tar.gz"
KEYWORDS="~amd64 ~arm ~arm64 ~loong ~ppc ~ppc64 ~riscv ~sparc ~x86"
fi

DESCRIPTION="Userspace access to FTDI USB interface chips"
HOMEPAGE="https://www.intra2net.com/en/developer/libftdi/"

LICENSE="LGPL-2"
SLOT="0"
IUSE="cxx doc examples python static-libs"
REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"

RDEPEND="
virtual/libusb:0
cxx? ( dev-libs/boost )
python? ( ${PYTHON_DEPS} )
"
DEPEND="${RDEPEND}"
BDEPEND="
doc? ( app-doc/doxygen )
python? ( dev-lang/swig )
"

PATCHES=(
"${FILESDIR}"/${P}-cmake-include.patch
"${FILESDIR}"/${P}-cmake-version.patch
)

pkg_setup() {
use python && python-single-r1_pkg_setup
}

src_prepare() {
if use python; then
sed -i \
-e "s:[$]{PYTHON_LIB_INSTALL}/../site-packages:$(python_get_sitedir):" \
bindings/CMakeLists.txt || die
fi
sed -i \
-e '/SET(LIB_SUFFIX /d' \
CMakeLists.txt || die

cmake_src_prepare
}

src_configure() {
local mycmakeargs=(
-DFTDIPP=$(usex cxx)
-DDOCUMENTATION=$(usex doc)
-DEXAMPLES=$(usex examples)
-DPYTHON_BINDINGS=$(usex python)
-DCMAKE_SKIP_BUILD_RPATH=ON
)

cmake_src_configure
}

src_install() {
cmake_src_install
use python && python_optimize
dodoc ChangeLog README

if use doc ; then
# Clean up man pages with too generic names. #356369
rm -vf "${BUILD_DIR}"/doc/man/man3/{_,usb_,deprecated}* || die

doman "${BUILD_DIR}"/doc/man/man3/*
dodoc -r "${BUILD_DIR}"/doc/html
fi

if use examples ; then
docinto examples
dodoc examples/*.c
fi

use static-libs || rm "${ED}"/usr/$(get_libdir)/${PN}.a || die
}
89 changes: 89 additions & 0 deletions dev-embedded/libftdi/libftdi-1.5-r5.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

PYTHON_COMPAT=( python3_{9..11} )
inherit cmake python-single-r1

MY_P="${PN}1-${PV}"
if [[ ${PV} == 9999* ]] ; then
inherit git-r3
EGIT_REPO_URI="git://developer.intra2net.com/${PN}"
else
SRC_URI="https://www.intra2net.com/en/developer/${PN}/download/${MY_P}.tar.bz2"
S="${WORKDIR}/${MY_P}"

KEYWORDS="~amd64 ~arm ~arm64 ~loong ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86"

PATCHES=(
"${FILESDIR}"/${P}-tests-no-cxx.patch
"${FILESDIR}"/${P}-cmake-cxx.patch
)
fi

DESCRIPTION="Userspace access to FTDI USB interface chips"
HOMEPAGE="https://www.intra2net.com/en/developer/libftdi/"

LICENSE="LGPL-2"
SLOT="1"
IUSE="cxx doc examples python test tools"
RESTRICT="!test? ( test )"
REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"

RDEPEND="
virtual/libusb:1
cxx? ( dev-libs/boost )
python? ( ${PYTHON_DEPS} )
tools? ( dev-libs/confuse:= )
"
DEPEND="${RDEPEND}
test? ( dev-libs/boost )
"
BDEPEND="
doc? ( app-doc/doxygen )
python? ( dev-lang/swig )
"

pkg_setup() {
use python && python-single-r1_pkg_setup
}

src_configure() {
local mycmakeargs=(
-DFTDIPP=$(usex cxx)
-DDOCUMENTATION=$(usex doc)
-DEXAMPLES=$(usex examples)
-DPYTHON_BINDINGS=$(usex python)
-DBUILD_TESTS=$(usex test)
-DFTDI_EEPROM=$(usex tools)
-DCMAKE_SKIP_BUILD_RPATH=ON
-DSTATICLIBS=OFF
)
cmake_src_configure
}

src_test() {
cd "${BUILD_DIR}/test" || die
LD_LIBRARY_PATH="${BUILD_DIR}/src" ./test_libftdi1 -l all || die
}

src_install() {
cmake_src_install

use python && python_optimize
dodoc AUTHORS ChangeLog README TODO

if use doc ; then
# Clean up man pages with too generic names. #356369
rm -vf "${BUILD_DIR}"/doc/man/man3/_* || die

doman "${BUILD_DIR}"/doc/man/man3/*
dodoc -r "${BUILD_DIR}"/doc/html
fi

if use examples ; then
docinto examples
dodoc examples/*.c
fi
}
26 changes: 15 additions & 11 deletions dev-embedded/libftdi/libftdi-9999.ebuild
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7
EAPI=8

PYTHON_COMPAT=( python3_{9..10} )
PYTHON_COMPAT=( python3_{9..11} )
inherit cmake python-single-r1

MY_P="${PN}1-${PV}"
Expand All @@ -14,7 +14,12 @@ else
SRC_URI="https://www.intra2net.com/en/developer/${PN}/download/${MY_P}.tar.bz2"
S="${WORKDIR}/${MY_P}"

KEYWORDS="~amd64 ~arm ~arm64 ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86"
KEYWORDS="~amd64 ~arm ~arm64 ~loong ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86"

PATCHES=(
"${FILESDIR}"/${P}-tests-no-cxx.patch
"${FILESDIR}"/${P}-cmake-cxx.patch
)
fi

DESCRIPTION="Userspace access to FTDI USB interface chips"
Expand All @@ -26,20 +31,19 @@ IUSE="cxx doc examples python test tools"
RESTRICT="!test? ( test )"
REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"

BDEPEND="
doc? ( app-doc/doxygen )
python? ( dev-lang/swig )"
RDEPEND="
virtual/libusb:1
cxx? ( dev-libs/boost )
python? ( ${PYTHON_DEPS} )
tools? (
!<dev-embedded/ftdi_eeprom-1.0
dev-libs/confuse:=
)"
tools? ( dev-libs/confuse:= )
"
DEPEND="${RDEPEND}
test? ( dev-libs/boost )
"
BDEPEND="
doc? ( app-doc/doxygen )
python? ( dev-lang/swig )
"

pkg_setup() {
use python && python-single-r1_pkg_setup
Expand Down Expand Up @@ -71,7 +75,7 @@ src_install() {
dodoc AUTHORS ChangeLog README TODO

if use doc ; then
# Clean up crap man pages. #356369
# Clean up man pages with too generic names. #356369
rm -vf "${BUILD_DIR}"/doc/man/man3/_* || die

doman "${BUILD_DIR}"/doc/man/man3/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7
PYTHON_COMPAT=( python3_{9..10} )
EAPI=8
PYTHON_COMPAT=( python3_{9..11} )
DISTUTILS_USE_PEP517=setuptools

inherit distutils-r1

Expand All @@ -24,8 +25,7 @@ IUSE="test"

BDEPEND="${PYTHON_DEPS}
dev-python/setuptools[${PYTHON_USEDEP}]
test? ( dev-python/nose[${PYTHON_USEDEP}]
dev-python/six[${PYTHON_USEDEP}] )
test? ( dev-python/six[${PYTHON_USEDEP}] )
"

RDEPEND="
Expand All @@ -41,14 +41,19 @@ RDEPEND="

DOCS=( "${S}/docs/README" )

PATCHES=(
"${FILESDIR}"/${P}-unittest-mock.patch
"${FILESDIR}"/${P}-mock-import-pattern.patch
)

# tests are hanging using default below
RESTRICT="!test? ( test )"

distutils_enable_tests nose

python_test() {
EPYTEST_DESELECT=(
# remaining tests involve way too much file I/O
nosetests -sx --verbosity=3 --detailed-errors \
tests/test_bmap_helpers.py \
tests/test_compat.py || die "Tests fail with ${EPYTHON}"
}
tests/test_api_base.py # too many open files
tests/test_bmap_helpers.py::TestBmapHelpers::test_get_file_system_type_symlink # depends on backports.tempfile
tests/test_bmap_helpers.py::TestBmapHelpers::test_is_zfs_configuration_compatible_unreadable_file # fails
)

distutils_enable_tests pytest
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
Upstream commit: https://github.com/intel/bmap-tools/commit/47908b5389d1f3de9306c0030856b3d3180ade86
Related Gentoo bug: https://bugs.gentoo.org/833258

I had to change the first hunk a bit to also remove `backports`

From 47908b5389d1f3de9306c0030856b3d3180ade86 Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@debian.org>
Date: Thu, 28 Oct 2021 12:23:30 +0100
Subject: [PATCH] tests: Fix import pattern for mock objects

The legacy mock module contains a mock.mock submodule, but unittest.mock
does not contain a redundant unittest.mock.mock. This bug was masked by
the transparent fallback to the legacy mock module.

The actual test only uses mock.patch(), so we can simplify by just
importing the one member that we need.

Fixes: a1ca1172 "tests: Use unittest.mock from Python standard library if possible"
Signed-off-by: Simon McVittie <smcv@debian.org>
---
tests/test_bmap_helpers.py | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/tests/test_bmap_helpers.py b/tests/test_bmap_helpers.py
index 56b079e..36c4557 100644
--- a/tests/test_bmap_helpers.py
+++ b/tests/test_bmap_helpers.py
@@ -22,10 +22,9 @@
import sys
import tempfile
try:
- from unittest.mock import patch, mock
+ from unittest.mock import patch
except ImportError: # for Python < 3.3
- from mock import patch, mock
-from backports import tempfile as btempfile
+ from mock import patch
from bmaptools import BmapHelpers


@@ -76,7 +76,7 @@ def test_is_zfs_configuration_compatible_enabled(self):
delete=True, dir=".", suffix=".txt") as fobj:
fobj.write("1")
fobj.flush()
- mockobj = mock.patch.object(BmapHelpers, "ZFS_COMPAT_PARAM_PATH", fobj.name)
+ mockobj = patch.object(BmapHelpers, "ZFS_COMPAT_PARAM_PATH", fobj.name)
with mockobj:
self.assertTrue(BmapHelpers.is_zfs_configuration_compatible())

@@ -88,7 +88,7 @@ def test_is_zfs_configuration_compatible_disabled(self):
delete=True, dir=".", suffix=".txt") as fobj:
fobj.write("0")
fobj.flush()
- mockobj = mock.patch.object(BmapHelpers, "ZFS_COMPAT_PARAM_PATH", fobj.name)
+ mockobj = patch.object(BmapHelpers, "ZFS_COMPAT_PARAM_PATH", fobj.name)
with mockobj:
self.assertFalse(BmapHelpers.is_zfs_configuration_compatible())

@@ -97,7 +97,7 @@ def test_is_zfs_configuration_compatible_invalid_read_value(self):

with tempfile.NamedTemporaryFile("a", prefix="testfile_",
delete=True, dir=".", suffix=".txt") as fobj:
- mockobj = mock.patch.object(BmapHelpers, "ZFS_COMPAT_PARAM_PATH", fobj.name)
+ mockobj = patch.object(BmapHelpers, "ZFS_COMPAT_PARAM_PATH", fobj.name)
with self.assertRaises(BmapHelpers.Error):
with mockobj:
BmapHelpers.is_zfs_configuration_compatible()
@@ -116,7 +116,7 @@ def test_is_zfs_configuration_compatible_notinstalled(self):

directory = os.path.dirname(__file__)
filepath = os.path.join(directory, "BmapHelpers/file/does/not/exist")
- mockobj = mock.patch.object(BmapHelpers, "ZFS_COMPAT_PARAM_PATH", filepath)
+ mockobj = patch.object(BmapHelpers, "ZFS_COMPAT_PARAM_PATH", filepath)
with mockobj:
self.assertFalse(BmapHelpers.is_zfs_configuration_compatible())

@@ -128,7 +128,7 @@ def test_is_compatible_file_system_zfs_valid(self, mock_get_fs_type): #pylint: d
delete=True, dir=".", suffix=".img") as fobj:
fobj.write("1")
fobj.flush()
- mockobj = mock.patch.object(BmapHelpers, "ZFS_COMPAT_PARAM_PATH", fobj.name)
+ mockobj = patch.object(BmapHelpers, "ZFS_COMPAT_PARAM_PATH", fobj.name)
with mockobj:
self.assertTrue(BmapHelpers.is_compatible_file_system(fobj.name))

@@ -140,7 +140,7 @@ def test_is_compatible_file_system_zfs_invalid(self, mock_get_fs_type): #pylint:
delete=True, dir=".", suffix=".img") as fobj:
fobj.write("0")
fobj.flush()
- mockobj = mock.patch.object(BmapHelpers, "ZFS_COMPAT_PARAM_PATH", fobj.name)
+ mockobj = patch.object(BmapHelpers, "ZFS_COMPAT_PARAM_PATH", fobj.name)
with mockobj:
self.assertFalse(BmapHelpers.is_compatible_file_system(fobj.name))