|
| 1 | +# Copyright 1999-2024 Gentoo Authors |
| 2 | +# Distributed under the terms of the GNU General Public License v2 |
| 3 | + |
| 4 | +EAPI=8 |
| 5 | + |
| 6 | +DISTUTILS_EXT=1 |
| 7 | +DISTUTILS_USE_PEP517=setuptools |
| 8 | +PYTHON_COMPAT=( python3_{11..13} ) |
| 9 | + |
| 10 | +inherit distutils-r1 |
| 11 | + |
| 12 | +MY_P=${P/_beta/b} |
| 13 | +DESCRIPTION="Data parsing and validation using Python type hints" |
| 14 | +HOMEPAGE=" |
| 15 | + https://github.com/pydantic/pydantic/ |
| 16 | + https://pypi.org/project/pydantic/ |
| 17 | +" |
| 18 | +SRC_URI=" |
| 19 | + https://github.com/pydantic/pydantic/archive/v${PV/_beta/b}.tar.gz |
| 20 | + -> ${MY_P}.gh.tar.gz |
| 21 | +" |
| 22 | +S=${WORKDIR}/${MY_P} |
| 23 | + |
| 24 | +LICENSE="MIT" |
| 25 | +SLOT="0" |
| 26 | +KEYWORDS="amd64 arm arm64 x86" |
| 27 | +IUSE="native-extensions" |
| 28 | + |
| 29 | +RDEPEND=" |
| 30 | + >=dev-python/typing-extensions-4.1.0[${PYTHON_USEDEP}] |
| 31 | +" |
| 32 | +BDEPEND=" |
| 33 | + native-extensions? ( |
| 34 | + <dev-python/cython-3[${PYTHON_USEDEP}] |
| 35 | + ) |
| 36 | + test? ( |
| 37 | + >=dev-python/email-validator-1.2.1[${PYTHON_USEDEP}] |
| 38 | + dev-python/hypothesis[${PYTHON_USEDEP}] |
| 39 | + dev-python/pytest-mock[${PYTHON_USEDEP}] |
| 40 | + dev-python/python-dotenv[${PYTHON_USEDEP}] |
| 41 | + ) |
| 42 | +" |
| 43 | + |
| 44 | +distutils_enable_tests pytest |
| 45 | + |
| 46 | +src_prepare() { |
| 47 | + sed -i -e '/CFLAGS/d' setup.py || die |
| 48 | + distutils-r1_src_prepare |
| 49 | +} |
| 50 | + |
| 51 | +python_compile() { |
| 52 | + if [[ ${EPYTHON} == pypy3 ]] || ! use native-extensions; then |
| 53 | + # do not build extensions on PyPy to workaround |
| 54 | + # https://github.com/cython/cython/issues/4763 |
| 55 | + local -x SKIP_CYTHON=1 |
| 56 | + fi |
| 57 | + distutils-r1_python_compile |
| 58 | +} |
| 59 | + |
| 60 | +python_test() { |
| 61 | + local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 |
| 62 | + local -x PYTEST_PLUGINS=pytest_mock |
| 63 | + |
| 64 | + local EPYTEST_DESELECT=( |
| 65 | + # flaky test, known upstream |
| 66 | + tests/test_hypothesis_plugin.py::test_can_construct_models_with_all_fields |
| 67 | + # mypy linting causes regressions with new mypy versions |
| 68 | + tests/mypy |
| 69 | + ) |
| 70 | + case ${EPYTHON} in |
| 71 | + pypy3) |
| 72 | + EPYTEST_DESELECT+=( |
| 73 | + tests/test_private_attributes.py::test_private_attribute |
| 74 | + tests/test_private_attributes.py::test_private_attribute_annotation |
| 75 | + tests/test_private_attributes.py::test_private_attribute_factory |
| 76 | + tests/test_private_attributes.py::test_private_attribute_multiple_inheritance |
| 77 | + tests/test_private_attributes.py::test_underscore_attrs_are_private |
| 78 | + ) |
| 79 | + ;; |
| 80 | + python3.12) |
| 81 | + EPYTEST_DESELECT+=( |
| 82 | + tests/test_abc.py::test_model_subclassing_abstract_base_classes_without_implementation_raises_exception |
| 83 | + tests/test_generics.py::test_partial_specification_name |
| 84 | + tests/test_generics.py::test_parse_generic_json |
| 85 | + tests/test_types.py::test_secretfield |
| 86 | + ) |
| 87 | + ;; |
| 88 | + esac |
| 89 | + rm -rf pydantic || die |
| 90 | + epytest |
| 91 | +} |
0 commit comments