Debian Codegraph @

src/bonsai/docs/guides/development/installation.rst

raw
1 Installation
2 ============
3
4 There are different methods of installation, depending on your situation.
5
6 1. :ref:`guides/development/installation:Unstable installation` is recommended
7 for power users helping with testing.
8 2. :ref:`guides/development/installation:Bundling for blender` is recommended for distributing the add-on.
9 3. :ref:`guides/development/installation:Live development environment` is
10 recommended for developers who are actively coding.
11 4. :ref:`guides/development/installation:Packaged installation` is recommended
12 for those who use a package manager.
13
14 System requirements
15 -------------------
16
17 Bonsai officially supports all major 64-bit platforms, as well as the Python
18 version shipped by the Blender Foundation for the most recent three major
19 Blender versions:
20
21 - 64-bit Linux (``linux-x64``)
22 - 64-bit MacOS Intel (``macos-x64``)
23 - 64-bit MacOS Silicon (``macos-arm64``)
24 - 64-bit Windows (``windows-x64``)
25 - Blender 4.2 with Python 3.11
26
27 Due to significant changes in the Blender extensions system, Blender versions
28 <4.2 are not supported.
29
30 Developer builds may exist for different versions of Python but there will be
31 no guarantee of the uptime or stability of these builds.
32
33 Other system specifications match the `Blender Requirements
34 <https://www.blender.org/download/requirements/>`_ and the `VFX Platform
35 <https://vfxplatform.com/>`_ standard.
36
37 Sometimes, a build may be delayed, or contain broken code. We try to avoid this,
38 but it happens.
39
40 Unstable installation
41 ---------------------
42
43 **Unstable installation** is almost the same as **Stable installation**, except
44 that they are typically updated every day. To install the **Unstable** version:
45
46 1. Open up Blender, and click on ``Edit > Preferences``.
47
48 .. image:: /quickstart/images/install-bonsai-1.png
49
50 2. Select the **Get Extensions** tab, and press **Allow Online Access**.
51
52 .. image:: /quickstart/images/install-bonsai-2.png
53
54 3. Go to the `Bonsai Unstable Repository
55 <https://github.com/IfcOpenShell/bonsai_unstable_repo>`__, and drag and drop
56 from the appropriate link in the ``ID`` column of the table into Blender
57 depending on your operating system.
58
59 .. image:: images/unstable-drag-drop.png
60
61 4. Enable **Check for Updates on Startup** to get updates for daily Bonsai
62 builds automatically.
63
64 .. image:: images/unstable-auto-update.png
65
66 .. tip::
67
68 Instead of drag and drop, you can manually create the repository:
69
70 Open :menuselection:`Topbar --> Edit --> Preferences --> Get Extensions
71 --> Repositories (Top Right) --> "+" Icon --> Add Remote Remository`.
72 You'll see a window similar to the one above.
73
74 Use as URL:
75 ``https://raw.githubusercontent.com/IfcOpenShell/bonsai_unstable_repo/main/index.json``
76 and enable **Check for Updates on Startup** if you want them.
77
78 5. Search for **Bonsai** in the top left search bar, then press the **Install**
79 button.
80
81 .. image:: /quickstart/images/install-bonsai-3.png
82
83 .. warning::
84
85 Make sure the extension you install has ``raw.githubusercontent.com`` as
86 it's "Repository" (not ``extensions.blender.org``).
87
88 .. image:: images/unstable-repo.png
89
90 6. Whenever a new update is available, you'll see it in the bottom right
91 :menuselection:`Status Bar`
92
93 .. image:: images/unstable-icon.png
94
95 7. To update, click on the update button in :menuselection:`Topbar --> Edit -->
96 Preferences --> Get Extensions`.
97
98 .. image:: /guides/images/update.png
99
100 8. After an update, be sure to restart.
101
102 .. image:: images/unstable-restart.png
103
104 If you wish to install an **Unstable** version offline, you can download a
105 daily or previous build from the `GitHub releases page
106 <https://github.com/IfcOpenShell/IfcOpenShell/releases?q=bonsai&expanded=true>`__,
107 then go to :menuselection:`Topbar --> Edit --> Preferences --> Get Extensions
108 --> "V" Icon (top right) --> Install from Disk`.
109
110 .. tip::
111
112 Installing a previous build is a great way to roll back to previous versions. Uninstall the current version,
113 then install the previous version from your disk. Make the install directory into the repo folder, and you can still
114 update by the click of a button, when you are ready for the latest build.
115
116 Bundling for Blender
117 --------------------
118
119 Instead of waiting for an official release on the Bonsai website, it
120 is possible to make your own Blender add-on from the bleeding edge source code
121 of Bonsai. Bonsai is coded in Python and doesn't require any
122 compilation, so this is a relatively easy process.
123
124 Note that Bonsai depends on IfcOpenShell, and IfcOpenShell does require
125 compilation. The following instructions will use a pre-built IfcOpenShell
126 (using an IfcOpenBot build) for convenience. Instructions on how to compile
127 IfcOpenShell is out of scope of this document.
128
129 You can create your own package by using the Makefile as shown below. You can
130 choose between a ``PLATFORM`` of ``linux``, ``macos``, ``macosm1``, and ``win``.
131 You can choose between a ``PYVERSION`` of ``py312``, ``py311``, ``py310``, or
132 ``py39``.
133
134 .. code-block:: bash
135
136 cd src/bonsai
137 make dist PLATFORM=linux PYVERSION=py311
138 ls dist/
139
140 This will give you a fully packaged Blender add-on zip that you can distribute
141 and install.
142
143 Live development environment
144 ----------------------------
145
146 One option for developers who want to actively develop from source is to follow
147 the instructions from :ref:`guides/development/installation:Bundling for Blender`. However,
148 creating a build, uninstalling the old add-on, and installing a new build is a
149 slow process. Although it works, it is very slow, so we do not recommend it.
150
151 A more rapid approach is to follow the
152 :ref:`guides/development/installation:Unstable installation` method, as this
153 provides all dependencies for you out of the box.
154
155 Once you've done this, you can replace certain Python files that tend to be
156 updated frequently with those from the Git repository. We're going to use
157 symbolic links, so we can code in our Git repository, and see the changes in
158 our Blender installation (you will need to restart Blender to see changes).
159
160 For Linux or Mac:
161
162 .. literalinclude:: ../../../scripts/installation/dev_environment.sh
163 :language: bash
164 :caption: dev_environment.sh
165
166 Or, if you're on Windows, you can use the batch script below. You need to run
167 it as an administrator. Before running it follow the instructions descibed
168 in the `rem` tags.
169
170 .. literalinclude:: ../../../scripts/installation/dev_environment.bat
171 :language: bat
172 :caption: dev_environment.bat
173
174 After you modify your code in the Git repository, you will need to restart
175 Blender for the changes to take effect.
176
177 If there are changes to the IfcOpenShell binaries, you may replace the two
178 ``*ifcopenshell_wrapper*`` files with new ones downloaded from the automated
179 `IfcOpenShell builds directory <https://builds.ifcopenshell.org/>`__.
180
181 The downside with this approach is that if a new dependency is added, or a
182 compiled dependency has changed (that is not available via the build
183 directory), or the build system changes, you'll need to fix your setup
184 manually. But this is relatively rare. Reviewing the Makefile history, `here
185 <https://github.com/IfcOpenShell/IfcOpenShell/commits/v0.8.0/src/bonsai/Makefile>`__,
186 is one quick way to see if a dependency has changed.
187
188 .. seealso::
189
190 There is a `useful Blender Addon
191 <https://blenderartists.org/uploads/short-url/yto1sjw7pqDRVNQzpVLmn51PEDN.zip>`__
192 (see `forum thread
193 <https://blenderartists.org/t/reboot-blender-addon/640465/13>`__) that adds
194 a Reboot button in File menu. In this way, it's possible to directly
195 restart Blender and test the modified source code. There is also a VS Code
196 add-on called `Blender Development
197 <https://marketplace.visualstudio.com/items?itemName=JacquesLucke.blender-development>`__
198 that has a similar functionality.
199
200
201 Packaged installation
202 ---------------------
203
204 - **Arch Linux**: `Direct from Git <https://aur.archlinux.org/packages/ifcopenshell-git/>`__.
205 - **Chocolatey on Windows**: `Unstable <https://community.chocolatey.org/packages/bonsai-nightly/>`__.
206
207 Tips for package managers
208 -------------------------
209
210 Bonsai is fully contained in the ``bonsai/`` subfolder of the Blender add-ons
211 directory. This is typically distributed as a zipfile as per Blender add-on
212 conventions. Within this folder, you'll find the following file structure:
213
214 ::
215
216 core/ (Blender agnostic core logic)
217 tool/ (Blender specific shared functionality)
218 bim/ (Blender specific UI)
219 libs/ (other assets)
220 wheels/ (dependencies)
221 __init__.py
222
223 This corresponds to the structure found in the source code `here
224 <https://github.com/IfcOpenShell/IfcOpenShell/tree/v0.8.0/src/bonsai/bonsai>`__.
225
226 Bonsai is complex, and requires many dependencies, including Python modules,
227 binaries, and static assets. When packaged for users, these dependencies are
228 bundled with the add-on for convenience.
229
230 If you choose to install Bonsai and use your own system dependencies, the
231 source of truth for how dependencies are bundled are found in
232 the `Makefile
233 <https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/src/bonsai/Makefile>`__
234 in the ``dist`` target.
235
236 Add-on compatibility
237 --------------------
238
239 Bonsai is a non-trivial add-on. By turning Blender into a graphical front-end
240 to a native IFC authoring platform, some fundamental Blender features (such as
241 hotkeys for basic functionality like object deletion or duplication) have been
242 patched and many dependencies have been introduced.
243
244 Other add-ons may no longer work as intended when Bonsai is enabled, or vice
245 versa, Bonsai may no longer work as intended when other add-ons are enabled.
246
247 Known scenarios which will lead to add-on incompatibility include:
248
249 - The add-on also overrides the same hotkeys. For example, if an add-on
250 overrides the "X" key to delete an object, you will need to manually trigger
251 (either via menu or custom hotkey) the Bonsai equivalent operator
252 (e.g. IFC Delete).
253 - The add-on uses object deletion or duplication macros with dictionary
254 override. Note that this is also deprecated in Blender, so the other add-on
255 should be updated to fix this.
256 - The add-on requires a conflicting dependency, or a conflicting version of the
257 same dependency. Neither add-on may work simultaneously.