qgis / QGIS-Mac-Packager

Scripts for Official QGIS MacOS Packages
https://www.qgis.org
GNU General Public License v2.0
54 stars 21 forks source link

Build for Apple Silicon (Arm64, aarch64) #147

Open RemiDesgrange opened 2 years ago

RemiDesgrange commented 2 years ago

Hi :wave:

It seems that there is no QGIS build for apple silicon hardware so far. I started to look at, it's much more tricky that it seems !! I listed some checks that needed to be performed in order for QGIS to work on Apple Silicon hardware (arm64 ou aarch64)

Maybe the qgis mac deps need to be completely revamp with 1 build for x86 and 1 build for arm (ex: `qgis-deps-x86_64-0.10.0.tar.gz).

I'll fork the repo and make some tried, but I already identify some hardcoded path that need to be added to the config files. Feel free to add more checks in order to have a complete build of QGIS on Apple Silicon hardware !

nyalldawson commented 2 years ago

@RemiDesgrange be aware that you can't build qgis on qt6 completely yet -- see https://github.com/qgis/QGIS-Enhancement-Proposals/issues/243 for a summary of the current situation

3nids commented 2 years ago

Hi Remi, Thanks for raising this!

Side note, I am working a bit on trying to bring the deps to a CI (see https://github.com/qgis/QGIS-Mac-Packager/tree/ci-v2).

RemiDesgrange commented 2 years ago

I can confirm that you have an adherence to where ninja is located, we'll have to use $(brew --prefix) instead of hardocding /usr/local path, but no big change.

I'll try to build with Qt5. But I'll first have to build the deps :smile:

RemiDesgrange commented 2 years ago

On the other hand, it is possible to ship Apple Silicon and x86_64 binary in the same DMG: "universal binary" (https://developer.apple.com/documentation/apple-silicon/building-a-universal-macos-binary). I have little knowledge of how Qt build works, so no idea if it's possible or not to ship Apple Silicon and x86_64 binary of QGIS in the same DMG.

3nids commented 2 years ago

On the other hand, it is possible to ship Apple Silicon and x86_64 binary in the same DMG: "universal binary"

that's the road vcpkg is apparently following https://github.com/microsoft/vcpkg/pull/22908

PeterPetrik commented 2 years ago

we do not bundle anything from homebre

RemiDesgrange commented 2 years ago

@nyalldawson I identified that steps have been made to build QGIS with Qt6, What I can't see though is where we are regarding the QEP you wrote. Is it started yet? Is there a branch where we could test it (in the qgis/QGIS repo)? Thx.

3nids commented 2 years ago

This QEP will go through the grant proposal (funding) process, so it is not started yet. All the base work for Qt6 has been merged to master, and we have a CI running with Qt6 builds for core and analysis libraries going, see https://github.com/qgis/QGIS/blob/master/.github/workflows/run-tests.yml#L62

liberostelios commented 1 year ago

Since qt5 seems to be available for Apple Silicon right now (at least in homebrew) is there a reconsideration about this? I would be interested in working on it, but I am no CMAKE expert and could use some help.

RemiDesgrange commented 1 year ago

If Qt5 is available on m1, there should have nothing but some hard-coded /usr/local/opt path to change. I will see if I can find an old m1 machine to test stuff on. Every package will need to be recompile (usually, pre-compile version of lib are used). This should take some time, even on an Apple Silicon machine.

liberostelios commented 1 year ago

Actually, in Apple Silicon the default path for homebrew is /opt/homebrew, instead of /usr/local. Not sure why that is, but just mentioning it. Does it matter, though? Isn't Qt5 supposed to be installed on it's own /opt/QT folder outside of homebrew?

I tried to build the dependencies, but certain things aren't working out of the box. I suppose the build configuration of certain dependencies might need to be changed to fit for the platform.

RemiDesgrange commented 1 year ago

Is there any news on this side?

Qt5 can be compiled on m1, several attempts have been made to have a native Apple Silicon build (see https://github.com/qgis/QGIS/issues/46299), conda have one, macports allow you to compile QGIS on a m1. Is there anything we can do to help on this topic ? Thx.

justinbb commented 1 year ago

It is possible to build up-to-date QGIS completely on Apple Silicon, running Ventura, with Xcode 14.2 – despite still using Qt5. It's all set up on MacPorts, currently for 3.28.4. There are a couple of traps, however:

Is there anyone around who knows how to fix the QGIS-Mac-Packager? I tried, but gave up in despair rather early in the process; MacPorts was a more effective way of getting a functioning QGIS without investing several days deciphering this packager.

SrNetoChan commented 1 year ago

The conda-forge community have successfully built QGIS 3.28 and 3.30 for Arm64 and aarach64. I wasn't able to test it much as I don't have a mac arm64 myself, but seems functional to others. But it's definitely possible:

https://github.com/conda-forge/qgis-feedstock

RemiDesgrange commented 1 year ago

Correct me if I'm wrong @SrNetoChan, but I can't take the DMG from conda, copy/paste it to a computer without conda, and having QGIS to work properly? That's the problem with macports/conda setup. @justinbb I already try to make this repo working with AppleSilicon but it was a lot a work, and a lot of breaking changes.

joaoponceleao commented 1 year ago

@RemiDesgrange You can't with conda (though perhaps there is a way, never checked). You can with macports. I haven't managed to install it with macports however. Perhaps on a clean vm it might work, but I don't have experience with ports, just know there is a command to build an independent binary.

SrNetoChan commented 1 year ago

Correct me if I'm wrong @SrNetoChan, but I can't take the DMG from conda, copy/paste it to a computer without conda, and having QGIS to work properly? That's the problem with macports/conda setup. @justinbb I already try to make this repo working with AppleSilicon but it was a lot a work, and a lot of breaking changes.

Probably there is, but I don't know how to do it. I know there's something called conda constructor to create installers.

https://github.com/conda/constructor

justinbb commented 1 year ago

conda is at the moment the easiest, quickest way to get an up-to-date QGIS running on a Mac. @SrNetoChan Nicely done!

The problem with the conda version is that it is not a Mac app bundle (though there is a vestigial bundle created by QGIS's own cmake configuration); you run it from the shell by starting "qgis" in conda's bin directory, as if it were a command-line tool, and it dynamically links with many libraries in conda's lib directory. @RemiDesgrange To move it to a new computer, it's much easier to install Miniconda3 anew, then conda install qgis, than to try to make an archive of the conda directory hierarchy and copy it elsewhere.

Compared with MacPorts, conda installs QGIS very quickly, uses more up-to-date versions of many libraries, and has a better-configured GDAL library. However, since there are various optional bits and pieces that not everyone uses, it's possible there might be gaps here and there. MacPorts does a better job of making an app bundle – not according to the rules, but it is usable.

The proofs of concept clearly exist for building on Mac (Intel or Apple Silicon) the latest QGIS with recent versions of the libraries it depends on. The problems making official, standalone app bundles should eventually get dealt with (see https://github.com/qgis/QGIS-Mac-Packager/issues/160#issuecomment-1483897570 in QGIS-Mac-Packager).

SrNetoChan commented 1 year ago

@justinbb neither me or @gillins (who's the main maintainer of qgis-feedstock) have much experience with Mac OS, so any pointers are welcome.

justinbb commented 1 year ago

@SrNetoChan There is one more thing I had to do to avoid startup errors from SIP and Python. That vestigial bundle is not completely unused…

cd QGIS.app/Contents/MacOS
ln -s ../../../lib .
ln -s ../../../share .

For the more general question of making app bundles from conda: see the interesting discussion by Daniël Schreij and set of scripts. I'll try out his suggestion one of these days. However, it's still not a way of making a conformant bundle, which requires strict separation of code and data directories to allow effective code signing.

ivn951 commented 1 year ago

Some time back, I wrote an article in Italian on how to install QGIS with MacPorts. It might be useful although I should update it.

https://ivano-giuliano.medium.com/installazione-di-qgis-3-beta-su-piattaforme-macos-tramite-macports-28940731ed2b

Il giorno dom 26 mar 2023 alle 04:40 justinbb @.***> ha scritto:

@SrNetoChan https://github.com/SrNetoChan There is one more thing I had to do to avoid startup errors from SIP and Python. That vestigial bundle is not completely unused…

cd QGIS.app/Contents/MacOS ln -s ../../../lib . ln -s ../../../share .

For the more general question of making app bundles from conda: see the interesting discussion by Daniël Schreij https://dschreij.github.io/how-to/package-anaconda-environments-as-apps and set of scripts https://github.com/dschreij/anaconda-env-to-osx-app. I'll try out his suggestion one of these days. However, it's still not a way of making a conformant bundle, which requires strict separation of code and data directories to allow effective code signing.

— Reply to this email directly, view it on GitHub https://github.com/qgis/QGIS-Mac-Packager/issues/147#issuecomment-1483977525, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACMJDNGPYTFXBREZW33IPSTW56UC7ANCNFSM5N3SZQRQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

vlebert commented 11 months ago

Hi

I found this thread and it's nice to read good news regarding Mac environment, especially Apple Silicon Arch.

A small tip for those who want to test conda native build without polluting the system environment, or even try multiple QGIS vesions at once :

  1. Open "Automator" on your Mac (you can find it in the Applications folder).
  2. In the Automator app, select "Application" as the document type for your new workflow.
  3. In the search bar, type "Run Shell Script" and drag the "Run Shell Script" action to the workflow area on the right.
  4. In the "Run Shell Script" action, change the "Pass input" option to "as arguments".

Script:

eval "$(/Users/YOUR_USERNAME/miniforge3/bin/conda shell.zsh hook)"
conda activate qgis
qgis "$@"

digi-studio 2023-08-01 at 08 58 12