Provide your own scripts#

You may provide your own scripts as a Pywikibot plugin. All you have to do is to bind your package and define an entry point for pywikibot.

Caution

pywikibot >= 9.4.0 is required for this possibility.

For example having package files like this:

my_pwb_scripts/
├── LICENSE
├── pyproject.toml
├── README.md
├── src/
│   └── wikidata_scripts/
│       ├── __init__.py
│       ├── drop_entities.py
│       └── show_entities.py
└── tests/

Add the following code in your wikidata_scripts.__init__.py:

from pathlib import Path
base_dir = Path(__file__).parent

Add Pywikibot dependency and register the entry point, which is the base_dir above, within your preferred config file:

[project]
dependencies = [
    "pywikibot >= 9.4.0",
]

[project.entry-points."pywikibot"]
scriptspath = "wikidata_scripts:base_dir"

After installing your package scripts are available via pwb wrapper and can be invoked like this:

$ pwb <global options> show_entities <scripts options>

Note

If you have several Pywikibot scripts installed, there script names must be different; otherwise the started script might not that you have expected.

Warning

This guide is not tested. Test it locally before uploading to pypi.