diff options
Diffstat (limited to 'dev-python/setuptools-rust')
-rw-r--r-- | dev-python/setuptools-rust/files/setuptools-rust-1.2.0-fix-distutils-conflict.patch | 67 | ||||
-rw-r--r-- | dev-python/setuptools-rust/setuptools-rust-1.2.0-r2.ebuild | 158 |
2 files changed, 225 insertions, 0 deletions
diff --git a/dev-python/setuptools-rust/files/setuptools-rust-1.2.0-fix-distutils-conflict.patch b/dev-python/setuptools-rust/files/setuptools-rust-1.2.0-fix-distutils-conflict.patch new file mode 100644 index 000000000000..1cc16184a945 --- /dev/null +++ b/dev-python/setuptools-rust/files/setuptools-rust-1.2.0-fix-distutils-conflict.patch @@ -0,0 +1,67 @@ +https://github.com/PyO3/setuptools-rust/pull/222 +https://github.com/PyO3/setuptools-rust/issues/221 +https://bugs.gentoo.org/840122 + +From 3441f25d9524d649f17475a40c292a7fdb14efd4 Mon Sep 17 00:00:00 2001 +From: David Hewitt <1939362+davidhewitt@users.noreply.github.com> +Date: Sat, 23 Apr 2022 07:23:08 +0100 +Subject: [PATCH] remove setuptools monkey patch + +--- a/pyproject.toml ++++ b/pyproject.toml +@@ -1,5 +1,5 @@ + [build-system] +-requires = ["setuptools>=46.1", "setuptools_scm[toml]>=3.4.3"] ++requires = ["setuptools>=58.0", "setuptools_scm[toml]>=3.4.3"] + build-backend = "setuptools.build_meta" + + [tool.setuptools_scm] +--- a/setuptools_rust/setuptools_ext.py ++++ b/setuptools_rust/setuptools_ext.py +@@ -240,44 +240,19 @@ def get_tag(self) -> Tuple[str, str, str]: + dist.cmdclass["bdist_wheel"] = bdist_wheel_rust_extension + + +-def patch_distutils_build() -> None: +- """Patch distutils to use `has_ext_modules()` +- +- See https://github.com/pypa/distutils/pull/43 +- """ +- from distutils.command import build as _build +- +- class build(_build.build): +- # Missing type def from distutils.cmd.Command; add it here for now +- distribution: Distribution +- +- def finalize_options(self) -> None: +- build_lib_user_specified = self.build_lib is not None +- super().finalize_options() +- if not build_lib_user_specified: +- if self.distribution.has_ext_modules(): # type: ignore[attr-defined] +- self.build_lib = self.build_platlib +- else: +- self.build_lib = self.build_purelib +- +- _build.build = build # type: ignore[misc] +- +- + def rust_extensions( + dist: Distribution, attr: Literal["rust_extensions"], value: List[RustExtension] + ) -> None: + assert attr == "rust_extensions" + has_rust_extensions = len(value) > 0 + +- # Monkey patch has_ext_modules to include Rust extensions; pairs with +- # patch_distutils_build above. ++ # Monkey patch has_ext_modules to include Rust extensions. + # + # has_ext_modules is missing from Distribution typing. + orig_has_ext_modules = dist.has_ext_modules # type: ignore[attr-defined] + dist.has_ext_modules = lambda: (orig_has_ext_modules() or has_rust_extensions) # type: ignore[attr-defined] + + if has_rust_extensions: +- patch_distutils_build() + add_rust_extension(dist) + + + diff --git a/dev-python/setuptools-rust/setuptools-rust-1.2.0-r2.ebuild b/dev-python/setuptools-rust/setuptools-rust-1.2.0-r2.ebuild new file mode 100644 index 000000000000..c4227ba0011e --- /dev/null +++ b/dev-python/setuptools-rust/setuptools-rust-1.2.0-r2.ebuild @@ -0,0 +1,158 @@ +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +CARGO_OPTIONAL=yes +DISTUTILS_USE_PEP517=setuptools +PYTHON_COMPAT=( python3_{8..10} pypy3 ) + +CRATES=" + bitflags-1.3.2 + byteorder-1.4.3 + cfg-if-1.0.0 + convert_case-0.4.0 + cssparser-0.27.2 + cssparser-macros-0.6.0 + derive_more-0.99.17 + dtoa-0.4.8 + dtoa-short-0.3.3 + futf-0.1.5 + fxhash-0.2.1 + getrandom-0.1.16 + html5ever-0.25.1 + indoc-1.0.4 + instant-0.1.12 + itoa-0.4.8 + kuchiki-0.8.1 + lazy_static-1.4.0 + libc-0.2.121 + lock_api-0.4.6 + log-0.4.14 + mac-0.1.1 + markup5ever-0.10.1 + matches-0.1.9 + new_debug_unreachable-1.0.4 + nodrop-0.1.14 + once_cell-1.10.0 + parking_lot-0.11.2 + parking_lot_core-0.8.5 + phf-0.8.0 + phf_codegen-0.8.0 + phf_generator-0.8.0 + phf_macros-0.8.0 + phf_shared-0.10.0 + phf_shared-0.8.0 + ppv-lite86-0.2.16 + precomputed-hash-0.1.1 + proc-macro2-1.0.36 + proc-macro-hack-0.5.19 + pyo3-0.16.2 + pyo3-build-config-0.16.2 + pyo3-ffi-0.16.2 + pyo3-macros-0.16.2 + pyo3-macros-backend-0.16.2 + quote-1.0.16 + rand-0.7.3 + rand_chacha-0.2.2 + rand_core-0.5.1 + rand_hc-0.2.0 + rand_pcg-0.2.1 + redox_syscall-0.2.11 + rustc_version-0.4.0 + scopeguard-1.1.0 + selectors-0.22.0 + semver-1.0.6 + serde-1.0.136 + servo_arc-0.1.1 + siphasher-0.3.10 + smallvec-1.8.0 + stable_deref_trait-1.2.0 + string_cache-0.8.3 + string_cache_codegen-0.5.1 + syn-1.0.89 + tendril-0.4.2 + thin-slice-0.1.1 + unicode-xid-0.2.2 + unindent-0.1.8 + utf-8-0.7.6 + wasi-0.9.0+wasi-snapshot-preview1 + winapi-0.3.9 + winapi-i686-pc-windows-gnu-0.4.0 + winapi-x86_64-pc-windows-gnu-0.4.0 +" + +inherit distutils-r1 cargo + +DESCRIPTION="A plugin for setuptools to build Rust Python extensions" +HOMEPAGE=" + https://github.com/PyO3/setuptools-rust/ + https://pypi.org/project/setuptools-rust/ +" +SRC_URI=" + mirror://pypi/${PN::1}/${PN}/${P}.tar.gz + test? ( $(cargo_crate_uris ${CRATES}) ) +" + +LICENSE="MIT" +SLOT="0" +KEYWORDS="~amd64 ~ppc ~ppc64 ~riscv" +IUSE="test" +RESTRICT="!test? ( test )" + +RDEPEND=" + virtual/rust + <dev-python/semantic_version-3[${PYTHON_USEDEP}] + >=dev-python/semantic_version-2.8.2[${PYTHON_USEDEP}] + >=dev-python/typing-extensions-3.7.4.3[${PYTHON_USEDEP}] +" +BDEPEND=" + >=dev-python/setuptools_scm-6.3.2[${PYTHON_USEDEP}] + test? ( + ${RDEPEND} + dev-python/beautifulsoup4[${PYTHON_USEDEP}] + $(python_gen_cond_dep ' + dev-python/cffi[${PYTHON_USEDEP}] + ' 'python*') + dev-python/lxml[${PYTHON_USEDEP}] + dev-python/pytest[${PYTHON_USEDEP}] + ) +" + +PATCHES=( + "${FILESDIR}"/${P}-fix-distutils-conflict.patch +) + +src_unpack() { + cargo_src_unpack +} + +python_test() { + local examples=( + html-py-ever + namespace_package + rust_with_cffi + ) + for example_dir in ${examples[@]}; do + pushd examples/${example_dir} >/dev/null || die + einfo "Running ${example_dir} test" + esetup.py build --build-lib=build/lib + + case ${example_dir} in + html-py-ever) + pushd test >/dev/null || die + local -x PYTHONPATH=../build/lib + ${EPYTHON} run_all.py || die "Tests failed with ${EPYTHON}" + popd >/dev/null || die + ;; + *) + pushd build/lib >/dev/null || die + epytest ../../tests + popd >/dev/null || die + ;; + esac + + rm -rf build || die + popd >/dev/null || die + done +} |