From 5cb73c94e947f8567159618b609227a2900f1082 Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Fri, 14 Mar 2014 14:35:09 +0000 Subject: [PATCH] Fixed some Windows issues. --- libImaging/Incremental.c | 14 ++++++++------ setup.py | 13 ++++++++++++- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/libImaging/Incremental.c b/libImaging/Incremental.c index bc6a36b3e..b3a1cb00a 100644 --- a/libImaging/Incremental.c +++ b/libImaging/Incremental.c @@ -88,7 +88,7 @@ struct ImagingIncrementalCodecStruct { static void flush_stream(ImagingIncrementalCodec codec); #if _WIN32 -static void __stdcall +static unsigned int __stdcall codec_thread(void *ptr) { ImagingIncrementalCodec codec = (ImagingIncrementalCodec)ptr; @@ -98,6 +98,8 @@ codec_thread(void *ptr) flush_stream(codec); SetEvent(codec->hCodecEvent); + + return 0; } #else static void * @@ -327,7 +329,7 @@ ImagingIncrementalCodecPushBuffer(ImagingIncrementalCodec codec, /* Wait for the thread to ask for data */ #ifdef _WIN32 - WaitForSingleObject(codec->hCodecEvent); + WaitForSingleObject(codec->hCodecEvent, INFINITE); #else pthread_mutex_lock(&codec->codec_mutex); pthread_cond_wait(&codec->codec_cond, &codec->codec_mutex); @@ -375,7 +377,7 @@ ImagingIncrementalCodecPushBuffer(ImagingIncrementalCodec codec, #ifdef _WIN32 SetEvent(codec->hDataEvent); - WaitForSingleObject(codec->hCodecEvent); + WaitForSingleObject(codec->hCodecEvent, INFINITE); #else pthread_cond_signal(&codec->data_cond); pthread_mutex_unlock(&codec->data_mutex); @@ -433,7 +435,7 @@ ImagingIncrementalCodecRead(ImagingIncrementalCodec codec, codec->result = (int)(codec->stream.ptr - codec->stream.buffer); #if _WIN32 SetEvent(codec->hCodecEvent); - WaitForSingleObject(codec->hDataEvent); + WaitForSingleObject(codec->hDataEvent, INFINITE); #else pthread_cond_signal(&codec->codec_cond); pthread_mutex_unlock(&codec->codec_mutex); @@ -509,7 +511,7 @@ ImagingIncrementalCodecSkip(ImagingIncrementalCodec codec, codec->result = (int)(codec->stream.ptr - codec->stream.buffer); #if _WIN32 SetEvent(codec->hCodecEvent); - WaitForSingleObject(codec->hDataEvent); + WaitForSingleObject(codec->hDataEvent, INFINITE); #else pthread_cond_signal(&codec->codec_cond); pthread_mutex_unlock(&codec->codec_mutex); @@ -590,7 +592,7 @@ ImagingIncrementalCodecWrite(ImagingIncrementalCodec codec, codec->result = (int)(codec->stream.ptr - codec->stream.buffer); #if _WIN32 SetEvent(codec->hCodecEvent); - WaitForSingleObject(codec->hDataEvent); + WaitForSingleObject(codec->hDataEvent, INFINITE); #else pthread_cond_signal(&codec->codec_cond); pthread_mutex_unlock(&codec->codec_mutex); diff --git a/setup.py b/setup.py index 8d3511e0c..7d387b822 100644 --- a/setup.py +++ b/setup.py @@ -89,6 +89,7 @@ NAME = 'Pillow' VERSION = '2.3.0' TCL_ROOT = None JPEG_ROOT = None +JPEG2K_ROOT = None ZLIB_ROOT = None TIFF_ROOT = None FREETYPE_ROOT = None @@ -152,7 +153,7 @@ class pil_build_ext(build_ext): # # add configured kits - for root in (TCL_ROOT, JPEG_ROOT, TIFF_ROOT, ZLIB_ROOT, + for root in (TCL_ROOT, JPEG_ROOT, JPEG2K_ROOT, TIFF_ROOT, ZLIB_ROOT, FREETYPE_ROOT, LCMS_ROOT): if isinstance(root, type(())): lib_root, include_root = root @@ -323,6 +324,16 @@ class pil_build_ext(build_ext): _add_directory(library_dirs, "/usr/lib") _add_directory(include_dirs, "/usr/include") + # on Windows, look for the OpenJPEG libraries in the location that + # the official installed puts them + if sys.platform == "win32": + _add_directory(library_dirs, + os.path.join(os.environ.get("ProgramFiles", ""), + "OpenJPEG 2.0", "lib")) + _add_directory(include_dirs, + os.path.join(os.environ.get("ProgramFiles", ""), + "OpenJPEG 2.0", "include")) + # # insert new dirs *before* default libs, to avoid conflicts # between Python PYD stub libs and real libraries