#-*- mode: org -*-
* DONE [3/3] fix all the scripts (wrong path) maybe the best solution is to patch the script generator.
  - [X] removed the export of LIBTBX_BUILD in order to find the installed libtbx_env file.
  - [X] fix the patch to make the script works out of the box
  - [X] install all the .sh script. (only .py scripts are install for now)
* TODO [2/3] unit test
** DONE install all tst_*.py
   some of the tst_* files are installed in the python modules
   tree. nevertheless they are not part of the modules (their
   directory does not contain an __init__.py file

   the unit test rely on the presence of these files here, so we need
   to install all of them manually.
** DONE RuntimeError: cctbx Error: MTZ file read error: tst_diffuse.mtz
   libtbx.python "/usr/lib/python3/dist-packages/cctbx/regression/tst_diffuse.py" [FAIL] 1.0s
     Time:  0.98
     Return code: 1
     OKs: 0
     Standard error:
       Traceback (most recent call last):
         File "/usr/lib/python3/dist-packages/cctbx/command_line/diffuse.py", line 183, in <module>
           run(sys.argv[1:])
         File "/usr/lib/python3/dist-packages/cctbx/command_line/diffuse.py", line 57, in run
           diffuse(
         File "/usr/lib/python3/dist-packages/cctbx/command_line/diffuse.py", line 163, in write_mtz_file
           mtz_dataset = ma.as_mtz_dataset(column_root_label="I")
         File "/usr/lib/python3/dist-packages/cctbx/miller/__init__.py", line 4805, in as_mtz_dataset
           return iotbx.mtz.miller_array_as_mtz_dataset(self,
         File "/usr/lib/python3/dist-packages/iotbx/mtz/__init__.py", line 1149, in miller_array_as_mtz_dataset
           mtz_object = object() \
         File "/usr/lib/python3/dist-packages/iotbx/mtz/__init__.py", line 268, in set_space_group_info
           symbol = extract_from_symmetry_lib.ccp4_symbol(
         File "/usr/lib/python3/dist-packages/iotbx/mtz/extract_from_symmetry_lib.py", line 59, in ccp4_symbol
           assert found_at_least_one_lib
       AssertionError
       Traceback (most recent call last):
         File "/usr/lib/python3/dist-packages/cctbx/regression/tst_diffuse.py", line 129, in <module>
           exercise()
         File "/usr/lib/python3/dist-packages/cctbx/regression/tst_diffuse.py", line 116, in exercise
           mas = iotbx.mtz.object(file_name="tst_diffuse.mtz").as_miller_arrays()
       RuntimeError: cctbx Error: MTZ file read error: tst_diffuse.mtz

       the python modules was looking for libccp4 data at the wrong place.
** TODO [0/1] missing modules
   - [ ] need to package https://github.com/ccpem/mrcfile
* TODO [0/1] annlib
  - [ ] need to deal with the self_annlib ???, which is the annlib but
    build with a different env set. Maybe the best solution would be
    to produce the second version of this annlib library from the
    annlib package.
* TODO [1/2] cpp4io
  - [ ] the ccp4c library is modifyed in order to be compiled as the
    ccp4io library. for now only use the official ccp4c library and
    see if all the unit test pass.
  - [X] thr ccp4io library is a Shared library on Debian.
* TODO libtbx_env
  the strategy is wrong other packages use a cmake findCCTBX
  script. the idea is not to chabge the libtbx_env filename but to
  install the different version under different directory.
* TODO soname
  Need to patch the library to add the soname for each of them like this
  patchelf --set-soname libnewname.so.3.4.5 path/to/libmylibrary.so.1.2.3
* TODO /usr/share/cctbx -> /urs/lib/cctbx
  the build directory contain also binaries (unit test executables)
* TODO need to link the library with the right symbols
  picca@grades-01:~/debian/science-team$ rgrep "shlibdeps: warning" cctbx_2022.9+ds2+~3.11.2+ds1-1_amd64.build | grep -v Py | grep -v "see them all" | grep -v "similar"
  dpkg-shlibdeps: warning: symbol cbf_get_value used by debian/libcctbx0/usr/lib/x86_64-linux-gnu/libcbf-private.so.0.0.1 found in none of the libraries
  dpkg-shlibdeps: warning: symbol img_read_mar345header used by debian/libcctbx0/usr/lib/x86_64-linux-gnu/libcbf-private.so.0.0.1 found in none of the libraries
  dpkg-shlibdeps: warning: symbol cbf_rewind_column used by debian/libcctbx0/usr/lib/x86_64-linux-gnu/libcbf-private.so.0.0.1 found in none of the libraries
  dpkg-shlibdeps: warning: symbol img_read_mar345data used by debian/libcctbx0/usr/lib/x86_64-linux-gnu/libcbf-private.so.0.0.1 found in none of the libraries
  dpkg-shlibdeps: warning: symbol cbf_find_column used by debian/libcctbx0/usr/lib/x86_64-linux-gnu/libcbf-private.so.0.0.1 found in none of the libraries
  dpkg-shlibdeps: warning: symbol cbf_rewind_row used by debian/libcctbx0/usr/lib/x86_64-linux-gnu/libcbf-private.so.0.0.1 found in none of the libraries
  dpkg-shlibdeps: warning: symbol img_get_field used by debian/libcctbx0/usr/lib/x86_64-linux-gnu/libcbf-private.so.0.0.1 found in none of the libraries
  dpkg-shlibdeps: warning: symbol img_make_handle used by debian/libcctbx0/usr/lib/x86_64-linux-gnu/libcbf-private.so.0.0.1 found in none of the libraries
  dpkg-shlibdeps: warning: symbol cbf_find_category used by debian/libcctbx0/usr/lib/x86_64-linux-gnu/libcbf-private.so.0.0.1 found in none of the libraries
  dpkg-shlibdeps: warning: symbol img_set_tags used by debian/libcctbx0/usr/lib/x86_64-linux-gnu/libcbf-private.so.0.0.1 found in none of the libraries
  dpkg-shlibdeps: warning: symbol _ZN10ANNkd_treeC1EPPdiii12ANNsplitRule used by debian/libcctbx0/usr/lib/x86_64-linux-gnu/libann_adaptor.so.0.0.1 found in none of the libraries
  dpkg-shlibdeps: warning: symbol _ZN15annself_include10ANNkd_treeC1EPPdiiiNS_12ANNsplitRuleE used by debian/libcctbx0/usr/lib/x86_64-linux-gnu/libann_adaptor.so.0.0.1 found in none of the libraries
  dpkg-shlibdeps: warning: symbol _ZTIN5Distl9diffimageE used by debian/libcctbx0/usr/lib/x86_64-linux-gnu/libdxtbxspotfinder.so.0.0.1 found in none of the libraries
  dpkg-shlibdeps: warning: symbol _ZN5Distl9diffimageD2Ev used by debian/libcctbx0/usr/lib/x86_64-linux-gnu/libdxtbxspotfinder.so.0.0.1 found in none of the libraries
  dpkg-shlibdeps: warning: symbol _ZN5Distl9diffimage13set_imagedataEPKiii used by debian/libcctbx0/usr/lib/x86_64-linux-gnu/libdxtbxspotfinder.so.0.0.1 found in none of the libraries
  dpkg-shlibdeps: warning: symbol _ZTVN5Distl4spotE used by debian/libcctbx0/usr/lib/x86_64-linux-gnu/libdxtbxspotfinder.so.0.0.1 found in none of the libraries
  dpkg-shlibdeps: warning: symbol _ZN5Distl9diffimageC2Ev used by debian/libcctbx0/usr/lib/x86_64-linux-gnu/libdxtbxspotfinder.so.0.0.1 found in none of the libraries
  dpkg-shlibdeps: warning: symbol _ZTVN5Distl9spot_baseE used by debian/libcctbx0/usr/lib/x86_64-linux-gnu/libdxtbxspotfinder.so.0.0.1 found in none of the libraries
  dpkg-shlibdeps: warning: debian/python3-cctbx/usr/lib/python3/dist-packages/ccp4io_adaptbx_ext.cpython-310-x86_64-linux-gnu.so contains an unresolvable reference to symbol _ZN3ssm9InitGraphEv: it's probably a plugin
  dpkg-shlibdeps: warning: debian/python3-cctbx/usr/lib/python3/dist-packages/rstbx_bandpass_ext.cpython-310-x86_64-linux-gnu.so contains an unresolvable reference to symbol _ZN14annlib_adaptbx21AnnAdaptorSelfIncludeC1EN6scitbx2af6sharedIdEEii: it's probably a plugin
  dpkg-shlibdeps: warning: package could avoid a useless dependency if debian/python3-cctbx/usr/lib/python3/dist-packages/annlib_ext.cpython-310-x86_64-linux-gnu.so was not linked against libann-cctbx.so.0 (it uses none of the library's symbols)
  dpkg-shlibdeps: warning: package could avoid a useless dependency if debian/python3-cctbx/usr/lib/python3/dist-packages/annlib_ext.cpython-310-x86_64-linux-gnu.so was not linked against libann.so.0 (it uses none of the library's symbols)²

* TODO Package nxmx
  dials need this new package
  https://github.com/dials/nxmx
