You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: scripts/mrbind/README-generating.md
+33-1Lines changed: 33 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -80,6 +80,8 @@ The resulting Python modules are created next to the MeshLib shared libraries, i
80
80
* If you built MeshLib in a different directory (e.g. if using CMake), also pass `MESHLIB_SHLIB_DIR=...`, pointing to the directory where `MRMesh.dll` was built.<br/>
81
81
When using CMake, `VS_MODE` has to be set to `Debug` when `CMAKE_BUILD_TYPE` is `Debug`, and to `Release` otherwise. It controls which libraries (debug vs release) we use from Vcpkg.
82
82
83
+
* Windows is prone to Python version mismatches. If you see errors such as ``pybind11 non-limited-api: Failed to load library `pybind11nonlimitedapi_meshlib_3.13` with error `126`.``, proceed to [Dealing with Python version mismatches]()
84
+
83
85
### Linux
84
86
85
87
* Run <code>make -f scripts\mrbind\generate.mk -B --trace MESHLIB_SHLIB_DIR=<b>\<see below\></b></code>
@@ -130,8 +132,38 @@ The resulting Python modules are created next to the MeshLib shared libraries, i
130
132
131
133
When this is disabled, a stub Cuda bindings are still generated, with a single function that reports that Cuda is not available.
132
134
135
+
***`BUILD_SHIMS=1` — support multiple Python versions.** This enables support for all Python versions found on the system, as opposed a single default one. See the relevant section in the [troubleshooting guide](#troubleshooting-python-bindings).
136
+
137
+
***`shims` — add support for multiple Python versions.** Same effect as `BUILD_SHIMS=1`, but instead of regenerating the bindings, this just adds the missing version support to existing bindings. This is great if you forgot the flag during the initial compilation.
138
+
139
+
***`FOR_WHEEL=1` — build for wheel packaging.** This is primarily for CI, not for local use. Indicates that you want to package the resulting module into a wheel (a Python module archive for distribution), instead of using it locally. Enabling this might prevent the module from working locally.
140
+
141
+
This automatically enables `BUILD_SHIMS=1`, among other things.
142
+
133
143
### Troubleshooting Python bindings
134
144
145
+
***Importing the wheel prints error ``pybind11 non-limited-api: Failed to load library `pybind11nonlimitedapi_meshlib_3.13` with error `126`.`` or similar.**
146
+
147
+
* This primarily happens on Windows.
148
+
149
+
* When built locally, Python bindings only support one speific Python version by default. If you try to import them from another version, you will get errors such as the one above.
150
+
151
+
* To check which version you built for, look for shared libraried named `pybind11nonlimitedapi_meshlib_3.??` next to the Python modules. On Windows, those should be in `source/x64/Release/meshlib` (or `.../Debug/...`). The number in the filename is the Python version.
152
+
153
+
* The easiest fix to use that Python version.
154
+
155
+
* On Windows, run e.g. `py -3.12` to use that specific version (`3.12` is our default for the bindings at the time of writing). You might need to install it first from [here](https://www.python.org/downloads/windows/).
156
+
157
+
* On Linux, just running `python3` without specifying the minor version should use the correct version by default.
158
+
159
+
* Alternatively, you can add the missing shared libraries to support your preferred Python version.
160
+
161
+
* You can build them by rerunning the generation script with additional flag `shims`. This will build the libraries for all Python versions found on your system.
162
+
163
+
This commands only builds the libraries and does nothing else. You can use `BUILD_SHIMS=1` instead of `shims` to regenerate the bindings and build those libraries at the same time.
164
+
165
+
* You can also download the prebuilt libraries from [here](https://pypi.org/project/meshlib/#files). Download the archive for your OS and extract the `pybind11nonlimitedapi_meshlib_...` shared libraries next to yours.
166
+
135
167
***`could not open 'MRMesh.lib': No such file or directory`**
136
168
137
169
* MeshLib wasn't built, or `VS_MODE` is set incorrectly.
@@ -144,7 +176,7 @@ The resulting Python modules are created next to the MeshLib shared libraries, i
144
176
145
177
* Update your VS 2022.
146
178
147
-
***Undefined references to MeshLib functions**.
179
+
***Undefined references to MeshLib functions**
148
180
149
181
* This can only happen on Linux/Mac. If you look at the offending functions in the headers, they should have `requires` on them.
# Build `libpybind11nonlimitedapi_meshlib_X.Y.so` shims automatically, for all installed Python versions?
110
110
# You can always build them manually via `make shims -B`.
111
-
BUILD_SHIMS := $(FOR_WHEEL)
111
+
# The default is "yes" if we're either building for a Wheel, or if we're doing `make shims` (then we're enabling this variable to use the correct detection logic on Windows).
0 commit comments