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

Test building a casa-distro environment in a Conda environment #345

Open
sapetnioc opened this issue May 11, 2023 · 54 comments
Open

Test building a casa-distro environment in a Conda environment #345

sapetnioc opened this issue May 11, 2023 · 54 comments
Labels
enhancement New feature or request

Comments

@sapetnioc
Copy link
Member

Conda is a packaging system that is widely used in research (e.g. FSL is now distributed through Conda). At first sight, it seems to provide a complete self-content environment that is not limited to Python-related packages. If we succeed in building a casa-distro environment based on a Conda environment, it could make it possible to have a fully modular environment that would be highly compatible with a standard packaging system of the Python community.

The first thing to do could be to start from a Miniforge environment and build our software on the top of it without using a container. If it is successful, we would have the possibility to build conda package for a specific system and to bring Apptainer in the game as a minimal read-only base system using a read-write conda environment.

@sapetnioc
Copy link
Member Author

I have been able to build an environment from scratch (using an AppTainer container) and install dependencies mainly with Mamba (C++ implementation of Conda packaging system). Not counting sources download, the whole process to get ready to start bv_maker takes 4 minute on my laptop (it was 8 minutes before I switch to Mamba). There are some packages missing (tensorflow for instance) but is it fast anyway.

I am stuck with PyQt configuration in CMake since there is no sip executable. There is a sip package that is meant to build PyQt extensions using *.sip files but it does not provide the command. Instead, it follows PEP 517 and PEP 518 specifications that defines a build system for Python. I found a few information in this page. I do not know yet if it will be possible to adapt our compilation code to this system.

It is possible to test my very experimental build system. There is a recipe here.

@denisri
Copy link
Contributor

denisri commented May 22, 2023

In sip >= 6, the sip command is not sip any longer, but is replaced with several ones, sip-build, sip-distinfo, sip-install, sip-module, sip-sdist, sip-wheel. Outside a conda environment, they are installed via the pip package sip, but I don't know if they are packages the same way in condaforge.
I have started adaptations of the build system for sip6/Qt6 in the experimental containers casa-dev-5.4, based on the pip packages. I think sip6 can also build for Qt5/PyQt5 (I have not tried, I wanted to port to Qt6/PyQt6), and the builds seem to work provided changes in LD_LIBRARY_PATH to use the Qt libs in the pip packages at runtime. But this setup is still hybrid because it builds C++ sources with the system Qt6, and sip bindings with the pip install of Qt6. Anyway I have done the adaptations for both sip6 and Qt6 and have assumed using sip6 for Qt6, thus in bv_maker.cfg you switch to it using cmake_options += -DDESIRED_QT_VERSION=6. Maybe using this in your new dev environment would be a path to the solution.
But the other critical point then is: could you use the Qt libs and includes installed in conda with cmake/bv_maker for C++ code (not speaking of sip and PyQt) ? If yes I guess we are close to the solution...

@sapetnioc
Copy link
Member Author

I am pleased to hear that because these sip-* commands are installed. I cannot answer your question yet but what I know is encouraging:

  • Qt related executables are found in CMakeCache.txt
  • Qt libraries are installed in the lib directory of conda
  • Qt include files are in conda's include/qt
  • In the container, finding Qt5Core with pkg-config return the following lines for --cflags and --libs:
-DQT_CORE_LIB -I/casa/conda/include/qt/QtCore -I/casa/conda/include/qt
-L/casa/conda/lib -lQt5Core

@denisri
Copy link
Contributor

denisri commented May 22, 2023

This looks good... except that bv_maker handles sip6 with Qt6 only for now.

@sapetnioc
Copy link
Member Author

I do not see PyQt6 packaged in conda-forge but there are older sip packages. I installed version 4.19.25 that installed. Now I have to find a way to install pyqt without upgrading sip, there is a pyqt5-sip package, let's try.

sapetnioc added a commit that referenced this issue May 22, 2023
@denisri
Copy link
Contributor

denisri commented May 22, 2023

There was a bug in sip 4.19.x which caused crashes in our programs. The bug has been fixed, but not in the 4.x branch which is considered obsolete by the author. That's why we had to rebuild and reinstall a version 4.19.15 (prior to the bug), and rebuild PyQt using it, in our apptainer images. So sip4 packages will certainly cause problems. Plus they are probably not compatible with recent PyQt binary distributions. At this point we should use sip6, and either jump to Qt6, or finish adapting bv_maker to build with Qt5 and sip6.

@sapetnioc
Copy link
Member Author

Well, after some fighting, I had been able to finish a bv_maker configure and to start a compilation.

@denisri
Copy link
Contributor

denisri commented May 22, 2023

Great ! Using which sip ?

@sapetnioc
Copy link
Member Author

The bad one. But I am stuck on a compilation error on aims-free that may be due to a change in gcc (12.2.0 in conda-forge). I am writing an issue in aims-free and I am also rewriting the scripts to download end build everything (and get the error). I tried to download the source separately with git submodules but it is not appropriate, I will just make a script for now.

sapetnioc added a commit that referenced this issue May 22, 2023
sapetnioc added a commit that referenced this issue May 22, 2023
@sapetnioc
Copy link
Member Author

Anatomis is being compiled ! There will be problems due to sip but this is very promising. And the time to be able to launch bv_maker from scratch is less than 4 minutes in Neurospin. It seems that network bandwidth plays an important role here since it took me more than 20 minutes this week-end with a slower connection (but same laptop).

@denisri
Copy link
Contributor

denisri commented May 22, 2023

