summaryrefslogtreecommitdiff
path: root/dev-python/setuptools-rust
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2024-06-12 00:08:13 +0100
committerV3n3RiX <venerix@koprulu.sector>2024-06-12 00:08:13 +0100
commitf0ddcad13515f66d2f3bf827d33c277bdba7e1dd (patch)
tree3e1da8fa4626163bda62e9e8b6129867de5be46d /dev-python/setuptools-rust
parent65ff3cc3bd9c3f8e718a67dfecf1f8215bf5d1d4 (diff)
gentoo auto-resync : 12:06:2024 - 00:08:13
Diffstat (limited to 'dev-python/setuptools-rust')
-rw-r--r--dev-python/setuptools-rust/Manifest2
-rw-r--r--dev-python/setuptools-rust/files/setuptools-rust-1.9.0-delay-non-stdlib-imports.patch156
-rw-r--r--dev-python/setuptools-rust/setuptools-rust-1.9.0-r1.ebuild198
3 files changed, 356 insertions, 0 deletions
diff --git a/dev-python/setuptools-rust/Manifest b/dev-python/setuptools-rust/Manifest
index dacfc1df47df..1e84254fe92f 100644
--- a/dev-python/setuptools-rust/Manifest
+++ b/dev-python/setuptools-rust/Manifest
@@ -1,3 +1,4 @@
+AUX setuptools-rust-1.9.0-delay-non-stdlib-imports.patch 5233 BLAKE2B 3ef12092aafed300da3945422f8ce52536de03b57af5607d3b42d7a86afd8c41ff14bfb69a5960222f280921cfcf3fb03bc1b02da4b28e93d2b19a5528ad2af7 SHA512 4f6090f6a2e1bb7997c2614c92abe74e0182ad76f0c397d454282af9685ec7b1b629783f738eb823fc572addec6332dfb97e2f7449ec66c08c85bca829b91f5d
DIST autocfg-1.1.0.crate 13272 BLAKE2B 7724055c337d562103f191f4e36cab469e578f0c51cc24d33624dea155d108a07578703766341fd6a4cc1ef52acda406e7dba1650d59115f18261281e5b40203 SHA512 df972c09abbdc0b6cb6bb55b1e29c7fed706ece38a62613d9e275bac46a19574a7f96f0152cccb0239efea04ee90083a146b58b15307696c4c81878cd12de28f
DIST bitflags-1.3.2.crate 23021 BLAKE2B eb990bb27b2bdeb66fd7212ce582cb36e1c616debbac85df642d0c82b25439e6bf9b1e811fac76b59e58ea3c1bbea6170d03a61e8f9a395e4334a0e2e2987eda SHA512 3c698f757b5cc62f815f9a1cce365c3d2dd88e4db71f331dff8bba86c2865f755b81cb4c9bfc59bd86b7643b0943f9e09a7c4f8ad75eb2ab0e714803d0129f62
DIST byteorder-1.4.3.crate 22512 BLAKE2B d39c546ba7346df315297fc53da4bfc77ecb1f38567ddb788549ee31cae2719a8bc0b7d1f1705abb3cff033aa57af004987d90748f5a31765273b3223a011c0d SHA512 8c8000eb8ecf40351c9ce36a3a8acd7a02f81786d1b11aab85adfeffa0f2267ed74df29b2ca5d1d38128484d1d3cad2b673aa0d0441dcd0620dfd3934bb888fa
@@ -107,5 +108,6 @@ DIST windows_x86_64_gnullvm-0.48.0.crate 366536 BLAKE2B 295dc3aef18c604d15799780
DIST windows_x86_64_gnullvm-0.48.5.crate 418486 BLAKE2B 12a2199d434617c1df1a839e9f435620ad64b40c579f6d0c3677553ad7a48e5765d12c266b04946402e15c92cff2e4ac4979ce2130750ef426e2672119680284 SHA512 c016d5b5e73832b61ff67929d92fa8c16e154656294357266ad29ce1f44db4ca2d2935dba31a6b571187dc838b1d22f1e3b41fefffd1d719a338439adf1646aa
DIST windows_x86_64_msvc-0.48.0.crate 671422 BLAKE2B abb063610dcc38581657133182b7d9efeed5553df67bd2bd6f30f1668a645186e4824f9ef556a5abc84ace10b1b437b6325bbda6df5a64ce880d7dcb743ac786 SHA512 6e598b8e3ac54912a8ebac01b0dd2c58fd282072527d7fedc7f6ebecdfb7dcb09ae46c22293bc0117849437f8b053db5e90406e7a38276f0f0afd06be3966795
DIST windows_x86_64_msvc-0.48.5.crate 798412 BLAKE2B 8abc0721e2fb337fe17c91d278947d36122d9045b839ba0cf3e690202d242265b676f23cc301da5f9d98c56ca4ecb76f7d6f072ee71bf986a1deca87020b90e5 SHA512 fa1c5cd14ca2ff0082e2504cf59d317dc4dc6f7138d35c12f95d4476a9c13d8b7f5537d0ee251eee7c99411ad31b22263171b7fbd391daa5d3ea3488ceaa61a0
+EBUILD setuptools-rust-1.9.0-r1.ebuild 4131 BLAKE2B 1cbc1ca9d3c1b076d5e1e0f0bd4a0721c72e80d6ca59a3650173ac8cf935cbd244dfd305f5321e47ba5c7ec5f2f036075372c214f7823710ab26889f6c7f90e7 SHA512 db531320511aab4ad1f45b7beb05b3dbc284257f809b9bb81092950a9aded2360922b1429934e4134211e6ce45c5d5d4be8e6235d4292e7bf7139744368c6705
EBUILD setuptools-rust-1.9.0.ebuild 4060 BLAKE2B ba9f1ea158fa2b680bbc4103bf82007b3cb00792b5472ed423f95ed315f4f158fbf8083a463c430507fbc4c8f559edda7a3972c411496b997faa3aa7675941a5 SHA512 cf0dfa821c51198730505d49c0e06d1835d4a817ebdf2a8ccec7c84ac30f664af436192b3307bcb0d3bb50edb6648d9d802a348007361bc7e25baf0c3c0c17f5
MISC metadata.xml 476 BLAKE2B c8f0ef0779f0a4412a7d9b97e1bb03e3bfb3c031209f489a100b30402d99224014e379712989afd0cb76c85be301dcf9a51e21e8f9195262c5920dd1db0703d1 SHA512 af74755e9e8fb61cbded2dc3e63cd20f95393ef2650bed9f81e299f7759ae79c63b45df8048cd0fe25397ec7db10156be681fa5278606a20481f78d5279b815b
diff --git a/dev-python/setuptools-rust/files/setuptools-rust-1.9.0-delay-non-stdlib-imports.patch b/dev-python/setuptools-rust/files/setuptools-rust-1.9.0-delay-non-stdlib-imports.patch
new file mode 100644
index 000000000000..ea36c235beea
--- /dev/null
+++ b/dev-python/setuptools-rust/files/setuptools-rust-1.9.0-delay-non-stdlib-imports.patch
@@ -0,0 +1,156 @@
+From 06d236045b6a69c94c68f255dc683219ec833c83 Mon Sep 17 00:00:00 2001
+From: Eli Schwartz <eschwartz93@gmail.com>
+Date: Fri, 7 Jun 2024 00:15:26 -0400
+Subject: [PATCH 1/2] Delay imports of non-stdlib dependencies until time of
+ use
+
+This is a bit of a hack, but we do this to ensure that when setuptools
+loads entrypoint based hooks it cannot (will not?) crash.
+
+The issue is that setuptools plugins are autoloaded, whether any given
+project uses them at all or not. So if setuptools-rust is installed,
+setuptools always tries to use it, and crashes if setuptools-rust is
+broken.
+
+Of course, setuptools-rust can't be broken, because it's a wonderful
+project.
+
+BUT.
+
+As it happens, third-party vendors providing setuptools-rust can get
+into a situation where multiple packages need to be installed, including
+setuptools-rust, and also build yet other packages from source. In the
+middle of this, setuptools-rust itself could be installed but in
+"half-configured" state, i.e. its dependencies were queued for
+afterwards due to complicated dependency graph magic.
+
+In such a scenario, it should be nominally all right to have an inert
+package installed, since if nothing actually uses setuptools-rust it
+doesn't need to *work* yet. And in fact, it is all right, as long as
+setuptools can import the autoloaded plugin hooks (and do nothing with
+them).
+
+Bug: https://bugs.gentoo.org/933553
+Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
+---
+ setuptools_rust/extension.py | 7 ++++++-
+ setuptools_rust/rustc_info.py | 8 ++++++--
+ 2 files changed, 12 insertions(+), 3 deletions(-)
+
+diff --git a/setuptools_rust/extension.py b/setuptools_rust/extension.py
+index 2d6e5aa..9ba1cf5 100644
+--- a/setuptools_rust/extension.py
++++ b/setuptools_rust/extension.py
+@@ -1,3 +1,5 @@
++from __future__ import annotations
++
+ import json
+ import os
+ import re
+@@ -14,11 +16,13 @@ from typing import (
+ NewType,
+ Optional,
+ Sequence,
++ TYPE_CHECKING,
+ Union,
+ cast,
+ )
+
+-from semantic_version import SimpleSpec
++if TYPE_CHECKING:
++ from semantic_version import SimpleSpec
+
+ from ._utils import format_called_process_error
+
+@@ -185,6 +189,7 @@ class RustExtension:
+ if self.rust_version is None:
+ return None
+ try:
++ from semantic_version import SimpleSpec
+ return SimpleSpec(self.rust_version)
+ except ValueError:
+ raise SetupError(
+diff --git a/setuptools_rust/rustc_info.py b/setuptools_rust/rustc_info.py
+index 070be0c..d1d4748 100644
+--- a/setuptools_rust/rustc_info.py
++++ b/setuptools_rust/rustc_info.py
+@@ -1,15 +1,19 @@
++from __future__ import annotations
++
+ import subprocess
+ from setuptools.errors import PlatformError
+ from functools import lru_cache
+-from typing import Dict, List, NewType, Optional
++from typing import Dict, List, NewType, Optional, TYPE_CHECKING
+
+-from semantic_version import Version
++if TYPE_CHECKING:
++ from semantic_version import Version
+
+
+ def get_rust_version() -> Optional[Version]: # type: ignore[no-any-unimported]
+ try:
+ # first line of rustc -Vv is something like
+ # rustc 1.61.0 (fe5b13d68 2022-05-18)
++ from semantic_version import Version
+ return Version(_rust_version().split(" ")[1])
+ except (subprocess.CalledProcessError, OSError):
+ return None
+--
+2.44.2
+
+
+From a98e8a8d31d30c5d304e9ee7b48ba739946dea6f Mon Sep 17 00:00:00 2001
+From: Eli Schwartz <eschwartz93@gmail.com>
+Date: Fri, 7 Jun 2024 00:34:59 -0400
+Subject: [PATCH 2/2] Try extra hard to pick up an existing tomli library from
+ setuptools
+
+Since setuptools-rust already depends on setuptools, it is reasonable to
+assume that even if tomli isn't installed, setuptools is. And setuptools
+includes a vendored copy of tomli.
+
+If the copy in setuptools has been devendored, it will be available via
+"tomli". If it isn't devendored, it will be available via
+"setuptools.extern.tomli" unless setuptools changes their vendoring
+approach which has lasted many years so far. Either way, we are sure to
+have a fallback tomli without explicitly depending on one, which means
+one less dependency to install in the common case.
+
+Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
+---
+ pyproject.toml | 1 -
+ setuptools_rust/setuptools_ext.py | 5 ++++-
+ 2 files changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/pyproject.toml b/pyproject.toml
+index cae0536..148d85b 100644
+--- a/pyproject.toml
++++ b/pyproject.toml
+@@ -26,7 +26,6 @@ classifiers = [
+ dependencies = [
+ "setuptools>=62.4",
+ "semantic_version>=2.8.2,<3",
+- 'tomli>=1.2.1; python_version<"3.11"'
+ ]
+
+ [project.entry-points."distutils.commands"]
+diff --git a/setuptools_rust/setuptools_ext.py b/setuptools_rust/setuptools_ext.py
+index d4a0204..0ea6f58 100644
+--- a/setuptools_rust/setuptools_ext.py
++++ b/setuptools_rust/setuptools_ext.py
+@@ -26,7 +26,10 @@ except ImportError:
+ if sys.version_info[:2] >= (3, 11):
+ from tomllib import load as toml_load
+ else:
+- from tomli import load as toml_load
++ try:
++ from tomli import load as toml_load
++ except ImportError:
++ from setuptools.extern.tomli import load as toml_load
+
+
+ logger = logging.getLogger(__name__)
+--
+2.44.2
+
diff --git a/dev-python/setuptools-rust/setuptools-rust-1.9.0-r1.ebuild b/dev-python/setuptools-rust/setuptools-rust-1.9.0-r1.ebuild
new file mode 100644
index 000000000000..82babde79723
--- /dev/null
+++ b/dev-python/setuptools-rust/setuptools-rust-1.9.0-r1.ebuild
@@ -0,0 +1,198 @@
+# Copyright 1999-2024 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_{10..13} pypy3 )
+
+CRATES="
+ autocfg@1.1.0
+ bitflags@1.3.2
+ byteorder@1.4.3
+ cfg-if@1.0.0
+ convert_case@0.4.0
+ cssparser-macros@0.6.0
+ cssparser@0.27.2
+ derive_more@0.99.17
+ dtoa-short@0.3.3
+ dtoa@0.4.8
+ futf@0.1.5
+ fxhash@0.2.1
+ getrandom@0.1.16
+ heck@0.4.1
+ html5ever@0.25.1
+ indoc@2.0.4
+ instant@0.1.12
+ itoa@0.4.8
+ kuchiki@0.8.1
+ lazy_static@1.4.0
+ libc@0.2.121
+ libc@0.2.147
+ lock_api@0.4.10
+ lock_api@0.4.6
+ log@0.4.14
+ mac@0.1.1
+ markup5ever@0.10.1
+ matches@0.1.9
+ memoffset@0.9.0
+ new_debug_unreachable@1.0.4
+ nodrop@0.1.14
+ once_cell@1.10.0
+ once_cell@1.18.0
+ parking_lot@0.11.2
+ parking_lot@0.12.1
+ parking_lot_core@0.8.5
+ parking_lot_core@0.9.8
+ 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
+ portable-atomic@1.6.0
+ ppv-lite86@0.2.16
+ precomputed-hash@0.1.1
+ proc-macro-hack@0.5.19
+ proc-macro2@1.0.66
+ proc-macro2@1.0.69
+ pyo3-build-config@0.20.3
+ pyo3-ffi@0.20.3
+ pyo3-macros-backend@0.20.3
+ pyo3-macros@0.20.3
+ pyo3@0.20.3
+ quote@1.0.32
+ quote@1.0.33
+ 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
+ redox_syscall@0.3.5
+ rustc_version@0.4.0
+ scopeguard@1.1.0
+ scopeguard@1.2.0
+ selectors@0.22.0
+ semver@1.0.6
+ serde@1.0.136
+ servo_arc@0.1.1
+ siphasher@0.3.10
+ smallvec@1.11.0
+ 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
+ syn@2.0.32
+ syn@2.0.38
+ target-lexicon@0.12.11
+ target-lexicon@0.12.3
+ tendril@0.4.3
+ thin-slice@0.1.1
+ unicode-ident@1.0.11
+ unicode-ident@1.0.12
+ unicode-xid@0.2.2
+ unindent@0.2.3
+ utf-8@0.7.6
+ wasi@0.9.0+wasi-snapshot-preview1
+ winapi-i686-pc-windows-gnu@0.4.0
+ winapi-x86_64-pc-windows-gnu@0.4.0
+ winapi@0.3.9
+ windows-targets@0.48.1
+ windows-targets@0.48.5
+ windows_aarch64_gnullvm@0.48.0
+ windows_aarch64_gnullvm@0.48.5
+ windows_aarch64_msvc@0.48.0
+ windows_aarch64_msvc@0.48.5
+ windows_i686_gnu@0.48.0
+ windows_i686_gnu@0.48.5
+ windows_i686_msvc@0.48.0
+ windows_i686_msvc@0.48.5
+ windows_x86_64_gnu@0.48.0
+ windows_x86_64_gnu@0.48.5
+ windows_x86_64_gnullvm@0.48.0
+ windows_x86_64_gnullvm@0.48.5
+ windows_x86_64_msvc@0.48.0
+ windows_x86_64_msvc@0.48.5
+"
+
+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="
+ https://github.com/PyO3/setuptools-rust/archive/v${PV}.tar.gz
+ -> ${P}.gh.tar.gz
+ test? ( ${CARGO_CRATE_URIS} )
+"
+
+# crates are used at test time only, update via pycargoebuild -L -i ...
+LICENSE="MIT"
+SLOT="0"
+KEYWORDS="~amd64 ~arm ~arm64 ~loong ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
+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/setuptools-62.4[${PYTHON_USEDEP}]
+"
+BDEPEND="
+ >=dev-python/setuptools-62.4[${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}-delay-non-stdlib-imports.patch
+)
+
+src_unpack() {
+ cargo_src_unpack
+}
+
+python_test() {
+ local -x UNSAFE_PYO3_SKIP_VERSION_CHECK=1
+
+ 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 tests >/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
+}