Unverified Commit bf89cebd authored by Sandro Jäckel's avatar Sandro Jäckel Committed by GitHub
Browse files

sasview: 5.0.6 -> 6.1.1 (#449089)

parents 6643f393 8dec332c
Loading
Loading
Loading
Loading
+84 −32
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  python3,
  fetchFromGitHub,
  wrapQtAppsHook,
  writeShellScriptBin,
  qt6,
  writableTmpDirAsHomeHook,
  ausaxs,
}:

python3.pkgs.buildPythonApplication rec {
let
  version = "6.1.1";

  pyside-tools-uic = writeShellScriptBin "pyside6-uic" ''
    exec ${qt6.qtbase}/libexec/uic -g python "$@"
  '';

  pyside-tools-rcc = writeShellScriptBin "pyside6-rcc" ''
    exec ${qt6.qtbase}/libexec/rcc -g python "$@"
  '';
in
python3.pkgs.buildPythonApplication {
  pname = "sasview";
  version = "5.0.6";
  inherit version;
  pyproject = true;

  src = fetchFromGitHub {
    owner = "SasView";
    repo = "sasview";
    rev = "refs/tags/v${version}";
    hash = "sha256-cwP9VuvO4GPlbAxCqw31xISTi9NoF5RoBQmjWusrnzc=";
    tag = "v${version}";
    hash = "sha256-dc1vr+YFHItCI4NnSa+yF948/t7B6utoSp2ps/J40ys=";
  };

  # AttributeError: module 'numpy' has no attribute 'float'.
  postPatch = ''
    substituteInPlace src/sas/sascalc/pr/p_invertor.py \
      --replace "dtype=np.float)" "dtype=float)"
  '';
  build-system = with python3.pkgs; [
    hatchling
    hatch-build-scripts
    hatch-requirements-txt
    hatch-sphinx
    hatch-vcs
  ];

  nativeBuildInputs = [
    python3.pkgs.pyqt5
    python3.pkgs.setuptools
    wrapQtAppsHook
    qt6.wrapQtAppsHook
    pyside-tools-rcc
    pyside-tools-uic
    python3.pkgs.pyside6
    python3.pkgs.sasdata
    python3.pkgs.sasmodels
  ];

  propagatedBuildInputs = with python3.pkgs; [
  buildInputs = [ qt6.qtbase ];

  dependencies = with python3.pkgs; [
    sasmodels
    siphash24
    bumps
    h5py
    lxml
    columnize
    tccbox
    hatch-sphinx
    sasdata
    matplotlib
    appdirs
    dominate
    html2text
    html5lib
    ipython
    jsonschema
    mako
    numba
    periodictable
    pillow
    pyparsing
    pyqt5
    qt5reactor
    sasmodels
    scipy
    setuptools
    platformdirs
    pybind11
    pylint
    pyopencl
    pyopengl
    pyside6
    pytools
    qtconsole
    superqt
    twisted
    uncertainties
    xhtml2pdf
    zope-interface
  ];

  pythonRemoveDeps = [ "zope" ];

  postBuild = ''
    ${python3.interpreter} src/sas/qtgui/convertUI.py
  '';
@@ -54,20 +96,30 @@ python3.pkgs.buildPythonApplication rec {
    "\${qtWrapperArgs[@]}"
  ];

  nativeCheckInputs = with python3.pkgs; [
  nativeCheckInputs =
    with python3.pkgs;
    [
      pytestCheckHook
      unittest-xml-reporting
    ]
    ++ [
      writableTmpDirAsHomeHook
      ausaxs
    ];

  enabledTestPaths = [
    "test"
  ];

  disabledTests = [
    # NoKnownLoaderException
    "test_invalid_cansas"
    "test_data_reader_exception"
  ];
  disabledTestPaths = [ "test/sascalculator/utest_sas_gen.py::sas_gen_test::test_debye_impl" ];

  preCheck =
    let
      ext = stdenv.hostPlatform.extensions.sharedLibrary;
    in
    ''
      ln -s ${ausaxs}/lib/libausaxs.${ext} src/sas/sascalc/calculator/ausaxs/lib/libausaxs.${ext}
    '';

  meta = {
    description = "Fitting and data analysis for small angle scattering data";
+54 −0
Original line number Diff line number Diff line
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -85,7 +85,7 @@
 	set(DLIB_USE_MKL_FFT OFF)
 	set(DLIB_USE_FFMPEG OFF)
 	set(CMAKE_CXX_STANDARD 17) # dlib must be compiled with C++17
-	FetchContent_MakeAvailable(dlib)
+	add_subdirectory(dlib)
 	set(CMAKE_CXX_STANDARD 20) # continue with C++20	
 	add_compile_definitions("DLIB_AVAILABLE")
 endif()
@@ -105,8 +105,9 @@
 	GIT_REPOSITORY https://github.com/klytje/gcem
 )
 
-FetchContent_MakeAvailable(thread_pool GCEM backward)
-include_directories(${thread_pool_SOURCE_DIR}/include ${gcem_SOURCE_DIR}/include ${backward_SOURCE_DIR})
+add_subdirectory(gcem)
+add_subdirectory(backward)
+include_directories(thread_pool/include gcem/include backward)
 
 ############################################
 ##           Find and link CURL           ##

--- a/executable/gui/CMakeLists.txt
+++ b/executable/gui/CMakeLists.txt
@@ -6,7 +6,9 @@
 	nfd
 	GIT_REPOSITORY https://github.com/btzy/nativefiledialog-extended.git
 )
-FetchContent_MakeAvailable(elements CLI11 nfd)
+find_package(CLI11 CONFIG REQUIRED)
+add_subdirectory(${CMAKE_SOURCE_DIR}/elements elements_build)
+add_subdirectory(${CMAKE_SOURCE_DIR}/nfd nfd_build)
 
 # set the path to the elements root & module path
 set(ELEMENTS_ROOT "${elements_SOURCE_DIR}")

--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -18,10 +18,10 @@
 	GIT_TAG 914aeecfe23b1e16af6ea675a4fb5dbd5a5b8d0a
 	GIT_PROGRESS TRUE
 )
-FetchContent_MakeAvailable(Catch2)
+add_subdirectory(${CMAKE_SOURCE_DIR}/catch2 catch2_build)

 # make the tests available through CTest
-list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
+list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/catch2/extras)
 include(CTest)
 include(Catch)

 
+21 −0
Original line number Diff line number Diff line
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -229,7 +229,7 @@
   GIT_SUBMODULES_RECURSE ON
 )
 
