1515from pathlib import Path
1616from typing import Any , Union
1717
18+ from buildconfig .get_version import version
19+
1820MOD_NAME = "pygame-ce"
1921DIST_DIR = "dist"
2022
@@ -204,9 +206,11 @@ def __init__(self) -> None:
204206
205207 def cmd_build (self ):
206208 wheel_dir = self .args .get ("wheel" , DIST_DIR )
209+ quiet = self .args .get ("quiet" , False )
207210 debug = self .args .get ("debug" , False )
208211 lax = self .args .get ("lax" , False )
209212 sdl3 = self .args .get ("sdl3" , False )
213+ sanitize = self .args .get ("sanitize" )
210214 coverage = self .args .get ("coverage" , False )
211215 if wheel_dir and coverage :
212216 pprint ("Cannot pass --wheel and --coverage together" , Colors .RED )
@@ -228,6 +232,8 @@ def cmd_build(self):
228232
229233 if not wheel_dir :
230234 # editable install
235+ if not quiet :
236+ install_args .append ("-Ceditable-verbose=true" )
231237 install_args .append ("--editable" )
232238
233239 install_args .append ("." )
@@ -245,15 +251,19 @@ def cmd_build(self):
245251 if coverage :
246252 install_args .extend (COVERAGE_ARGS )
247253
254+ if sanitize :
255+ install_args .append (f"-Csetup-args=-Db_sanitize={ sanitize } " )
256+
248257 info_str = f"with { debug = } , { lax = } , { sdl3 = } , and { coverage = } "
249258 if wheel_dir :
250259 pprint (f"Building wheel at '{ wheel_dir } ' ({ info_str } )" )
251260 cmd_run (
252261 [self .py , "-m" , "pip" , "wheel" , "-v" , "-w" , wheel_dir , * install_args ]
253262 )
254263 pprint ("Installing wheel" )
264+ mod_name = f"{ MOD_NAME } =={ version } "
255265 pip_install (
256- self .py , ["--no-index" , "--force" , "--find-links" , wheel_dir , MOD_NAME ]
266+ self .py , ["--no-index" , "--force" , "--find-links" , wheel_dir , mod_name ]
257267 )
258268 else :
259269 pprint (f"Installing in editable mode ({ info_str } )" )
@@ -352,6 +362,11 @@ def parse_args(self):
352362 f"wheel (if not passed, '{ DIST_DIR } ' is used)"
353363 ),
354364 )
365+ build_parser .add_argument (
366+ "--quiet" ,
367+ action = "store_true" ,
368+ help = "Silence build log in editable install (doing editable-verbose=false)" ,
369+ )
355370 build_parser .add_argument (
356371 "--debug" ,
357372 action = "store_true" ,
@@ -367,6 +382,20 @@ def parse_args(self):
367382 action = "store_true" ,
368383 help = "Build against SDL3 instead of the default SDL2" ,
369384 )
385+ build_parser .add_argument (
386+ "--sanitize" ,
387+ choices = [
388+ "address" ,
389+ "undefined" ,
390+ "address,undefined" ,
391+ "leak" ,
392+ "thread" ,
393+ "memory" ,
394+ "none" ,
395+ ],
396+ default = "none" ,
397+ help = "Enable compiler sanitizers. Defaults to 'none'." ,
398+ )
370399 build_parser .add_argument (
371400 "--coverage" ,
372401 action = "store_true" ,
0 commit comments