1
1
import os
2
+ import re
2
3
import sys
3
4
from typing import *
4
5
from pathlib import Path
@@ -257,27 +258,6 @@ def compile_extensions_to_c(platforms: List[str], root: Path) -> None:
257
258
return
258
259
259
260
260
- def _is_valid_identifier (string : str ) -> Union [Match [str ], None , bool ]:
261
- import re
262
- match = re .search ('^[A-Za-z_][A-Z-a-z0-9_\\ -]*' , string )
263
- return match and len (match .string ) == len (string )
264
-
265
-
266
- def _is_semver (string : str ) -> bool :
267
- try :
268
- lib_name , lib_version = string .rsplit ('-' , maxsplit = 1 )
269
- assert _is_valid_identifier (lib_name )
270
-
271
- major , minor , patch = lib_version .split ('.' )
272
- assert major .isdigit ()
273
- assert minor .isdigit ()
274
- assert patch .isdigit ()
275
-
276
- return True
277
- except :
278
- return False
279
-
280
-
281
261
def prevent_win32_max_path_length_error (path : Path ) -> None :
282
262
"""
283
263
Nim generates C files that contain `@` symbols to encode the original path
@@ -296,6 +276,24 @@ def prevent_win32_max_path_length_error(path: Path) -> None:
296
276
That's a lot less characters!
297
277
"""
298
278
279
+ def _is_valid_identifier (string : str ) -> Union [re .Match [str ], None , bool ]:
280
+ match = re .search ('^[A-Za-z_][A-Z-a-z0-9_\\ -]*' , string )
281
+ return match and len (match .string ) == len (string )
282
+
283
+ def _is_semver (string : str ) -> bool :
284
+ try :
285
+ lib_name , lib_version = string .rsplit ('-' , maxsplit = 1 )
286
+ assert _is_valid_identifier (lib_name )
287
+
288
+ major , minor , patch = lib_version .split ('.' )
289
+ assert major .isdigit ()
290
+ assert minor .isdigit ()
291
+ assert patch .isdigit ()
292
+
293
+ return True
294
+ except :
295
+ return False
296
+
299
297
for item in path .iterdir ():
300
298
if item .is_file () and item .name .startswith ('@m' ):
301
299
0 commit comments