-FetchContent_MakeAvailable(cycfi_infra)
+add_subdirectory(${CMAKE_SOURCE_DIR}/cycfi_infra cycfi_infra_build)
 target_link_libraries(elements PUBLIC cycfi::infra)
 
 ###############################################################################
@@ -270,9 +270,7 @@
 
 FetchContent_Declare(
   asio
-  GIT_REPOSITORY https://github.com/chriskohlhoff/asio.git
-  GIT_TAG asio-1-29-0
-  GIT_SHALLOW TRUE
+  SOURCE_DIR ${CMAKE_SOURCE_DIR}/asio
 )
 FetchContent_MakeAvailable(asio)
+148 −0
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  fetchFromGitHub,
  cmake,
  doxygen,
  libwebp,
  curl,
  cli11,
  python3,
  pkg-config,
  cairo,
  gtk3,
}:

let
  dlib = fetchFromGitHub {
    owner = "davisking";
    repo = "dlib";
    tag = "v20.0";
    hash = "sha256-VTX7s0p2AzlvPUsSMXwZiij+UY9g2y+a1YIge9bi0sw=";
  };

  thread-pool = fetchFromGitHub {
    owner = "bshoshany";
    repo = "thread-pool";
    tag = "v5.0.0";
    hash = "sha256-1TTpt6u3NVIMSExl0ttuwH2owQCetujolnR/t8hDMh0=";
  };

  gcem = fetchFromGitHub {
    owner = "klytje";
    repo = "gcem";
    rev = "c5464969d373ed0a763c3562656798d1cc00687f";
    hash = "sha256-bnWakLHl/afpeFm6S32ku0IkniyIs8X+LE1NmV6p0ho=";
  };

  backward-cpp = fetchFromGitHub {
    owner = "bombela";
    repo = "backward-cpp";
    rev = "0bfd0a07a61551413ccd2ab9a9099af3bad40681";
    hash = "sha256-nLH8jfdgzmlUTg6zwY/h0HVnDMeC9rvmX1x4Ithu9dI=";
  };

  catch2 = fetchFromGitHub {
    owner = "catchorg";
    repo = "Catch2";
    rev = "914aeecfe23b1e16af6ea675a4fb5dbd5a5b8d0a";
    hash = "sha256-2gK+CUpml6AaHcwNoq0tHLr2NwqtMPx+jP80/LLFFr4=";
  };

  elements = fetchFromGitHub {
    owner = "cycfi";
    repo = "elements";
    rev = "71ecd1f4ebc76967c6812b1872db639784e40a2d";
    hash = "sha256-F3Dv+QboXfOSaXpbdOeWPtOC8orWGZc8ZBFho/X8Ky8=";
  };

  nfd = fetchFromGitHub {
    owner = "btzy";
    repo = "nativefiledialog-extended";
    tag = "v1.2.1";
    hash = "sha256-GwT42lMZAAKSJpUJE6MYOpSLKUD5o9nSe9lcsoeXgJY=";
  };

  asio = fetchFromGitHub {
    owner = "chriskohlhoff";
    repo = "asio";
    tag = "asio-1-29-0";
    hash = "sha256-5WSrMe9n+8i/ZyvCsa4MMBguYbSz+7FwH0Z5JfHtRGM=";
  };

  cycfi_infra = fetchFromGitHub {
    owner = "cycfi";
    repo = "infra";
    rev = "2dff97a4b107eced78e426152f5001a2331cb1cf";
    hash = "sha256-NmoPYhfsrC5oWFjJ9Ol83sR8aIkyQr6UpaCeZpW58PI=";
    fetchSubmodules = true;
  };
