Making .exe from .py
After mentioned in Validating XML against XSD I gave pyinstaller a try and converted my XSDValidator.py into XSDValidator.exe on my Windows.
First of all I had to set up my Python environment. Yes, I have already 3.3 installed however pyinstaller works only with versions up to 2.7.
This is not a big problem because Python offers binary installers for all possible Windows versions. So downloaded the file and installed it.
After this I had to set-up my Python to have lxml. Well, this was not easy because one option was to compile the whole thing and so. However there exists some not official binary distributions of lxml which one can download and they will possibly work. The downloads for lxml are available here but you have to install some other packages to have a working lxml (these are listed in the above mentioned article and are provided as binaries by Igor Zlatkovic). So make sure you have at least libxml2 and libxsdlt installed and then install lxml.
Making of an executable
Before going to pyinstaller and building our package, we should run the script to see if it works correctly or not. Just download the Python script and execute it (with valid arguments to see if lxml is working). If we get the expected result we can go on.
I searched the WWW for some pyinstaller tutorials but to be honest all of them seemed a bit overwhelming and old. I always gave up by creating the specification… So I ended up tired and hopeless last night and entered following command in the pyinstaller folder:
C:\Python27\python.exe <path to the python script>\XSDValidator.py
Well, this did the trick and I got an executable (XSDValidator.exe) in the <pyinstaller folder>\XSDValidator\dist\ folder. So I navigated there, got my XSDs and XMLs and started testing. And the spec file was generated too.
Nice one I tought so I brought the exe with me into the office and tried here too — and it worked. So I sent it to our customer to have a look and try this validator.
Now after some cofffees I looked at the pyinstaller homepage and found the documentation. This describes how to release an executable without much ado. So I’d suggest to take a look at the page, if you have other special wishes this would be a great site to refer for.
And of course the executable is available at gitHub.