Python: Installing 4Suite Python XML Library on OS X
This howto covers my experience installing the 4Suite XML library for Python on OS X. The steps in the installation process for any UNIX based system are covered in detail on the 4Suite site. However, I ran across a few glitches and gotchas along the way. This note covers the installation of the latest version 1.03a on Mac OS X 10.3 Panther.
Note: This howto assumes that you have installed the developer utilities for OS X on your system. You need the GNU gcc C compiler to build certain portions of the suite. In addition, python 2.3 comes pre-installed on OS X 10.3 Panther.
Preparing for the Installation
The 4suite libraries depened upon the expat
C based XML parser. This program and the pyexpat module that wraps it, should be preinstalled on the system. You can test for them by typing: python -c 'import pyexpat'
. If this command returns an error message you will need to install the expat parser.
The next step in the process is to download the compressed library source files and follow the installation instructions. The URLs to each are as follows:
http://4suite.org/?xslt=downloads.xslt
http://4suite.org/docs/howto/UNIX.xml
There are quick start and detailed instructions for the installation. Both are well written and easy to follow.
Problems During Installation
Next, I entered the command for installing this application: python setup.py install
. I received a number of errors and warnings during compilation. The build failed and the installation tests given in the instructions threw error messages. Googling around a bit I ran across the following explanation of the problem at this URL. Here is what the message said:
There are two relatively small platform bugs in the 4Suite build process that prevent it from building properly on Panther. This is from looking at 1.0a3, not all of the tests passed and I don't have any experience with 4Suite to determine whether or not these are "expected" so I am not going to put it in my PackageManager repository yet. 1) It assumes a really brain-dead Python and tries to link it with -flat_namespace. That's not necessary nor desired (except MAYBE on OS X 10.2's awfully broken Python 2.2.0, but you don't need -flat_namespace if you use -bundle_loader). Edit Ft/Lib/DistExt/PackageManager.py and remove the code that adds '-flat_namespace' to the linker flags if the platform is 'darwin'. 2) It assumes that you can get a pointer to environ from a bundle/dylib, you can't. Change the "environ" trap in Ft/Server/Server/src/process.c to the following: #if !defined(_MSC_VER) && !defined(__APPLE__) && ( !defined(__WATCOMC__) || defined(__QNX__) ) extern char **environ; #elif defined(__APPLE__) #include <crt_externs.h> #define environ (*_NSGetEnviron()) #endif /* !_MSC_VER */
As instructed, I looked for the linker flag issue in step 1, but could not find any reference to this problem. So I did not make this change. However, I did cut and paste the code from (2) above into the location indicated. (Make sure that all of the first #if
statement is on one line or you will get a compiler error.) After saving the file and rerunning the installation command, everything compiled correctly. All the test import statements showed in the instructions worked without an error.
However, the command line utilities listed in the instructions were nowhere to be found. Looking around my system I had NO idea where any of the files had been installed. The python library files should be installed in /System/Library/Frameworks/Python.framework
and they were. But, I could not find the executables and other files.
While snooping around I discovered the following text at the end of the compilation messages:
4Suite version 1.0a3 has been successfully installed! Data directory: /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site- packages/Ft/Share The data directory includes documentation, demos and test suites. The documentation is in text, html and xml formats. Library code is installed at: /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site- packages/Ft. You probably want to add to your executable path: /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site- packages/Ft/Share/Bin. Documentation is installed at: /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site- packages/Ft/Share/Docs. Tests are installed at /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site- packages/Ft/Share/Tests. Execute tests by changing to this directory and running: "python test.py Path/To/Test/Module" $
The output indicates that the binaries can be found in: /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/Ft/Share/Bin
and I can confirm they were there for me and worked. I will probably create a symbolic link to the directory and include that in my path.
The documentation did not install for me, I'm not sure why. It hasn't been an issue so far. You can download the documentation from the link you used to download the program source files.
That is it. I thought I would write this down in case I run into the same problem again. Hope it is helpful.