Showing posts with label pdf. Show all posts
Showing posts with label pdf. Show all posts

December 3, 2011

Installing ReportLab's Open Source Package on a Mac

I'm setting up to do some development, and this has meant installation work–never my favorite task, but  man's got to do what a man's go to do.

I mostly (i.e. when it there's a recipe for it) use homebrew to install functionality on my Mac. This isn't a religion, just my own particular choice, and by and large I'm comfortable with it. The current homebrew recipe for Python offers an easy update to 2.7 (while retaining 2.6 as the “system” Python) and includes the distribute package. This means you can immediately run

    easy_install virtualenvwrapper

and fixed up your shell initialization per the installation instructions you are ready to go. Once I'd done that I created a virtual environment with

    workon test1

and installed the recent PIL fork–which I felt would be a good compatibility test–with

    pip install pillow

The virtual environments you create with virtualenvwrapper already have pip installed, which is neat. Next I thought I'd see whether I could just do a vanilla install of the reportlab package, which is admirably good at writing PDF files. With some delight I observed

    pip install reportlab

appeared to go out to the Internet for the package, download and correctly install it. Except there was this annoying message about how it hadn't been built with freetype2 support.


    # installing without freetype no ttf, sorry!
    # You need to install a static library version of the freetype2 software


Hmm, no problem, uninstall it again (thank you pip) and install freetype2. Except that

    brew install freetype2

shows me that there's no brew formula for the dratted package, and there's (what seems to be) a perfectly good freetype2 library in /usr/X11. This is kind of annoying (there must be hundreds of Mac users of ReportLab's stuff, surely?) but I downloaded the source and tweaked around with it to see if I can get it to “see” the X11 library (all the time wondering whether that's some X-dependent stuff I don't really want to tangle with). Eventually I realized it didn't matter. Without writing a brew recipe for reportlab (which is what really seems to be required—that would allow patching of setup.py—but how could we persuade Python users not to user easy_install?) I needed a freetype2 that the standard pip install could see.

So I just had to go out in the hopeful spirit of yak-shavers everywhere and download and install freetype2 from source. Exactly what I was hoping to avoid, but I don't remember it being that difficult. I also remember blessing the author for including an “uninstall” target to try and remove it, which seems to work pretty effectively. Maybe I'll see if I can write a brew formula and submit it. Anyway, I now had a second copy of freetype2 happily occupying its own little corner of /usr/local, and that was all that was required since the standard reportlab build appears to look there for libraries.

Which meant that pip installed the package beautifully, complete with freetype2 (and therefore TrueType font) support. Hooray!

May 17, 2009

Python is So Versatile

Even though I use Python all the time, and I am well-connected in the Python world, so much is happening that it's difficult to stay in touch with everything Python. Taking a look at the Python Package Index, in just the last 24 hours there have been over 40 submissions. Not all of them will be new releases, but it's instructive to take a look at what's come in to PyPI as an indication of the breadth of applications in which Python is used. Rather than list all 40 submissions available from the RSS feed, let's just take a look at some of the more interesting items.

You could use the new release of Dumbo to write programs in Hadoop, the language for specifying massively parallel map-reduce computations. With AMFast you could create rich Internet applications using Flash remoting. If you wanted to write a Unix daemon in Python you could use the python-daemon library that implements PEP 3143. You could write a network time client with ntplib.

If you wanted to add automated image processing to your Django web application you could do it with django-imagekit, or you could add AJAX with Dajax. To make it useful to a broader audience you could add django-bidi-utils to handle bi-directional text.

You might want to analyze some PDF files, in which case you could use pdfminer. If you are more interested in structural bioinformatics research then Biskit might be more your cup of tea. With all this complex software flying around you might need a program to handle a structured to-do list, and Task Coach would be ready and waiting for you.

There's also a slew of Zope and Plone components to add to these already very capable systems. Python is just so versatile!

February 13, 2009

Impress Me ...

Dear Lazy Web:

I've created a presentation for PyCon and I want to publish it as a PDF. Open Office seems like the best bet (yes, I created in it PowerPoint, but I did have my reasons, honest).

Unfortunately I can't seem to find a way to get Impress to produce a PDF containing only the notes pages (each slide with its notes underneath); it insists on putting all the slides in before it starts on the notes pages. This is probably just some UI aspect that I am unfamiliar with and can't find. But it would be really nice to know how to do this.

So, PowerPoint slides to PDF, what's my best path without involving more proprietary software?

regards
 Steve