scikit-hep / aghast

Aghast: aggregated, histogram-like statistics, sharable as Flatbuffers.
BSD 3-Clause "New" or "Revised" License
17 stars 8 forks source link

How to import ROOT #28

Closed LovelyBuggies closed 4 years ago

LovelyBuggies commented 4 years ago

I tried pip install ROOT and cannot find ROOT wheel. How can I install Python ROOT?

jpivarski commented 4 years ago
conda install -c conda-forge root

ROOT is a large binary; it's not likely that it will ever be available on PyPI. (I have the PyPI name registered in case it ever becomes possible, but it's not likely.)

LovelyBuggies commented 4 years ago

@jpivarski Thx, but still a problem here.

I cannot use this command conda install -c conda-forge root directly in a Python3 venv. I have all other packages listed in requirements.txt and install them in my virtual environment to set up my dev env now. I wonder if there is a good way to install ROOT just like this.

Log:

(.env) NinodeMacBook-Pro:Nino-hist nino$ conda install -c conda-forge root
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: - failed with initial frozen solve. Retrying with flexible solve.

CondaError: KeyboardInterrupt
jpivarski commented 4 years ago

Conda environments are their own virtual environments. If you just need isolation, you can conda create, but if you need it to specifically be a Python 3 venv, then you might be out of luck. Python venv might be limited to Python packaging, but the vast majority of ROOT is not Python and not easily packaged within Python's directory structures.

LovelyBuggies commented 4 years ago

Thanks. We might need to change our developing method. However, whether the new version aghast will do some improvements on this feature, in order to better facilitate development in Python venv (it looks like we have to use conda if we want to import ROOT now)?

jpivarski commented 4 years ago

ROOT is not a requirement for hist or aghast, and that's something that won't change when aghast becomes based on jagged arrays. (Be sure to keep in mind that that update is many months in the future.)

Some of the histogram types that aghast converts to and from are ROOT histograms; when converting from ROOT histograms, the user has already imported ROOT somehow—we don't care how—and when converting to ROOT histograms, we have to import ROOT internally in that function. If it fails with ImportError, we give an error message asking the user to install ROOT and provide some hints about how to do that.

How users install ROOT is their own business, and there are many ways. Conda is a new one, which plays well with the Python ecosystem because it can manage Python package versions in the same optimization as the ROOT version. Pip probably won't be one because ROOT extends so far beyond the expectations of what a Python package looks like. (It puts constraints on which C++ compiler you use for projects that use ROOT—things like that.) Most of the users who want to convert histograms into and out of PyROOT objects already have ROOT installed. In fact, it's not uncommon for physicists to have several versions of ROOT installed, some of which were compiled manually to get some feature.

So this is why our use of ROOT doesn't imply any changes in whether hist or aghast uses venv, pip, or other Python standards. It should be thought of as a big thing on the border, not a small package to absorb into the stack.

As a testing dependency, we can absorb it into the testing stack with conda, but that means that any projects with ROOT in their tests have to install testing dependencies with conda (uproot did that, for instance).