So we have to distinguish between sip6 and Qt6 in brainvisa-cmake in order to build for sip6+Qt5.

denisri added a commit to brainvisa/brainvisa-cmake that referenced this issue May 22, 2023
allows to select sip6 with Qt5. Not tested bewond that...
(brainvisa/casa-distro#345)
denisri added a commit to brainvisa/brainvisa-cmake that referenced this issue May 22, 2023
allows to select sip6 with Qt5. Not tested bewond that...
(brainvisa/casa-distro#345)
@denisri
Copy link
Contributor

denisri commented May 22, 2023

I have pushed an experimental change to allow to switch to sip6 while using Qt5. In bv_maker.cfg, add the line:

  cmake_options += -DDESIRED_QT_VERSION=5 -DDESIRED_SIP_VERSION=6

I have not tested beyond the selection of sip6 and PyQt5 in the CMakeCache.txt because I don't have a conda environment yet, and pip doesn't provide dev headers for Qt (but it's the same situation for PyQt6 so I could build and test a mixed-up build using the system Qt5 and runtime of PyQt5).

@sapetnioc
Copy link
Member Author

I will give a try to your solution for sip 6. However, I am stuck on a problem that may be difficult to solve. There is one library that I had to install with apt and not from conda-forge: libGL.so. This causes two problems:

  1. CMake cannot find the library. I do not know exactly why yet but this is something we can handle.
  2. If I copy/paste the linking command and add manually the libraries missed by CMake (libGL.so.1 and libGLX.so.0), I get undefined symbols both from OpenGL and glibc :
Apptainer> cd /casa/build/build_files/aims-free/aimsgui/src
Apptainer> /casa/conda/bin/c++ -O3 -DNDEBUG CMakeFiles/AimsAttributedViewer.dir/AimsAttributedViewer/attributedViewer.cc.o -o ../../../../bin/AimsAttributedViewer  -Wl,-rpath,/casa/build/lib: ../../../../lib/libaimsgui.so.5.2.0 /casa/conda/lib/libQt5Widgets.so.5.15.8 /casa/conda/lib/libQt5Gui.so.5.15.8 /casa/conda/lib/libQt5Sql.so.5.15.8 /casa/conda/lib/libQt5Core.so.5.15.8 ../../../../lib/libaimsdata.so.5.2.0 ../../../../lib/libgraph.so.5.2.0 ../../../../lib/libcartodata.so.5.2.0 ../../../../lib/libsoma-io.so.5.2.0 /usr/lib/x86_64-linux-gnu/libGL.so.1 /usr/lib/x86_64-linux-gnu/libGLX.so.0 -ldl ../../../../lib/libcartobase.so.5.2.0 ../../../../lib/libcartobase_1.so.5.2.0 ../../../../lib/libcartobase_0.so.5.2.0 /casa/conda/lib/libxml2.so /casa/conda/lib/libsigc-2.0.so -lm -lpthread
/casa/conda/bin/../lib/gcc/x86_64-conda-linux-gnu/12.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: warning: libGLdispatch.so.0, needed by /usr/lib/x86_64-linux-gnu/libGL.so.1, not found (try using -rpath or -rpath-link)
/casa/conda/bin/../lib/gcc/x86_64-conda-linux-gnu/12.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libGLX.so.0: undefined reference to `__glDispatchDestroyTable'
/casa/conda/bin/../lib/gcc/x86_64-conda-linux-gnu/12.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libGLX.so.0: undefined reference to `__glDispatchGetABIVersion'
/casa/conda/bin/../lib/gcc/x86_64-conda-linux-gnu/12.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libGLX.so.0: undefined reference to `__glDispatchCreateTable'
/casa/conda/bin/../lib/gcc/x86_64-conda-linux-gnu/12.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libGL.so.1: undefined reference to `__glDispatchFini'
/casa/conda/bin/../lib/gcc/x86_64-conda-linux-gnu/12.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libGLX.so.0: undefined reference to `dlclose@GLIBC_2.34'
/casa/conda/bin/../lib/gcc/x86_64-conda-linux-gnu/12.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libGL.so.1: undefined reference to `__glDispatchRegisterStubCallbacks'
/casa/conda/bin/../lib/gcc/x86_64-conda-linux-gnu/12.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libGLX.so.0: undefined reference to `__glDispatchLoseCurrent'
/casa/conda/bin/../lib/gcc/x86_64-conda-linux-gnu/12.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libGLX.so.0: undefined reference to `dlopen@GLIBC_2.34'
/casa/conda/bin/../lib/gcc/x86_64-conda-linux-gnu/12.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: /casa/conda/lib/libQt5Widgets.so.5.15.8: undefined reference to `memcpy@GLIBC_2.14'
/casa/conda/bin/../lib/gcc/x86_64-conda-linux-gnu/12.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libGL.so.1: undefined reference to `__glDispatchUnregisterStubCallbacks'
/casa/conda/bin/../lib/gcc/x86_64-conda-linux-gnu/12.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libGLX.so.0: undefined reference to `__glDispatchNewVendorID'
/casa/conda/bin/../lib/gcc/x86_64-conda-linux-gnu/12.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: /casa/conda/lib/libQt5Core.so.5.15.8: undefined reference to `getauxval@GLIBC_2.16'
/casa/conda/bin/../lib/gcc/x86_64-conda-linux-gnu/12.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libGLX.so.0: undefined reference to `__glDispatchForceUnpatch'
/casa/conda/bin/../lib/gcc/x86_64-conda-linux-gnu/12.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libGL.so.1: undefined reference to `_glapi_tls_Current'
/casa/conda/bin/../lib/gcc/x86_64-conda-linux-gnu/12.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libGLX.so.0: undefined reference to `__glDispatchGetCurrentThreadState'
/casa/conda/bin/../lib/gcc/x86_64-conda-linux-gnu/12.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libGLX.so.0: undefined reference to `__glDispatchCheckMultithreaded'
/casa/conda/bin/../lib/gcc/x86_64-conda-linux-gnu/12.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: /casa/conda/lib/libQt5Core.so.5.15.8: undefined reference to `clock_gettime@GLIBC_2.17'
/casa/conda/bin/../lib/gcc/x86_64-conda-linux-gnu/12.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libGLX.so.0: undefined reference to `dlsym@GLIBC_2.34'
/casa/conda/bin/../lib/gcc/x86_64-conda-linux-gnu/12.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libGLX.so.0: undefined reference to `__glDispatchMakeCurrent'
/casa/conda/bin/../lib/gcc/x86_64-conda-linux-gnu/12.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libGL.so.1: undefined reference to `__glDispatchInit'
/casa/conda/bin/../lib/gcc/x86_64-conda-linux-gnu/12.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libGLX.so.0: undefined reference to `__glDispatchGetProcAddress'
/casa/conda/bin/../lib/gcc/x86_64-conda-linux-gnu/12.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: /usr/lib/x86_64-linux-gnu/libGLX.so.0: undefined reference to `__glDispatchReset'
collect2: error: ld returned 1 exit status

For glibc, I will try to find-out what kind of system is used to build conda-forge packages (I suspect it is CentOS 6 or 7). Using a system with a more recent Ubuntu may solve some glibc problems. There are so few system dependencies (wget, build-essential, distro-info-data and libgl1-mesa-dev) that it is not impossible to switch to a non Debian system if it is more compatible with conda-forge.

@denisri
Copy link
Contributor

denisri commented May 23, 2023

For sip6 at least in pip installs of PyQt5, there is a mismatch in sip ABI versions of the module lib and includes (well I'm not sure yet of what happens, I'm still struggling with it). So if it doesn't work straight for you, hold on...

For libGL, it is needed by Qt5 (libQt5Gui.so links against OpenGL) so the library has to be present on the system anyway.
"Modern" versions of libGL on linux are using a switch library called "gldispatch", which goal is to redirect GL calls to the correct implementation (hardware, software, nvidia...). I guess you also have to link against it if you are linking with a libGL which implements this switch mechanism. But CMake should be able to handle it, as we are using it in our libraries for many years. You are probably missing a dev package.
On Ubuntui 22.04 we have libgl-dev, libglx-dev, libglu1-mesa-dev. libGLdispatch.so is part of the package libglvnd0, and should be installed as a dependency of libgl I guess.

@denisri
Copy link
Contributor

denisri commented May 23, 2023

I can't make it work using pip installs. There seems to be a discrepancy between the sip runtime module and the sip-build tool. I can compile pyaims but not run it, it fails with a sip ABI mismatch error. By the way I have discovered the existence of sip5 which doesn't appear on riverbankcomputing site... and it did not work any better. I'm giving up. Hope you're more lucky using conda.

@sapetnioc
Copy link
Member Author

Well, not really. On the OpenGL side I still have undefined symbols (I got rid of glibc symbols using CentOS 7 but got other problems) but as you can see in CMake log below, I can try to add option to use GLVND. I can also try your suggestion to find a gldispatch library. On the sip side, I switched back to sip 6 merged your mods but there are two errors in bv_maker configure:

  • one in FindSIP.cmake because there is no sipconfig module (I am still looking for a package for it), there is only a sipbuild for now.
  • The other in maketemplates.py because there is no sipcommand installed.
=== now configuring all other projects ===
$ cmake -DDESIRED_QT_VERSION=5 -DDESIRED_SIP_VERSION=6 -DCMAKE_BUILD_TYPE:STRING=Release -DBRAINVISA_CMAKE_BUILD_TYPE=no-brainvisa-cmake /casa/build
-- Add specific paths for Ubuntu distribution
-- Configuring component brainvisa-cmake from source directory "/casa/src/brainvisa-cmake"
-- Configuring component casa-distro from source directory "/casa/build/build_files/casa-distro_src"
-- Configuring component brainvisa-share from source directory "/casa/src/brainvisa-share"
-- Found PythonInterp: /casa/conda/bin/python3 (Required is at least version "2") 
-- Configuring component soma-base from source directory "/casa/src/soma-base"
-- Configuring component soma-io from source directory "/casa/src/soma-io"
-- Checking for one of the modules 'openslide'
-- Configuring component soma-workflow from source directory "/casa/src/soma-workflow"
-- LibDRMAA was not found.
-- Configuring component capsul from source directory "/casa/build/build_files/capsul_src"
-- Configuring component populse_db from source directory "/casa/build/build_files/populse_db_src"
-- Configuring component aims-free from source directory "/casa/src/aims-free"
-- Checking for one of the modules 'openslide'
-- Found PythonInterp: /casa/conda/bin/python3  
CMake Deprecation Warning at /casa/src/aims-free/aimsgui/src/CiftiLib-1.5.1/CMakeLists.txt:7 (CMAKE_POLICY):
  The OLD behavior for policy CMP0045 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


RUN MAKETEMPLATES: /casa/conda/bin/python3;/casa/build/share/aims-5.2/sip/maketemplates.py;-i;/casa/src/aims-free/pyaims/src/sip/generatedtypes.py;-p;/casa/src/aims-free/pyaims/src/sip;-o;/casa/build/share/aims-5.2/sip;-t;/casa/src/aims-free/pyaims/src/sip/typessub.py;-l;-m;/casa/conda/bin/moc;-P;cpp -C;-D;SIP_MODULE="PyQt5.sip"
Traceback (most recent call last):
  File "/casa/build/share/aims-5.2/sip/maketemplates.py", line 159, in <module>
    six.exec_(code, globals(), globals())
  File "/casa/src/aims-free/pyaims/src/sip/generatedtypes.py", line 36, in <module>
    import sip
ModuleNotFoundError: No module named 'sip'
CMake Error at /casa/src/aims-free/pyaims/src/sip/CMakeLists.txt:48 (message):
  The sip generation from pyaims templates failed.  Command:



  returned output:



  ========================


Traceback (most recent call last):
  File "/casa/build/share/aims-5.2/sip/maketemplates.py", line 172, in <module>
    six.exec_(code, globals(), globals())
  File "/casa/src/aims-free/pyaims/src/sip/typessub.py", line 37, in <module>
    import sip
ModuleNotFoundError: No module named 'sip'
CMake Error at /casa/src/aims-free/pyaimsalgo/src/sip/CMakeLists.txt:27 (message):
  The sip generation from pyaimsalgo templates with
  "/casa/build/share/aims-5.2/sip/maketemplates.py" returned an error:



-- Configuring component aims-gpl from source directory "/casa/src/aims-gpl"
-- Checking for one of the modules 'openslide'
Traceback (most recent call last):
  File "/casa/build/share/brainvisa-cmake-5.2/cmake/modules/FindPyQt.py", line 110, in <module>
    sip_dir = get_default_sip_dir()
  File "/casa/build/share/brainvisa-cmake-5.2/cmake/modules/FindPyQt.py", line 44, in get_default_sip_dir
    import sipconfig
ModuleNotFoundError: No module named 'sipconfig'
CMake Error at /casa/src/aims-gpl/pyaimsgui/src/sip_gui/CMakeLists.txt:28 (message):
  The sip generation from pyaimsgui templates with
  "/casa/build/share/aims-5.2/sip/maketemplates.py" returned an error:

  Traceback (most recent call last):

    File "/casa/build/share/aims-5.2/sip/maketemplates.py", line 172, in <module>
      six.exec_(code, globals(), globals())
    File "/casa/build/share/aims-5.2/sip/typessub.py", line 37, in <module>
      import sip

  ModuleNotFoundError: No module named 'sip'

  ========================


Warning: file "/casa/src/aims-gpl/pyaimsgui/src/sip_gui/Traceback (most recent call last):
  File "/casa/build/share/aims-5.2/sip/maketemplates.py", line 172, in <module>
    six.exec_(code, globals(), globals())
  File "/casa/build/share/aims-5.2/sip/typessub.py", line 37, in <module>
    import sip
ModuleNotFoundError: No module named 'sip'" does not exists
-- Configuring component anatomist-free from source directory "/casa/src/anatomist-free"
-- Checking for one of the modules 'openslide'
CMake Warning (dev) at /casa/conda/share/cmake-3.26/Modules/FindOpenGL.cmake:315 (message):
  Policy CMP0072 is not set: FindOpenGL prefers GLVND by default when
  available.  Run "cmake --help-policy CMP0072" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  FindOpenGL found both a legacy GL library:

    OPENGL_gl_LIBRARY: /usr/lib/x86_64-linux-gnu/libGL.so

  and GLVND libraries for OpenGL and GLX:

    OPENGL_opengl_LIBRARY: /usr/lib/x86_64-linux-gnu/libOpenGL.so
    OPENGL_glx_LIBRARY: /usr/lib/x86_64-linux-gnu/libGLX.so

  OpenGL_GL_PREFERENCE has not been set to "GLVND" or "LEGACY", so for
  compatibility with CMake 3.10 and below the legacy GL library will be used.
Call Stack (most recent call first):
  /casa/src/anatomist-free/CMakeLists.txt:8 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Qwt was not found.
VTK5 and Qt5+ are not supported. The VTK plugin is disabled.
WARNING: anatomist modules anaroibase and anahistogram will not be build because Qwt library has not been found
WARNING: anatomist modules anavtk will not be build because VTK or vtkINRIA3D library has not been found
-- Configuring component anatomist-gpl from source directory "/casa/src/anatomist-gpl"
-- Checking for one of the modules 'openslide'
-- Checking for one of the modules 'openslide'
CMake Warning (dev) at /casa/conda/share/cmake-3.26/Modules/FindOpenGL.cmake:315 (message):
  Policy CMP0072 is not set: FindOpenGL prefers GLVND by default when
  available.  Run "cmake --help-policy CMP0072" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  FindOpenGL found both a legacy GL library:

    OPENGL_gl_LIBRARY: /usr/lib/x86_64-linux-gnu/libGL.so

  and GLVND libraries for OpenGL and GLX:

    OPENGL_opengl_LIBRARY: /usr/lib/x86_64-linux-gnu/libOpenGL.so
    OPENGL_glx_LIBRARY: /usr/lib/x86_64-linux-gnu/libGLX.so

  OpenGL_GL_PREFERENCE has not been set to "GLVND" or "LEGACY", so for
  compatibility with CMake 3.10 and below the legacy GL library will be used.
Call Stack (most recent call first):
  share/anatomist-free-5.2/cmake/anatomist-free-config.cmake:65 (find_package)
  share/brainvisa-cmake-5.2/cmake/brainvisa-cmake-config.cmake:259 (find_package)
  /casa/src/anatomist-gpl/CMakeLists.txt:6 (BRAINVISA_FIND_PACKAGE)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Qwt was not found.
Traceback (most recent call last):
  File "/casa/build/share/brainvisa-cmake-5.2/cmake/modules/FindPyQt.py", line 110, in <module>
    sip_dir = get_default_sip_dir()
  File "/casa/build/share/brainvisa-cmake-5.2/cmake/modules/FindPyQt.py", line 44, in get_default_sip_dir
    import sipconfig
ModuleNotFoundError: No module named 'sipconfig'
WARNING: Not building pyanatomist due to missing dependency:
  PYTHON_FOUND=TRUE
SIP_FOUND=TRUE
NUMPY_FOUND=TRUE
PYQT5_FOUND=

-- Configuring component axon from source directory "/casa/src/axon"
-- Checking for one of the modules 'openslide'
Traceback (most recent call last):
  File "/casa/build/share/brainvisa-cmake-5.2/cmake/modules/FindPyQt.py", line 110, in <module>
    sip_dir = get_default_sip_dir()
  File "/casa/build/share/brainvisa-cmake-5.2/cmake/modules/FindPyQt.py", line 44, in get_default_sip_dir
    import sipconfig
ModuleNotFoundError: No module named 'sipconfig'
SIP VERSION: 6.7.9
-- Configuring component brainvisa-spm from source directory "/casa/src/brainvisa-spm"
-- Configuring component highres-cortex from source directory "/casa/src/highres-cortex"
-- Checking for one of the modules 'openslide'
-- Found OpenMP: TRUE (found version "4.5")  
-- Configuring component morphologist-nonfree from source directory "/casa/src/morphologist-nonfree"
-- Checking for one of the modules 'openslide'
-- Checking for one of the modules 'openslide'
-- Configuring component morphologist-gpl from source directory "/casa/src/morphologist-gpl"
-- Checking for one of the modules 'openslide'
-- Configuring component morphologist-baby from source directory "/casa/src/morphologist-baby"
-- Checking for one of the modules 'openslide'
-- Checking for one of the modules 'openslide'
-- Configuring component sulci-nonfree from source directory "/casa/src/sulci-nonfree"
-- Checking for one of the modules 'openslide'
-- Could NOT find SWIG (missing: SWIG_EXECUTABLE SWIG_DIR) 
Traceback (most recent call last):
  File "/casa/build/share/aims-5.2/sip/maketemplates.py", line 172, in <module>
    six.exec_(code, globals(), globals())
  File "/casa/build/share/aims-5.2/sip/typessub.py", line 37, in <module>
    import sip
ModuleNotFoundError: No module named 'sip'
CMake Error at /casa/src/sulci-nonfree/pysigraph/src/sip/CMakeLists.txt:29 (message):
  The sip generation from sulci-nonfree templates with
  "/casa/build/share/aims-5.2/sip/maketemplates.py" returned an error:



  ========================


-- Checking for one of the modules 'openslide'
CMake Warning (dev) at /casa/conda/share/cmake-3.26/Modules/FindOpenGL.cmake:315 (message):
  Policy CMP0072 is not set: FindOpenGL prefers GLVND by default when
  available.  Run "cmake --help-policy CMP0072" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  FindOpenGL found both a legacy GL library:

    OPENGL_gl_LIBRARY: /usr/lib/x86_64-linux-gnu/libGL.so

  and GLVND libraries for OpenGL and GLX:

    OPENGL_opengl_LIBRARY: /usr/lib/x86_64-linux-gnu/libOpenGL.so
    OPENGL_glx_LIBRARY: /usr/lib/x86_64-linux-gnu/libGLX.so

  OpenGL_GL_PREFERENCE has not been set to "GLVND" or "LEGACY", so for
  compatibility with CMake 3.10 and below the legacy GL library will be used.
Call Stack (most recent call first):
  share/anatomist-free-5.2/cmake/anatomist-free-config.cmake:65 (find_package)
  share/brainvisa-cmake-5.2/cmake/brainvisa-cmake-config.cmake:259 (find_package)
  /casa/src/sulci-nonfree/CMakeLists.txt:35 (BRAINVISA_FIND_PACKAGE)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Qwt was not found.
-- Configuring component morphologist-ui from source directory "/casa/src/morphologist"
-- Checking for one of the modules 'openslide'
-- Checking for one of the modules 'openslide'
CMake Warning (dev) at /casa/conda/share/cmake-3.26/Modules/FindOpenGL.cmake:315 (message):
  Policy CMP0072 is not set: FindOpenGL prefers GLVND by default when
  available.  Run "cmake --help-policy CMP0072" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  FindOpenGL found both a legacy GL library:

    OPENGL_gl_LIBRARY: /usr/lib/x86_64-linux-gnu/libGL.so

  and GLVND libraries for OpenGL and GLX:

    OPENGL_opengl_LIBRARY: /usr/lib/x86_64-linux-gnu/libOpenGL.so
    OPENGL_glx_LIBRARY: /usr/lib/x86_64-linux-gnu/libGLX.so

  OpenGL_GL_PREFERENCE has not been set to "GLVND" or "LEGACY", so for
  compatibility with CMake 3.10 and below the legacy GL library will be used.
Call Stack (most recent call first):
  share/anatomist-free-5.2/cmake/anatomist-free-config.cmake:65 (find_package)
  share/brainvisa-cmake-5.2/cmake/brainvisa-cmake-config.cmake:259 (find_package)
  share/anatomist-gpl-5.2/cmake/anatomist-gpl-config.cmake:36 (BRAINVISA_FIND_PACKAGE)
  share/brainvisa-cmake-5.2/cmake/brainvisa-cmake-config.cmake:259 (find_package)
  /casa/src/morphologist/CMakeLists.txt:7 (BRAINVISA_FIND_PACKAGE)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Qwt was not found.
-- Configuring component morpho-deepsulci from source directory "/casa/src/morpho-deepsulci"
-- Checking for one of the modules 'openslide'
-- Checking for one of the modules 'openslide'
-- Configuring component brainrat-gpl from source directory "/casa/src/brainrat-gpl"
-- Checking for one of the modules 'openslide'
-- Configuring component brainrat-private from source directory "/casa/src/brainrat-private"
-- Checking for one of the modules 'openslide'
-- Configuring component bioprocessing from source directory "/casa/src/bioprocessing"
-- Found OpenMP: TRUE (found version "4.5")  
-- Checking for one of the modules 'openslide'
-- Configuring component preclinical-imaging-iam from source directory "/casa/src/preclinical-imaging-iam"
-- Configuring component primatologist-gpl from source directory "/casa/src/primatologist-gpl"
-- Checking for one of the modules 'openslide'
-- Configuring component 3dns-private from source directory "/casa/src/3dns-private"
CMake Deprecation Warning at /casa/src/3dns-private/CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- Checking for one of the modules 'openslide'
-- Configuring component constellation-gpl from source directory "/casa/src/constellation-gpl"
-- Configuring component constellation-nonfree from source directory "/casa/src/constellation-nonfree"
-- Checking for one of the modules 'openslide'
-- Checking for one of the modules 'openslide'
CMake Warning (dev) at /casa/conda/share/cmake-3.26/Modules/FindOpenGL.cmake:315 (message):
  Policy CMP0072 is not set: FindOpenGL prefers GLVND by default when
  available.  Run "cmake --help-policy CMP0072" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  FindOpenGL found both a legacy GL library:

    OPENGL_gl_LIBRARY: /usr/lib/x86_64-linux-gnu/libGL.so

  and GLVND libraries for OpenGL and GLX:

    OPENGL_opengl_LIBRARY: /usr/lib/x86_64-linux-gnu/libOpenGL.so
    OPENGL_glx_LIBRARY: /usr/lib/x86_64-linux-gnu/libGLX.so

  OpenGL_GL_PREFERENCE has not been set to "GLVND" or "LEGACY", so for
  compatibility with CMake 3.10 and below the legacy GL library will be used.
Call Stack (most recent call first):
  share/anatomist-free-5.2/cmake/anatomist-free-config.cmake:65 (find_package)
  /casa/src/constellation-nonfree/CMakeLists.txt:24 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Qwt was not found.
-- Configuring component cortical_surface-nonfree from source directory "/casa/src/cortical_surface-nonfree"
-- Checking for one of the modules 'openslide'
-- Configuring component cortical_surface-gpl from source directory "/casa/src/cortical_surface-gpl"
-- Configuring component brainvisa_freesurfer from source directory "/casa/src/brainvisa_freesurfer"
Traceback (most recent call last):
  File "/casa/build/share/brainvisa-cmake-5.2/cmake/modules/FindPyQt.py", line 110, in <module>
    sip_dir = get_default_sip_dir()
  File "/casa/build/share/brainvisa-cmake-5.2/cmake/modules/FindPyQt.py", line 44, in get_default_sip_dir
    import sipconfig
ModuleNotFoundError: No module named 'sipconfig'
-- Configuring component nuclear_imaging-gpl from source directory "/casa/src/nuclear_imaging-gpl"
-- Configuring component nuclear_imaging-nonfree from source directory "/casa/src/nuclear_imaging-nonfree"
-- Checking for one of the modules 'openslide'
-- Configuring component catidb-client from source directory "/casa/build/build_files/catidb-client_src"
-- Configuring component sacha-nonfree from source directory "/casa/src/sacha-nonfree"
-- Checking for one of the modules 'openslide'
-- Configuring component sacha-gpl from source directory "/casa/src/sacha-gpl"
-- Configuring component whasa-nonfree from source directory "/casa/src/whasa-nonfree"
-- Checking for one of the modules 'openslide'
-- Configuring component whasa-gpl from source directory "/casa/src/whasa-gpl"
-- Configuring component longitudinal_pipelines from source directory "/casa/src/longitudinal_pipelines"
-- Checking for one of the modules 'openslide'
-- Configuring component disco from source directory "/casa/src/brainvisa-disco"
-- Checking for one of the modules 'openslide'
-- Checking for one of the modules 'openslide'
-- Checking for one of the modules 'openslide'
CMake Warning (dev) at /casa/conda/share/cmake-3.26/Modules/FindOpenGL.cmake:315 (message):
  Policy CMP0072 is not set: FindOpenGL prefers GLVND by default when
  available.  Run "cmake --help-policy CMP0072" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  FindOpenGL found both a legacy GL library:

    OPENGL_gl_LIBRARY: /usr/lib/x86_64-linux-gnu/libGL.so

  and GLVND libraries for OpenGL and GLX:

    OPENGL_opengl_LIBRARY: /usr/lib/x86_64-linux-gnu/libOpenGL.so
    OPENGL_glx_LIBRARY: /usr/lib/x86_64-linux-gnu/libGLX.so

  OpenGL_GL_PREFERENCE has not been set to "GLVND" or "LEGACY", so for
  compatibility with CMake 3.10 and below the legacy GL library will be used.
Call Stack (most recent call first):
  share/anatomist-free-5.2/cmake/anatomist-free-config.cmake:65 (find_package)
  share/brainvisa-cmake-5.2/cmake/brainvisa-cmake-config.cmake:259 (find_package)
  /casa/src/brainvisa-disco/CMakeLists.txt:45 (BRAINVISA_FIND_PACKAGE)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Qwt was not found.
-- Configuring component qualicati from source directory "/casa/build/build_files/qualicati_src"
-- Configuring component deidentification from source directory "/casa/build/build_files/deidentification_src"
-- Configuring component rsfmri from source directory "/casa/build/build_files/rsfmri_src"
-- Configuring incomplete, errors occurred!
Traceback (most recent call last):
  File "/casa/build/python/brainvisa_cmake/commands.py", line 68, in process
    logs = getattr(o, method)(*meth_args,
  File "/casa/build/python/brainvisa_cmake/build.py", line 606, in configure
    system(cwd=self.directory,
  File "/casa/build/python/brainvisa_cmake/subprocess.py", line 59, in system
    six.reraise(*error)
  File "/casa/conda/lib/python3.10/site-packages/six.py", line 718, in reraise
    raise value.with_traceback(tb)
  File "/casa/build/python/brainvisa_cmake/subprocess.py", line 48, in system
    raise OSError()
OSError: Command failed: 'cmake' '-DDESIRED_QT_VERSION=5' '-DDESIRED_SIP_VERSION=6' '-DCMAKE_BUILD_TYPE:STRING=Release' '-DBRAINVISA_CMAKE_BUILD_TYPE=no-brainvisa-cmake' '/casa/build'
From directory: /casa/build

@sapetnioc
Copy link
Member Author

I think the FindSIP.cmake problem was due to brainvisa-cmake that was run from build tree and not correctly updated.

@sapetnioc
Copy link
Member Author

sapetnioc commented May 26, 2023

I edited my previous post, I wrote Py_ssize_t instead of Py_hash_t.

@denisri
Copy link
Contributor

denisri commented May 26, 2023

I don't remember exactly but I think the typedef was here because depending on sip/abi/python versions it was not defined as the same type: long may not work with all sip versions. You can try like this, but I think we would need to find another solution later.
Why does the typedef thing not work ?

The errors you get seem to mean (to me) that there is a discrepency between the sip ABI / sip.h file, and the generated code.
In FindSIP.cmake, did you also uncomment the lines:

            ## not taken into account by sip-build, so it is useless and breaks
            # set( _added_flags "--abi-version" "${SIP_ABI}" )

If not, you should ;)

@sapetnioc
Copy link
Member Author

It is working !

I now have to fix OpenGL for libanatomist. By the way, I noticed that the generation of sip files is now slow and always done twice when running make. We will probably have to look at his old known problem.

@denisri
Copy link
Contributor

denisri commented May 26, 2023

Wondeful !!
So there will be a conda package for pyanatomist ?? ;) 8)

@sapetnioc
Copy link
Member Author

If it goes to the end of the build (it is a bit long because everything is compiles each time I make a change in any CMakeLists.txt) it will be possible to package all our software. But I let others handle the Windows and Mac platforms...

@sapetnioc
Copy link
Member Author

image
We are getting close to the end !

For OpenGL compilation, I had to do two things:

  • To avoid conflict with existinf CMake modules, I introduced two CMake variables that must be used whenever compiling Qt/OpenGL code (in aims-free and anatomist-free): OPENGL_FIX_LIBRARY_DIRECTORIES and OPENGL_FIX_LIBRARIES.
  • To make anatomist work from build tree, I asked linker to use RUNPATH instead of RPATH because it leaves the priority to LD_LIBRARY_PATH whereas RPATH takes precedence over it. This is simply done by adding linker flag --enable-new-dtags. To date, I defined it specifically for Conda in bv_maker.cfg but we may put it in brainvisa-cmake.

I still have a sip compilation problem in Axon:

[ 61%] Generating sipbuild/somaqt/sipsomaqtpart0.cpp, sipbuild/somaqt/sipsomaqtpart1.cpp, sipbuild/somaqt/sipsomaqtpart2.cpp, sipbuild/somaqt/sipsomaqtpart3.cpp, sipbuild/somaqt/sipsomaqtpart4.cpp, sipbuild/somaqt/sipsomaqtpart5.cpp, sipbuild/somaqt/sipsomaqtpart6.cpp, sipbuild/somaqt/sipsomaqtpart7.cpp
cd /home/yann/casaconda/build/build_files/axon/src/sipsomaqt && /home/yann/casaconda/build/bin/bv_sip4make -S /home/yann/casaconda/conda/bin/sip-build -c /home/yann/casaconda/build/build_files/axon/src/sipsomaqt/sipbuild/somaqt -j 8 --no-compile
These bindings will be built: soma_qt6.
Generating the soma_qt6 bindings...
sip-build: /home/yann/casaconda/conda/lib/python3.10/site-packages/PyQt5/bindings/QtCore/QtCoremod.sip: line 27: column 1: 'WS_X11' has already been defined as a qualifier
/home/yann/casaconda/conda/lib/python3.10/site-packages/PyQt5/bindings/QtCore/QtCoremod.sip: line 27: column 1: 'WS_WIN' has already been defined as a qualifier
Error: sip exited with signal 1
make[2]: *** [build_files/axon/src/sipsomaqt/CMakeFiles/somaqt.dir/build.make:81 : build_files/axon/src/sipsomaqt/sipbuild/somaqt/sipsomaqtpart0.cpp] Erreur 1

This is probably due to the use of soma_qt6.sip. It looks that this test uses the wrong variable (sip instead of PyQt).

@denisri
Copy link
Contributor

denisri commented May 30, 2023

Yes, probaby. Can you try using QT_VERSION instead of SIP_VERSION ? I'm not sure where these variables are defined (or not defined)...

@sapetnioc
Copy link
Member Author

This is it. The recipe given in this page allowed me to compile everything from scratch.

Since OpenGL is the only dependency, the resulting directory may be used "as is" in another system. To be tested...

The directory size is 12 Gb including 3.6 Gb for src, 1.4 Gb for build and 6.8 Gb for Conda. This is quite good since my casa-distro development environment is 16Go not including Apptainer image. Moreover, conda/pkgs is 3.1 Gb and seems to contain packages cache (it could be removed from distribution).

Next may be:

  • Try to copy and use the build environment directory on other Linux systems. I will try on Windows/WSL2/Ubuntu.
  • Try to compile on other environment than my laptop.
  • Make a run environment with less Conda packages and containing the result of make install

@sapetnioc
Copy link
Member Author

I had been able to create a runtime Conda environment, to launch make install-runtime in it and to run Anatomist. The final size of the directory is 6.5 Go (without doc, without Pytorch). I already found a few difficulties that we will have to deal with in order to have an easily installable Conda package.

  • Conda environment are not relocatable. For instance, there are hundreds of references to the absolute path of conda directory in bin. Possible options to overcome this problem:
    • Create packages directly installable by Conda ; either in conda-forge (open source probably required) or in our own repository
    • Use conda-pack to create an archive. For the user, it will require to install and use conda-unpack in order to have BrainVISA.
    • Keep using an AppTainer container through casa-distro. Having Conda would allow to have a writable environment. Many dependencies (such as Pytorch) could be installed from conda-forge by user (via scripts). We would not have to provide them in our distro.
  • Everything is not working. New environment means new software versions. We will have tests to do. Two example of problems:
    • An error when running anatomist (1). A module is probably missing.
    • anasimpleviewer.py cannot start (2).

(1)

Starting Anatomist.....
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'sip'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'sip' is not defined. Did you mean: 'zip'?

(2)

config.setitem: commonScannerBasedReferential : 1
controls registered.
Traceback (most recent call last):
  File "/home/yann/casaconda/install/bin/anasimpleviewer.py", line 87, in <module>
    anasimple = AnaSimpleViewer()
  File "/home/yann/casaconda/install/python/anatomist/simpleviewer/anasimpleviewer.py", line 136, in __init__
    self.init_global_handlers()
  File "/home/yann/casaconda/install/python/anatomist/simpleviewer/anasimpleviewer.py", line 241, in init_global_handlers
    a.setGraphParams(label_attribute='label')
  File "/home/yann/casaconda/install/python/anatomist/base.py", line 1261, in setGraphParams
    self.execute(
  File "/home/yann/casaconda/install/python/anatomist/direct/api.py", line 1140, in execute
    params = dict((ununderscore(k), self.convertParamsToIDs(v)) for k, v
  File "/home/yann/casaconda/install/python/anatomist/direct/api.py", line 1140, in <genexpr>
    params = dict((ununderscore(k), self.convertParamsToIDs(v)) for k, v
  File "/home/yann/casaconda/install/python/anatomist/base.py", line 1408, in convertParamsToIDs
    return self.convertSingleObjectParamsToIDs(params)
  File "/home/yann/casaconda/install/python/anatomist/direct/api.py", line 1174, in convertSingleObjectParamsToIDs
    np.float, np.float16, np.float32, np.float64,
  File "/home/yann/casaconda/install/lib/python3.10/site-packages/numpy/__init__.py", line 305, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'float'.
`np.float` was a deprecated alias for the builtin `float`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'cfloat'?
Exiting Anatomist --- Goodbye.

denisri added a commit to brainvisa/anatomist-gpl that referenced this issue Jun 1, 2023
denisri added a commit to brainvisa/anatomist-gpl that referenced this issue Jun 1, 2023
@denisri
Copy link
Contributor

denisri commented Jun 1, 2023

Point2 should be fixed but I have not reproduced point 1 yet. The sip module is not available directly as import sip any longer because several sip modules may exist in PyQt5, PyQt6 etc. It can be found in PyQt5.sip, but it depends on how it has been installed. The cmake config tries to detect the right one, and pyaims imports it, and has a function to tell which sip it has been built with. After that, sys.modules['sip'] is updated, and any later import sip should work as before. So we must find out if sip is imported before soma.aims is imported, and in which source...

sapetnioc added a commit that referenced this issue Jul 13, 2023
sapetnioc added a commit that referenced this issue Jul 13, 2023
sapetnioc added a commit that referenced this issue Jul 13, 2023
sapetnioc added a commit that referenced this issue Jul 13, 2023
sapetnioc added a commit that referenced this issue Jul 13, 2023
sapetnioc added a commit that referenced this issue Jul 13, 2023
sapetnioc added a commit that referenced this issue Aug 23, 2023
sapetnioc added a commit that referenced this issue Aug 23, 2023
sapetnioc added a commit that referenced this issue Aug 23, 2023
sapetnioc added a commit that referenced this issue Sep 6, 2023
sapetnioc added a commit that referenced this issue Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants