[sword-devel] Sword Python bindings for Windows

R Johnson ps16thypresenceisfullnessofjoy at gmail.com
Fri Oct 3 14:32:11 MST 2014


Thanks for the suggestion, Nic. I don't think it would work to use 
cygwin, because I have to use the same compiler that Python is built 
with on Windows to be able to build the SWIG bindings, but maybe I 
should look into building Sword without ICU.

I corresponded with Greg Hellings, and he suggested that maybe I could 
"just build Sword with the bundled vc10 solution and drop in a manual 
execution of swordswig akin to the one in CMake," which seemed like a 
good idea.I tried it, and was able to successfully build Sword and run 
SWIG, but now I'm stuck on a setup.py file that needs to be run.

What I'm currently doing is:
1. Building lib/vcppmake/libsword.sln in Visual Studio 2010 (with a few 
minor changes to the SLN and VCXPROJ files necessary to make it work 
because it is a VC2013 project), which works.
2. From the bindings/swig directory, running the command:
    swig.exe -w-451,-402 -shadow -c++ -python -o 
../../bindings/swig/python/Sword.cxx -I../../bindings/swig 
-I../../include -I../../include/internal/regex 
-I../../../icu-sword/include -I../../src/utilfuns/win32 
-I../../../curl/include ../../bindings/swig/sword.i
This also works.
3. From the bindings/swig/python directory (where SWIG generated the CXX 
file), running the command:
    C:\Python34\python.exe setup.py build
I have attached the setup.py file that I am using. This does *not* work. 
I get the following error:
    C:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\link.exe /DLL 
/nologo /INCREMENTAL:NO /LIBPATH:../../../../sword-build 
/LIBPATH:C:\Python34\libs /LIBPATH:C:\Python34\PCbuild sword.lib 
/EXPORT:PyInit__Sword build\temp.win32-3.4\Release\Sword.obj 
/OUT:build\lib.win32-3.4\_Sword.pyd 
/IMPLIB:build\temp.win32-3.4\Release\_Sword.lib 
/MANIFESTFILE:build\temp.win32-3.4\Release\_Sword.pyd.manifest
    LINK : fatal error LNK1181: cannot open input file 'sword.lib'
    error: command 'C:\\Program Files\\Microsoft Visual Studio 
10.0\\VC\\BIN\\link.exe' failed with exit status 1181
4. Because #3 does not work, running "C:\Python34\python.exe setup.py 
install" doesn't either and gives the same error.

The problem is that I have no file named sword.lib, because libsword.sln 
generates libsword.lib. I tried renaming it, and just got some different 
errors.

(I'm also somewhat confused about the CMake path variables in the 
setup.py file. Given my current directory tree:
Sword
    > bzip2
    > curl
    > icu-sword
    > sword-1.7.3
            > bindings
                    > swig
                            > python
            > include
          > lib
                > vcppmake
                      > Release
    > sword-build
    > xz
What would be the appropriate values for CMAKE_CURRENT_SOURCE_DIR, 
CMAKE_SOURCE_DIR, and CMAKE_BINARY_DIR? Currently I'm using the values 
'sword-1.7.3/bindings/swig/python', 'sword-1.7.3', and 'sword-build', 
respectively, but I'm not sure how setup.py would find files in the 
lib/vcppmake/Release directory.)

I'm not quite sure what to try next. Is there a way I am not aware of to 
obtain the sword.lib file that I need, or should I try building Sword 
using CMake with ICU disabled?

Thank you.

-- Timothy
-------------- next part --------------
from distutils.core import setup, Extension
setup(name='sword',version='1.7.3',
maintainer='Sword Developers',
maintainer_email='sword-devel at crosswire.org',
url='http://www.crosswire.org/sword',
py_modules=['Sword'],
include_dirs=['../', '../../../include', '../../', '../../../'],
ext_modules = [Extension('_Sword',['Sword.cxx'],
libraries=[('sword')],
library_dirs=[('../../../../sword-build')],
)]
,)


More information about the sword-devel mailing list