11# /// script
22# dependencies = [
33# "auditwheel < 5",
4+ # "packaging",
45# "pefile",
56# "pyelftools", # elftools
67# "setuptools < 74",
1516import sys
1617from datetime import datetime
1718
19+ import packaging .version
1820import setuptools .msvc
19- from pkg_resources import parse_version
2021
2122os .chdir (os .path .dirname (os .path .dirname (os .path .realpath (__file__ ))))
2223
2324
24- # Python 3.7 workaround:
25- def parse_version_wrapper (txt ):
26- version = parse_version (txt )
27-
28- try :
29- version .major # noqa
30- version .minor # noqa
31- except AttributeError :
32- # Python 3.7 doesn't have these so we patch them in
33- version .major = version ._version .release [0 ]
34- version .minor = version ._version .release [1 ]
35-
36- return version
37-
38-
3925def _run (cmd , ** kwargs ):
4026 # For some reason, when combined with wsl calls, Python thinks the directory we're in has been deleted
4127 # so os.getcwd() fails
@@ -75,7 +61,7 @@ def del_rw(action, name, exc):
7561
7662
7763def create_interpreters (version , dest ):
78- version = parse_version_wrapper (version )
64+ version = packaging . version . Version (version )
7965 print (f'Creating Python { version } interpreters in "{ dest } " directory...' , flush = True )
8066 _run ([sys .executable , os .path .join ('tools' , 'create_embedded_python.py' ), '--version' , str (version ), dest ], check = True )
8167
@@ -95,7 +81,7 @@ def _get_embed(version, system, arch):
9581
9682
9783def build_binaries (version , arch , system , run_tests = True ):
98- version = parse_version_wrapper (version )
84+ version = packaging . version . Version (version )
9985 print (f'Building { arch } binaries for { system } ...' , flush = True )
10086
10187 if system == 'linux' :
@@ -128,7 +114,7 @@ def build_binaries(version, arch, system, run_tests=True):
128114
129115
130116def run_tests (version , arch , system ):
131- version = parse_version_wrapper (version )
117+ version = packaging . version . Version (version )
132118 print (f'Running tests for { arch } { system } ...' , flush = True )
133119
134120 _verbose_run ([_get_embed (version , system , arch ), os .path .join ('tests' , 'tests.py' )], check = True )
@@ -140,7 +126,7 @@ def build_pbos():
140126
141127
142128def copy_templates (version ):
143- version = parse_version_wrapper (version )
129+ version = packaging . version . Version (version )
144130 print ('Copying files to @Pythia folder...' , flush = True )
145131
146132 for f in os .listdir ('templates' ):
@@ -157,7 +143,7 @@ def copy_templates(version):
157143
158144
159145def safety_checks (version ):
160- version = parse_version_wrapper (version )
146+ version = packaging . version . Version (version )
161147 print ('Running safety checks...' , flush = True )
162148 _run ([sys .executable , os .path .join ('tools' , 'safety_checks.py' ), str (version )], check = True )
163149
0 commit comments