当前位置: 代码迷 >> Sybase >> 替Sybase ASE15.x编译安装python-sybase模块
  详细解决方案

替Sybase ASE15.x编译安装python-sybase模块

热度:6985   发布时间:2013-02-26 00:00:00.0
为Sybase ASE15.x编译安装python-sybase模块
如果你有陈旧的vs2003编译器,那么这篇短文或者意义不是很大,
http://blog.donews.com/tekjian/archive/2006/08/06/990279.aspx 有简单的介绍如何直接安装这个玩意儿。
但是,现在很多人都用上了vs2005或者vs2008,可是python还是用的2.5.x版。这个时候痛苦就来了,
下载完python-sybase-0.38之后,如果你执行:
python setup.py intall,

肯定会出这样的错:

error: Python was built with Visual Studio 2003;extensions must be built with a compiler than can generate compatible binaries.Visual Studio 2003 was not found on this system. If you have Cygwin installed,you can try compiling with MingW32, by passing "-c mingw32" to setup.py.

经过若干周折,发现,有办法绕过去,让vs2008直接支持编译安装。
先让sybase.bat环境变量生效,接着让vcvars.bat生效,(即执行这两个 bat)

把ASE15.x\OCS-150\lib下的三个文件libsyb*.lib,重命名为lib*.lib, 这三个新文件是:libct.lib, libcs.lib, libblk.lib

然后要修改python\Lib\distutils\msvccomiler.py, 找到:

    # x86      if self.__version >= 7:          self.__root = r"Software\Microsoft\VisualStudio"          self.__macros = MacroExpander(self.__version)      else:          self.__root = r"Software\Microsoft\Devstudio"  
注释掉这一行:self.__macros = MacroExpander(self.__version)

之后,把对应的pyc文件删掉,让它强制重新编译。

设置两个环境变量:set DISTUTILS_USE_SDK=1
set MSSdk=1

这之后执行python setup.py install, 就可以完全成功的安装了。

以下是详细的编译安装结果:

E:\learn\db_research\python-sybase-0.39>python setup.py install---------------------------------------------------------------------------This script requires setuptools version 0.6c6 to run (even to displayhelp).  I will attempt to download it for you (fromhttp://cheeseshop.python.org/packages/2.5/s/setuptools/), butyou may need to enable firewall access for this script first.I will start the download in 15 seconds.(Note: if this machine does not have network access, please obtain the file   http://cheeseshop.python.org/packages/2.5/s/setuptools/setuptools-0.6c6-py2.5.eggand place it in this directory before rerunning this script.)---------------------------------------------------------------------------Downloading http://cheeseshop.python.org/packages/2.5/s/setuptools/setuptools-0.6c6-py2.5.eggrunning installrunning bdist_eggrunning egg_infocreating python_sybase.egg-infowriting python_sybase.egg-info\PKG-INFOwriting top-level names to python_sybase.egg-info\top_level.txtwriting dependency_links to python_sybase.egg-info\dependency_links.txtwriting manifest file 'python_sybase.egg-info\SOURCES.txt'reading manifest file 'python_sybase.egg-info\SOURCES.txt'writing manifest file 'python_sybase.egg-info\SOURCES.txt'installing library code to build\bdist.win32\eggrunning install_librunning build_pycreating buildcreating build\lib.win32-2.5copying Sybase.py -> build\lib.win32-2.5running build_extbuilding 'sybasect' extensioncreating build\temp.win32-2.5creating build\temp.win32-2.5\ReleaseC:\tools\vs9\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GX /DNDEBUG -DWANT_BULKCOPY -DHAVE_DATETIME -DHAVE_DECIMAL -DHAVE_BLK_ALLOC -DHAVE_BLK_DESCRIBE -DHAVE_BLK_DROP -DHAVE_BLK_ROWXFER_MULT -DHAVE_BLK_TEXTXFER -DHAVE_CT_CURSOR -DHAVE_CT_DATA_INFO -DHAVE_CT_DYNAMIC -DHAVE_CT_SEND_DATA -DHAVE_CT_SETPARAM -DHAVE_CS_CALC -DHAVE_CS_CMP -ID:\sybase\OCS-15_0\include -Id:\tools\python\include -Id:\tools\python\PC /Tcblk.c /Fobuild\temp.win32-2.5\Release\blk.objcl : Command line warning D9035 : option 'GX' has been deprecated and will be removed in a future releasecl : Command line warning D9036 : use 'EHsc' instead of 'GX'blk.cC:\tools\vs9\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GX /DNDEBUG -DWANT_BULKCOPY -DHAVE_DATETIME -DHAVE_DECIMAL -DHAVE_BLK_ALLOC -DHAVE_BLK_DESCRIBE -DHAVE_BLK_DROP -DHAVE_BLK_ROWXFER_MULT -DHAVE_BLK_TEXTXFER -DHAVE_CT_CURSOR -DHAVE_CT_DATA_INFO -DHAVE_CT_DYNAMIC -DHAVE_CT_SEND_DATA -DHAVE_CT_SETPARAM -DHAVE_CS_CALC -DHAVE_CS_CMP -ID:\sybase\OCS-15_0\include -Id:\tools\python\include -Id:\tools\python\PC /Tcdatabuf.c /Fobuild\temp.win32-2.5\Release\databuf.objcl : Command line warning D9035 : option 'GX' has been deprecated and will be removed in a future releasecl : Command line warning D9036 : use 'EHsc' instead of 'GX'databuf.cC:\tools\vs9\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GX /DNDEBUG -DWANT_BULKCOPY -DHAVE_DATETIME -DHAVE_DECIMAL -DHAVE_BLK_ALLOC -DHAVE_BLK_DESCRIBE -DHAVE_BLK_DROP -DHAVE_BLK_ROWXFER_MULT -DHAVE_BLK_TEXTXFER -DHAVE_CT_CURSOR -DHAVE_CT_DATA_INFO -DHAVE_CT_DYNAMIC -DHAVE_CT_SEND_DATA -DHAVE_CT_SETPARAM -DHAVE_CS_CALC -DHAVE_CS_CMP -ID:\sybase\OCS-15_0\include -Id:\tools\python\include -Id:\tools\python\PC /Tccmd.c /Fobuild\temp.win32-2.5\Release\cmd.objcl : Command line warning D9035 : option 'GX' has been deprecated and will be removed in a future releasecl : Command line warning D9036 : use 'EHsc' instead of 'GX'cmd.cC:\tools\vs9\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GX /DNDEBUG -DWANT_BULKCOPY -DHAVE_DATETIME -DHAVE_DECIMAL -DHAVE_BLK_ALLOC -DHAVE_BLK_DESCRIBE -DHAVE_BLK_DROP -DHAVE_BLK_ROWXFER_MULT -DHAVE_BLK_TEXTXFER -DHAVE_CT_CURSOR -DHAVE_CT_DATA_INFO -DHAVE_CT_DYNAMIC -DHAVE_CT_SEND_DATA -DHAVE_CT_SETPARAM -DHAVE_CS_CALC -DHAVE_CS_CMP -ID:\sybase\OCS-15_0\include -Id:\tools\python\include -Id:\tools\python\PC /Tcconn.c /Fobuild\temp.win32-2.5\Release\conn.objcl : Command line warning D9035 : option 'GX' has been deprecated and will be removed in a future releasecl : Command line warning D9036 : use 'EHsc' instead of 'GX'conn.cC:\tools\vs9\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GX /DNDEBUG -DWANT_BULKCOPY -DHAVE_DATETIME -DHAVE_DECIMAL -DHAVE_BLK_ALLOC -DHAVE_BLK_DESCRIBE -DHAVE_BLK_DROP -DHAVE_BLK_ROWXFER_MULT -DHAVE_BLK_TEXTXFER -DHAVE_CT_CURSOR -DHAVE_CT_DATA_INFO -DHAVE_CT_DYNAMIC -DHAVE_CT_SEND_DATA -DHAVE_CT_SETPARAM -DHAVE_CS_CALC -DHAVE_CS_CMP -ID:\sybase\OCS-15_0\include -Id:\tools\python\include -Id:\tools\python\PC /Tcctx.c /Fobuild\temp.win32-2.5\Release\ctx.objcl : Command line warning D9035 : option 'GX' has been deprecated and will be removed in a future releasecl : Command line warning D9036 : use 'EHsc' instead of 'GX'ctx.cC:\tools\vs9\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GX /DNDEBUG -DWANT_BULKCOPY -DHAVE_DATETIME -DHAVE_DECIMAL -DHAVE_BLK_ALLOC -DHAVE_BLK_DESCRIBE -DHAVE_BLK_DROP -DHAVE_BLK_ROWXFER_MULT -DHAVE_BLK_TEXTXFER -DHAVE_CT_CURSOR -DHAVE_CT_DATA_INFO -DHAVE_CT_DYNAMIC -DHAVE_CT_SEND_DATA -DHAVE_CT_SETPARAM -DHAVE_CS_CALC -DHAVE_CS_CMP -ID:\sybase\OCS-15_0\include -Id:\tools\python\include -Id:\tools\python\PC /Tcdatafmt.c /Fobuild\temp.win32-2.5\Release\datafmt.objcl : Command line warning D9035 : option 'GX' has been deprecated and will be removed in a future releasecl : Command line warning D9036 : use 'EHsc' instead of 'GX'datafmt.cC:\tools\vs9\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GX /DNDEBUG -DWANT_BULKCOPY -DHAVE_DATETIME -DHAVE_DECIMAL -DHAVE_BLK_ALLOC -DHAVE_BLK_DESCRIBE -DHAVE_BLK_DROP -DHAVE_BLK_ROWXFER_MULT -DHAVE_BLK_TEXTXFER -DHAVE_CT_CURSOR -DHAVE_CT_DATA_INFO -DHAVE_CT_DYNAMIC -DHAVE_CT_SEND_DATA -DHAVE_CT_SETPARAM -DHAVE_CS_CALC -DHAVE_CS_CMP -ID:\sybase\OCS-15_0\include -Id:\tools\python\include -Id:\tools\python\PC /Tciodesc.c /Fobuild\temp.win32-2.5\Release\iodesc.objcl : Command line warning D9035 : option 'GX' has been deprecated and will be removed in a future releasecl : Command line warning D9036 : use 'EHsc' instead of 'GX'iodesc.cC:\tools\vs9\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GX /DNDEBUG -DWANT_BULKCOPY -DHAVE_DATETIME -DHAVE_DECIMAL -DHAVE_BLK_ALLOC -DHAVE_BLK_DESCRIBE -DHAVE_BLK_DROP -DHAVE_BLK_ROWXFER_MULT -DHAVE_BLK_TEXTXFER -DHAVE_CT_CURSOR -DHAVE_CT_DATA_INFO -DHAVE_CT_DYNAMIC -DHAVE_CT_SEND_DATA -DHAVE_CT_SETPARAM -DHAVE_CS_CALC -DHAVE_CS_CMP -ID:\sybase\OCS-15_0\include -Id:\tools\python\include -Id:\tools\python\PC /Tclocale.c /Fobuild\temp.win32-2.5\Release\locale.objcl : Command line warning D9035 : option 'GX' has been deprecated and will be removed in a future releasecl : Command line warning D9036 : use 'EHsc' instead of 'GX'locale.cC:\tools\vs9\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GX /DNDEBUG -DWANT_BULKCOPY -DHAVE_DATETIME -DHAVE_DECIMAL -DHAVE_BLK_ALLOC -DHAVE_BLK_DESCRIBE -DHAVE_BLK_DROP -DHAVE_BLK_ROWXFER_MULT -DHAVE_BLK_TEXTXFER -DHAVE_CT_CURSOR -DHAVE_CT_DATA_INFO -DHAVE_CT_DYNAMIC -DHAVE_CT_SEND_DATA -DHAVE_CT_SETPARAM -DHAVE_CS_CALC -DHAVE_CS_CMP -ID:\sybase\OCS-15_0\include -Id:\tools\python\include -Id:\tools\python\PC /Tcmsgs.c /Fobuild\temp.win32-2.5\Release\msgs.objcl : Command line warning D9035 : option 'GX' has been deprecated and will be removed in a future releasecl : Command line warning D9036 : use 'EHsc' instead of 'GX'msgs.cC:\tools\vs9\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GX /DNDEBUG -DWANT_BULKCOPY -DHAVE_DATETIME -DHAVE_DECIMAL -DHAVE_BLK_ALLOC -DHAVE_BLK_DESCRIBE -DHAVE_BLK_DROP -DHAVE_BLK_ROWXFER_MULT -DHAVE_BLK_TEXTXFER -DHAVE_CT_CURSOR -DHAVE_CT_DATA_INFO -DHAVE_CT_DYNAMIC -DHAVE_CT_SEND_DATA -DHAVE_CT_SETPARAM -DHAVE_CS_CALC -DHAVE_CS_CMP -ID:\sybase\OCS-15_0\include -Id:\tools\python\include -Id:\tools\python\PC /Tcnumeric.c /Fobuild\temp.win32-2.5\Release\numeric.objcl : Command line warning D9035 : option 'GX' has been deprecated and will be removed in a future releasecl : Command line warning D9036 : use 'EHsc' instead of 'GX'numeric.cC:\tools\vs9\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GX /DNDEBUG -DWANT_BULKCOPY -DHAVE_DATETIME -DHAVE_DECIMAL -DHAVE_BLK_ALLOC -DHAVE_BLK_DESCRIBE -DHAVE_BLK_DROP -DHAVE_BLK_ROWXFER_MULT -DHAVE_BLK_TEXTXFER -DHAVE_CT_CURSOR -DHAVE_CT_DATA_INFO -DHAVE_CT_DYNAMIC -DHAVE_CT_SEND_DATA -DHAVE_CT_SETPARAM -DHAVE_CS_CALC -DHAVE_CS_CMP -ID:\sybase\OCS-15_0\include -Id:\tools\python\include -Id:\tools\python\PC /Tcmoney.c /Fobuild\temp.win32-2.5\Release\money.objcl : Command line warning D9035 : option 'GX' has been deprecated and will be removed in a future releasecl : Command line warning D9036 : use 'EHsc' instead of 'GX'money.cC:\tools\vs9\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GX /DNDEBUG -DWANT_BULKCOPY -DHAVE_DATETIME -DHAVE_DECIMAL -DHAVE_BLK_ALLOC -DHAVE_BLK_DESCRIBE -DHAVE_BLK_DROP -DHAVE_BLK_ROWXFER_MULT -DHAVE_BLK_TEXTXFER -DHAVE_CT_CURSOR -DHAVE_CT_DATA_INFO -DHAVE_CT_DYNAMIC -DHAVE_CT_SEND_DATA -DHAVE_CT_SETPARAM -DHAVE_CS_CALC -DHAVE_CS_CMP -ID:\sybase\OCS-15_0\include -Id:\tools\python\include -Id:\tools\python\PC /Tcdatetime.c /Fobuild\temp.win32-2.5\Release\datetime.objcl : Command line warning D9035 : option 'GX' has been deprecated and will be removed in a future releasecl : Command line warning D9036 : use 'EHsc' instead of 'GX'datetime.cC:\tools\vs9\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GX /DNDEBUG -DWANT_BULKCOPY -DHAVE_DATETIME -DHAVE_DECIMAL -DHAVE_BLK_ALLOC -DHAVE_BLK_DESCRIBE -DHAVE_BLK_DROP -DHAVE_BLK_ROWXFER_MULT -DHAVE_BLK_TEXTXFER -DHAVE_CT_CURSOR -DHAVE_CT_DATA_INFO -DHAVE_CT_DYNAMIC -DHAVE_CT_SEND_DATA -DHAVE_CT_SETPARAM -DHAVE_CS_CALC -DHAVE_CS_CMP -ID:\sybase\OCS-15_0\include -Id:\tools\python\include -Id:\tools\python\PC /Tcdate.c /Fobuild\temp.win32-2.5\Release\date.objcl : Command line warning D9035 : option 'GX' has been deprecated and will be removed in a future releasecl : Command line warning D9036 : use 'EHsc' instead of 'GX'date.cC:\tools\vs9\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GX /DNDEBUG -DWANT_BULKCOPY -DHAVE_DATETIME -DHAVE_DECIMAL -DHAVE_BLK_ALLOC -DHAVE_BLK_DESCRIBE -DHAVE_BLK_DROP -DHAVE_BLK_ROWXFER_MULT -DHAVE_BLK_TEXTXFER -DHAVE_CT_CURSOR -DHAVE_CT_DATA_INFO -DHAVE_CT_DYNAMIC -DHAVE_CT_SEND_DATA -DHAVE_CT_SETPARAM -DHAVE_CS_CALC -DHAVE_CS_CMP -ID:\sybase\OCS-15_0\include -Id:\tools\python\include -Id:\tools\python\PC /Tcsybasect.c /Fobuild\temp.win32-2.5\Release\sybasect.objcl : Command line warning D9035 : option 'GX' has been deprecated and will be removed in a future releasecl : Command line warning D9036 : use 'EHsc' instead of 'GX'sybasect.cC:\tools\vs9\VC\BIN\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:D:\sybase\OCS-15_0\lib /LIBPATH:d:\tools\python\libs /LIBPATH:d:\tools\python\PCBuild libblk.lib libct.lib libcs.lib /EXPORT:initsybasect build\temp.win32-2.5\Release\blk.obj build\temp.win32-2.5\Release\databuf.obj build\temp.win32-2.5\Release\cmd.obj build\temp.win32-2.5\Release\conn.obj build\temp.win32-2.5\Release\ctx.obj build\temp.win32-2.5\Release\datafmt.obj build\temp.win32-2.5\Release\iodesc.obj build\temp.win32-2.5\Release\locale.obj build\temp.win32-2.5\Release\msgs.obj build\temp.win32-2.5\Release\numeric.obj build\temp.win32-2.5\Release\money.obj build\temp.win32-2.5\Release\datetime.obj build\temp.win32-2.5\Release\date.obj build\temp.win32-2.5\Release\sybasect.obj /OUT:build\lib.win32-2.5\sybasect.pyd /IMPLIB:build\temp.win32-2.5\Release\sybasect.libLINK : fatal error LNK1181: cannot open input file 'libblk.lib'error: command 'link.exe' failed with exit status 1181E:\learn\db_research\python-sybase-0.39>python setup.py installrunning installrunning bdist_eggrunning egg_infowriting python_sybase.egg-info\PKG-INFOwriting top-level names to python_sybase.egg-info\top_level.txtwriting dependency_links to python_sybase.egg-info\dependency_links.txtreading manifest file 'python_sybase.egg-info\SOURCES.txt'writing manifest file 'python_sybase.egg-info\SOURCES.txt'installing library code to build\bdist.win32\eggrunning install_librunning build_pyrunning build_extbuilding 'sybasect' extensionC:\tools\vs9\VC\BIN\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:D:\sybase\OCS-15_0\lib /LIBPATH:d:\tools\python\libs /LIBPATH:d:\tools\python\PCBuild libblk.lib libct.lib libcs.lib /EXPORT:initsybasect build\temp.win32-2.5\Release\blk.obj build\temp.win32-2.5\Release\databuf.obj build\temp.win32-2.5\Release\cmd.obj build\temp.win32-2.5\Release\conn.obj build\temp.win32-2.5\Release\ctx.obj build\temp.win32-2.5\Release\datafmt.obj build\temp.win32-2.5\Release\iodesc.obj build\temp.win32-2.5\Release\locale.obj build\temp.win32-2.5\Release\msgs.obj build\temp.win32-2.5\Release\numeric.obj build\temp.win32-2.5\Release\money.obj build\temp.win32-2.5\Release\datetime.obj build\temp.win32-2.5\Release\date.obj build\temp.win32-2.5\Release\sybasect.obj /OUT:build\lib.win32-2.5\sybasect.pyd /IMPLIB:build\temp.win32-2.5\Release\sybasect.lib   Creating library build\temp.win32-2.5\Release\sybasect.lib and object build\temp.win32-2.5\Release\sybasect.expcreating build\bdist.win32creating build\bdist.win32\eggcopying build\lib.win32-2.5\Sybase.py -> build\bdist.win32\eggcopying build\lib.win32-2.5\sybasect.pyd -> build\bdist.win32\eggcopying build\lib.win32-2.5\sybasect.pyd.manifest -> build\bdist.win32\eggbyte-compiling build\bdist.win32\egg\Sybase.py to Sybase.pyccreating stub loader for sybasect.pydbyte-compiling build\bdist.win32\egg\sybasect.py to sybasect.pyccreating build\bdist.win32\egg\EGG-INFOwriting python_sybase.egg-info\native_libs.txtcopying python_sybase.egg-info\PKG-INFO -> build\bdist.win32\egg\EGG-INFOcopying python_sybase.egg-info\SOURCES.txt -> build\bdist.win32\egg\EGG-INFOcopying python_sybase.egg-info\dependency_links.txt -> build\bdist.win32\egg\EGG-INFOcopying python_sybase.egg-info\top_level.txt -> build\bdist.win32\egg\EGG-INFOzip_safe flag not set; analyzing archive contents...creating distcreating 'dist\python_sybase-0.39-py2.5-win32.egg' and adding 'build\bdist.win32\egg' to itremoving 'build\bdist.win32\egg' (and everything under it)Processing setuptools-0.6c6-py2.5.eggCopying setuptools-0.6c6-py2.5.egg to d:\tools\python\lib\site-packagesAdding setuptools 0.6c6 to easy-install.pth fileInstalling easy_install-script.py script to d:\tools\python\ScriptsInstalling easy_install.exe script to d:\tools\python\ScriptsInstalling easy_install-2.5-script.py script to d:\tools\python\ScriptsInstalling easy_install-2.5.exe script to d:\tools\python\ScriptsInstalled d:\tools\python\lib\site-packages\setuptools-0.6c6-py2.5.eggProcessing dependencies for setuptools==0.6c6Finished processing dependencies for setuptools==0.6c6Processing python_sybase-0.39-py2.5-win32.eggCopying python_sybase-0.39-py2.5-win32.egg to d:\tools\python\lib\site-packagesAdding python-sybase 0.39 to easy-install.pth fileInstalled d:\tools\python\lib\site-packages\python_sybase-0.39-py2.5-win32.eggProcessing dependencies for python-sybase==0.39Finished processing dependencies for python-sybase==0.39

经此实验,可以确定不一定要安装vc7,就可以安装一些要编译的python模块了。 当然,如果你机器上可以安装,最省事儿了。至于vc7,你完全可以自己整理出一个解压缩的绿色包,也就20来兆的样子。