-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMPR] Provide an entry point to connect foreign scripts with pwb wapper
- modify the wrapper script to support pywikibot entry points to support script packages with Pywikibot. The entry point is just the package path. It also checks for i18n files and sets the message package. - define base directory of the scripts which is connected to the entry point. - add pyproject.toml for the script package - add a MANIFEST.in for the script package - modify make_dist.py to support creating the pywikibot or the pywikibot-scripts distribution. - add documentation for providing external scripts - add sphinx-tabs - ignore directive tabs with rstcheck as it cause warnings Bug: T139143 Bug: T139144 Change-Id: I5705d240639190e0260299241d2bb76201dde7d2
- Loading branch information
Showing
12 changed files
with
341 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
[rstcheck] | ||
ignore_directives=automodule,autoclass,autofunction | ||
ignore_directives=automodule,autoclass,autofunction,tabs | ||
ignore_messages=(Undefined substitution referenced: "(release|today|version)") | ||
ignore_roles=api,phab,pylib,source,wiki |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
************************ | ||
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``: | ||
|
||
.. code-block:: python | ||
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: | ||
|
||
.. tabs:: | ||
.. tab:: pyproject.toml | ||
|
||
.. code-block:: toml | ||
[project] | ||
dependencies = [ | ||
"pywikibot >= 9.4.0", | ||
] | ||
[project.entry-points."pywikibot"] | ||
scriptspath = "wikidata_scripts:base_dir" | ||
.. tab:: setup.cfg | ||
|
||
.. code-block:: ini | ||
[options] | ||
install_requires = | ||
pywikibot >= 9.4.0 | ||
[options.entry_points] | ||
pywikibot = | ||
scriptspath = wikidata_scripts:base_dir | ||
.. tab:: setup.py | ||
|
||
.. code-block:: python | ||
from setuptools import setup | ||
setup( | ||
install_requires=[ | ||
'pywikibot >= 9.4.0', | ||
], | ||
entry_points={ | ||
'pywikibot': [ | ||
'scriptspath = wikidata_scripts:base_dir', | ||
] | ||
} | ||
) | ||
After installing your package scripts are available via :mod:`pwb` wrapper and | ||
can be invoked like this: | ||
|
||
.. tabs:: | ||
|
||
.. tab:: Unix/macOS | ||
|
||
.. code-block:: shell | ||
$ pwb <global options> show_entities <scripts options> | ||
.. tab:: Windows | ||
|
||
.. code-block:: shell | ||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,7 @@ Contents | |
recipes | ||
api_ref/index | ||
mwapi | ||
entrypoint | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
graft scripts/i18n/ | ||
include CODE_OF_CONDUCT.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.