Hello SuSE list, SuSE Feedback (sent separately), Although I'm running an old SuSE version (6.3), upgrading to some 7.2 rpm's did not seem to work either, so, anticipating my future server upgrade from 6.3 to 7.3, I have the following request to SuSE feedback and included, for those of you who struggled like me, my modest HowTo (install Python 2.1.1, Numeric, MySQL-python (mysqldb) and wxPython/wxWindows). In SuSE Linux 7.3 my request to SuSE is to include rpm's for...: o Python 2.1.1 or higher (or perhaps make 2.2 optional/experimental) o The Numeric library http://numpy.sourceforge.net/ o The MySQL interface (also necessary for Zope with the MySQL adapter) http://sourceforge.net/projects/mysql-python/ o wxPython (and wxWindows, thus glib, gtk+, wxGTK: please don't forget the contrib/src stuff or demo/demo.py won't run! (see howto below)) http://wxpython.org/ o PIL library http://www.pythonware.com/downloads/#pil o PyQt bindings http://www.thekompany.com/projects/pykde/ And (sort of Python related): o Zope (www.zope.org) with the CMF product __and__ the MySQL database adapter product. ** ** How to install MySQL-Python, wxPython and Python 2.1.1 on SuSE 6.x ** ** Howto use MySQL and wxPython and Python 2.1.1 with SuSE 6.3 (and possibly 6.4 and 7.0 to some extent, and 7.1-7.2 regarding 2.1.1). Although I tried to be as accurate as possible, the std. disclaimer applies: use of this info is at your own risk... Good luck and I hope you may find something useful, bye-bye, Eric The idea: install to /usr/local, thus not interfering with SuSE 6.3's setup (/usr). Put /usr/local/bin in your PATH, before /usr/bin. 0. Distutils First download Distutils from www.python.org if not already installed (not by default on SuSE Linux 6.3): http://www.python.org/sigs/distutils-sig/download.html and put it in /usr/src/packages/SOURCES, e.g.: /usr/src/packages/SOURCES/Distutils-1.0.2.tar.gz Verify in a python shell ("import sys ; sys.exec_prefix; sys.prefix") that the prefix of configure was '/usr' and _not_ the default '/usr/local'! So install with this prefix: # python setup.py install --prefix=/usr o Update to Python 2.1.1 (terse summary). This was necessary to get a simulation program of ours working, which required Python 2.1 and Numeric (with MLab): this module is not included in the SuSE 6.3 standard Python rpm (1.5.2). Installing MLab separately was not necessary: it seemed to be a part of the Numeric package/tarball. A. Python 2.1.1 Proved to be easy, because the --prefix (in configure) is /usr/local by default, so 2.1.1 does not interfere with 1.5.2 (std. SuSE 6.3) which has prefix /usr (all is in /usr/{bin,lib} etc). Furthermore, hand editing Modules/Setup is _not_ necessary either, because the setup.py script figured things out correctly. So it was the simply Gnu dance: # ./configure && make && make install Tkinter was also automatically detected and installed ok. B. NumPy: Numeric-20.2.1 Also simple, cuz distutils is nicely callable. Remove the '--dry-run' if install targets look ok. # /usr/local/bin/python \ ./setup_all.py install --prefix=/usr/local --dry-run 1. MySQL-python-0.9.0 If you just upgraded to Python 2.1.1, logout en login again and make sure ('which python') the correct python version is first in your PATH, so the typical '#!/usr/bin/env python' script heading selects the right Python version if you have 1.5.2 in /usr/bin, but installed 2.1.1 in /usr/local/bin. The MySQL-Python package was formerly aka mysqldb. Extract, fix permissions and cd to the ./MySQL-python-0.9.0 dir: # cd /to/some/temp/work/dir # tar zxvf /usr/src/packages/SOURCES/MySQL-python-0.9.0.tar.gz # chown -R root:root MySQL-python-0.9.0 # chmod -R og-w MySQL-python-0.9.0 # cd MySQL-python-0.9.0 Edit the setup.py script ("sys.platform" returns "linux2" on SuSE 6.3): [---- Begin file (fragment): MySQL-python-0.9.0/setup.py ----] #EM# - SuSE Linux elif added below Red Hat. #EM# - Note that contrary to the include files, the mysqlclient lib files are #EM# in /usr/lib (at least for SuSE Linux 6.3, I don't know for 6.4/7.x). if sys.platform == "linux-i386": # Red Hat include_dirs = ['/usr/include/mysql'] library_dirs = ['/usr/lib/mysql'] libraries = [mysqlclient, "z"] runtime_library_dirs = [] extra_objects = [] elif sys.platform == "linux2" and os.name == "posix": # SuSE Linux 6.3 include_dirs = ['/usr/include/mysql'] library_dirs = ['/usr/lib'] libraries = [mysqlclient, "z"] runtime_library_dirs = [] extra_objects = [] elif sys.platform in ("freebsd4", "openbsd2"): [------ End file (fragment): MySQL-python-0.9.0/setup.py ----] Build the package: # python ./setup.py build Before really installing, do a dry-run test first: # python ./setup.py --dry-run install And then really install: # python ./setup.py install Most files are installed in /usr/lib/python1.5/site-packages/MySQLdb/, or /usr/local/lib/python2.1/site-packages/MySQLdb if you use Python version 2.1.1. Here is a complete list (byte-compiled *.pyc files omitted): /usr/lib/python1.5/site-packages/CompatMysqldb.py /usr/lib/python1.5/site-packages/_mysql_exceptions.py /usr/lib/python1.5/site-packages/MySQLdb/* several files and dirs /usr/lib/python1.5/site-packages/_mysql.so o Using MySQLdb from Python scripts. Under Linux, it is very simple to use the MySQLdb module from Python scripts, to access a MySQL database, retrieve records and store them in Python variables for subsequent processing or calculations. Under Windows, use your favorite editor (or PythonWin) and create this file as 'mysql-demo.py' on your network disk: [==== Begin file (complete): mysql-demo.py ====] #!/usr/bin/env python import MySQLdb db = MySQLdb.connect(db='database_name', \ user='username', \ passwd='password') c = db.cursor() c.execute('SELECT subject_name, city, email_address \ FROM subjects \ WHERE subject_name = "John Doe";') results = c.fetchall() print results [====== End file (complete): mysql-demo.py ====] When saved, e.g. as U:\mysql-demo.py, log in on the server, and from your Linux prompt ("john@linus:~ $ ", shortened to "$ " here) type (example user: john): $ chmod u+x mysql-demo.py This makes the Python script 'executable', and you only need to do this once. Note that your U:\ disk is the same as Unix directory '/home/john', which is abreviated to the tilde (~). Now run the script: $ mysql-demo.py Or, if the current directory (.) is not in your PATH: $ ./mysql-demo.py This will return a number of records (each record as a Python tuple). For more information and examples on using MySQL from Python, see: http://dustman.net/andy/python/MySQLdb/doc/MySQLdb.html http://www.python.org/topics/database/DatabaseAPI-2.0.html http://www.amk.ca/python/writing/DB-API.html D. wxPython An alternative to the ("default") Tkinter GUI, based on wxWindows (http://wxwindows.org/) which it "wraps" (http://wxpython.org/). See http://wxpython.org/download.php: the (free) Gtk port thus requires glib, gtk+ and wxGtk. Installing rpm version from higher SuSE versions (upto 7.2) did not make wxPython work (and, by the way, rpm --nodeps was necessary to force the installation), so a source build and install was performed, moreover because wxPython (2.3.1) needed the very latest wxGtk, also at 2.3.1 (non-stable development version by the way): a recommended practice to keep the versions in sync. - Step 1/4: glib and gtk+ Download glib and gtk+ from: http://www.gtk.org/ ftp://ftp.gtk.org/pub/gtk/v1.2/ ftp://ftp.gtk.org/pub/gtk/v1.2/glib-1.2.9.tar.gz ftp://ftp.gtk.org/pub/gtk/v1.2/gtk+-1.2.9.tar.gz Extract (tar zxvf foo.tar.gz) to a temporary work directory and fix ownership (chmod -R root:root glib* gtk*), then install: # cd glib-1.2.9 && more README INSTALL # ./configure --prefix=/usr/local && make && make install Actually the '--prefix' flag is not necessary, because /usr/local is the default, but it does not harm to be explicit. Update system and library paths with 'ldconfig', pseudo re-login and list glib settings to verify the installation: # ldconfig # exec bash --login # glib-config --version; glib-config --prefix 1.2.9 /usr/local # glib-config --libs; glib-config --cflags -L/usr/local/lib -lglib -I/usr/local/include/glib-1.2 -I/usr/local/lib/glib/include The same for gtk+: # cd gtk+-1.2.9 && more README INSTALL # ./configure --prefix=/usr/local && make && make install # ldconfig # exec bash --login # gtk-config --version; gtk-config --prefix 1.2.9 /usr/local # gtk-config --libs -L/usr/local/lib -L/usr/X11R6/lib -lgtk -lgdk -rdynamic -lgmodule -lglib -ldl -lXext -lX11 -lm # gtk-config --cflags -I/usr/local/include/gtk-1.2 -I/usr/local/include/glib-1.2 -I/usr/local/lib/glib/include -I/usr/X11R6/include - Step 2/4: wxGTK Download wxGTK, wxWindows for GTK+, from: http://wxwindows.org/ http://wxwindows.org/dl_gtk.htm http://prdownloads.sourceforge.net/wxwindows/wxGTK-2.3.1.tar.gz Extract, fix ownership, install and verify with: # cd wxGTK-2.3.1 && more README.txt INSTALL.txt # ./configure --prefix=/usr/local --with-gtk --with-opengl # make && make install # ldconfig # exec bash --login # wx-config --version; wx-config --prefix 2.3.1 /usr/local # wx-config --libs -L/usr/local/lib -lwx_gtk -L/usr/local/lib -L/usr/X11R6/lib -lgtk -lgdk -rdynamic -lgmodule -lgthread -lglib -lpthread -ldl -lXext -lX11 -lm -ldl -lpthread -lm # wx-config --cflags -I/usr/local/include -I/usr/local/lib/wx/include -D__USE_WXCONFIG__ -DGTK_NO_CHECK_CASTS -D__WXGTK__ Note that 'wxgtk-config' is a symlink to 'wx-config'. You can test wxGTK by running 'make' in the 'demos' directory and test a couple of programs their directory. Make sure you work under X Windows, e.g. KDE or Gnome, or with an X emulator, and that the $DISPLAY variable is set to your X console (e.g. yourhost.yourdomain.com:0.0): bombs forty fractal life poem Optionally, also 'make' in the 'samples' directory and test some programs there or all like: cd samples for f in *; do if [ -d $f -a -x $f/$f ]; then echo -n "Execute sample program $f/$f (Y/n)? " read ans [ -z "$ans" -o "$ans" = "Y" -o "$ans" = "y" ] && \ { cd $f && ./$f; cd ..; } fi done Finally, build and install the following wxWindows extension modules, which are present in the 'contrib/src' directory and are necessary for wxPython's demo/demo.py program: - canvas - Open GL canvas extension module - ogl - Object Graphics Library extension module - stc - wxStyledTextCtrl (Scintilla wrapper) extension module - xrc - XML Resources extension module with this all-in-one loop: # for f in canvas ogl stc xrc; do cd contrib/src/$f make && make install cd ../../.. done Or separately, like: # cd contrib/src/xrc && make && make install && cd ../../.. and likewise for all extension modules. Rehash library paths etc.: # ldconfig # exec bash --login - Step 3/4: PyOpenGL Download PyOpenGL and the Mesa patches from: http://pyopengl.sourceforge.net/ http://prdownloads.sourceforge.net/pyopengl/PyOpenGL-2.0.0.44.tar.gz http://prdownloads.sourceforge.net/pyopengl/mesa-setup-patch.tar.gz Skip this step for now. Note: does not seem to be necessary! - Step 4/4: wxPython Download wxPython from: http://wxpython.org/ http://wxpython.org/download.php http://prdownloads.sourceforge.net/wxpython/wxPython-2.3.1.tar.gz Extract and fix ownership, and also download the docu files: wxPython-docs-2.3.1.tar.gz, wxPython-demo-2.3.1.tar.gz # tar zxvf wxPython-2.3.1.tar.gz # tar zxvf wxPython-docs-2.3.1.tar.gz # tar zxvf wxPython-demo-2.3.1.tar.gz # chown -R root.root wxPython* wxpython* wxPython itself extracts to wxPython-2.3.1 and the demo is also extracted to that dir, the docs, however, did not (for 2.3.1): # mv wxpython-/docs wxPython-2.3.1/. # rmdir wxpython- Go to the wxPython-2.3.1 directory, read files 'README.txt' and 'BUILD.unix.txt', and start building, after making the following software availability and version verifications (this should be ok if you executed the previous steps succesfully): - Gtk version is ok (e.g. >= 1.2.5 for wxPython 2.3.1): # gtk-config --version 1.2.9 - wxGtk is installed and version is ok (same version as wxPython): # wxgtk-config --version 2.3.1 - Make sure library paths, etc., are set up ok: # ldconfig # exec bash --login Now read docu, adjust BUILD_GLCANVAS and BUILD_OGL in 'setup.py' if necessary (should be installed in step 2/4), and build and install: # cd wxPython-2.3.1 && more README.txt BUILD.unix.txt # python setup.py build # python setup.py install Test wxPython (via an X emulator or behind an X terminal): # cd ./demo && python demo.py And interactively with this small program: from wxPython.wx import * class MyApp(wxApp): def OnInit(self): frame = wxFrame(NULL, -1, "Hello from wxPython") frame.Show(true) self.SetTopWindow(frame) return true app = MyApp(0) app.MainLoop() A simple hello window should pop up, that you can close. Finally, put the 'demo' and 'docs' directories in an appropiate place, e.g. /usr/local/lib/wx: # mv demo docs /usr/local/lib/wx/. End. -- Eric Maryniak <e.maryniak@pobox.com> WWW homepage: http://pobox.com/~e.maryniak/ Mobile phone: +31 6 52047532, or (06) 520 475 32 in NL. Internet Explorer, n.: Another bug -- that is, a feature that can't be turned off -- in Windows.