Skip to content
Snippets Groups Projects
Commit 10509a28 authored by Masood Malekghassemi's avatar Masood Malekghassemi Committed by Nicolas "Pixel" Noble
Browse files

Fix Python Windows build

parent ab7055a0
No related branches found
No related tags found
No related merge requests found
......@@ -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()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment