Skip to content
This repository was archived by the owner on Aug 31, 2025. It is now read-only.

Commit 25ddedf

Browse files
authored
Merge pull request #2351 from mu-editor/pip-download-platform
wheel: Add --package flag to mu.wheels to include extra pip flags.
2 parents f8e6fb1 + 9fc7206 commit 25ddedf

File tree

4 files changed

+45
-9
lines changed

4 files changed

+45
-9
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ win64: check
105105

106106
macos: check
107107
@echo "\nFetching wheels."
108-
python -m mu.wheels
108+
python -m mu.wheels --package
109109
@echo "\nPackaging Mu into a macOS native application."
110110
python -m virtualenv venv-pup
111111
# Don't activate venv-pup because:
@@ -119,7 +119,7 @@ macos: check
119119

120120
linux: check
121121
@echo "\nFetching wheels."
122-
python -m mu.wheels
122+
python -m mu.wheels --package
123123
@echo "\nPackaging Mu into a Linux AppImage."
124124
python -m virtualenv venv-pup
125125
# Don't activate venv-pup because:

make.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ def _build_windows_msi(bitness=64):
415415
if check() != 0:
416416
raise RuntimeError("Check failed")
417417
print("Fetching wheels")
418-
subprocess.check_call([sys.executable, "-m", "mu.wheels"])
418+
subprocess.check_call([sys.executable, "-m", "mu.wheels", "--package"])
419419
print("Building {}-bit Windows installer".format(bitness))
420420
if pup_pbs_url:
421421
os.environ["PUP_PBS_URL"] = pup_pbs_url

mu/wheels/__init__.py

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
5779
def 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)

mu/wheels/__main__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import logging
2+
import sys
3+
24
from . import logger, download
35

46
#
@@ -8,4 +10,10 @@
810
logger.setLevel(logging.DEBUG)
911
logger.addHandler(logging.StreamHandler())
1012

11-
download()
13+
# A single flag is accepted to trigger a `pip download` using flag to increase
14+
# compatibility with older operating system versions.
15+
# As there is a single option available sys.argv is used for simplicity,
16+
# if more options are added in the future we should start using argparse
17+
os_old_compat = sys.argv[1] == "--package"
18+
19+
download(os_old_compat=os_old_compat)

0 commit comments

Comments
 (0)