Skip to content

Commit

Permalink
Merge pull request #5807 from DWesl/tkimaging-on-cygwin
Browse files Browse the repository at this point in the history
Use the Windows method to get TCL functions on Cygwin
  • Loading branch information
radarhere committed Dec 29, 2021
2 parents d8f2fb5 + 5a41417 commit 4d1d2c9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Tests/test_image.py
Expand Up @@ -192,6 +192,10 @@ def test_internals(self):
assert not im.readonly

@pytest.mark.skipif(is_win32(), reason="Test requires opening tempfile twice")
@pytest.mark.skipif(
sys.platform == "cygwin",
reason="Test requires opening an mmaped file for writing",
)
def test_readonly_save(self, tmp_path):
temp_file = str(tmp_path / "temp.bmp")
shutil.copy("Tests/images/rgb32bf-rgba.bmp", temp_file)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -898,7 +898,7 @@ def build_extensions(self):
else:
self._remove_extension("PIL._webp")

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

build_ext.build_extensions(self)
Expand Down
2 changes: 1 addition & 1 deletion src/Tk/tkImaging.c
Expand Up @@ -219,7 +219,7 @@ TkImaging_Init(Tcl_Interp *interp) {

#define TKINTER_FINDER "PIL._tkinter_finder"

#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__CYGWIN__)

/*
* On Windows, we can't load the tkinter module to get the Tcl or Tk symbols,
Expand Down
9 changes: 8 additions & 1 deletion src/libImaging/ImPlatform.h
Expand Up @@ -25,11 +25,18 @@
#endif
#endif

#ifdef _WIN32
#if defined(_WIN32) || defined(__CYGWIN__)

#define WIN32_LEAN_AND_MEAN
#include <Windows.h>

#ifdef __CYGWIN__
#undef _WIN64
#undef _WIN32
#undef __WIN32__
#undef WIN32
#endif

#else
/* For System that are not Windows, we'll need to define these. */

Expand Down

0 comments on commit 4d1d2c9

Please sign in to comment.