mu-editor / mu

A small, simple editor for beginner Python programmers. Written in Python and Qt5.
http://codewith.mu
GNU General Public License v3.0
1.41k stars 435 forks source link

Distribute Mu as a snap #698

Open bennuttall opened 5 years ago

bennuttall commented 5 years ago

I'm working with @flexiondotorg and @waveform80 on publishing a snap for Mu, which will make it easy to install Mu across Linux distributions and potentially Windows and Mac in future. When a snap is published in the snapcraft store, Mu will be installable with snap install mu-editor and will bundle all dependencies, including Python, QT and all python libs.

We will introduce a snapcraft.yml into the root of the project. This will contain the spec for how the snap is built.

bennuttall commented 5 years ago

Features:

carlosperate commented 5 years ago

I've never done snap packaging before, but one thing to keep in mind would be the sandboxing. I assume access to the file system to open files is fine, but Mu saves config data in the user locations indicated by the appdirs python module, does that still work correctly?

Also, Mu launches the debugger as a separate process and connects to it via localhost, so that's something to check as well if it works.

Apart from that, the other thing I'd keep an eye on is having access to the serial for the micro:bit and adafruit modes.

bennuttall commented 5 years ago

Yep - the debugger works

This comes up when launching:

ben@bionic:~/Projects/mu$ snap run mu-editor
Logging to /home/ben/snap/mu-editor/common/.cache/mu/log/mu.log

Also this:

sh: 0: getcwd() failed: No such file or directory

Yeah, thinking about serial and the ability to flash the device.

bennuttall commented 5 years ago

Progress! A partially functional Mu v1.0.0 is now released in the snap store!

Linux users with snap support, try this:

snap install mu-editor --edge

Launch from your application drawer/menu or form the command line with snap run mu-editor.

We need to figure out USB permissions and whatnot, but the Python 3 and pgzero stuff works!

bennuttall commented 5 years ago

One thing to consider is that there's no clear way (I can think of) to install additional libraries. It's not using the system Python.

carlosperate commented 5 years ago

Awesome news!

About installing packages, when https://github.com/mu-editor/mu/issues/675 is implemented it should cover this scenario by default, as I assume snap packs its own Python interpreter, and the built-in solution would install the packages in that environment.

In the meantime, as a workaround, packages can be installed via REPL:

image
ZanderBrown commented 5 years ago

Semi-related: I've been talking to people about flatpak'ing but PyQt is being a hurdle (as ever)

bennuttall commented 5 years ago

I've fast-forwarded to the 1.0.1 tag and released this version too.

bennuttall commented 5 years ago

Also I've moved this work into the snap branch here. Thanks to @waveform80 and @flexiondotorg for the work getting us this far!

I'm out of sync with master due to having to rip out some stuff from setup.py. I'm sure we can piece it back together at some point though.

flexiondotorg commented 5 years ago

@bennuttall Please take a look at https://github.com/flexiondotorg/mu/commit/a65b58e67b8731e58c239832b206b6634cac3a76

It adds pip3 to the snap and also exposes the command mu-editor.pip. With the mu-editor snap installed you can now run something like mu-editor.pip install requests which will install requests to the user writable common data area inside the mu-editor snap :smiley:

As for accessing devices over USB, the raw-usb interface may help here but will (currently) require manual connection using snap connect mu-editor:raw-usb. With raw-usb interface connected does this improve device access?

waveform80 commented 5 years ago

@ZanderBrown If the block is the PyQt version then it's worth noting that the snap uses PyQt 5.5 (the requirements listed in the setup.py are much later than they actually need to be). In other words, the system PyQt5 shipped with Ubuntu Xenial or Raspbian Stretch are both sufficient to run mu

carlosperate commented 5 years ago

Just a note on PyQt versions, there were quite a few issues that turned out to be bugs in specific PyQt versions (a lot of them were platform specific, so not all will apply to Linux), so there might be some regressions if using an older version. I don't recall any show stoppers, but something to keep an eye if something misbehaves.

Also PyQtChart was only available since PyQt5.7 (before it was a commercial module). Does that mean the snap can't have the plotter?

waveform80 commented 5 years ago

Also PyQtChart was only available since PyQt5.7 (before it was a commercial module). Does that mean the snap can't have the plotter?

Yes, that's correct - the xenial-base libs used in the snap can't support the plotter. The bionic-base libs (when they become available) might do but I haven't checked whether they've got all the necessary bits either.

waveform80 commented 5 years ago

Well, I'm reliably informed core18 (the bionic base) has been available for some time now! Might be worth throwing that in the snap and seeing if you can get PyQtChart working via that (core18 should have Qt 5.10 IIRC)

carlosperate commented 5 years ago

That's great news! I assume that a snap with core18 would also work on 16.04?

flexiondotorg commented 5 years ago

Yes, core18 provides the base runtime snaps sit atop. Snaps using core18 will still run on all the distros where snapd is available 🙂

bennuttall commented 5 years ago

The snap doesn't provide audio support - I've added it to the list above

Sorry everyone who replied, I wasn't getting email notifications.

flexiondotorg commented 5 years ago

If you add the pulseaudio interfaces to the plugs: in the snapcraft.yaml then audio should work.

bennuttall commented 5 years ago

I've pushed another release with your changes. Also tried to build with core18 but got an issue with build dependencies:

Files from the build host were migrated into the snap to satisfy dependencies that would otherwise not be met. This feature will be removed in a future release. If these libraries are needed in the final snap, ensure that the following are either satisfied by a stage-packages entry or through a part:
usr/lib/x86_64-linux-gnu/libdb-5.3.so

I've pushed it but I'm not sure what I can change to deal with that.

waveform80 commented 5 years ago

Add libdb to stage-packages? :)