Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macos: use arm64 Kart releases on Apple Silicon #108

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions kart/gui/installationwarningdialog.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import os
import sys
import requests
import shutil
import subprocess
import sys
import tempfile
import requests
import webbrowser
import shutil

from qgis.PyQt.QtWidgets import QDialog
from qgis.PyQt.QtCore import QThread, Qt, pyqtSignal, QEventLoop
from qgis.PyQt import uic


from qgis.utils import iface

from kart.gui.settingsdialog import SettingsDialog
Expand All @@ -24,7 +23,7 @@
RELEASE_URL = "https://github.com/koordinates/kart/releases/tag/v{version}"

WINDOWS_FILE = "Kart-{version}-win64.msi"
OSX_FILE = "Kart-{version}-macOS-x86_64.pkg"
MACOS_FILE = "Kart-{version}-macOS-{arch}.pkg"


class DownloadAndInstallThread(QThread):
Expand Down Expand Up @@ -57,7 +56,19 @@ def run(self):
subprocess.call(command, shell=True)
shutil.rmtree(os.path.dirname(msipath))
elif sys.platform == "darwin":
filename = OSX_FILE.format(version=self.version)
arch = subprocess.check_output(["arch"], text=True).strip()
if arch != "arm64":
# If QGIS is running under Rosetta2, then we get the wrong
# arch back. So check that too.
is_rosetta = subprocess.check_output(
["sysctl", "-in", "sysctl.proc_translated"], text=True
).strip()
if is_rosetta == "1":
arch = "arm64"
else:
arch = "x86_64"

filename = MACOS_FILE.format(version=self.version, arch=arch)
pkgpath = self._download(url, filename)
command = f"open -W {pkgpath}"
if pkgpath is not None:
Expand All @@ -73,6 +84,7 @@ def run(self):

def _download(self, url, filename):
fullurl = f"{url}/{filename}"
logging.info(f"Downloading Kart from: {fullurl}")
dirname = tempfile.mkdtemp()
downloadpath = os.path.join(dirname, filename)
chunk_size = 1024
Expand Down
Loading