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

Apple M1 Support #801

Open
tcpekin opened this issue Mar 3, 2022 · 11 comments
Open

Apple M1 Support #801

tcpekin opened this issue Mar 3, 2022 · 11 comments
Labels
audience - user affects users effort - week a week or less f - build f - installation feature impact - low has easy obvious workaround needs planning needs planning reach - medium affects several users weekly

Comments

@tcpekin
Copy link

tcpekin commented Mar 3, 2022

I am getting an error when installing Nion Swift as not all the submodules (not sure if that is the right word) are M1/Arm compatible. Nion Swift can be installed and is available on the following platforms:

image

But nionswift-tool cannot be installed as it is only specified for x64 Macs.
image

I do not know if Rosetta the transpiler can handle things like installed packages from conda, so I don't know if this is as simple as changing a flag to the conda upload as to which processors are supported, or it would require more work on your end, but it would be nice to be able to install Nion Swift on newer Macs.

Additional information after quick error checking w/ @Brow71189 :

╰─ conda search -c nion nionswift-tool
Loading channels: done
No match found for: nionswift-tool. Search: *nionswift-tool*

PackagesNotFoundError: The following packages are not available from current channels:

  - nionswift-tool

Current channels:

  - https://conda.anaconda.org/nion/osx-arm64
  - https://conda.anaconda.org/nion/noarch
  - https://repo.anaconda.com/pkgs/main/osx-arm64
  - https://repo.anaconda.com/pkgs/main/noarch
  - https://repo.anaconda.com/pkgs/r/osx-arm64
  - https://repo.anaconda.com/pkgs/r/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

    https://anaconda.org

and use the search bar at the top of the page.

Thanks!

@tcpekin
Copy link
Author

tcpekin commented Mar 3, 2022

Nion Swift works if I install the nionswift-tool from the source found here: https://anaconda.org/Nion/nionswift-tool/files. I ran:

conda create -n nionswift -c nion nionswift python=3.9
conda activate nionswift
conda install /Users/tompekin/Downloads/nionswift-tool-0.4.13-py39_0.tar.bz2

nionswift # this fails with the following output
Please install either pyqt or PySide2 using pip or conda or use nionswift-tool to launch.

conda install pyqt # this was necessary
nionswift # now this works

I will continue to use Nion Swift and see if any odd errors arise due to the x64/M1 incompatibilities.

@cmeyer
Copy link
Collaborator

cmeyer commented Mar 6, 2022

TL;DR: No M1 support yet and its a few months away, depending on conda-forge community support. And you're using a less performant UI when using pyqt. Read on below...

Nion Swift defines a user interface API that is required to be able to run its UI. The UI API is implemented in almost identical ways by nionswift-tool or by pyqt along with a related Python file PyQtProxy.py.

The two implementations are very similar, one being a C++ implementation and one being a Python implementation using the underlying pyqt (or PySide2) library. The difference is in display optimization - the C++ implementation is capable of significantly faster raster display updates, which is particularly important for live acquisition.

Also, Qt has stopped releasing new version of Qt 5.15. Unfortunately, they made this choice right around the time the M1 processor started being used; so with Qt 5, we're stuck using Qt 5.15.3 and that does not support the M1. There are community efforts to support the M1 on Qt 5.15, but so far, nothing is available.

Qt also has made available Qt 6 with support for the M1 processor. However, up until now, Qt 6 has not been available for many of the community distributions that we use (i.e. conda-forge and conda), so I've held off making a new UI API implementation for Qt 6 until those are available. Again, they're slowly progressing and I'm hopeful everything will be available soon.

Another potential, but expensive, solution in the future is to make purely native (macOS, Windows, Linux) implementations of the UI API and take Qt out of the equation. This would be time consuming, so I'd probably only advocate for this as a last resort if Qt continues to narrow their licensing terms for open source.

As a fun thought experiment, too, I've considered making a web browser canvas-based UI API implementation and then be able to run Swift (and any other nionui based projects) in the browser. It's a dream, but it would be quite time consuming and performance wouldn't be great, but kind of fun to think about!

