Install root using snap

Hi, I would like to install ROOT on ubuntu workstation via

sudo snap install root-framework

A few questions:

  • Does it install for all users on the machine? For example, to /user/bin.
  • Does it come with pyROOT binding? If not, how to?
  • Do I get to choose the root version?

Thanks, Allen

Please publish to the #snap post category for issues regarding a particular snap, I’ve fixed for you.

Yes.

No idea what that is, however, there’s a problem that development resources(even if available) will be on a different path and you may need to change your build configuration to reference it.

Contact the publisher to be sure.

It depends whether the developer has distributed different versions of the distribution via Using Tracks or other means(like different snap names for different versions).

1 Like

The ROOT snap does have the pyroot bindings but due to being a snap it comes with caveats.

The system version of python cannot be modified, so rather than using python followed by import ROOT, you need to use pyroot followed by import ROOT, and use the snap specific Python environment that’s immutable and contains its own predefined set of packages. (Alternatively, you might like to try root --notebook for a Jupyter environment).

I do use tracks as mentioned above, however I imagine the majority of people who use ROOT as a snap would prefer to use whatever version of ROOT happens to be latest. Because of the nature of being a snap, using ROOT as a build dependency in other projects isn’t a goal for example, so given how reliable the update process is, there’s little reason for most its users to not receive the continual updates. Still, there are currently tracks for v6.22 and V6.24 and these two tracks have effectively EOL’d, so their ROOT and Python environments will never change and you could have an effectively unchanging root environment for them forever. Similarly, the v6.26 track would freeze when 6.28 releases. (On a very technicality, they still receive security updates / rebuilds and very specific bug fixes as appropriate, but I’d not expect people to notice)

1 Like

Hi James,

Thanks for your reply. It sounds like it does come with python binding but we just need to do pyroot and followed by import ROOT. Here pyroot is a specific python environment. My next question is: how to install other python package to use with ROOT in pyroot environment?

Allen

Generally speaking, snaps aren’t a good format for allowing users to make changes to the bundled packages (they’re designed to be immutable). However if the package is likely to benefit the average university student and the license & technical requirements allow, I’d be happy to consider adding new packages to be included properly.

For a truly custom Python experience however, I’d recommend trying to rebuild the snap with a modified Python package list. The build environment should be fairly easy to set up, and you’d generate a file for yourself that you’re free to share with others and would never automatically update any of the bundled packages unless you rebuilt it and reinstalled it manually.

But aside from that, you can still instruct Python to look elsewhere for packages, including locations that are writable, and the snap still ships with Pip, which means you can do something like this:

root-framework.run pip3 install torch -t $HOME/pyroot-extras

You could then use the packages in that folder by prepending pyroot scripts with

import sys
sys.path.append("/home/james/pyroot_extras")

The issue with this approach is that the Python environment may still change as the snap receives updates, e.g, there’ll be an update later this year from Python 3.8 --> 3.10, and you’d be responsible for setting up that folder again manually since it wouldn’t be included in the snap itself and would presumably break when that happens.

However, I might make some wrappers/changes (e.g, to the default $PYTHONPATH variable) which might make that easier. But as is, the majority of the target audience doesn’t appear to mind the status quo, which makes this a relatively low priority.

1 Like

I’ve deployed some changes to the snap now, so that you can do this

james@james-Virtual-Machine:~$ sudo snap install root-framework
[sudo] password for james: 
root-framework v6-26-02 from James Carroll installed
james@james-Virtual-Machine:~$ root-framework.pip install torch
Collecting torch
  Downloading torch-1.11.0-cp38-cp38-manylinux1_x86_64.whl (750.6 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 750.6/750.6 MB 6.1 MB/s eta 0:00:00
Collecting typing-extensions
  Downloading typing_extensions-4.2.0-py3-none-any.whl (24 kB)
Installing collected packages: typing-extensions, torch
Successfully installed torch-1.11.0 typing-extensions-4.2.0
james@james-Virtual-Machine:~$ pyroot
Python 3.8.10 (default, Mar 15 2022, 12:22:08) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> 

Please note:

  1. Python packages sideloaded this way are preferred over any Python packages included in the snap itself (with the exception of the PyROOT bindings).
  2. Packages installed like this are never automatically updated, which means they may break when the snap itself is automatically updated (E.G, updating to Python 3.10 for ROOT 6.28)
  3. You could likely cause conflicts between the embedded packages and sideloaded packages, particularly if there’s conflicting dependencies (e.g, numpy)
  4. It won’t work for every package.
  5. This only applies to the user on the system, so won’t effect other users if you happen to be sharing a machine.

If root-framework.pip doesn’t work on your system, try running sudo snap refresh first.

And finally, in the worst case scenario, you can always delete $HOME/snap/root-framework/common/.pip to undo any packages sideloaded.

1 Like