Skip to content

Commit a8cb259

Browse files
authored
Add documentation for using local Mantid builds with pixi environments (#39724)
Added documentation explaining how to configure pixi environments to use local Mantid builds instead of conda packages in dependent projects. #### Purpose of work This documentation addresses the need for developers working on projects that depend on Mantid (like SNAPRed) to easily test their Mantid changes without having to publish and install new conda packages. It enables simultaneous development and testing across both Mantid and dependent codebases. *There is no associated issue.* #### Further detail of work Created comprehensive documentation (`LocalMantidBuildWithPixi.rst`) that covers: - Prerequisites for setting up local Mantid builds with pixi - Complete pixi configuration examples for `pyproject.toml` - Required environment variables (PYTHONPATH, LD_LIBRARY_PATH, MANTIDPATH, etc.) - Usage instructions for installing and running the environment - Troubleshooting guide for common setup issues - References to related Mantid documentation The documentation is based on the implementation pattern used in SNAPRed [PR #616](neutrons/SNAPRed#616) and provides a reusable guide for other projects that need similar functionality.
1 parent b947b84 commit a8cb259

File tree

2 files changed

+102
-0
lines changed

2 files changed

+102
-0
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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

dev-docs/source/index.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Guides
2020
Architecture
2121
BuildingOnOSX
2222
BuildingWithCMake
23+
LocalMantidBuildWithPixi
2324
CMakeBestPractices
2425
Standards/index
2526
Testing/index
@@ -40,6 +41,9 @@ Guides
4041
:doc:`Architecture`
4142
Describes the architecture of the mantid libraries and applications.
4243

44+
:doc:`LocalMantidBuildWithPixi`
45+
How to set up a pixi environment to use a local Mantid build instead of conda packages in other projects.
46+
4347
:doc:`Standards <Standards/index>`
4448
Details of coding and documentation standards for the project. Includes specifics regarding algorithms.
4549

0 commit comments

Comments
 (0)