We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
remove distutils usage
In Python 3.10 and 3.11, distutils has been formally marked as deprecated. Code that imports distutils will no longer work from Python 3.12.

`searx_extra/update/update_firefox_version.py` still uses distutils. Maybe its use of `distutils.version` can be replaced by the `packaging` module?

See https://peps.python.org/pep-0632/

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `searx_extra/update/update_firefox_version.py`
Content:
```
1 #!/usr/bin/env python
2 
3 import json
4 import requests
5 import re
6 from os.path import dirname, join
7 from urllib.parse import urlparse, urljoin
8 from distutils.version import LooseVersion, StrictVersion
9 from lxml import html
10 from searx import searx_dir
11 
12 URL = 'https://ftp.mozilla.org/pub/firefox/releases/'
13 RELEASE_PATH = '/pub/firefox/releases/'
14 
15 NORMAL_REGEX = re.compile('^[0-9]+\.[0-9](\.[0-9])?$')
16 # BETA_REGEX = re.compile('.*[0-9]b([0-9\-a-z]+)$')
17 # ESR_REGEX = re.compile('^[0-9]+\.[0-9](\.[0-9])?esr$')
18 
19 # 
20 useragents = {
21     "versions": (),
22     "os": ('Windows NT 10.0; WOW64',
23            'X11; Linux x86_64'),
24     "ua": "Mozilla/5.0 ({os}; rv:{version}) Gecko/20100101 Firefox/{version}"
25 }
26 
27 
28 def fetch_firefox_versions():
29     resp = requests.get(URL, timeout=2.0)
30     if resp.status_code != 200:
31         raise Exception("Error fetching firefox versions, HTTP code " + resp.status_code)
32     else:
33         dom = html.fromstring(resp.text)
34         versions = []
35 
36         for link in dom.xpath('//a/@href'):
37             url = urlparse(urljoin(URL, link))
38             path = url.path
39             if path.startswith(RELEASE_PATH):
40                 version = path[len(RELEASE_PATH):-1]
41                 if NORMAL_REGEX.match(version):
42                     versions.append(LooseVersion(version))
43 
44         list.sort(versions, reverse=True)
45         return versions
46 
47 
48 def fetch_firefox_last_versions():
49     versions = fetch_firefox_versions()
50 
51     result = []
52     major_last = versions[0].version[0]
53     major_list = (major_last, major_last - 1)
54     for version in versions:
55         major_current = version.version[0]
56         if major_current in major_list:
57             result.append(version.vstring)
58 
59     return result
60 
61 
62 def get_useragents_filename():
63     return join(join(searx_dir, "data"), "useragents.json")
64 
65 
66 useragents["versions"] = fetch_firefox_last_versions()
67 with open(get_useragents_filename(), "w") as f:
68     json.dump(useragents, f, indent=4, ensure_ascii=False)
69
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/searx_extra/update/update_firefox_version.py b/searx_extra/update/update_firefox_version.py
--- a/searx_extra/update/update_firefox_version.py
+++ b/searx_extra/update/update_firefox_version.py
@@ -5,7 +5,7 @@
 import re
 from os.path import dirname, join
 from urllib.parse import urlparse, urljoin
-from distutils.version import LooseVersion, StrictVersion
+from packaging.version import Version, parse
 from lxml import html
 from searx import searx_dir
 
@@ -39,7 +39,7 @@
             if path.startswith(RELEASE_PATH):
                 version = path[len(RELEASE_PATH):-1]
                 if NORMAL_REGEX.match(version):
-                    versions.append(LooseVersion(version))
+                    versions.append(Version(version))
 
         list.sort(versions, reverse=True)
         return versions
@@ -49,12 +49,12 @@
     versions = fetch_firefox_versions()
 
     result = []
-    major_last = versions[0].version[0]
+    major_last = versions[0].major
     major_list = (major_last, major_last - 1)
     for version in versions:
-        major_current = version.version[0]
+        major_current = version.major
         if major_current in major_list:
-            result.append(version.vstring)
+            result.append(str(version))
 
     return result

{"golden_diff": "diff --git a/searx_extra/update/update_firefox_version.py b/searx_extra/update/update_firefox_version.py\n--- a/searx_extra/update/update_firefox_version.py\n+++ b/searx_extra/update/update_firefox_version.py\n@@ -5,7 +5,7 @@\n import re\n from os.path import dirname, join\n from urllib.parse import urlparse, urljoin\n-from distutils.version import LooseVersion, StrictVersion\n+from packaging.version import Version, parse\n from lxml import html\n from searx import searx_dir\n \n@@ -39,7 +39,7 @@\n             if path.startswith(RELEASE_PATH):\n                 version = path[len(RELEASE_PATH):-1]\n                 if NORMAL_REGEX.match(version):\n-                    versions.append(LooseVersion(version))\n+                    versions.append(Version(version))\n \n         list.sort(versions, reverse=True)\n         return versions\n@@ -49,12 +49,12 @@\n     versions = fetch_firefox_versions()\n \n     result = []\n-    major_last = versions[0].version[0]\n+    major_last = versions[0].major\n     major_list = (major_last, major_last - 1)\n     for version in versions:\n-        major_current = version.version[0]\n+        major_current = version.major\n         if major_current in major_list:\n-            result.append(version.vstring)\n+            result.append(str(version))\n \n     return result\n", "issue": "remove distutils usage\nIn Python 3.10 and 3.11, distutils has been formally marked as deprecated. Code that imports distutils will no longer work from Python 3.12.\r\n\r\n`searx_extra/update/update_firefox_version.py` still uses distutils. Maybe its use of `distutils.version` can be replaced by the `packaging` module?\r\n\r\nSee https://peps.python.org/pep-0632/\n", "before_files": [{"content": "#!/usr/bin/env python\n\nimport json\nimport requests\nimport re\nfrom os.path import dirname, join\nfrom urllib.parse import urlparse, urljoin\nfrom distutils.version import LooseVersion, StrictVersion\nfrom lxml import html\nfrom searx import searx_dir\n\nURL = 'https://ftp.mozilla.org/pub/firefox/releases/'\nRELEASE_PATH = '/pub/firefox/releases/'\n\nNORMAL_REGEX = re.compile('^[0-9]+\\.[0-9](\\.[0-9])?$')\n# BETA_REGEX = re.compile('.*[0-9]b([0-9\\-a-z]+)$')\n# ESR_REGEX = re.compile('^[0-9]+\\.[0-9](\\.[0-9])?esr$')\n\n# \nuseragents = {\n    \"versions\": (),\n    \"os\": ('Windows NT 10.0; WOW64',\n           'X11; Linux x86_64'),\n    \"ua\": \"Mozilla/5.0 ({os}; rv:{version}) Gecko/20100101 Firefox/{version}\"\n}\n\n\ndef fetch_firefox_versions():\n    resp = requests.get(URL, timeout=2.0)\n    if resp.status_code != 200:\n        raise Exception(\"Error fetching firefox versions, HTTP code \" + resp.status_code)\n    else:\n        dom = html.fromstring(resp.text)\n        versions = []\n\n        for link in dom.xpath('//a/@href'):\n            url = urlparse(urljoin(URL, link))\n            path = url.path\n            if path.startswith(RELEASE_PATH):\n                version = path[len(RELEASE_PATH):-1]\n                if NORMAL_REGEX.match(version):\n                    versions.append(LooseVersion(version))\n\n        list.sort(versions, reverse=True)\n        return versions\n\n\ndef fetch_firefox_last_versions():\n    versions = fetch_firefox_versions()\n\n    result = []\n    major_last = versions[0].version[0]\n    major_list = (major_last, major_last - 1)\n    for version in versions:\n        major_current = version.version[0]\n        if major_current in major_list:\n            result.append(version.vstring)\n\n    return result\n\n\ndef get_useragents_filename():\n    return join(join(searx_dir, \"data\"), \"useragents.json\")\n\n\nuseragents[\"versions\"] = fetch_firefox_last_versions()\nwith open(get_useragents_filename(), \"w\") as f:\n    json.dump(useragents, f, indent=4, ensure_ascii=False)\n", "path": "searx_extra/update/update_firefox_version.py"}], "after_files": [{"content": "#!/usr/bin/env python\n\nimport json\nimport requests\nimport re\nfrom os.path import dirname, join\nfrom urllib.parse import urlparse, urljoin\nfrom packaging.version import Version, parse\nfrom lxml import html\nfrom searx import searx_dir\n\nURL = 'https://ftp.mozilla.org/pub/firefox/releases/'\nRELEASE_PATH = '/pub/firefox/releases/'\n\nNORMAL_REGEX = re.compile('^[0-9]+\\.[0-9](\\.[0-9])?$')\n# BETA_REGEX = re.compile('.*[0-9]b([0-9\\-a-z]+)$')\n# ESR_REGEX = re.compile('^[0-9]+\\.[0-9](\\.[0-9])?esr$')\n\n# \nuseragents = {\n    \"versions\": (),\n    \"os\": ('Windows NT 10.0; WOW64',\n           'X11; Linux x86_64'),\n    \"ua\": \"Mozilla/5.0 ({os}; rv:{version}) Gecko/20100101 Firefox/{version}\"\n}\n\n\ndef fetch_firefox_versions():\n    resp = requests.get(URL, timeout=2.0)\n    if resp.status_code != 200:\n        raise Exception(\"Error fetching firefox versions, HTTP code \" + resp.status_code)\n    else:\n        dom = html.fromstring(resp.text)\n        versions = []\n\n        for link in dom.xpath('//a/@href'):\n            url = urlparse(urljoin(URL, link))\n            path = url.path\n            if path.startswith(RELEASE_PATH):\n                version = path[len(RELEASE_PATH):-1]\n                if NORMAL_REGEX.match(version):\n                    versions.append(Version(version))\n\n        list.sort(versions, reverse=True)\n        return versions\n\n\ndef fetch_firefox_last_versions():\n    versions = fetch_firefox_versions()\n\n    result = []\n    major_last = versions[0].major\n    major_list = (major_last, major_last - 1)\n    for version in versions:\n        major_current = version.major\n        if major_current in major_list:\n            result.append(str(version))\n\n    return result\n\n\ndef get_useragents_filename():\n    return join(join(searx_dir, \"data\"), \"useragents.json\")\n\n\nuseragents[\"versions\"] = fetch_firefox_last_versions()\nwith open(get_useragents_filename(), \"w\") as f:\n    json.dump(useragents, f, indent=4, ensure_ascii=False)\n", "path": "searx_extra/update/update_firefox_version.py"}]}