Only import ctypes as needed on Windows

This commit is contained in:
Andrew Murray 2022-03-19 14:46:25 +11:00
parent ca3bc290e3
commit 2a285d1b1f
2 changed files with 3 additions and 2 deletions

View File

@ -1,4 +1,3 @@
import ctypes
import os import os
import subprocess import subprocess
import sys import sys
@ -404,6 +403,8 @@ class TestEmbeddable:
"not from shell", "not from shell",
) )
def test_embeddable(self): def test_embeddable(self):
import ctypes
with open("embed_pil.c", "w") as fh: with open("embed_pil.c", "w") as fh:
fh.write( fh.write(
""" """

View File

@ -1,4 +1,3 @@
import ctypes
from io import BytesIO from io import BytesIO
from PIL import Image, ImageWin from PIL import Image, ImageWin
@ -8,6 +7,7 @@ from .helper import hopper, is_win32
# see https://github.com/python-pillow/Pillow/pull/1431#issuecomment-144692652 # see https://github.com/python-pillow/Pillow/pull/1431#issuecomment-144692652
if is_win32(): if is_win32():
import ctypes
import ctypes.wintypes import ctypes.wintypes
class BITMAPFILEHEADER(ctypes.Structure): class BITMAPFILEHEADER(ctypes.Structure):