Have gotten pyuv compiling a pyd extension module on Windows. #2

Closed
wants to merge 1 commit into
from

Projects

None yet

3 participants

@rmtew
rmtew commented Dec 16, 2011

Note that it still does not pass the tests and I also haven't tested "python setup.py install" :-) I'll take a whack at that next, but having spent the day fighting gyp on the changes in the libuv patch I'm somewhat worn out for now.

D:\VCS\GIT\pyuv-rmtew\tests>c:\python27\python run-tests
test_async1 (test_async.AsyncTest) ... ok
test_check1 (test_check.CheckTest) ... ok
test_lstat (test_fs.FSTest) ... ERROR
test_stat (test_fs.FSTest) ... ERROR
test_stat_error (test_fs.FSTest) ... ERROR
test_idle1 (test_idle.IdleTest) ... ok
test_multihandle1 (test_multihandles.MultiHandleTest) ... ok
test_client1 (test_pipe.PipeErrorTest) ... ok
test_pipe1 (test_pipe.PipeTest) ... ERROR
test_pipe1 (test_pipe.PipeShutdownTest) ... ERROR
test_prepare1 (test_prepare.PrepareTest) ...
locks up in some likely threading-related code at this point.

@saghul
Owner
saghul commented Dec 16, 2011

Hi!

Thanks for taking the time to put this together! I'm currently away for christmas, so I'll not be able to test this. I plan to release 0.2.0 soon, and after that I'll merge your pull request and fix whatever is required to pass the test suite :-)

Thanks!

@rmtew
rmtew commented Dec 16, 2011

Excellent. Hopefully, I'll have some time to help out with the
getting it working over Christmas.

@tanbro
tanbro commented Jan 6, 2012

i have compiled it in windows(mingw32+py27). but libuv itself is not completed on windows yet...

@saghul
Owner
saghul commented Jan 6, 2012

@tanbro what do you mean by "is not completed"? I know that some tests cannot pass on Windows because libuv doesn't implement multiple loops, for instance but I recently added a way to skip tests based on the platform (e574168) look at the disabled thing. It may contain "linux", "darwin" or "win32".

Also, did you need to make any change to get it working on mingw? I expect to start looking into that next week, now that I'm back from holydays :-)

@tanbro
tanbro commented Jan 9, 2012

@saghul Oh, i just compile libuv on mingw32,but some functions in libuv's windows sources is not implemented yet.
for example:
0 && "implement me", file src/win/core.c, line 109

uv_loop_t* uv_loop_new(void) {
assert(0 && "implement me");
return NULL;
}

void uv_loop_delete(uv_loop_t* loop) {
assert(0 && "implement me");
}

is the latest libuv implement these functions?

@saghul
Owner
saghul commented Jan 9, 2012

@tanbro Unfortunately not. That's why I added the ability to skip tests based on the platform, because in Windows we can only use the default loop, so any test involving more than one loop will need to be disabled for Windows.

@saghul
Owner
saghul commented Jan 12, 2012

Hi @tanbro ,

I just managed to compile pyuv on mingw, but when importing the module I'm getting this error:

c:\work\pyuv-0.3.0 in ()
----> 1 import pyuv

ImportError: DLL load failed: The specified procedure could not be found.

Any idea why?

@tanbro
tanbro commented Jan 12, 2012

Oh @saghul , i don't know...
i just do that in eclipse cdt.

CDT's inner builder's output:

**** Build of configuration Release-Shared-windows-x86-Python2.7 for project pyuv ****

**** Internal Builder is used for build ****
gcc -DNDEBUG -DMODULE_VERSION=0.2 -I../include -ID:\Python27/include -O3 -Wall -c -fmessage-length=0 -o src\pyuv.o ..\src\pyuv.c
In file included from ..\src\pyuv.c:28:0:
..\src/loop.c: In function 'Loop_default_get':
..\src/loop.c:127:9: warning: dereferencing type-punned pointer will break strict-aliasing rules
..\src/loop.c:129:9: warning: dereferencing type-punned pointer will break strict-aliasing rules
In file included from ..\src\pyuv.c:30:0:
..\src/timer.c: In function 'Timer_active_get':
..\src/timer.c:190:9: warning: dereferencing type-punned pointer will break strict-aliasing rules
gcc -L../lib/windows-x86 -LD:\Python27/libs -shared -o pyuv.pyd src\pyuv.o -luv -lpython27 -lPsapi -lIphlpapi -lWs2_32 -lpthread
Build complete for project pyuv
Time consumed: 4260 ms.

What export functions of "pyuv.pyd" can you see in depend.exe ?
i saw

ares_destroy
ares_destroy_options
ares_dup
ares_expand_name
ares_free_data
ares_free_hostent
ares_free_string
ares_get_servers
ares_gethostbyname
ares_gethostbyname_file
ares_init
ares_init_options
ares_library_cleanup
ares_library_init
ares_mkquery
ares_parse_a_reply
ares_parse_aaaa_reply
ares_process
ares_process_fd
ares_query
ares_save_options
ares_search
ares_send
ares_set_local_dev
ares_set_local_ip4
ares_set_local_ip6
ares_set_servers
ares_set_servers_csv
ares_set_socket_callback
initpyuv

Is "initpyuv" exported in your pyuv.pyd?

@saghul
Owner
saghul commented Jan 12, 2012

@tanbro I finally managed to compile it by doing:

python setup.py build_ext --inplace

In a MinGW / MSys environment.

The trick was to replace this:

self.extensions[0].extra_objects = [os.path.join(self.libuv_dir, 'uv.a')]

And copy uv.a to libuv.a and use -luv instead. The former works on Linux and OSX but doesn't on Windows. The latter works everywhere, so I'll use that.

No I need to start ifdef-ing around to avoid all those asserts due to not yet implemented functions :-S

Thanks for the help!

@tanbro
tanbro commented Jan 12, 2012

i think the only thing i can do is to run two loop in separated runtime. for python, it will be a separated process, or use other runtime.

now i'm considering to use nodejs as extension's runtime, so that i can make two loops separated, to avoid them trouble each other. pyuv is very nice, but python's GIL is not nice ;(, i can not make two loops work nice in heavy duty...

Thanks for your help!

@saghul
Owner
saghul commented Jan 15, 2012

Thank you both for the help. Windows support landed in 50a2c2e

@saghul saghul closed this Jan 15, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment