Feeds:
Posts
Comments

Posts Tagged ‘Python’

There is no binary of MySQLdb for Python 2.6 on Windows, so I have to build it from the source. We’ll need to install MySQL, MySQL Connector C and Python setuptools, and of course uncompressed MySQL-python-1.2.3.tar.gz.

Environment:

Windows 7, MySQL 5.5, MySQL Connector C 6.0.2, Python 2.6, MySQL-python-1.2.3, Microsoft VC2008(Visual Studio 9.0)

1. Edit site.cfg :

# Change the version number accordingly.
registry_key = SOFTWARE\MySQL AB\MySQL Server 5.5
# Append this line, Windows connector libs for MySQL.
connector = C:\Program Files\MySQL\MySQL Connector C 6.0.2

2. Edit setup_windows.py :

# Make the section in this file as below.
library_dirs = [ os.path.join(mysql_root, r'lib\opt') ]
library_dirs = [ os.path.join(options['connector'], r'lib\opt') ]
libraries = [ 'kernel32', 'advapi32', 'wsock32', client ]
include_dirs = [ os.path.join(mysql_root, r'include') ]
include_dirs = [ os.path.join(options['connector'], r'include') ]
extra_compile_args = [ '/Zl' ]

3. Edit C:\Python26\Lib\distutils\msvc9compiler.py :

ld_args.append(‘/MANIFESTFILE:’ + temp_manifest)
# Append this line after above line.
ld_args.append(‘/MANIFEST’)

Then go back to run setup.py build  and setup.py install.

Read Full Post »