Installing mwlib, mwlib.rl, and Collection on Windows
Introduction
Instructions for installing mwlib on Windows using MinGW and MSYS (part of MinGW). The installation guide is broken into four sections covering the installation of the development, build, and runtime environment for Windows, the mwlib component, the mwlib.rl component, and the Collection extension.
- These instructions do not use Cygwin.
- These instructions have been verified on Windows XP and Windows Vista
written by Brion Finlay
Questions, requests, and further information can be posted to the Google group, or corrections can be made to this wiki page.
Prerequisites
- You have a working MediaWiki installation, including PHP, a webserver, a database server, and the MediaWiki software. XAMPP is a very easy way to install a webserver, database, and PHP.
- your PHP configuration must support CURL. I describe how to enable CURL for XAMPP below.
- Perl may be needed. I did not verify if is Perl needed to be installed. XAMPP will also install Perl for you, but you may need to add the Perl directory to your path.
Installing the Development/Build/Run-time Environment for Windows
Install Python for Windows
- go to http://www.python.org/download/
- Choose Python 2.5.2 Windows installer
- Install Python to c:\python25
Install Python Imaging Library
- go to http://www.pythonware.com/products/pil/
- Download Python Imaging Library 1.1.6 for Python 2.5
- The following error messages occur under Windows Vista, but it seems safe to ignore them. They seem related to registry keys. You may be able to prevent them by right clicking on the installer and running it as an administrator.
- Error messages under windows vista
- Could not create ... PIL-py2.5
- Could not set key value... Python 2.5 PIL-1.1.6
- Could not set key value: "C:\Python25\RemovePIL.exe" -u "C:\Python25\PIL-wininst.log"
- Error messages under windows vista
Install MinGW
- go to http://sourceforge.net/project/showfiles.php?group_id=2435
- Download Automated MinGW Installer
- Choose MinGW-5.1.4.exe
- run MinGW auto installer
- choose "download and install"
- Read license and agree
- Choose "Current" package
- Choose "MinGW base tools"
- Choose "g++ compiler"
- Choose "mingw make" (maybe not needed)
- Install to C:\MinGW
- Install to MinGW group.
- MinGW will download and install
Install MSYS
- download msys 1.0.10
- install
- agree to license
- choose c:\msys\1.0
- choose i386
- choose group MinGW
- post install process pops up
- answer yes for mingw
- type c:\mingw
- hit return
- select finish
Setup Paths
- Add Python to path: c:\python25\
- Add MSYS to path: c:\msys\1.0\bin
- add MinGW to path: c:\mingw\bin
Configure Python to use MinGW
Configure Python to work with MinGW, to solve the "visual studio 2003" issue.
Create mingw_setup.py
- Copy this file to mingw_setup.py:
#=== mingw_setup.py by Phillip J. Eby """Create pythonNN.def and libpythonNN.a in 'PythonNN/libs' directory This script makes it possible to use the MinGW compiler tools to build C extensions that work with the standard Windows Python distribution. Before running, you should have installed the MinGW compiler toolset, and placed its 'bin' directory on your PATH. An easy way to do this is to install Cygwin's "binutils", "gcc", and "mingw-*" packages, then run this script from the Cygwin shell. (Be sure to use *Windows* Python, not Cygwin python!) Once this script has been run, you should be able to build extensions using distutils in the standard way, as long as you select the 'mingw32' compiler, and the required tools are on your PATH. See the "Installing Python Modules" manual for more information on selecting a compiler. """ from distutils.spawn import find_executable from distutils.sysconfig import get_config_var from distutils import __file__ as distutils_file import os, re, sys if sys.platform=='cygwin': print "Please run this script using Windows python,", print "not Cygwin python. E.g, try:" print print "/cygdrive/c/PythonNN/python", " ".join(sys.argv) print print "(where NN is the major/minor python version number)" sys.exit() basename = 'python%d%d' % sys.version_info[:2] libs_dir = os.path.join(get_config_var('prefix'),'libs') lib_file = os.path.join(libs_dir,basename+'.lib') def_file = os.path.join(libs_dir,basename+'.def') ming_lib = os.path.join(libs_dir,'lib%s.a' % basename) distutils_cfg = os.path.join(os.path.dirname(distutils_file),'distutils.cfg') export_match = re.compile(r"^_imp__(.*) in python\d+\.dll").match nm = find_executable('nm') dlltool = find_executable('dlltool') if not nm or not dlltool: print "'nm' and/or 'dlltool' were not found;" print "Please make sure they're on your PATH." sys.exit() nm_command = '%s -Cs %s' % (nm, lib_file) print "Building", def_file, "using", nm_command f = open(def_file,'w') print >>f, "LIBRARY %s.dll" % basename print >>f, "EXPORTS" nm_pipe = os.popen(nm_command) for line in nm_pipe.readlines(): m = export_match(line) if m: print >>f, m.group(1) f.close() exit = nm_pipe.close() if exit: print "nm exited with status", exit print "Please check that", lib_file, "exists and is valid." sys.exit() print "Building",ming_lib,"using",dlltool dlltool_pipe = os.popen( "%s --dllname %s.dll --def %s --output-lib %s" % (dlltool, basename, def_file, ming_lib) ) dlltool_pipe.readlines() exit = dlltool_pipe.close() if exit: print "dlltool exited with status", exit print "Unable to proceed." sys.exit() print print "Installation complete. You may wish to add the following" print "lines to", distutils_cfg, ':' print print "[build]" print "compiler = mingw32" print print "This will make the distutils use MinGW as the default" print "compiler, so that you don't need to configure this for" print "every 'setup.py' you run."
Run mingw_setup.py
- run "python mingw_setup.py"
- create distutils as directed by script:
Installation complete. You may wish to add the following lines to C:\Python25\lib\distutils\distutils.cfg : [build] compiler = mingw32
Install easy_install
- download http://peak.telecommunity.com/dist/ez_setup.py
- run 'python ez_setup.py'
- this will install setuptools
Windows Vista: administrator CMD
In Vista, open cmd window as administrator. Remaining components should be installed from the administrator shell.
- open start menu
- search for cmd
- right click cmd and choose "run as administrator"
Installing mwlib on Windows
- mwlib is the component that processes wikitext in MediaWiki articles.
Install mwlib
- cd \python25\scripts
- easy_install mwlib
Build latest mwlib
Step 1: Download and install re2c
- http://downloads.sourceforge.net/re2c/re2c-0.13.5-bin.zip
- extract re2c – I put it in c:\python25. It probably belongs somewhere better, like its own path. You could put it in MSYS or MinGW directories but then if you upgrade MSYS or MinGW you have to remember to upgrade re2c. Its own path is probably best.
Step 2: Get latest mwlib version
- download mwlib source
- extract mwlib source
- cd to mwlib source
- run 'sh'
- type 'make'
- type 'python setup.py install'
Installing mwlib.rl on Windows
- mwlibrl mwlib.rl is the component used by mwlib to write PDF output.
Install mwlib.rl
- cd \python25\scripts
- easy_install mwlib.rl
Install ReportLab? (SVN)
- download ReportLab? from SVN
- extract source
- (Windows Vista: use administrator shell)
- cd reportlab-full-xxx\reportlab
- run 'sh'
- run 'python setup.py install'
Installing the MediaWiki Collection Extension on Windows
- The MediaWiki Collection extension makes it possible to organize personal selections of pages in a collection, and adds a Download as PDF link in the toolbox on mediawiki.
Install Collection Extension
- download latest Collection extension:
- extract to MediaWiki extensions/Collection
- Add the following to LocalSettings.php
# Extension: Collection require_once("$IP/extensions/Collection/Collection.php"); $wgCollectionMWServeURL = 'http://localhost/cgi-bin/mwlib.cgi'; $wgHTTPTimeout = 30; $wgEnableAPI=true; // uncomment the next line if you need login // domain is optional. Can be set to "local" for authentication against wiki database. //$wgCollectionMWServeCredentials = "user:password:domain"; - Create "MediaWiki:PDF Template Blacklist" page
- enter "none" and save the page.
Enable CURL in PHP
- For XAMPP, modify XAMPP\apache\bin\php.ini, and uncomment the line "extension=php_curl.dll".
- Restart Apache.
Install mwlib.cgi
- copy mwlib.cgi from the mwlib source download (in the cgi-bin directory) to the cgi-bin directory on your server.
- edit mwlib.cgi:
- modify first line, change to "#! c:\python25\python"
- your webserver must be setup properly to execute cgi-bin files, especially processing the path behind the shebang. An easy way to do this is to install XAMPP.
- modify MWRENDER: MWRENDER = 'c:/python25/scripts/mw-render.exe'
- modify MWZIP: MWZIP = 'c:/python25/scripts/mw-zip.exe'
- modify MWPOST: MWPOST = 'c:/python25/scripts/mw-post.exe'
- update locations for log files and cache directory. Remember to use forward slashes "/" for the python strings.
- modify first line, change to "#! c:\python25\python"
Add Collection portlet to MediaWiki
- see README.txt:
- Add a portlet to the skin of your MediaWiki installation: Just before the line:
in the file skins/MonoBook.php or skins/Modern.php insert the following code:
<div class="portlet" id="p-tb"><?php if(isset($GLOBALS['wgSpecialPages']['Collection'])) { Collection::printPortlet(); } ?>
Further Configuration
- more options are availble to configure for the Collection extension. See the README.txt file for more information.
