Fix python bindings compilation on Windows #19

Closed
mitjat opened this Issue Sep 25, 2012 · 7 comments

3 participants

@mitjat

Thanks for the nice repackaging. It still needs some work on Windows though. To compile:
1) open a cmd window
2) run vcvarsall.bat (FIXME: why is this commented out in build.win.bat?)
3) run build.win.bat
4) FIXME: copy libcld.lib to ports/python/cld.lib
5) FIXME (biggest one): setup.py fails on Windows

The hackish solution to (5) is to make pkgconfig return (on Windows only) the dict {'define_macros': [('WIN32',None)], 'libraries': packages}
Why the hack is necessary: On windows, pkg-config is not available by default. If you get it, it depends on a dll. If you get that one as well, it doesn't find the cld.pc file. If you copy it over, it returns the nonsensical (for MSVC) value "-I/usr/local/include/cld -L/usr/local/lib/cld -lcld". It also fails to define WIN32, without which the whole thing does not compile.

Do you prefer getting a pull request or making the changes yourself? Thanks.

@jakc

Related - http://stackoverflow.com/questions/13328180/installing-cld-libary-on-windows-and-bind-to-python

Im having some problems getting this up and running on Windows. I have got as far as 5, but not entirely sure on the steps involved in your hack. Can you elaborate? (im a rookie at python, but keen to learn)

@mzsanford
Owner

@mitjat pull request welcomed since my Windows environment is onerous to setup for testing.

@jakc My Python is pretty shaky and my Windows programming a bit rusty but I'm asking some friends for help on this.

@mitjat

@jakc Huh, sorry, missed your post. Step 5 is to edit setup.py and replace the whole pkgconfig function with simply just this:

def pkgconfig(*packages, **kw): 
    return {'define_macros': [('WIN32',None)], 'libraries': packages}

@mzsanford OK, I'll follow up with the patch, I just don't have it handy at the moment.

@mitjat

Also, for posterity, CLD is now included in the absolutely wonderful Unofficial Windows Binaries for Python Extension Packages list: http://www.lfd.uci.edu/~gohlke/pythonlibs/

@mzsanford
Owner

Fixing up old projects and made the requested change in the issue_19_python_windows branch (SHA: 5a29fd5). Can you try that out and let me know if it works?

@mitjat

Thanks for the fix, Matt. I'm sorry to say I don't have that dev environment set up any more. It would take quite some effort and time to get everything to the point where I can test it, so I'll leave it be right now.

@mzsanford mzsanford self-assigned this Mar 2, 2014
@mzsanford
Owner

Merged it in

@mzsanford mzsanford closed this Mar 2, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment