@@ -54,6 +54,28 @@ class WheelsBuildError(WheelsError):
5454]
5555
5656
57+ def os_compatibility_flags ():
58+ """
59+ Determine additional `pip download` flags required to maximise
60+ compatibility with older versions of the current operating system.
61+
62+ If downloading wheels with these flags fails, then we should consider it
63+ an issue to be resolved before doing a Mu release.
64+ """
65+ extra_flags = []
66+ # For macOS the oldest supported version is 10.12 Sierra, as that's the
67+ # oldest version supported by PyQt5 v5.13
68+ if sys .platform == "darwin" :
69+ extra_flags .extend (
70+ [
71+ "--platform=macosx_10_12_x86_64" ,
72+ "--only-binary=:all:" ,
73+ ]
74+ )
75+ # At the moment there aren't any additional flags for Windows or Linux
76+ return extra_flags
77+
78+
5779def compact (text ):
5880 """Remove double line spaces and anything else which might help"""
5981 return "\n " .join (line for line in text .splitlines () if line .strip ())
@@ -76,13 +98,14 @@ def remove_dist_files(dirpath, logger):
7698 os .remove (rm_filepath )
7799
78100
79- def pip_download (dirpath , logger ):
101+ def pip_download (dirpath , logger , additional_flags = [] ):
80102 for name , pip_identifier , * extra_flags in mode_packages :
81103 logger .info (
82- "Running pip download for %s / %s / %s" ,
104+ "Running pip download for %s / %s / %s / %s " ,
83105 name ,
84106 pip_identifier ,
85107 extra_flags ,
108+ additional_flags ,
86109 )
87110 process = subprocess .run (
88111 [
@@ -97,7 +120,8 @@ def pip_download(dirpath, logger):
97120 dirpath ,
98121 pip_identifier ,
99122 ]
100- + extra_flags ,
123+ + extra_flags
124+ + additional_flags ,
101125 stdout = subprocess .PIPE ,
102126 stderr = subprocess .STDOUT ,
103127 )
@@ -152,7 +176,7 @@ def zip_wheels(zip_filepath, dirpath, logger=logger):
152176 z .write (filepath , filename )
153177
154178
155- def download (zip_filepath = ZIP_FILEPATH , logger = logger ):
179+ def download (zip_filepath = ZIP_FILEPATH , logger = logger , os_old_compat = False ):
156180 """Download from PyPI, convert to wheels, and zip up
157181
158182 To make all the libraries available for Mu modes (eg pygame zero, Flask etc.)
@@ -162,8 +186,12 @@ def download(zip_filepath=ZIP_FILEPATH, logger=logger):
162186 We allow `logger` to be overridden because output from the
163187 virtual_environment module logger goes to the splash screen, while
164188 output from this module's logger doesn't
189+
190+ Additional pip download flags to maximise wheel compatibility with old
191+ operating systems can be included using the `os_old_compat` parameter.
165192 """
166193 logger .info ("Downloading wheels to %s" , zip_filepath )
194+ extra_pip_flags = os_compatibility_flags () if os_old_compat else []
167195
168196 #
169197 # Remove any leftover files from the place where the zip file
@@ -172,6 +200,6 @@ def download(zip_filepath=ZIP_FILEPATH, logger=logger):
172200 remove_dist_files (os .path .dirname (zip_filepath ), logger )
173201
174202 with tempfile .TemporaryDirectory () as temp_dirpath :
175- pip_download (temp_dirpath , logger )
203+ pip_download (temp_dirpath , logger , extra_pip_flags )
176204 convert_sdists_to_wheels (temp_dirpath , logger )
177205 zip_wheels (zip_filepath , temp_dirpath , logger )
0 commit comments