@@ -27,6 +27,9 @@ def get_version():
2727 return locals ()["__version__" ]
2828
2929
30+ configuration = {}
31+
32+
3033PILLOW_VERSION = get_version ()
3134FREETYPE_ROOT = None
3235HARFBUZZ_ROOT = None
@@ -333,15 +336,24 @@ def __iter__(self):
333336 + [("add-imaging-libs=" , None , "Add libs to _imaging build" )]
334337 )
335338
339+ @staticmethod
340+ def check_configuration (option , value ):
341+ return True if value in configuration .get (option , []) else None
342+
336343 def initialize_options (self ):
337- self .disable_platform_guessing = None
344+ self .disable_platform_guessing = self .check_configuration (
345+ "platform-guessing" , "disable"
346+ )
338347 self .add_imaging_libs = ""
339348 build_ext .initialize_options (self )
340349 for x in self .feature :
341- setattr (self , f"disable_{ x } " , None )
342- setattr (self , f"enable_{ x } " , None )
350+ setattr (self , f"disable_{ x } " , self . check_configuration ( x , "disable" ) )
351+ setattr (self , f"enable_{ x } " , self . check_configuration ( x , "enable" ) )
343352 for x in ("raqm" , "fribidi" ):
344- setattr (self , f"vendor_{ x } " , None )
353+ setattr (self , f"vendor_{ x } " , self .check_configuration (x , "vendor" ))
354+ if self .check_configuration ("debug" , "true" ):
355+ self .debug = True
356+ self .parallel = configuration .get ("parallel" , [None ])[- 1 ]
345357
346358 def finalize_options (self ):
347359 build_ext .finalize_options (self )
@@ -987,6 +999,12 @@ def debug_build():
987999 Extension ("PIL._imagingmorph" , ["src/_imagingmorph.c" ]),
9881000]
9891001
1002+
1003+ # parse configuration from _custom_build/backend.py
1004+ while sys .argv [- 1 ].startswith ("--pillow-configuration=" ):
1005+ _ , key , value = sys .argv .pop ().split ("=" , 2 )
1006+ configuration .setdefault (key , []).append (value )
1007+
9901008try :
9911009 setup (
9921010 cmdclass = {"build_ext" : pil_build_ext },
0 commit comments