Sleepycat Software recently released Berkeley DB XML 2.0, a native XML database built on top of Berkley DB. The major change from DB XML 1 to 2 is the addition of XPath 2. and XQuery 1.0 support. Here’s what I did to build and install DB XML 2.0 along with python bindings on OS X 10.3.7.
Having previously built DB XML 1.0 on OS X, I was pleased to see that all of the prerequisite libraries (Xerces-C, Pathan 2, Berkeley DB) are now included in the DB XML source package. After downloading the tarball from the website (see link above), extracting it and building everything was easy:
%> cd /Users/jclark/ext
%> tar -xzf dbxml-2.0.9.tar.gz
%> cd dbxml-2.0.9
%> sh buildall.sh
The buildall.sh script creates an install directory in the build root and installs all of the packages to this location. This gave me the following dir structure:
Users
+ jclark
+ ext
+ dbxml-2.0.9
+ install
+ bin
+ docs
+ include
+ lib
Next I wanted to build python support, which is not built by buildall.sh. The README cautions that the python bindings require the pybsddb package, which ships with python 2.3 and later, but which must be compiled against the same version of Berkeley DB as XML DB (the XML DB package builds BDB 4.3.0 from source). OS X 10.3 comes with python 2.3 installed, but the default copy of bsddb doesn’t seem to work. I downloaded the pybsddb for BDB 4.3 from Sourceforge (via link above), and built it. Because of the nonstandard install location used by buildall.sh, I had to pass an extra param (--berkeley-db) to setup.py. :
%> cd /Users/jclark/ext
%> tar -xzf bsddb3-4.3.0
%> cd bsddb3-4.3.0
%> python setup.py --berkeley-db=/Users/jclark/ext/dbxml-2.0.9/install/ build
%> python test.py
%> python setup.py install
With a working bsddb, It was time to build XML DB’s python bindings. As mentioned in the main README and in the dbxml/src/python README, the custom BDB/DBXML/etc install location requires an edit to dbxml/src/python/setup.py. I adjusted the paths thusly:
if os.name == "posix":
db_home = "/Users/jclark/ext/dbxml-2.0.9/install"
xerces_home = db_home
pathan_home = db_home
xquery_home = db_home
Building and installing was straightforward:
%> cd /Users/jclark/ext/dbxml-2.0.9/src/python
%> python setup.py build
%> python setup.py install
Time to test:
%> cd /Users/jclark/ext/dbxml-2.0.9/dbxml/examples/python
%> python examples.py test
Traceback (most recent call last):
File "examples.py", line 6, in ?
from bsddb.db import *
File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/bsddb/__init__.py", line 40, in ?
import _bsddb
ImportError: No module named _bsddb
Uh-oh. However, a quick look inside examples.py reveals the solution. The import from bsddb.db applies when using the version of pybsddb that ships with python; when using a custom pybsddb build you must import from bsddb3. This involved commenting out one line and uncommenting another in examples.py. Let’s try again:
%> python examples.py test
Traceback (most recent call last):
File "examples.py", line 7, in ?
from dbxml import *
File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/site-packages/dbxml.py", line 5, in ?
import _dbxml
ImportError: Failure linking new module: libxerces-c.26.dylib: dyld:
python can't open library: libxerces-c.26.dylib
(No such file or directory, errno = 2)
Still no joy in Mudville. It’s at this point that I began to have trouble with how to proceed; my knowledge of *nix linking, loading, and such is limited. My rough understanding of dylibs is that they are dynamically linked libraries, a bit like Windows DLLs. The errors above (a couple of newlines were added for formatting) seem to indicate that the xerces-c lib can’t be located. I checked the output from building dbxml.py and confirmed that the correct (to my untrained eye) -l
and -L flags were used to locate all of the required libs from /Users/jclark/ext/dbxml-2.0.9/install/libs.
My problem was, I didn’t really understand the dyld process. It was unclear to me whether dynamically linked libraries have the library location linked into the executable (as I suspected, but which didn’t explain the error) or if they rely on a search path (which probably defaults to /usr/lib or somesuch). In the end, man dyld proved somewhat enlightening. It turns out that there’s a slew of environment variables which can influence the locations searched for dylibs. It also turns out that otool -L can reveal information about linked libraries. Let’s see what we can learn (the two-step cd avoids a linebreak):
%> cd /System/Library/Frameworks/Python.framework/Versions/2.3/lib/
%> cd python2.3/site-packages
%> otool -L _dbxml.so
/System/Library/Frameworks/Python.framework/Versions/2.3/Python
(compatibility version 2.3.0, current version 2.3.0)
/Users/jclark/ext/dbxml-2.0.9/install/lib/libdbxml-2.0.dylib
(compatibility version 0.0.0, current version 0.0.0)
/Users/jclark/ext/dbxml-2.0.9/install/lib/libdb_cxx-4.3.dylib
(compatibility version 0.0.0, current version 0.0.0)
/Users/jclark/ext/dbxml-2.0.9/install/lib/libxquery-1.0.dylib
(compatibility version 0.0.0, current version 0.0.0)
/Users/jclark/ext/dbxml-2.0.9/install/lib/libpathan.3.dylib
(compatibility version 4.0.0, current version 4.1.0)
libxerces-c.26.dylib
(compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libSystem.B.dylib
(compatibility version 1.0.0, current version 71.1.1)
For some reason, libxerces-c was linked without path information, unlike all of the other libraries. If anyone knows why this happened, or how to avoid it, please email me or leave a comment. I couldn’t determine how to change this, so I set an evironmental variable to provide the correct search path:
%> setenv DYLD_LIBRARY_PATH /Users/jclark/ext/dbxml-2.0.9/install/lib
%> python examples.py test
Success!
As I said earlier, I’m a bit under-experienced with some of the details of building software on *nix systems. If anyone can provide any help with the xerces-c dylib issue, or any improvements to these directions, let me know; I’ll update this post with any additional information I find/receive.
With one thing and another, I never got around to posting about my pre-Christmas present. Having been very happy with my Powerbook for the past two years, I’ve been planning to buy a desktop Mac, sometime in January ’05. Originally I had been looking at the PowerMacs, but after getting my hands on an iMac G5 at the Apple store, I began to have second thoughts.
Initially, I was reluctant to consider an iMac G5. As incredible as the machine is, I’ve always had a problem with computers that have integrated monitors. “What happenens if something breaks? It’s just like a TV with a built-in VCR,” I reasoned. Then one day, it occurred to me that I’d owned just such a machine for years – the Powerbook. After that, reason took over, and I forgot my dislike for integrated monitors (surely a mental holdover from my younger, pro-PC days).
A couple of weeks before Christmas, the need presented itself. My Powerbook does not have a Superdrive, but Sherri and I wanted to put together a DVD for her parents as a Christmas present. Last year, a Christmas display her family had visited for 40 years closed down, and we shot some video to remember it by. I could produce a video using iMovie, but without a Superdrive I had no way to put it on DVD.
In an act of ultimate sacrifice, I bought my new computer a month early. I bought the 20″ iMac G5 with the Bluetooth package. What a gorgeous computer. The screen is huge and looks fantastic. The entire design is sleek and elegant. The bluetooth keyboard was an excellent addition, although I’m not using the bluetooth mouse… no amount of love for Apple will ever drive me to use a one-button mouse.
This machine will also become the ‘primary’ computer in the home office. Sherri still has an XP laptop, and the kids still have a PC in the basemaent, but there’s now a Mac that everyone can use. Eventually, I intend to win them all back from the dark side. I’ve already created an account for each of them, and enabled fast user switching.
Of course, now I have to wonder if I’ll miss out on anything this Monday, when His Steveness announces all of the cool new whizbangs in his Macworld Expo Keynote. I’m not too woried about new hardware… this G5 is big enough and fast enough for now. What I’m concerned with is new software… if the much rumored iWork suite and iLife ’05 start shipping with every new Mac on Monday, will there be any retroactive love for recent Mac buyers? I believe they did something similar last year when Panther shipped, but I don’t recall if that extended to iLife.
Guess we’ll see on Monday.
(p.s.: I’m certain Steve Jobs or Apple marketing or someone refered to the iMac g5 as “the ultimate accessory for the iPod” or something like that. I’ve searched all over the internets (several of them) and cannot find the quote. I’d be grateful to anyone who can provide a link. )
Everyone else, go buy a Mac.
Michael McCracken made the world a better place back in February, and I only just found out.
Incremental Search, or i-search, is the magic that powers Firefox‘s in-page search. It’s been around for years in emacs. If you haven’t seen it (why aren’t you using Firefox?), the search takes place in real time, as you type. I miss it in other apps… but not any more.
Michael’s I-Search plugin for NSTextView is a library (a bundle in Cocoa-speak) that adds i-search to all NSTextViews – which is nearly every bit of text you see in an OS X Cocoa application. You just drop the bundle and a keybindings file into a couple of special folders in ~/Library and you’re all set. TextEdit, XCode, and SubEthaEdit all have i-search now.
If you only know i-searching from Firefox, you should note that the I-Search Plugin uses emacs keybindings, not Firefox’s. To begin searching, use ctrl-s. To see the next match, press ctrl-s again (why does Firefox use a second keycombo for this?). To search backwards, use ctrl-r. To exit i-search and return your cursor to it’s pre-search location, press ctrl-g. To exit i-search and keep the current match selected, press return (or esc). Having pressed return or esc, you can return to your pre-search location with ctrl-x ctrl-x (yes, do it twice). You can even make an edit first. In emacs terms, i-search updates the mark before searching. Since Cocoa text editing supports many emacs features and keybindings, it works as expected. (If you don’t know what the last two sentences mean, don’t worry about it.)
While I’m not a fan of their operating systems, I definately like Microsoft’s mice. I’m very partial to the Intellimouse Optical, the beige and silver optical which is omni-handed. I’m not a lefty, I just find every “contoured” mouse I try to be wickedly uncomfortable. I use an Intellimouse on my home and work PCs. In particular, I’m extremeley dependant on the scroll wheel, scroll wheel button (to open a new tab in Firefox), and the thumb button (aka “Button 4”), which acts as a back button in Firefox (and in IE).
Tonight, I plugged my Intellimouse into my Mac, and was surprised to find that it did not work as expected. The left and right buttons worked fine, as did the scroll wheel. However, middle-clicking worked in Safari but not in Firefox. The thumb button did not work at all. Also, the scroll wheel seemed to accelerate as I used it, which I found to be very disorienting. I could find no answer to these problems in System Preferences, or Firefox’s preference panel.
After Googling a bit, it turns out that Microsoft provides Intellipoint software for OS X. I didn’t really think about needing additional software since I already knew that the Mac would handle right-clicking and scroll wheels. As loathe as I am to install Microsoft software on a Mac, I decided to give it a spin; I’ve had largely good experiences with Intellipoint on Windows, and I really needed to get a mouse set up that works like I expect.
Success. I downloaded and installed Intellipoint 5.1 for OS X*, which of course required a reboot (insert Windows joke here). The installation added a new item to System Preferences, which launches the Intellipoint software. Having this installed seems to fix the Back (thumb) and Forward (5th) button automagically. Also, the scrolling settings have an “Enable Accelerated Scrolling” option which was off by default; I no longer see the accelerated scrolling.
Fixing my middle click in Firefox was one extra step. Using the Intellimouse software, I had to change the meaning of middle click from the default “Next Application” to “Click”. Once “Click” is chosen, checkboxes allow you to select modifiers. I set up middle click to equal Cmd+Click, and all is well with the world.
Kudos to Ste Grainer, whose comment on Jeremey Zawodney’s blog outlined the middle click fix, and made me realized I must need some extra software.
P.S. – I’m behind on my blogging, but hey… it’s the holidays. I promise to try and catch up a little; I do have a few good things I need to blog.
*Note: I make no promises about the link above, Microsoft isn’t known for having Cool URIs. If the link doesn’t pan out, just poke around the Microsoft site like I did. One suggestion… I found the drivers on the product page, not in the Support section.
Update: As much as I hate closing comments on a post, this one is just a spam magnet. If you have anything to contribute, drop me a line.
After a long, busy weekend, yesterday was a long, busy Saturday. After everything wound down last night, we decided to go get some dinner at the mall. Of course, this was the perfect excuse for me to wander into the new Apple store.
The last time I was at the Apple store, I played with the iPods for a while. I was impressed by the sound quality of the headphones they use to demo the iPods, but I didn’t have time to inquire about them. Last night I learned that they are Bose Triport Headphones, and they cost $199 at the Apple store. No wonder they sound so good. Of course, the going rate everywhere else is $149. As much as I like the Apple store, 33% markup over street price on third-party merchandising is foolish and insulting.
Speaking of expensive, they also had the new 30″ Cinema Display available to play with. All I can say is “WOW”. What an incredible piece of hardware. Just for fun I opened three browser windows. Side-by-side. And they fit. No way I can justify the expense, but wow. Just breathtaking.
Another product I got to see for the first time is the new 20″ iMac G5. It’s a very slick piece of hardware. I’ve been wanting a desktop Mac for a while, and had been thinking about buying a Power Mac G5 after the new year. Given the price of Power Macs and Cinema Displays, I figured I’d use my existing VGA monitor for now, and look at getting a 20″ or 23″ cinema display in a year or so. But given the price/performance of a 20″ iMac, I’m seriously considering getting one of these.