Ryan Kelly
I am a freelance software developer based in Melbourne, Australia. Most of my days are spent coding in Python and JavaScript, for a variety of open-source projects as well as some commercial endeavours. I also maintain a strong interest in logic programming, mainly as a result of my doctoral thesis. I am available for contract development and consulting work; please read more about me and check out my curriculum vitae if you're interested.
The latest release of PyEnchant now contains an experimental binary distribution for OSX, as both an mpkg installer and a python egg. In theory, users on OSX 10.4 or later should be able to just drop pyenchant-1.6.3-py2.6-macosx-10.4-universal.egg somewhere on sys.path and be up and running and spellchecking with ease.
If you're a Mac user, please try it out and let me know if anything doesn't work the way you expect.
The experience of building this was quite interesting, and more than a little painful, because I wanted to build a proper universal library that could be used on almost any Mac out there. The gory details can be found in pyenchant-bdist-osx-sources-1.6.3.tar.gz; this post is a quick set of notes that might help others get started.
Fortunately for me, the familiar build toolchain of "./configure; make; make install" is pretty much intact on OSX. The only real trickery is getting the resulting library to work on systems other than your own. I hit two major stumbling blocks in this regard:
- how to build fat binaries that still work on older versions of OSX?
- how to make the libraries relocatable, so they can be installed at any location?
This may all be old news to seasoned OSX veterans, but hopefully these notes can help out other expat linux users like me.
Compiling RPython Programs
Inspired by a recent discussion on Reddit about a Python-to-C++ compiler called Shed Skin, I decided to write up my own experiences on compiling (a restricted subset of) Python to a stand-alone executable. My tool of choice is the translation toolchain from the PyPy project – a project, by the way, that every Python programmer should take a look at.
Take this very exciting (EDIT: and needlessly inefficient) python script, which we'll assume is in a file "factors.py":
def factors(n): """Calculate all the factors of n.""" for i in xrange(2,n / 2): if n % i == 0: return [i] + factors(n / i) return [n] def main(argv): n = int(argv[1]) print "factors of", n, "are", factors(n) if __name__ == "__main__": import sys main(sys.argv)
We can of course run this from the command-line using the python interpreter, but gosh that's boring:
$> python factors.py 987654321 factors of 987654321 are [3, 3, 17, 17, 379721]
Instead, let's compile it into a stand-alone executable! Grab the latest source tarball from the PyPy downloads page and unzip it in your work directory: