Xqt has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1218718?usp=email )

Change subject: tests: Support GraalPy and add it to Github test actions
......................................................................

tests: Support GraalPy and add it to Github test actions

Bug: T412739
Change-Id: I1cf3c9fbfd7ee7ddec5ca04e36e399e1ea00f706
---
M .github/workflows/pywikibot-ci.yml
M pywikibot/throttle.py
M pywikibot/userinterfaces/gui.py
M requirements.txt
M setup.py
5 files changed, 33 insertions(+), 12 deletions(-)

Approvals:
  jenkins-bot: Verified
  Xqt: Looks good to me, approved




diff --git a/.github/workflows/pywikibot-ci.yml 
b/.github/workflows/pywikibot-ci.yml
index cda59c6..8b894f6 100644
--- a/.github/workflows/pywikibot-ci.yml
+++ b/.github/workflows/pywikibot-ci.yml
@@ -57,6 +57,12 @@
           - python-version: 3.14t
             site: wikipedia:test
             experimental: true
+          - python-version: graalpy-24.1
+            site: wikipedia:test
+            experimental: true
+          - python-version: graalpy-25.0
+            site: wikipedia:test
+            experimental: true
           # ubuntu-22.04 required 3.15-dev due to T382214
           - python-version: 3.15-dev
             site: wikipedia:en
diff --git a/pywikibot/throttle.py b/pywikibot/throttle.py
index 53ed103..0fe30ad 100644
--- a/pywikibot/throttle.py
+++ b/pywikibot/throttle.py
@@ -16,12 +16,13 @@
 #
 from __future__ import annotations

+import hashlib
 import itertools
 import threading
 import time
 from collections import Counter
 from contextlib import suppress
-from hashlib import blake2b
+from platform import python_implementation
 from typing import NamedTuple

 import pywikibot
@@ -116,12 +117,24 @@
         """

     @staticmethod
-    def _module_hash(module=None) -> str:
-        """Convert called module name to a hash."""
+    def _module_hash(module: str | None = None) -> str:
+        """Convert called module name to a hash.
+
+        .. versionchanged:: 11.0
+           Set hashlib constructor *usedforsecurity* argument to ``False``
+           because the hash is not used in a security context. Use ``md5``
+           hash algorithm for GraalPy implementation instead of
+           ``blake2b``.
+        """
         if module is None:
             module = pywikibot.calledModuleName()
         module = module.encode()
-        hashobj = blake2b(module, digest_size=2)
+
+        if python_implementation() == 'GraalVM':
+            hashobj = hashlib.md5(module, usedforsecurity=False)
+            return hashobj.hexdigest()[:4]
+
+        hashobj = hashlib.blake2b(module, digest_size=2, usedforsecurity=False)
         return hashobj.hexdigest()

     def _read_file(self, raise_exc: bool = False):
diff --git a/pywikibot/userinterfaces/gui.py b/pywikibot/userinterfaces/gui.py
index 909b02f..3f86d3a 100644
--- a/pywikibot/userinterfaces/gui.py
+++ b/pywikibot/userinterfaces/gui.py
@@ -4,11 +4,10 @@

 .. note:: idlelib, tkinter and pillow modules are required.

-.. warning::
-   With Pillow 10.0, 10.1 no wheels for 32-bit Python on Windows are
-   supported. Pillow 10.2 supports it again. Either you have to update
-   your Python using a 64-bit version or you have to
-   :command:`pip install "pillow>8.1.1,!=10.0,!=10.1"`.
+.. caution::
+   Pillow probably cannot be installed with GraalPy. PyPy 3.9 needs
+   Pillow 10.4.0, PyPy 3.10 needs Pillow 11.3.0. CPython and other
+   Python versions needs Pillow >= 10.4.0 to use this module.

 .. seealso:: :mod:`editor`
 """
diff --git a/requirements.txt b/requirements.txt
index 84be879..7869b51 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -42,9 +42,10 @@
 python-stdnum >= 2.1

 # GUI
+# Pillow cannot be installed with GraalPy
 Pillow==10.4.0; platform_python_implementation == "PyPy" and python_version == 
"3.9"
 Pillow==11.3.0; platform_python_implementation == "PyPy" and python_version == 
"3.10"
-Pillow>=10.4.0; platform_python_implementation != "PyPy" or python_version >= 
"3.11"
+Pillow>=10.4.0; platform_python_implementation != "GraalVM" and 
(platform_python_implementation == "CPython" or python_version >= "3.11")

 # core pagegenerators
 googlesearch-python >= 1.3.0
diff --git a/setup.py b/setup.py
index c344367..19acf97 100755
--- a/setup.py
+++ b/setup.py
@@ -44,13 +44,15 @@
     'memento': ['memento_client==0.6.1'],
     'wikitextparser': ['wikitextparser>=0.56.4'],
     'mysql': ['PyMySQL >= 1.1.2'],
+    # Pillow cannot be installed with GraalPy
     'Tkinter': [
         'Pillow==10.4.0; platform_python_implementation == "PyPy" '
         'and python_version == "3.9"',
         'Pillow==11.3.0; platform_python_implementation == "PyPy" '
         'and python_version == "3.10"',
-        'Pillow>=10.4.0; platform_python_implementation != "PyPy" '
-        'or python_version >= "3.11"',
+        'Pillow>=10.4.0; platform_python_implementation != "GraalVM" '
+        'and (platform_python_implementation == "CPython" '
+        'or python_version >= "3.11")',
     ],
     'mwoauth': [
         'PyJWT != 2.10.0, != 2.10.1',  # T380270

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1218718?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I1cf3c9fbfd7ee7ddec5ca04e36e399e1ea00f706
Gerrit-Change-Number: 1218718
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to