Skip to content

Commit

Permalink
Merge pull request #108 from rcoup/rc-macos-arm64
Browse files Browse the repository at this point in the history
macos: use arm64 Kart releases on Apple Silicon
  • Loading branch information
rcoup authored Dec 6, 2023
2 parents ce6525a + 55d7c0b commit 874bc84
Showing 1 changed file with 18 additions and 6 deletions.
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

0 comments on commit 874bc84

Please sign in to comment.