Fix Python Windows build

pull/5064/head
Masood Malekghassemi 9 years ago committed by Nicolas "Pixel" Noble
parent ab7055a0e7
commit 10509a28c7
  1. 2
      include/grpc/impl/codegen/compression_types.h
  2. 21
      include/grpc/impl/codegen/port_platform.h
  3. 2
      include/grpc/impl/codegen/propagation_bits.h
  4. 8
      setup.py
  5. 5
      src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi
  6. 9
      src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi
  7. 11
      src/python/grpcio/grpc/_cython/cygrpc.pyx

@ -34,7 +34,7 @@
#ifndef GRPC_IMPL_CODEGEN_COMPRESSION_TYPES_H
#define GRPC_IMPL_CODEGEN_COMPRESSION_TYPES_H
#include <stdint.h>
#include <grpc/support/port_platform.h>
#ifdef __cplusplus
extern "C" {

@ -34,6 +34,23 @@
#ifndef GRPC_IMPL_CODEGEN_PORT_PLATFORM_H
#define GRPC_IMPL_CODEGEN_PORT_PLATFORM_H
#ifdef _MSC_VER
#if _MSC_VER < 1700
typedef __int8 int8_t;
typedef __int16 int16_t;
typedef __int32 int32_t;
typedef __int64 int64_t;
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
#else
#include <stdint.h>
#endif /* _MSC_VER < 1700 */
#else
#include <stdint.h>
#endif /* _MSC_VER */
/* Get windows.h included everywhere (we need it) */
#if defined(_WIN64) || defined(WIN64) || defined(_WIN32) || defined(WIN32)
#ifndef WIN32_LEAN_AND_MEAN
@ -254,10 +271,6 @@
#define GPR_FORBID_UNREACHABLE_CODE 1
#endif
/* For a common case, assume that the platform has a C99-like stdint.h */
#include <stdint.h>
/* Cache line alignment */
#ifndef GPR_CACHELINE_SIZE_LOG
#if defined(__i386__) || defined(__x86_64__)

@ -34,7 +34,7 @@
#ifndef GRPC_IMPL_CODEGEN_H
#define GRPC_IMPL_CODEGEN_H
#include <stdint.h>
#include <grpc/support/port_platform.h>
#ifdef __cplusplus
extern "C" {

@ -82,14 +82,16 @@ CYTHON_HELPER_C_FILES = (
CORE_C_FILES = ()
if not "win32" in sys.platform:
CORE_C_FILES += tuple(grpc_core_dependencies.CORE_SOURCE_FILES)
CORE_C_FILES += tuple(grpc_core_dependencies.CORE_SOURCE_FILES)
EXTENSION_INCLUDE_DIRECTORIES = (
(PYTHON_STEM,) + CORE_INCLUDE + BORINGSSL_INCLUDE + ZLIB_INCLUDE)
EXTENSION_LIBRARIES = ('m',)
EXTENSION_LIBRARIES = ()
if "linux" in sys.platform:
EXTENSION_LIBRARIES += ('rt',)
EXTENSION_LIBRARIES += ('rt',)
if not "win32" in sys.platform:
EXTENSION_LIBRARIES += ('m',)
DEFINE_MACROS = (('OPENSSL_NO_ASM', 1), ('_WIN32_WINNT', 0x600))

@ -28,11 +28,14 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
cimport libc.time
from libc.stdint cimport int64_t, uint32_t, int32_t
cdef extern from "grpc/_cython/loader.h":
ctypedef int int32_t
ctypedef unsigned uint32_t
ctypedef long int64_t
int pygrpc_load_core(const char*)
void *gpr_malloc(size_t size)

@ -146,8 +146,13 @@ cdef class Timespec:
gpr_convert_clock_type(self.c_time, GPR_CLOCK_REALTIME))
return <double>real_time.seconds + <double>real_time.nanoseconds / 1e9
infinite_future = Timespec(float("+inf"))
infinite_past = Timespec(float("-inf"))
@staticmethod
def infinite_future():
return Timespec(float("+inf"))
@staticmethod
def infinite_past():
return Timespec(float("-inf"))
cdef class CallDetails:

@ -47,16 +47,19 @@ include "grpc/_cython/_cygrpc/server.pyx.pxi"
cdef class _ModuleState:
cdef bint is_loaded
def __cinit__(self):
filename = pkg_resources.resource_filename(
__name__, '_windows/grpc_c.64.python')
directory = os.path.dirname(filename)
if not pygrpc_load_core(directory):
'grpc._cython', '_windows/grpc_c.64.python')
if not pygrpc_load_core(filename):
raise ImportError('failed to load core gRPC library')
grpc_init()
self.is_loaded = True
def __dealloc__(self):
grpc_shutdown()
if self.is_loaded:
grpc_shutdown()
_module_state = _ModuleState()

Loading…
Cancel
Save