jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/876339 )

Change subject: [IMPR] Make mwparserfromhell mandatory
......................................................................

[IMPR] Make mwparserfromhell mandatory

Require mwparserfromhell >= 0.6.3 which is preinstalled at Toolforge.

Bug: T326498
Change-Id: Iaa95ea13b82fa106a5c34b03e82ff432c6b8f029
---
M pywikibot/textlib.py
M README.rst
M scripts/commons_information.py
M .github/workflows/doctest.yml
M setup.py
M requirements.txt
M tox.ini
M scripts/patrol.py
8 files changed, 31 insertions(+), 69 deletions(-)

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




diff --git a/.github/workflows/doctest.yml b/.github/workflows/doctest.yml
index 467c7fc..cdf1885 100644
--- a/.github/workflows/doctest.yml
+++ b/.github/workflows/doctest.yml
@@ -54,10 +54,10 @@
         pip install -U setuptools
         pip install pytest
         pip install "sseclient<0.0.23,>=0.0.18"
-        pip install "mwparserfromhell>=0.5.0"
+        pip install mwparserfromhell
         pip install "PyMySQL >= 0.9.3"
         pip install codecov
-        pip install "coverage>=5.2.1"
+        pip install coverage
         python -c "import setuptools; print('setuptools:', 
setuptools.__version__)"

     - name: Generate user files
diff --git a/README.rst b/README.rst
index 8acdd16..eed4dc1 100644
--- a/README.rst
+++ b/README.rst
@@ -65,18 +65,6 @@
     pip install pywikibot
     pwb <scriptname>

-In addition a MediaWiki markup parser is required. Please install one of them:
-
-.. code:: text
-
-    pip install mwparserfromhell
-
-or
-
-.. code:: text
-
-    pip install wikitextparser
-
 Our `installation
 guide <https://www.mediawiki.org/wiki/Manual:Pywikibot/Installation>`_
 has more details for advanced usage.
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index 9d56f91..b3f4aa1 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -1,12 +1,10 @@
-"""
-Functions for manipulating wiki-text.
+"""Functions for manipulating wiki-text.

-Unless otherwise noted, all functions take a unicode string as the argument
-and return a unicode string.
-
+Unless otherwise noted, all functions take a unicode string as the
+argument and return a unicode string.
 """
 #
-# (C) Pywikibot team, 2008-2022
+# (C) Pywikibot team, 2008-2023
 #
 # Distributed under the terms of the MIT license.
 #
@@ -34,24 +32,11 @@
 )
 from pywikibot.userinterfaces.transliteration import NON_LATIN_DIGITS

-
 try:
     import wikitextparser
 except ImportError:
-    try:
-        import mwparserfromhell as wikitextparser
-    except ImportError:
-        # print required because pywikibot is not imported completely
-        raise ImportError("""
-Pywikibot is missing a MediaWiki markup parser which is necessary.
-Please update the required module with either
+    import mwparserfromhell as wikitextparser

-    pip install "mwparserfromhell>=0.5.0"
-
-or
-
-    pip install "wikitextparser>=0.47.5"
-""") from None

 ETPType = List[Tuple[str, OrderedDictType[str, str]]]

@@ -1672,8 +1657,8 @@
     only the last value provided will be returned.

     This uses the package :py:obj:`mwparserfromhell` or
-    :py:obj:`wikitextparser` as MediaWiki markup parser. It is mandatory
-    that one of them is installed.
+    :py:obj:`wikitextparser` as MediaWiki markup parser.
+    ``mwparserfromhell`` is installed by default.

     There are minor differences between the two implementations.

diff --git a/requirements.txt b/requirements.txt
index 5b0d8a2..c4bc403 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -18,6 +18,7 @@
 # $ awk -F '[#>=]' '{print $1}' requirements.txt | xargs apt-cache search

 # mandatory dependencies, others are optional
+mwparserfromhell>=0.6.3
 requests>=2.21.0, < 2.28.0; python_version < '3.7'
 requests>=2.21.0; python_version >= '3.7'
 setuptools>=48.0.0 ; python_version >= '3.10'
@@ -25,10 +26,9 @@
 setuptools>=40.8.0, <59.7.0 ; python_version < '3.7'

 # MediaWiki markup parser
-# mwparserfromhell is default, wikitextparser can be used instead
+# mwparserfromhell is mandatory but wikitextparser can be used instead
 # mwparserfromhell is still required for commons_information.py and patrol.py
 # wikitextparser>=0.47.5
-mwparserfromhell>=0.5.0

 # OAuth support
 # mwoauth 0.2.4 is needed because it supports getting identity information
diff --git a/scripts/commons_information.py b/scripts/commons_information.py
index c98fca4..cd7f746 100755
--- a/scripts/commons_information.py
+++ b/scripts/commons_information.py
@@ -1,22 +1,18 @@
 #!/usr/bin/python3
 """Insert a language template into the description field."""
 #
-# (C) Pywikibot team, 2015-2022
+# (C) Pywikibot team, 2015-2023
 #
 # Distributed under the terms of the MIT license.
 #
 import copy

+import mwparserfromhell
+
 import pywikibot
 from pywikibot import i18n, pagegenerators
 from pywikibot.bot import ExistingPageBot, SingleSiteBot

-
-try:
-    import mwparserfromhell
-except ImportError as e:
-    mwparserfromhell = e
-
 try:
     import langdetect
 except ImportError:
@@ -101,11 +97,6 @@
         rspaces = lstrip[len(lstrip.rstrip()):]
         param.value = f'{lspaces}{value}{rspaces}'

-    def setup(self):
-        """Raise exception if needed modules are missing."""
-        if isinstance(mwparserfromhell, Exception):
-            raise mwparserfromhell
-
     def treat_page(self) -> None:
         """Treat current page."""
         page = self.current_page
diff --git a/scripts/patrol.py b/scripts/patrol.py
index e29c8b2..16e14f7 100755
--- a/scripts/patrol.py
+++ b/scripts/patrol.py
@@ -42,7 +42,7 @@

 """
 #
-# (C) Pywikibot team, 2011-2022
+# (C) Pywikibot team, 2011-2023
 #
 # Distributed under the terms of the MIT license.
 #
@@ -50,16 +50,12 @@
 from collections import defaultdict
 from contextlib import suppress

+import mwparserfromhell
+
 import pywikibot
 from pywikibot import pagegenerators
 from pywikibot.backports import Container, removeprefix
-from pywikibot.bot import BaseBot, suggest_help
-
-
-try:
-    import mwparserfromhell
-except ImportError as e:
-    mwparserfromhell = e
+from pywikibot.bot import BaseBot


 def verbose_output(string) -> None:
@@ -447,10 +443,6 @@
         else:
             recentchanges = True

-    if isinstance(mwparserfromhell, ImportError):
-        suggest_help(missing_dependencies=('mwparserfromhell',))
-        return
-
     if newpages or usercontribs:
         pywikibot.info('Newpages:')
         gen = site.newpages
diff --git a/setup.py b/setup.py
index 1c9edae..c6e6c80 100755
--- a/setup.py
+++ b/setup.py
@@ -43,7 +43,6 @@
     'Graphviz': ['pydot>=1.4.1'],
     'Google': ['google>=1.7'],
     'memento': ['memento_client==0.6.1'],
-    'mwparserfromhell': ['mwparserfromhell>=0.5.0'],
     'wikitextparser': ['wikitextparser>=0.47.0'],
     'mysql': ['PyMySQL >= 0.9.3'],  # toolforge
     # vulnerability found in Pillow<8.1.1 but toolforge uses 5.4.1
@@ -86,8 +85,6 @@
 # ------- setup extra_requires for scripts ------- #
 script_deps = {
     'create_isbn_edition.py': ['isbnlib', 'unidecode'],
-    'commons_information.py': extra_deps['mwparserfromhell'],
-    'patrol.py': extra_deps['mwparserfromhell'],
     'weblinkchecker.py': extra_deps['memento'],
 }

@@ -97,6 +94,7 @@
 # ------- setup install_requires ------- #
 # packages which are mandatory
 dependencies = [
+    'mwparserfromhell>=0.6.3',
     'requests>=2.21.0, <2.28.0; python_version < "3.7"',
     'requests>=2.21.0; python_version>="3.7"',
     # PEP 440
@@ -104,7 +102,6 @@
     'setuptools>=40.8.0 ; python_version >= "3.7" and python_version < "3.10"',
     'setuptools>=40.8.0, <59.7.0 ; python_version < "3.7"',
 ]
-# in addition either mwparserfromhell or wikitextparser is required

 # ------- setup tests_require ------- #
 test_deps = ['mock']
diff --git a/tox.ini b/tox.ini
index 4f85c2b..c9e5e54 100644
--- a/tox.ini
+++ b/tox.ini
@@ -52,14 +52,12 @@
     fasttest: pytest-attrib>=0.1.3
     fasttest: pytest-subtests >= 0.3.2
     fasttest: mock
-    fasttest: .[mwparserfromhell]
     fasttest: .[scripts]

     fasttest-py36: .[html]
     fasttest-py37: .[wikitextparser]

     deeptest: .[html]
-    deeptest: .[mwparserfromhell]
     deeptest: .[scripts]
     deeptest-py39: .[wikitextparser]
     deeptest-py39: pytest >= 7.0.1
@@ -79,7 +77,6 @@
 deps =
     pytest >= 7.0.1
     .[eventstreams]
-    .[mwparserfromhell]
     .[mysql]

 [testenv:venv]

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

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

Reply via email to