@@ -28,6 +28,9 @@ def get_version():
2828 return locals ()["__version__" ]
2929
3030
31+ configuration = {}
32+
33+
3134PILLOW_VERSION = get_version ()
3235FREETYPE_ROOT = None
3336HARFBUZZ_ROOT = None
@@ -334,15 +337,24 @@ def __iter__(self):
334337 + [("add-imaging-libs=" , None , "Add libs to _imaging build" )]
335338 )
336339
340+ @staticmethod
341+ def check_configuration (option , value ):
342+ return True if configuration .get (option ) == value else None
343+
337344 def initialize_options (self ):
338- self .disable_platform_guessing = None
345+ self .disable_platform_guessing = self .check_configuration (
346+ "platform-guessing" , "disable"
347+ )
339348 self .add_imaging_libs = ""
340349 build_ext .initialize_options (self )
341350 for x in self .feature :
342- setattr (self , f"disable_{ x } " , None )
343- setattr (self , f"enable_{ x } " , None )
351+ setattr (self , f"disable_{ x } " , self . check_configuration ( x , "disable" ) )
352+ setattr (self , f"enable_{ x } " , self . check_configuration ( x , "enable" ) )
344353 for x in ("raqm" , "fribidi" ):
345- setattr (self , f"vendor_{ x } " , None )
354+ setattr (self , f"vendor_{ x } " , self .check_configuration (x , "vendor" ))
355+ if self .check_configuration ("debug" , "true" ):
356+ self .debug = True
357+ self .parallel = configuration .get ("parallel" )
346358
347359 def finalize_options (self ):
348360 build_ext .finalize_options (self )
@@ -390,6 +402,9 @@ def finalize_options(self):
390402 raise ValueError (msg )
391403 _dbg ("Using vendored version of %s" , x )
392404 self .feature .vendor .add (x )
405+ if x == "raqm" :
406+ _dbg ("--vendor-raqm implies --enable-raqm" )
407+ self .feature .required .add (x )
393408
394409 def _update_extension (self , name , libraries , define_macros = None , sources = None ):
395410 for extension in self .extensions :
@@ -985,6 +1000,17 @@ def debug_build():
9851000 Extension ("PIL._imagingmorph" , ["src/_imagingmorph.c" ]),
9861001]
9871002
1003+
1004+ # parse configuration from _custom_build/backend.py
1005+ while len (sys .argv [1 ]) >= 2 and sys .argv [1 ].startswith ("--pillow-configuration=" ):
1006+ _ , key , value = sys .argv [1 ].split ("=" , 2 )
1007+ old = configuration .get (key )
1008+ if old is not None :
1009+ msg = f"Conflicting options: '-C { key } ={ old } ' and '-C { key } ={ value } '"
1010+ raise ValueError (msg )
1011+ configuration [key ] = value
1012+ del sys .argv [1 ]
1013+
9881014try :
9891015 setup (
9901016 cmdclass = {"build_ext" : pil_build_ext },
0 commit comments