in
stdenv.mkDerivation (finalAttrs: {
  pname = "ausaxs";
  version = "1.1.2";

  src = fetchFromGitHub {
    owner = "AUSAXS";
    repo = "AUSAXS";
    tag = "v${finalAttrs.version}";
    hash = "sha256-83ZgplSZmY/2DZXG1t+/4+gzlv/YusRFeDRqNuie0JA=";
  };

  patches = [ ./cmake-no-fetchcontent.patch ];

  postPatch = ''
    cp --recursive --no-preserve=mode ${dlib} dlib
    cp --recursive --no-preserve=mode ${thread-pool} thread_pool
    cp --recursive --no-preserve=mode ${gcem} gcem
    cp --recursive --no-preserve=mode ${backward-cpp} backward
    cp --recursive --no-preserve=mode ${catch2} catch2
    cp --recursive --no-preserve=mode ${nfd} nfd
    cp --recursive --no-preserve=mode ${elements} elements
    cp --recursive --no-preserve=mode ${asio} asio
    cp --recursive --no-preserve=mode ${cycfi_infra} cycfi_infra
    substituteInPlace executable/CMakeLists.txt \
      --replace-fail "FetchContent_MakeAvailable(CLI11)" "find_package(CLI11 CONFIG REQUIRED)"
    substituteInPlace include/crystal/crystal/miller/MillerGenerationFactory.h \
      --replace-fail "namespace ausaxs::settings::crystal {enum class MillerGenerationChoice;}" '#include "../core/settings/CrystalSettings.h"'
    patch -p1 -d elements < ${./elements-cmake-no-fetchcontent.patch}
    substituteInPlace CMakeLists.txt \
      --replace-fail "-mavx" "${
        lib.optionalString (stdenv.hostPlatform.isx86_64 && stdenv.hostPlatform.isLinux) "-msse3"
      }"
    sed -i '/#include <iostream>/a\
    #include <numbers>' source/crystal/miller/FibonacciMillers.cpp
  '';

  nativeBuildInputs = [
    cmake
    doxygen
    python3
    pkg-config
  ];

  buildInputs = [
    curl
    cli11
    cairo
    libwebp
    gtk3
  ];

  cmakeFlags = [ (lib.cmakeBool "GUI" true) ];

  postInstall = ''
    cp --recursive lib/* $out/lib/
    cp --recursive bin $out/bin
    rm $out/bin/scripts
    cp --recursive ../scripts $out/bin/scripts
  '';

  meta = {
    description = "Small-angle X-ray scattering framework";
    homepage = "https://github.com/AUSAXS/AUSAXS";
    license = lib.licenses.lgpl3Plus;
    maintainers = with lib.maintainers; [ kyehn ];
    platforms = lib.platforms.unix;
  };
})
+36 −0
Original line number Diff line number Diff line
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  hatchling,
  hatch-vcs,
}:

let
  version = "1.0.0";
in
buildPythonPackage {
  pname = "hatch-build-scripts";
  inherit version;
  pyproject = true;

  src = fetchFromGitHub {
    owner = "rmorshea";
    repo = "hatch-build-scripts";
    tag = "v${version}";
    hash = "sha256-umqtfUGmmZ/j/E8JY+s6REmDeTYwbcE1jZ7w4nczazs=";
  };

  build-system = [ hatchling ];

  dependencies = [ hatch-vcs ];

  pythonImportsCheck = [ "hatch_build_scripts" ];

  meta = {
    description = "Plugin for Hatch that runs build scripts and saves their artifacts";
    homepage = "https://github.com/rmorshea/hatch-build-scripts";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ kyehn ];
  };
}
Loading