Merge pull request #5807 from DWesl/tkimaging-on-cygwin

Use the Windows method to get TCL functions on Cygwin
This commit is contained in:
Andrew Murray 2021-12-30 00:08:31 +11:00 committed by GitHub
commit 4d1d2c9855
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 3 deletions

View File

@ -192,6 +192,10 @@ class TestImage:
assert not im.readonly assert not im.readonly
@pytest.mark.skipif(is_win32(), reason="Test requires opening tempfile twice") @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): def test_readonly_save(self, tmp_path):
temp_file = str(tmp_path / "temp.bmp") temp_file = str(tmp_path / "temp.bmp")
shutil.copy("Tests/images/rgb32bf-rgba.bmp", temp_file) shutil.copy("Tests/images/rgb32bf-rgba.bmp", temp_file)

View File

@ -898,7 +898,7 @@ class pil_build_ext(build_ext):
else: else:
self._remove_extension("PIL._webp") 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) self._update_extension("PIL._imagingtk", tk_libs)
build_ext.build_extensions(self) build_ext.build_extensions(self)

View File

@ -219,7 +219,7 @@ TkImaging_Init(Tcl_Interp *interp) {
#define TKINTER_FINDER "PIL._tkinter_finder" #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, * On Windows, we can't load the tkinter module to get the Tcl or Tk symbols,

View File

@ -25,11 +25,18 @@
#endif #endif
#endif #endif
#ifdef _WIN32 #if defined(_WIN32) || defined(__CYGWIN__)
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <Windows.h> #include <Windows.h>
#ifdef __CYGWIN__
#undef _WIN64
#undef _WIN32
#undef __WIN32__
#undef WIN32
#endif
#else #else
/* For System that are not Windows, we'll need to define these. */ /* For System that are not Windows, we'll need to define these. */