dev-python/pynacl: enable py3.14

Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
Sam James
2025-06-07 08:10:47 +01:00
parent 0b688c7397
commit a2ef337bbf
2 changed files with 112 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
https://github.com/pyca/pynacl/commit/d33028e43b814615a33e231925eaddb0f679fa2b
From d33028e43b814615a33e231925eaddb0f679fa2b Mon Sep 17 00:00:00 2001
From: Karolina Surma <33810531+befeleme@users.noreply.github.com>
Date: Fri, 15 Nov 2024 04:53:12 +0100
Subject: [PATCH] Fix compatibility with Python 3.14.0a1 (#848)
typing.ByteString has been removed from Python 3.14.
Ported the suggested way from the documentation:
https://docs.python.org/3.13/library/typing.html#typing.ByteString
---
src/nacl/bindings/crypto_secretstream.py | 3 ++-
tests/test_secretstream.py | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/nacl/bindings/crypto_secretstream.py b/src/nacl/bindings/crypto_secretstream.py
index d7c6725e..59b074c5 100644
--- a/src/nacl/bindings/crypto_secretstream.py
+++ b/src/nacl/bindings/crypto_secretstream.py
@@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-from typing import ByteString, Optional, Tuple, cast
+from typing import Optional, Tuple, Union, cast
from nacl import exceptions as exc
from nacl._sodium import ffi, lib
@@ -73,6 +73,7 @@ class crypto_secretstream_xchacha20poly1305_state:
def __init__(self) -> None:
"""Initialize a clean state object."""
+ ByteString = Union[bytes, bytearray, memoryview]
self.statebuf: ByteString = ffi.new(
"unsigned char[]",
crypto_secretstream_xchacha20poly1305_STATEBYTES,
diff --git a/tests/test_secretstream.py b/tests/test_secretstream.py
index d1b72739..9a847bb4 100644
--- a/tests/test_secretstream.py
+++ b/tests/test_secretstream.py
@@ -16,7 +16,7 @@
import json
import os
import random
-from typing import ByteString, List, Optional, Tuple
+from typing import List, Optional, Tuple, Union
from _pytest._code import ExceptionInfo
from _pytest.monkeypatch import MonkeyPatch
@@ -219,6 +219,7 @@ def test_it_like_libsodium():
header = crypto_secretstream_xchacha20poly1305_init_push(state, k)
+ ByteString = Union[bytes, bytearray, memoryview]
state_save: ByteString = ffi.buffer(state.statebuf)[:]
c1 = crypto_secretstream_xchacha20poly1305_push(

View File

@@ -0,0 +1,54 @@
# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
DISTUTILS_EXT=1
DISTUTILS_USE_PEP517=setuptools
PYTHON_COMPAT=( pypy3_11 python3_{11..14} )
inherit distutils-r1
DESCRIPTION="Python binding to the Networking and Cryptography (NaCl) library"
HOMEPAGE="
https://github.com/pyca/pynacl/
https://pypi.org/project/PyNaCl/
"
SRC_URI="
https://github.com/pyca/pynacl/archive/${PV}.tar.gz
-> ${P}.gh.tar.gz
"
LICENSE="Apache-2.0"
SLOT="0"
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux"
DEPEND="
dev-libs/libsodium:=
"
RDEPEND="
${DEPEND}
$(python_gen_cond_dep '
>=dev-python/cffi-1.4.1[${PYTHON_USEDEP}]
' 'python*')
"
BDEPEND="
$(python_gen_cond_dep '
>=dev-python/cffi-1.4.1[${PYTHON_USEDEP}]
' 'python*')
test? (
>=dev-python/hypothesis-3.27.0[${PYTHON_USEDEP}]
)
"
PATCHES=(
"${FILESDIR}"/${PN}-1.5.0-py314.patch
)
distutils_enable_tests pytest
src_compile() {
# For not using the bundled libsodium
local -x SODIUM_INSTALL=system
distutils-r1_src_compile
}