Shipping a package dependent on ROOT with conda

Dear ROOT developers,

I have a package which depends solely on ROOT and I would like to ship it with conda.

You can find the package here: https://github.com/javierrico/gLike.

I went through the conda-build documentation, especially consulting the section on building conda packages from scratch.

The two files needed to build the package are the meta.yaml

package:
  name: glike
  version: 00.08.00

source:
  git_url: https://github.com/javierrico/gLike.git

requirements:
  host:
    - root
  run:
    - root

and a build.sh

echo "--> building gLike"

echo "--> check what's in SRC_DIR"
ls $SRC_DIR

export GLIKESYS=$SRC_DIR                                  
export DYLD_LIBRARY_PATH="${GLIKESYS}:${DYLD_LIBRARY_PATH}"    

make

(where GLIKESYS is a local variable needed to make the code).

The building, performed via

conda build . -c conda-forge

seems to go fine. I get the output messages that the makefile produces while compiling and linking libraries, e.g.

Compiling out/gLikeDict.cc...
g++ -fPIC `root-config --cflags` -c out/gLikeDict.cc -o out/gLikeDict.o
Generated out/gLikeDict.o 

Linking shared object lib/libgLike.so...
g++ -fPIC -shared out/Lkl.o out/ParabolaLkl.o out/PoissonLkl.o out/JointLkl.o out/Iact1dUnbinnedLkl.o out/Iact1dBinnedLkl.o out/IactEventListIrf.o out/FermiTables2016Lkl.o out/TemplateLkl.o out/MIACTEventListIRF.o out/GloryDuckTables2019Lkl.o out/gLikeDict.o `root-config --libs` -lMinuit -o lib/libgLike.so
Done!

and additionally the output of conda-build appears to be the one expected to show up at the end of a successful build - by looking at the documentation

# Automatic uploading is disabled
# If you want to upload package(s) to anaconda.org later, type:

anaconda upload /Users/cosimo/software/miniconda3/conda-bld/osx-64/glike-00.08.00-0.tar.bz2

# To have conda build upload to anaconda.org automatically, use
# $ conda config --set anaconda_upload yes

anaconda_upload is not set.  Not uploading wheels: []
####################################################################################
Resource usage summary:

Total time: 0:04:31.5
CPU usage: sys=0:00:00.6, user=0:00:03.5
Maximum memory usage observed: 104.5M
Total disk usage observed (not including envs): 25.8K


####################################################################################
Source and build intermediates have been left in /Users/cosimo/software/miniconda3/conda-bld.
There are currently 2 accumulated.
To remove them, you can run the ```conda build purge``` command

Once the package is built, as a check, it is recommended to try to build it locally. Therefore I try

conda install --use-local glike

but all I get is

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.
Solving environment: | 
Found conflicts! Looking for incompatible packages.
This can take several minutes.  Press CTRL-C to abort.
failed                                                                                                                                                                            

UnsatisfiableError: 

I am stuck: cases outside the python packaging are not well covered by the documentation and the error message I get is not very clear.

Anybody that contributed shipping ROOT with conda could help me?

Thank you,

Cosimo

Hi @cosimoNigro,

I cannot promise anything since I guess conda is not “officially” supported, but @eguiraud might be able to have a look here.

Hi @cosimoNigro,

This recipe and build script works, though I recommend adding a make install step that installs the library, headers and any other files into PREFIX. Better yet, consider using a build system like CMake that will handle most of this for you.

package:
  name: glike
  version: 00.08.00

source:
  git_url: https://github.com/javierrico/gLike.git
  # This is better as it ensures the correct version of the source is always used
  # url: https://github.com/javierrico/gLike/archive/v{{ version }}.tar.gz

requirements:
  build:
    - {{ compiler('cxx') }}
    - make
  host:
    - root_base
    - root-dependencies
    - root-binaries
  run:
    - root_base
    - root-dependencies
    - root-binaries
echo "--> building gLike"

echo "--> check what's in SRC_DIR"
ls $SRC_DIR

export GLIKESYS=$SRC_DIR
export DYLD_LIBRARY_PATH="${GLIKESYS}:${DYLD_LIBRARY_PATH}"  # <- I doubt this line is needed

make CXX="$CXX -fPIC" LIBDIR=$PREFIX/lib -j${CPU_COUNT}

Conda forge is a good place to find recipes and they tend to be of good quality, here are some randomly chosen ones which depend on ROOT:

If you want to add glike into conda-forge you can using the instructions at: https://conda-forge.org/#add_recipe

The actual issue is is due to the combination of ROOT’s complicated dependencies (e.g. needing a compiler a runtime) and some subtle details how how conda works. The root package is a “meta package” that contains nothing itself and just depends on root_base, root-dependencies, root-binaries and compilers. Normally installing root is the right thing however when building a new conda package you get exposed to the issues that required it to be split it up. It also allows packages that depend on ROOT to have fewer dependencies (root_numpy takes advantage of this). There is a little more detail here.

1 Like

Thanks a lot @chrisburr.

I tried your files but the error I get now, when trying to install it locally, is

(glike) cosimo [/Users/cosimo/work/test_gLike_conda]$ conda install --use-local glike 
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.
Solving environment: / 
Found conflicts! Looking for incompatible packages.
This can take several minutes.  Press CTRL-C to abort.
failed                                                                                                                                                                            

UnsatisfiableError: The following specifications were found to be incompatible with each other:

Output in format: Requested package -> Available versions

Package libcxx conflicts for:
python=3.8 -> libcxx[version='>=4.0.1']
glike -> libcxx[version='>=9.0.1']

I tried to create a new clean conda environment without any other package installed.
I guess it worked for you so it might be my OS, I am using Catalina 10.15.4.
Any clue on what could it be due?
I am trying on another OS in the meanwhile…
Thanks again!

Ok in fact it works on a Fedora 31 system,

the problem is that gLike's libraries are not uploaded into root
After I make gLike in its own repository I get gLike automatically loaded in root

(conda_root) cosimo$ root               
   ------------------------------------------------------------------
  | Welcome to ROOT 6.20/04                        https://root.cern |
  | (c) 1995-2020, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for macosx64 on Apr 01 2020, 16:23:00                      |
  | From tag , 1 April 2020                                          |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q'       |
   ------------------------------------------------------------------


Searching gLike in /Users/cosimo/work/gLike//lib/
Loading /Users/cosimo/work/gLike//lib/libgLike.so  
done.
Welcome to the gLike Root environment.
root [0]

How can I do it within the build.sh?
I’ll dig more into it, thanks for all the inputs @chrisburr.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.