Skip to content

Commit

Permalink
Almost there.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasnoble committed Feb 4, 2016
1 parent c9c53ee commit e018f9f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 290 deletions.
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ def cython_extensions(package_names, module_names, extra_sources, include_dirs,
'credentials/roots.pem'
],
'grpc._cython': [
'_windows/grpc.def',
'_windows/grpc_c.32.python',
'_windows/grpc_c.64.python',
],
Expand Down
261 changes: 0 additions & 261 deletions src/python/grpcio/grpc/_cython/_windows/grpc.def

This file was deleted.

2 changes: 1 addition & 1 deletion src/python/grpcio/grpc/_cython/cygrpc.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ include "grpc/_cython/_cygrpc/server.pyx.pxi"
cdef class _ModuleState:

def __cinit__(self):
filename = pkg_resources.resource_filename(__name__, '_windows/grpc.def')
filename = pkg_resources.resource_filename(__name__, '_windows/grpc_c.64.python')
directory = os.path.dirname(filename)
if not pygrpc_load_core(directory):
raise ImportError('failed to load core gRPC library')
Expand Down
31 changes: 4 additions & 27 deletions src/python/grpcio/grpc/_cython/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,35 +34,12 @@
#include "loader.h"

#if GPR_WIN32
#include <tchar.h>

int pygrpc_load_core(const char *path) {
if (!SetDllDirectoryA(path)) {
return 0;
}
#if GPR_ARCH_64
TCHAR fname[] = _T("grpc_c.64.python");
#else
TCHAR fname[] = _T("grpc_c.32.python");
#endif
HMODULE module = GetModuleHandle(_T("grpc_c.so"));
TCHAR path[2048 + 32] = _T("");
LPTSTR seek_back = NULL;
GetModuleFileName(module, path, 2048);

seek_back = _tcsrchr(path, _T('\\'));

while (seek_back) {
HMODULE grpc_c;
_tcscpy(seek_back + 1, fname);
grpc_c = LoadLibrary(path);
if (grpc_c) {
pygrpc_load_imports(grpc_c);
return 1;
} else {
*seek_back = _T('\0');
seek_back = _tcsrchr(path, _T('\\'));
}
HMODULE grpc_c = LoadLibraryA(path);
if (grpc_c) {
pygrpc_load_imports(grpc_c);
return 1;
}

return 0;
Expand Down

0 comments on commit e018f9f

Please sign in to comment.