Files

239 lines
7.0 KiB
Plaintext

Warning:
If you fail to read all of this document and ask questions that are
already answered, I reserve the right to verbally abuse you.
Binary Packages:
I don't plan to make binary packages any more. However, if someone
contributes one, I will make it available.
Prerequisites:
Python 1.5.2 or higher
* http://www.python.org/
* Versions lower than 1.5.2 WON'T WORK.
* All versions from 1.5.2 should work. 1.6.x versions have not been
tested. All of the recent testing has been done with 2.3.x.
* Red Hat Linux:
o Make sure you have the Python development headers
and libraries (python-devel).
Distutils 1.0.2 or higher
* comes starting with Python 1.6
* 1.0.2 is included in Python version 2.1 and newer
* http://www.python.org/sigs/distutils-sig/download.html
MySQL 3.22.19 or higher
* http://www.mysql.com/downloads/
* Versions lower than 3.22 definitely WON'T WORK.
* Versions lower than 3.22.19 might not work.
* MySQL-4.1 is not yet supported, and probably won't be until
MySQLdb-1.3 or 2.0. Current release 4.1.2 (alpha).
* MySQL-4.0 is supported, and all recent testing is with 4.0.x.
* MySQL-3.23 is supported, but slightly deprecated.
* MySQL-3.22 is deprecated in favor of 3.23, but still supported.
* Red Hat Linux packages:
o mysql-devel to compile
o mysql and/or mysql-devel to run
* MySQL.com RPM packages:
o MySQL-devel to compile
o MySQL-shared if you want to use their shared
library. Otherwise you'll get a statically-linked module,
which may or may not be what you want.
o MySQL-shared to run if you compiled with MySQL-shared installed
* Transactions (particularly InnoDB tables) are supported for
MySQL-3.23 and up. You may need a special package from your
vendor with this support turned on.
zlib
* Required for MySQL-3.23 and newer.
* Red Hat Linux
o zlib-devel to compile
o zlib to run
A C COMPILER!!!
* Most free software-based systems already have this, usually gcc.
* Most commercial UNIX platforms also come with a C compiler, or
you can also use gcc.
* If you have some Windows flavor, you usually have to pay extra
for this, or you can use Cygwin.
Building and installing
First thing to do is read setup.py. There are some variables towards
the beginning that tell it where your MySQL include files and
libraries are, compiler flags, loader flags, etc. You will rarely
have to change this unless you have some kind of weird setup.
After the main variables section, there is some platform-specific
configuration. If your platform is not listed, this is where you
want to add it. Note that most POSIX and UNIX-ish systems will work
just fine the way it is.
If you have an old version of distutils (pre-1.0.2), upgrade, or
remove the parameters that are complained about. Upgrading distutils
is the smart way to go.
Depending on which version of MySQL you have, you may have the
option of using three different client libraries:
mysqlclient -- mostly but not guaranteed thread-safe
mysqlclient_r -- thread-safe, use if you can
mysqld -- embedded server
mysqlclient is used by default. To use one of the others, set
the environment variable mysqlclient to the name of the library
you want to use.
There are several active versions of MySQL out there, and this
makes it a little tricky to configure setup.py automatically and
still be cross-platform. setup.py assumes you are using version
3.23.32. To specify a different version, set the environment
variable mysqlversion.
If your MySQL is compiled with certain options, you may need to
add some more libraries to the link. In particular, with 4.0 and
up, if MySQL was configured to use SSL, you need to link against
crypto and ssl. You can do this by setting the environment
variable mysqloptlibs a space-separated list of libraries.
If you have the dynamic client libraries (on Linux, .so vs. .a),
those will be used by default. If they are not on your standard
loader path, you will have to set or adjust the LD_LIBRARY_PATH
environment variable (on Linux) or whatever your platform
requires. Otherwise, you can adjust setup.py to link against the
static library. If you are using standard RPM packaging, you
shouldn't have to mess with this. If you compiled MySQL yourself,
you might. There is a runtime_libraries_dir variable you can play
with, but this does not work on all system; in particular, it
doesn't seem to work on Linux gcc.
Finally, putting it together:
$ tar xfz MySQL-python-1.0.0.tar.gz
$ cd MySQL-python-1.0.0
$ export mysqlversion="4.0.20"
$ export mysqlclient="mysqlclient_r"
$ export mysqloptlibs="ssl crypto"
$ python setup.py build
$ su
# python setup.py install
NOTE: You must export environment variables for setup.py to see
them. Depending on what shell you prefer, you may need to use
"export" or "set -x" (bash and other Bourne-like shells) or "setenv"
(csh-like shells).
Windows
I don't do Windows. However if someone provides me with a package
for Windows, I'll make it available. Don't ask me for help with
Windows because I can't help you.
Zope
If you are using a binary package of Zope, you need run setup.py
with the python executable that came with Zope. Otherwise, you'll
install into the wrong Python tree and Zope (ZMySQLDA) will not be
able to find _mysql.
With zope.org's Zope-2.5.1-linux2-x86 binary tarball, you'd do
something like this:
$ export ZOPEBIN=".../Zope-2.5.1-linux2-x86/bin" # wherever you unpacked it
$ $ZOPEBIN/python setup.py install # builds and installs
RPMs
If you prefer RPMs, you can use the bdist_rpm command with
setup.py. This only builds the RPM; it does not install it. You
may want to use the --python=XXX option, where XXX is the name of
the Python executable, i.e. python, python2, python2.1; the
default is python. Using this will incorporate the Python
executable name into the package name for the RPM so you have
install the package multiple times if you need to support more
than one version of Python.
Red Hat Linux
MySQL-python is pre-packaged in Red Hat Linux 7.x and newer.
Debian GNU/Linux
Packaged as python-mysql.
http://www.debian.org/distrib/packages
Gentoo Linux
It's in the portage tree. Gentoo is also my development platform.
# emerge sync
# emerge mysql-python
# emerge zmysqlda # if you use Zope
*BSD
MySQL-python is a ported package in FreeBSD, NetBSD, and OpenBSD,
although the name may vary to match OS conventions.
Acknowledgements
Thanks go to Brian Fordham for cooking up an early version of setup.py.
See the CHANGELOG for other individual contributions.
License
GPL or the original license based on Python 1.5.2's license.
Andy Dustman <andy@dustman.net>
2004-06-06 (D-Day + 60)