Also, for reference, the UI API interface is defined here in UserInterface.py. It's somewhat more complex than that single class, but if you're interested, it gives you an idea of how the UI API is defined.

@tcpekin
Copy link
Author

tcpekin commented Mar 7, 2022

Hi Chris, thanks for the info, it's always interesting to see behind the scenes. Right now, I think Swift works on my M1 Mac using the steps described above, so I wonder if it is useful putting this thread behind a link in the documentation, for anyone else who has the same issue as I do might be helpful. However, I haven't fully tested it as to how much of Swift works w/ M1 + Qt 5.15

@cmeyer cmeyer self-assigned this Mar 9, 2022
@tcpekin
Copy link
Author

tcpekin commented Jun 29, 2022

Hi Chris, any updates on this?

@cmeyer
Copy link
Collaborator

cmeyer commented Jun 29, 2022

I've had it running on my local machine for the last month. I think I will be able to get it released in the next Swift release, targeting late July.

Also, FYI, there are still issues with not all Python libraries being universal (x86_64 + arm64) so there will still be two separate installers built, but the command line installation should "just work" with whichever architecture you choose.

It's possible for technical users to get things running now using the nionui-tool which is built here (scroll to the bottom and download the 'artifact'), but it's tricky to get Python to install just right for this to work.
https://github.com/nion-software/nionui-tool/actions/runs/2416723914

The development branch is here:
https://github.com/nion-software/nionui-tool/commits/macos-qt6-universal

@tcpekin
Copy link
Author

tcpekin commented Jun 29, 2022

Great to hear! Thanks a ton Chris I'll give it a shot.

@tcpekin
Copy link
Author

tcpekin commented Sep 9, 2022

Hi Chris, I tried a bit and pretty much failed to get Swift running on my M1 Mac... both with installing from github and installing the nionui tool. Is this just operator error?

@cmeyer
Copy link
Collaborator

cmeyer commented Sep 9, 2022

I'm (hopefully) releasing this next week ... but if you want you can use nionui-tool (note: this is different from nionswift-tool in that you have to pass the application name to launch.

You can download the proper tool (macOS, probably Python 3.10) here:
https://github.com/nion-software/nionui-tool/actions/runs/3012405255

You will need to have an arm64 conda installation with nionswift installed. Something along the lines of:
CONDA_SUBDIR=osx-arm64 conda create -n my-swift nionswift nionswift-io

Then launch it using (the app name and the paths for your conda installation will be different, of course):
Nion UI Tool.app/Contents/MacOS/NionUILauncher /path/to/your/conda/env/my-swift nionui_app.nionswift

@tcpekin
Copy link
Author

tcpekin commented Oct 24, 2022

Bumping this again to say that these instructions worked for me, it was a little confusing but so far everything is running great!

@cmeyer
Copy link
Collaborator

cmeyer commented Oct 24, 2022

The standard nionswift-tool on the nion channel should work now too:

CONDA_SUBDIR=osx-arm64 conda install -c nion nionswift nionswift-tool

I'm waiting to close this until I can build an Apple M1 prepackaged installer version; and also the conda-forge arm64 too. Both of those require cross compiling, which I almost have working, but not quite!

@cmeyer cmeyer removed their assignment Dec 13, 2022
@cmeyer
Copy link
Collaborator

cmeyer commented Dec 21, 2022

Qt macdeployqt issue (wrt conda-forge): https://bugreports.qt.io/browse/QTBUG-109572

@cmeyer cmeyer added stage - waiting impact - low has easy obvious workaround audience - user affects users reach - medium affects several users weekly effort - week a week or less needs planning needs planning and removed stage - waiting labels Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
audience - user affects users effort - week a week or less f - build f - installation feature impact - low has easy obvious workaround needs planning needs planning reach - medium affects several users weekly
Projects
None yet
Development

No branches or pull requests

2 participants