No, I don't have any new ones, but 1.2.2b2 (released over the weekend) should hopefully build on Windows without any patches or modifications. If you find that it still does, please post your patch so I can incorporate it.
I have not yet fully added support for Python 2.5 yet, though it should work on x86. I need to test on x86-64 and may need to do some work on _mysql.c.
Also, I plan to add support for the new with statement because it is pretty trivial and won't break on older versions of Python. You'll be able to do stuff like this (in 2.5 and newer):
with db as c:
c.execute(...)
which more-or-less means this:
c = db.cursor()
try:
c.execute(...)
db.commit()
except:
db.rollback()
raise
When might a Windows binary for Python 2.5 be available? I must be doing something wrong because I cannot get it to build and install even trying the techniques given here.
Thanks in advance
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I finally was able to build MySQLDb for Windows Python 2.5 and MySQL 5.
Some of these steps may be obvious to experienced folks, but I have not seen them stated here. Soooo...
Downloaded MySQL source and built it using VC++.
Copied the following from the MySQL lib_release directory:
zlib.lib to [PYTHONPATH]/libs
libmysql.lib to [PYTHONPATH]/libs
mysqlclient.lib to [PYTHONPATH]/libs
libmysql.dll to [PYTHONPATH]/DLLs
Edited the MySQLdb site.cfg file as follows: [compiler]
mysql_root: d:/downloads/mysql/mysql-5.0.26 <-- this should be where you compiled MySQL
library_dirs: %(mysql_root)s/lib
include_dirs: %(mysql_root)s/include
libraries: mysqlclient
zlib
wsock32
advapi32
user32
libcmt <-- commented out
msvcrt <-- commented out
extra_compile_args:
extra_objects:
extra_link_args: /NODEFAULTLIB:msvcrt"
Edited the _mysql.c file adding the following just after copyright statement
define version_info "(1,2,1,'final',2)"
define version "1.2.1_p2"
Run "Python setup.py build" and get bunch of warnings.
Run "Python setup.py install" and it appears to work.
Hope this helps
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Please try 1.2.2b2. You should definitely not have to play around with the version numbers now. As for copying libraries, you shouldn't have to do this if you have edited site.cfg. You may also want to experiment with static linking.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have Python-2.5 win-xp sp2 patched to date and MySQL 5.0.27 binary install. After reading others contributions I installed in c:\usr\local\mysql (a dirname with no embedded spaces).
I then edited site.cfg so the very last section reads [compiler]
mysql_root: \usr\local\mysql
library_dirs: %(mysql_root)s\lib\opt
include_dirs: %(mysql_root)s\include
libraries: mysqlclient zlib wsock32 advapi32
I found the tests will run if I patch the connect_kw_args in test_MySQLdb_dbapi20.py and test_MySQLdb_capabilities.py. I needed to add my defaul user='root' and the default passwd='mypass'
I tried the ~/.my.cnf root, by putting this in a file in my HOME folder \usr\home\rgbecker.my.cnf
[default]
user: root
passwd: mypass
but that didn't work for me. I guess MySQL doesn't like the ~ on windows or perhaps my section is wrong.
Interestingly I had to remove the read_default_file='~/.my.cnf' from connect_kwargs or I got the same errors as before.
Robin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Got mine to finally compile and it appears to work with the instructions above. Here's a link to the distribution that I made. No warranty or guarantee that it will work for you. But until we get an official one, those of you without VS2003 can at least have something for 2.5. This was built on Windows XP SP2 with VS2003, MySQL 5.0.27, and Python 2.5.
No, I don't have any new ones, but 1.2.2b2 (released over the weekend) should hopefully build on Windows without any patches or modifications. If you find that it still does, please post your patch so I can incorporate it.
I have not yet fully added support for Python 2.5 yet, though it should work on x86. I need to test on x86-64 and may need to do some work on _mysql.c.
Also, I plan to add support for the new with statement because it is pretty trivial and won't break on older versions of Python. You'll be able to do stuff like this (in 2.5 and newer):
with db as c:
c.execute(...)
which more-or-less means this:
c = db.cursor()
try:
c.execute(...)
db.commit()
except:
db.rollback()
raise
http://docs.python.org/whatsnew/pep-343.html
Does anyone have a binary for the latest MySQL-python for use with Python 2.3 and Windows + VS2003?
When might a Windows binary for Python 2.5 be available? I must be doing something wrong because I cannot get it to build and install even trying the techniques given here.
Thanks in advance
It would be helpful to know:
I finally was able to build MySQLDb for Windows Python 2.5 and MySQL 5.
Some of these steps may be obvious to experienced folks, but I have not seen them stated here. Soooo...
Copied the following from the MySQL lib_release directory:
Edited the MySQLdb site.cfg file as follows:
[compiler]
mysql_root: d:/downloads/mysql/mysql-5.0.26 <-- this should be where you compiled MySQL
library_dirs: %(mysql_root)s/lib
include_dirs: %(mysql_root)s/include
libraries: mysqlclient
zlib
wsock32
advapi32
user32
libcmt <-- commented out
msvcrt <-- commented out
extra_compile_args:
extra_objects:
extra_link_args: /NODEFAULTLIB:msvcrt"
define version_info "(1,2,1,'final',2)"
define version "1.2.1_p2"
Hope this helps
Please try 1.2.2b2. You should definitely not have to play around with the version numbers now. As for copying libraries, you shouldn't have to do this if you have edited site.cfg. You may also want to experiment with static linking.
If the compiler section is mostly intended for Windows jedis, then I consider the site.cfg lacks a reminder in comments that slashes in these lines:
library_dirs: %(mysql_root)s/lib
include_dirs: %(mysql_root)s/include
should be converted to backslashes:
library_dirs: %(mysql_root)s\lib
include_dirs: %(mysql_root)s\include
Also in order to build the library, MySQL installation path shall contain no spaces, and I had to edit the site.cfg again:
library_dirs: %(mysql_root)s\lib\opt
since in MySQL 4.1 ...\lib\opt is the actual path to libraries.
Anyways, a successful build requires patient reading of compiler output, some time and a fresh head ;-)
Good luck, Windows builders!
I have Python-2.5 win-xp sp2 patched to date and MySQL 5.0.27 binary install. After reading others contributions I installed in c:\usr\local\mysql (a dirname with no embedded spaces).
I then edited site.cfg so the very last section reads
[compiler]
mysql_root: \usr\local\mysql
library_dirs: %(mysql_root)s\lib\opt
include_dirs: %(mysql_root)s\include
libraries: mysqlclient zlib wsock32 advapi32
extra_compile_args:
extra_objects:
extra_link_args: /NODEFAULTLIB:msvcrt
C:\Python\devel\MySQL-python-1.2.2b2>rm -r build
C:\Python\devel\MySQL-python-1.2.2b2>setup.py build
C:\Python\lib\distutils\extension.py:133: UserWarning: Unknown Extension options: 'mysql_root'
warnings.warn(msg)
running build
running build_py
creating build
creating build\lib.win32-2.5
copying _mysql_exceptions.py -> build\lib.win32-2.5
creating build\lib.win32-2.5\MySQLdb
copying MySQLdb__init.py -> build\lib.win32-2.5\MySQLdb
copying MySQLdb\converters.py -> build\lib.win32-2.5\MySQLdb
copying MySQLdb\connections.py -> build\lib.win32-2.5\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win32-2.5\MySQLdb
copying MySQLdb\release.py -> build\lib.win32-2.5\MySQLdb
copying MySQLdb\times.py -> build\lib.win32-2.5\MySQLdb
creating build\lib.win32-2.5\MySQLdb\constants
copying MySQLdb\constants__init.py -> build\lib.win32-2.5\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win32-2.5\MySQLdb\constants
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-2.5\MySQLdb\constants
copying MySQLdb\constants\ER.py -> build\lib.win32-2.5\MySQLdb\constants
copying MySQLdb\constants\FLAG.py -> build\lib.win32-2.5\MySQLdb\constants
copying MySQLdb\constants\REFRESH.py -> build\lib.win32-2.5\MySQLdb\constants
copying MySQLdb\constants\CLIENT.py -> build\lib.win32-2.5\MySQLdb\constants
running build_ext
building '_mysql' extension
creating build\temp.win32-2.5
creating build\temp.win32-2.5\Release
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe /c /nologo /Ox /MD /W3 /GX /DNDEBUG -I\usr\local\mysql
\include -IC:\Python\include -IC:\Python\PC /Tc_mysql.c /Fobuild\temp.win32-2.5\Release_mysql.obj /Dversion_info=(1,2,2
,'beta',2) /Dversion=1.2.2b2
_mysql.c
\usr\local\mysql\include\config-win.h(178) : warning C4005: 'SIZEOF_OFF_T' : macro redefinition
c:\Python\include\pyconfig.h(312) : see previous definition of 'SIZEOF_OFF_T'
\usr\local\mysql\include\config-win.h(328) : warning C4005: 'HAVE_STDDEF_H' : macro redefinition
c:\Python\include\pyconfig.h(605) : see previous definition of 'HAVE_STDDEF_H'
_mysql.c(1362) : warning C4018: '<' : signed/unsigned mismatch
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:\usr\local\mys
ql\lib\opt /LIBPATH:C:\Python\libs /LIBPATH:C:\Python\PCBuild mysqlclient.lib zlib.lib wsock32.lib advapi32.lib user32.l
ib /EXPORT:init_mysql build\temp.win32-2.5\Release_mysql.obj /OUT:build\lib.win32-2.5_mysql.pyd /IMPLIB:build\temp.win
32-2.5\Release_mysql.lib /NODEFAULTLIB:msvcrt
Creating library build\temp.win32-2.5\Release_mysql.lib and object build\temp.win32-2.5\Release_mysql.exp
_mysql.obj : warning LNK4217: locally defined symbol _strncpy imported in function mysql_row_to_dict
_mysql.obj : warning LNK4217: locally defined symbol _strncat imported in function mysql_row_to_dict
_mysql.obj : warning LNK4217: locally defined symbol _sprintf imported in function __mysql_ConnectionObject_repr
C:\Python\devel\MySQL-python-1.2.2b2>
I tried the tests, but they all fail with this
OperationalError: (1045, "Access denied for user 'ODBC'@'localhost' (using password: NO)")
I suppose I haven't set up something properly on my local machine. However, the extension seems to work.
Robin
I found the tests will run if I patch the connect_kw_args in test_MySQLdb_dbapi20.py and test_MySQLdb_capabilities.py. I needed to add my defaul user='root' and the default passwd='mypass'
I tried the ~/.my.cnf root, by putting this in a file in my HOME folder \usr\home\rgbecker.my.cnf
[default]
user: root
passwd: mypass
but that didn't work for me. I guess MySQL doesn't like the ~ on windows or perhaps my section is wrong.
Interestingly I had to remove the read_default_file='~/.my.cnf' from connect_kwargs or I got the same errors as before.
Robin
Got mine to finally compile and it appears to work with the instructions above. Here's a link to the distribution that I made. No warranty or guarantee that it will work for you. But until we get an official one, those of you without VS2003 can at least have something for 2.5. This was built on Windows XP SP2 with VS2003, MySQL 5.0.27, and Python 2.5.
http://www.guildmanus.com/uploaded/MySQL-python.exe-1.2.2b2.win32-py2.5.exe