|
| 1 | +.. _LocalMantidBuildWithPixi: |
| 2 | + |
| 3 | +==================================================== |
| 4 | +Using Local Mantid Build in Other Projects with Pixi |
| 5 | +==================================================== |
| 6 | + |
| 7 | +.. contents:: |
| 8 | + :local: |
| 9 | + |
| 10 | +Overview |
| 11 | +######## |
| 12 | + |
| 13 | +This guide shows how to configure a pixi environment to use your local Mantid build instead of the conda package in other projects that depend on Mantid. This is useful when you need to develop and test changes across both Mantid and dependent applications simultaneously. |
| 14 | + |
| 15 | +Prerequisites |
| 16 | +############# |
| 17 | + |
| 18 | +* A successfully built local Mantid installation (see :ref:`BuildingWithCMake`) |
| 19 | +* `Pixi <https://pixi.ws/latest/>`_ installed |
| 20 | +* Your dependent project with pixi configuration |
| 21 | + |
| 22 | +Configuration |
| 23 | +############# |
| 24 | + |
| 25 | +Add a new pixi environment to your project's ``pyproject.toml`` file: |
| 26 | + |
| 27 | +.. code-block:: toml |
| 28 | +
|
| 29 | + [tool.pixi.environments] |
| 30 | + local-mantid = { features = ["local-mantid"], solve-group = "default" } |
| 31 | +
|
| 32 | + [tool.pixi.feature.local-mantid.dependencies] |
| 33 | + # Include your project's dependencies but exclude mantid packages |
| 34 | + python = ">=3.10" |
| 35 | + numpy = "*" |
| 36 | + # ... other dependencies (do NOT include mantid, mantidworkbench, mantidqt) |
| 37 | +
|
| 38 | + [tool.pixi.feature.local-mantid.activation.env] |
| 39 | + MANTID_BUILD_DIR = "/absolute/path/to/your/mantid/build" |
| 40 | + MANTID_SOURCE_DIR = "/absolute/path/to/your/mantid/source" |
| 41 | + PYTHONPATH = "${MANTID_BUILD_DIR}/bin:${MANTID_SOURCE_DIR}/Framework/PythonInterface:${MANTID_SOURCE_DIR}/qt/python/mantidqt" |
| 42 | + LD_LIBRARY_PATH = "${MANTID_BUILD_DIR}/bin" # Linux |
| 43 | + DYLD_LIBRARY_PATH = "${MANTID_BUILD_DIR}/bin" # macOS |
| 44 | + MANTIDPATH = "${MANTID_BUILD_DIR}/bin" |
| 45 | +
|
| 46 | + [tool.pixi.feature.local-mantid.tasks] |
| 47 | + # Launch local Mantid Workbench with your application |
| 48 | + launch-local-workbench = { cmd = "cd $MANTID_BUILD_DIR/bin && ./launch_mantidworkbench.sh", description = "Launch local Mantid Workbench with your application available" } |
| 49 | +
|
| 50 | +Replace the paths with your actual Mantid build and source directories. |
| 51 | + |
| 52 | +Usage |
| 53 | +##### |
| 54 | + |
| 55 | +1. Install the environment: |
| 56 | + |
| 57 | + .. code-block:: bash |
| 58 | +
|
| 59 | + pixi install --environment local-mantid |
| 60 | +
|
| 61 | +2. Run your application: |
| 62 | + |
| 63 | + .. code-block:: bash |
| 64 | +
|
| 65 | + pixi run --environment local-mantid your-command |
| 66 | +
|
| 67 | +3. Run Local Workbench in your application's context: |
| 68 | + |
| 69 | + .. code-block:: bash |
| 70 | +
|
| 71 | + pixi run --environment local-mantid launch-local-workbench |
| 72 | +
|
| 73 | +Troubleshooting |
| 74 | +############### |
| 75 | + |
| 76 | +**Import errors**: Verify ``PYTHONPATH`` includes ``${MANTID_BUILD_DIR}/bin`` and your Mantid build completed successfully. |
| 77 | + |
| 78 | +**Library loading errors**: Check that ``LD_LIBRARY_PATH`` (Linux) or ``DYLD_LIBRARY_PATH`` (macOS) includes ``${MANTID_BUILD_DIR}/bin``. |
| 79 | + |
| 80 | +**Path issues**: Ensure all paths are absolute. Use ``realpath`` to resolve symbolic links if needed. |
| 81 | + |
| 82 | +You can verify the environment setup with: |
| 83 | + |
| 84 | +.. code-block:: bash |
| 85 | +
|
| 86 | + pixi run --environment local-mantid python -c " |
| 87 | + import os, mantid |
| 88 | + print('Mantid version:', mantid.__version__) |
| 89 | + print('Mantid path:', mantid.__file__) |
| 90 | + print('Build dir:', os.environ.get('MANTID_BUILD_DIR')) |
| 91 | + " |
| 92 | +
|
| 93 | +Related Documentation |
| 94 | +##################### |
| 95 | + |
| 96 | +* :ref:`BuildingWithCMake` - Building Mantid from source |
| 97 | +* :ref:`GettingStarted` - Initial setup for Mantid development |
| 98 | +* `Pixi Documentation <https://pixi.ws/latest/>`_ - Complete pixi reference |
0 commit comments