Prepare wikiq for release: fixes, dependency cleanup, and packaging #2
@@ -6,7 +6,6 @@ readme = "README.md"
|
||||
requires-python = ">=3.9"
|
||||
dependencies = [
|
||||
"deltas>=0.7.0",
|
||||
"mediawiki-utilities>=0.4.18",
|
||||
"more-itertools>=10.7.0",
|
||||
"mwparserfromhell>=0.6.0",
|
||||
"mwpersistence>=0.2.4",
|
||||
@@ -18,6 +17,17 @@ dependencies = [
|
||||
"yamlconf>=0.2.6",
|
||||
]
|
||||
|
||||
# Two features carry dependencies that are awkward enough to install that they
|
||||
# are kept out of the base install: -p legacy needs mediawiki-utilities, a 2015
|
||||
# package that also pulls in a MySQL client, and --diff and -p wikidiff2 need
|
||||
# pywikidiff2, which compiles a C++ extension. Everything else, including the
|
||||
# default -p sequence, works with neither.
|
||||
[project.optional-dependencies]
|
||||
legacy = ["mediawiki-utilities>=0.4.18"]
|
||||
# A wikidiff2 extra belongs here too, but pywikidiff2 is not yet published to
|
||||
# PyPI, so an extra naming it could not resolve. Until it is, wikiq reports the
|
||||
# git install command when --diff or -p wikidiff2 is used without it.
|
||||
|
||||
[project.scripts]
|
||||
wikiq = "wikiq:main"
|
||||
|
||||
|
||||
@@ -67,6 +67,22 @@ def require_pywikidiff2(feature: str):
|
||||
return pywikidiff2
|
||||
|
||||
|
||||
def require_mw_persistence():
|
||||
"""Import and return mw.lib.persistence, or exit explaining how to get it."""
|
||||
try:
|
||||
from mw.lib import persistence
|
||||
except ImportError:
|
||||
raise SystemExit(
|
||||
"-p legacy requires mediawiki-utilities, which wikiq no longer "
|
||||
"installs by default.\n"
|
||||
"Install it with:\n"
|
||||
" pip install 'mediawiki-dump-tools[legacy]'\n"
|
||||
"This method exists to reproduce results from older research "
|
||||
"projects; -p sequence is the current equivalent."
|
||||
)
|
||||
return persistence
|
||||
|
||||
|
||||
def pyarrow_type_to_spark(pa_type):
|
||||
"""Convert a PyArrow type to Spark JSON schema format."""
|
||||
if pa.types.is_int64(pa_type):
|
||||
@@ -845,7 +861,7 @@ class WikiqParser:
|
||||
wikidiff_matcher, revert_radius=PERSISTENCE_RADIUS
|
||||
)
|
||||
else:
|
||||
from mw.lib import persistence
|
||||
persistence = require_mw_persistence()
|
||||
persist_state = persistence.State()
|
||||
|
||||
# Pending persistence values waiting for window to fill
|
||||
@@ -1298,6 +1314,8 @@ def main():
|
||||
require_pywikidiff2("--diff")
|
||||
if persist == PersistMethod.wikidiff2:
|
||||
require_pywikidiff2("-p wikidiff2")
|
||||
elif persist == PersistMethod.legacy:
|
||||
require_mw_persistence()
|
||||
|
||||
if args.namespace_filter is not None:
|
||||
namespaces = args.namespace_filter
|
||||
|
||||
Reference in New Issue
Block a user