5656
5757
5858class Config :
59- # READ_722 = False
6059 READ_723 = True
61- # BLOCK_RE_722 = r"(?i)^#\s+script\s+dependencies:\s*$"
6260 BLOCK_RE_723 = r"(?m)^# /// (?P<type>[a-zA-Z0-9-]+)$\s(?P<content>(^#(| .*)$\s)+)^# ///$"
6361 PKG_BASE_DEFAULT = "https://pygame-web.github.io/archives/repo/"
6462 PKG_INDEXES = []
@@ -75,41 +73,16 @@ class Config:
7573 mapping = {
7674 "pygame" : "pygame.base" ,
7775 "pygame_ce" : "pygame.base" ,
76+ "pygame_static" : "pygame.base" ,
7877 "python_i18n" : "i18n" ,
7978 "pillow" : "PIL" ,
8079 "pyglm" : "glm" ,
8180 "opencv_python" : "cv2" ,
8281 "pysdl3" : "sdl3" ,
8382 }
8483
85-
86- def read_dependency_block_722 (code ):
87- # Skip lines until we reach a dependency block (OR EOF).
88- has_block = False
89- # Read dependency lines until we hit a line that doesn't
90- # start with #, or we are at EOF.
91- for line in code .split ("\n " ):
92- if not has_block :
93- if re .match (Config .BLOCK_RE_722 , line ):
94- has_block = True
95- continue
96-
97- if not line .startswith ("#" ):
98- break
99- # Remove comments. An inline comment is introduced by
100- # a hash, which must be preceded and followed by a
101- # space.
102- line = line [1 :].split (" # " , maxsplit = 1 )[0 ]
103- line = line .strip ()
104- # Ignore empty lines
105- if not line :
106- continue
107- # Try to convert to a requirement. This will raise
108- # an error if the line is not a PEP 508 requirement
109- yield Requirement (line )
110-
111-
11284def read_dependency_block_723 (code ):
85+ global HISTORY , hint_failed
11386 # Skip lines until we reach a dependency block (OR EOF).
11487 has_block = False
11588
@@ -143,7 +116,7 @@ def install(pkg_file, sconf=None):
143116 from installer .destinations import SchemeDictionaryDestination
144117 from installer .sources import WheelFile
145118 if pkg_file in HISTORY :
146- print (f"# 144: install: { pkg_file } already installed" )
119+ print (f"# 144: install: { pkg_file } already installed or skipped " )
147120 return
148121
149122 # Handler for installation directories and writing into them.
@@ -374,34 +347,34 @@ async def pip_install(pkg, sysconf={}):
374347
375348
376349async def parse_code (code , env ):
377- global PATCHLIST , PYGAME
350+ global PATCHLIST , PYGAME , HISTORY , hint_failed
378351
379352 maybe_missing = []
380353
381- # if Config.READ_722:
382- # for req in read_dependency_block_722(code):
383- # pkg = str(req)
384- # if (env / pkg).is_dir():
385- # print("found in env :", pkg)
386- # continue
387- # elif pkg not in maybe_missing:
388- # # do not change case ( eg PIL )
389- # maybe_missing.append(pkg.lower().replace("-", "_"))
354+ import platform
390355
391356 if Config .READ_723 :
392357 for req in read_dependency_block_723 (code ):
393358 pkg = str (req )
394359 if (env / pkg ).is_dir ():
395360 print ("found in env :" , pkg )
396361 continue
362+ elif pkg and pkg [0 ]== '!' :
363+ skip = pkg [1 :]
364+ if not skip in HISTORY :
365+ HISTORY .append (skip )
366+ if not skip in hint_failed :
367+ hint_failed .append (skip )
368+ if skip in platform .patches :
369+ if not skip in PATCHLIST :
370+ PATCHLIST .append (skip )
371+ continue
397372 elif pkg not in maybe_missing :
398373 # do not change case ( eg PIL )
399374 maybe_missing .append (pkg .lower ().replace ("-" , "_" ))
400375
401376 still_missing = []
402377
403- import platform
404-
405378 for dep in maybe_missing :
406379 if dep in platform .patches :
407380 PATCHLIST .append (dep )
0 commit comments