Commit 1fc45775 authored by Andrew Marshall's avatar Andrew Marshall
Browse files

pythonPackages.openusd: make many extras optional

- Docs are likely mostly unused, so don’t waste time and closure size
  building them by default
- UsdView requires Qt, hugely bloating closure size and build times;
  enabled for now
- Tools are CLI things not needed for lib usage; leave enabled for now
- Skip building tests since they’re not being run here anyway, so it
  just massively increases build time just for them to be thrown away

libGL and libX11 were implicit deps pulled in before (I guess), that now
need to be explicit.
parent 6a8ff011
Loading
Loading
Loading
Loading
+61 −42
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
  imath,
  jinja2,
  lib,
  libGL,
  libX11,
  ninja,
  numpy,
  opencolorio,
@@ -29,6 +31,10 @@
  qt6,
  setuptools,
  tbb,
  withDocs ? false,
  withOsl ? true,
  withTools ? true,
  withUsdView ? true,
  writeShellScriptBin,
}:

@@ -53,37 +59,38 @@ buildPythonPackage rec {

  stdenv = if python.stdenv.isDarwin then darwin.apple_sdk_11_0.stdenv else python.stdenv;

  outputs = [
    "out"
    "doc"
  ];
  outputs = [ "out" ] ++ lib.optional withDocs "doc";

  format = "other";

  cmakeFlags = [
    "-DPXR_BUILD_ALEMBIC_PLUGIN=ON"
    "-DPXR_BUILD_DOCUMENTATION=ON"
    "-DPXR_BUILD_DRACO_PLUGIN=ON"
    "-DPXR_BUILD_EMBREE_PLUGIN=ON"
    "-DPXR_BUILD_EXAMPLES=OFF"
    "-DPXR_BUILD_IMAGING=ON"
    "-DPXR_BUILD_MONOLITHIC=ON" # Seems to be commonly linked to monolithically
    "-DPXR_BUILD_PYTHON_DOCUMENTATION=ON"
    "-DPXR_BUILD_TESTS=OFF"
    "-DPXR_BUILD_TUTORIALS=OFF"
    "-DPXR_BUILD_USDVIEW=ON"
    "-DPXR_BUILD_USD_IMAGING=ON"
    "-DPXR_BUILD_USD_TOOLS=ON"
    (lib.cmakeBool "PXR_ENABLE_OSL_SUPPORT" (!stdenv.isDarwin))
    (lib.cmakeBool "PXR_BUILD_DOCUMENTATION" withDocs)
    (lib.cmakeBool "PXR_BUILD_PYTHON_DOCUMENTATION" withDocs)
    (lib.cmakeBool "PXR_BUILD_USDVIEW" withUsdView)
    (lib.cmakeBool "PXR_BUILD_USD_TOOLS" withTools)
    (lib.cmakeBool "PXR_ENABLE_OSL_SUPPORT" (!stdenv.isDarwin && withOsl))
  ];

  nativeBuildInputs = [
  nativeBuildInputs =
    [
      cmake
    doxygen
      ninja
    ]
    ++ lib.optionals withDocs [
      git
      graphviz-nox
    ninja
    qt6.wrapQtAppsHook
  ];
      doxygen
    ]
    ++ lib.optionals withUsdView [ qt6.wrapQtAppsHook ];

  buildInputs =
    [
@@ -97,40 +104,52 @@ buildPythonPackage rec {
      opencolorio
      openimageio
      opensubdiv
      osl
      ptex
      qt6.qtbase
      tbb
    ]
    ++ lib.optionals stdenv.isLinux [ qt6.qtwayland ]
    ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk_11_0.frameworks; [ Cocoa ]);
    ++ lib.optionals stdenv.isLinux [
      libGL
      libX11
    ]
    ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk_11_0.frameworks; [ Cocoa ])
    ++ lib.optionals withOsl [ osl ]
    ++ lib.optionals withUsdView [ qt6.qtbase ]
    ++ lib.optionals (withUsdView && stdenv.isLinux) [
      qt6.qtbase
      qt6.qtwayland
    ];

  propagatedBuildInputs = [
  propagatedBuildInputs =
    [
      boost
      jinja2
      numpy
      pyopengl
    pyqt6
      setuptools
    ]
    ++ lib.optionals (withTools || withUsdView) [
      pyside-tools-uic
      pyside6
    setuptools
  ];
    ]
    ++ lib.optionals withUsdView [ pyqt6 ];

  pythonImportsCheck = [
    "pxr"
    "pxr.Usd"
  ];

  postInstall = ''
  postInstall =
    ''
      # Make python lib properly accessible
      target_dir=$out/${python.sitePackages}
      mkdir -p $(dirname $target_dir)
      mv $out/lib/python $target_dir

    ''
    + lib.optionalString withDocs ''
      mv $out/docs $doc

    ''
    + ''
      rm $out/share -r # only examples
    rm $out/tests -r
    '';

  meta = {