Skip to content

Commit 4d1d2c9

Browse files
authored
Merge pull request #5807 from DWesl/tkimaging-on-cygwin
Use the Windows method to get TCL functions on Cygwin
2 parents d8f2fb5 + 5a41417 commit 4d1d2c9

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

Tests/test_image.py

+4
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@ def test_internals(self):
192192
assert not im.readonly
193193

194194
@pytest.mark.skipif(is_win32(), reason="Test requires opening tempfile twice")
195+
@pytest.mark.skipif(
196+
sys.platform == "cygwin",
197+
reason="Test requires opening an mmaped file for writing",
198+
)
195199
def test_readonly_save(self, tmp_path):
196200
temp_file = str(tmp_path / "temp.bmp")
197201
shutil.copy("Tests/images/rgb32bf-rgba.bmp", temp_file)

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ def build_extensions(self):
898898
else:
899899
self._remove_extension("PIL._webp")
900900

901-
tk_libs = ["psapi"] if sys.platform == "win32" else []
901+
tk_libs = ["psapi"] if sys.platform in ("win32", "cygwin") else []
902902
self._update_extension("PIL._imagingtk", tk_libs)
903903

904904
build_ext.build_extensions(self)

src/Tk/tkImaging.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ TkImaging_Init(Tcl_Interp *interp) {
219219

220220
#define TKINTER_FINDER "PIL._tkinter_finder"
221221

222-
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
222+
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__CYGWIN__)
223223

224224
/*
225225
* On Windows, we can't load the tkinter module to get the Tcl or Tk symbols,

src/libImaging/ImPlatform.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,18 @@
2525
#endif
2626
#endif
2727

28-
#ifdef _WIN32
28+
#if defined(_WIN32) || defined(__CYGWIN__)
2929

3030
#define WIN32_LEAN_AND_MEAN
3131
#include <Windows.h>
3232

33+
#ifdef __CYGWIN__
34+
#undef _WIN64
35+
#undef _WIN32
36+
#undef __WIN32__
37+
#undef WIN32
38+
#endif
39+
3340
#else
3441
/* For System that are not Windows, we'll need to define these. */
3542

0 commit comments

Comments
 (0)