Pywikipedia is dead! Long live to PyWikibot!

Pywikipedia is dead! Long live to PyWikibot!

Published Aug. 20, 2015 in Development - Last update on Aug. 21, 2015.

Make a Wikipedia bot is one of the first thing I made in Python. I used to make toolbox, categories and tasks for sort articles. There are a lot of client library for use MediaWiki API, more than 20, and my goal wasn't really to use MediaWiki API but more to read and write pages. Between Java, JS, Lisp, Perl, C# (OMG) and Python, I choose the last, and between all Python library I choose Pywikipedia.

As many society has a MediaWiki for collaborative work, I used to code with Pywikipedia until I wrote a full Django app with panel of tool and asynchronous task with Celery. I really made a lots of things with this library but today after a retrospective and analysis, I do not regret but admit Pywikipedia was a bad choice.

Why ?

Firstly, Pywikipedia wasn't packaged, it was not using distutils or setuptools for installation, instead it was a plain folder with a lot of Python scripts inside. Users had to add it themselves to PYTHONPATH and launch a wizard which create a huge credentials Python file. Briefly there's no installation and you must manually configure it for before usage: the worst things for a library.

But in fact it was not a library but more a toolbox of lot scripts using MediaWiki API, and due to how it was designed, it was difficult to integrate it in other project with a simple and quick install. For example, it was not possible to include it in a requirements.txt and use it as an automatic dependency of another package.

Many developers saw this lack and a plenty of GitHub fork has emerged without a great consensus of which the leading project.

Secondly, there was no real documentation, oh sorry: wiki documentation, docstrings, raw examples, but nothing for a noob like I was. I looked for more for a clear tutorial as Django made for getting started with their documentation. Better was to understand some examples findable in Pywikipedia's source code and look at other Wikipedia bots' code.

Despite all this trouble I didn't really feel the problems I explain above, I was a beginner and all seemed difficult (and simple with Python). It allowed me to learn a lot of things about Python environment, maybe more than Python language itself, such as:

Some say "smalls craps", but enough for a beginner like I was, and useful stuffs for my work today.

As title say: "Pywikipedia is dead", it was replaced by Pywikibot which is more contemporary with GitHub, Travis and collaborative work tools. This new version seems to be more modern and easy to use as their README says:

import pywikibot
site = pywikibot.Site('en', 'wikipedia')  # The site we want to run our bot on
page = pywikibot.Page(site, 'Wikipedia:Sandbox')
page.text = page.text.replace('foo', 'bar')'Replacing "foo" with "bar"')  # Saves the page

Maybe it's time for me to hack that a little ...


Post your comment

Comment as . Log out.