Incredible 2D Images using NodeBox (Intel Binary!)

Recently, I’ve been busy exploring 2d graphics algorithms for generating great looking logos, wallpapers, and backgrounds. The article “Blog Redesign” drew my attention to a great tool on Mac OS X. NodeBox is an open-source application for programming 2-dimensional graphics and animation in the Python language. NodeBox lets the user focus on coding graphics without worrying about the underlying technology.

NodeBox ScreenshotIt is based on another open-source project, DrawBot, and is inspired by technologies like OpenGL and PostScript. This means NodeBox is based on vector graphics rather than pixels. As such it’s an excellent tool for generating 2D graphics intended for print, and in particular typographic experiments. NodeBox can generate PDF documents that can easily be used in Adobe Illustrator or any professional vector graphics package. NodeBox can also generate QuickTime movies for animations.

If you’re curious, the NodeBox Gallery shows off some good-looking sketches. Tom de Smedt, one of NodeBox’s authors, has published two good examples: Supercurly uses the modular font Superveloz by Andreu Balius to construct organic compositions, while Photobjects is a database of images which can be queried for images connected to certain keywords. These are then used to create randomized collages of images.
Prism is an algorithm for creating a color palette on any subject. It uses the internet as a semantic database.

NodeBox is available in version 1.0 release candidate 7, and is sophisticated enough to count as a real production tool. However, NodeBox is compiled only as a PowerPC binary for Mac OS X. As a proud owner of a new Intel-based Macbook, I’ve been looking for a way to compile the source (included in the download) as a binary for Intel-based Macs.

So read on for the required steps to compile and build it yourself, or just download my build, NodeBox 1.0rc7 Intel Binary for Mac OS 10.4.

1. Installation of required Tools and Libraries

The first part requires the installation of some essential tools that are missing from Mac OS X 10.4’s bundled Python 2.3.5. The tools are:

I thought that the installation would be a no-brainer. But it turned out there were some issues the took me some hours to fix. Here’s my step-by-step guide of what I’ve done:

Install the Apple Developer CD

We require the GNU compiler and tools (XCode and the Apple Documentation is not required).

PyObjC

Download the PyObjC 1.4 source release (a compressed tar archive).

Extract it and open a terminal. Enter

python setup.py bdist_mpkg --open

This will compile and build an Mac OS X installation package and open it. Now, this is important: DO NOT INSTALL py2app; you should select “Custom Installation” and deselect all py2app 0.2.5 items!

Numeric

Download the Numeric source package.

In the terminal enter

sudo python setup.py install

An admin account is required for the sudo!

Py2App

Download the py2app 0.3.4 source package for Mac OS X 10.4 and Python 2.3.

Py2App seems to be broken and would produce a binary that prints an error message upon startup:

NodeBox Error
An unexpected error has occurred during execution of the main script

ImportError:
‘/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/lib-dynload/objc/_objc.so’ not found

Very annoying! But there’s an easy fix: we have to modify a file to make it work and produce a proper NodeBox binary:

In folder “py2app/apptemplate” of the source package, open the source file “plist_template.py” and locate the line (line 26)

PyResourcePackages=[],

and replace it with

PyResourcePackages=[(s % version) for s in [
u'lib/python%s',
u'lib/python%s/lib-dynload',
u'lib/python%s/site-packages',
u'lib/python%s/site-packages.zip',
]],

Now build and install Py2App with

sudo python setup.py install

Again, an admin account is required for the sudo!

2. Patching and Building NodeBox

The source of NodeBox requires some fixes to work under 10.4 and Python 2.3.

First download the NodeBox DMG file from the homepage and extract the Source folder.

Patching QTSupport.py

Edit QTSupport.py and locate the line (line 8 )

import QuickTime as Qt

and replace it with

import QTKit as Qt

Copying Missing Files

The Dashboard.py file is missing in the source. So take the PowerPC-Binary and copy the file Dashboard.pyc over to the Source folder. The file is located in the ZIP archive “site-packages.zip” in the folder “NodeBox.app/Contents/Resources/Python”. Just copy it into the “Source” folder. You might use a tool like BetterZIP.

Build

Finally, build the NodeBox application with

python setup.py py2app

The application is located in the dist folder.

Copy Missing Help Files

They are also missing in the Source folder. So copy them over, like

ditto "../PPC/NodeBox.app/Contents/Resources/English.lproj/NodeBox Help" "dist/NodeBox.app/Contents/Resources/English.lproj/NodeBox Help"

Copy the NodeBox.app to your program folder.

That’s it. Enjoy!

Troubleshooting

If you forgot to patch Py2App and get the error message shown above, then try to modify the Info.plist of the built NodeBox application bundle. Replace

PyResourcePackages

with

PyResourcePackages

lib/python2.3/lib-dynload

About these ads

6 Comments »

  1. Excellent! Thanks for taking the time to write this up. I had tried compiling it on my Mac, too, and run into some of the same problems. Actually, I never figured out how to get past them (the QuickTime one seemed to plague me first), so this will be really handy reference when I revisit that.

  2. Thanks for the port. I’m the creator of NodeBox, and don’t have an Intel Mac handy to make the binary. However, the binary you created is not universal, it’s an Intel binary. That leaves us with two versions of NodeBox (one for PPC, one for Intel), but that’ll have to do for now.

    If you’d like to discuss this some more, please send me an email and we’ll get in touch.

  3. maba said

    Frederik, you are right. I changed the labeling “universal” to “intel”.

  4. Just a small update to indicate that NodeBox is now a Universal Binary! Thanks to Martin for some of his compilation suggestions.

  5. hajime said

    I got a same error with py2app + MySQLdb.
    But this solution works perfectly!!!

    Thanks thanks thanks!

  6. LEA HARRIS said

    I do not think I’ve seen this said that way before. You actually have clarified this for me. Thanks!

RSS feed for comments on this post · TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: