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
Key changes:
- Instead of a single top-level workspace, we go for one workspace per exercise
- All exercises now require Python 3.13+ and `maturin` 1.8+
- We use the `dev` profile when building Rust extensions
Copy file name to clipboardExpand all lines: book/src/01_intro/01_setup.md
+13-34Lines changed: 13 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,9 +20,17 @@ To invoke Rust code from Python we need to create a **Python extension module**.
20
20
We'll use `maturin` to build, package and publish Python extensions written in Rust. Let's install it:
21
21
22
22
```bash
23
-
rye install "maturin>=1.6"
23
+
uv tool install "maturin>=1.8"
24
24
```
25
25
26
+
Tools installed via `uv` should be available in your path. Run:
27
+
28
+
```bash
29
+
uv tool update-shell
30
+
```
31
+
32
+
to make sure that's the case.
33
+
26
34
## Exercise structure
27
35
28
36
All exercises in this course will follow the same structure:
@@ -153,20 +161,20 @@ Before we move on, let's take a look at `pyproject.toml`, the Python "manifest"
153
161
154
162
```toml
155
163
[build-system]
156
-
requires = ["maturin>=1.6,<2.0"]
164
+
requires = ["maturin>=1.8,<2.0"]
157
165
build-backend = "maturin"
158
166
159
167
[project]
160
168
name = "setup"
161
169
# [...]
162
-
requires-python = ">=3.8"
163
-
dynamic = ["version"]
170
+
requires-python = ">=3.13"
171
+
164
172
[tool.maturin]
165
173
features = ["pyo3/extension-module"]
166
174
```
167
175
168
176
It specifies the build system, the extension name and version, the required Python version, and the features to enable when building the extension module.
169
-
This is what `rye` looks at when building the extension module, before delegating the build
177
+
This is what `uv` looks at when building the extension module, before delegating the build
170
178
process to `maturin`, which in turn invokes `cargo` to compile the Rust code.
171
179
172
180
## What do I need to do?
@@ -177,35 +185,6 @@ that you can build and test a Python extension module without issues.
177
185
178
186
Things will get a lot more interesting over the coming sections, I promise!
179
187
180
-
## Troubleshooting
181
-
182
-
You may run into this error when using `rye` and `pyo3` together:
183
-
184
-
```plaintext
185
-
<compiler output>
186
-
= note: ld: warning: search path '/install/lib' not found
187
-
ld: library 'python3.12' not found
188
-
clang: error: linker command failed with exit code 1
189
-
```
190
-
191
-
This seems to be a [bug in `rye`](https://github.com/astral-sh/rye/issues/1050#issuecomment-2079270180).\
192
-
To work around the issue, run the following command in the root of the course repository:
193
-
194
-
```bash
195
-
cargo run -p "patcher"
196
-
```
197
-
198
-
`wr` should now be able to build the extension module without issues and run the tests. No linker errors
199
-
should be surfaced.
200
-
201
-
<divclass="warning">
202
-
203
-
The `patcher` tool is a temporary workaround for a bug in `rye`.\
204
-
It hasn't been tested on Windows: please [open an issue](https://github.com/mainmatter/rust-python-interoperability/issues)
205
-
if you encounter any problems.
206
-
207
-
</div>
208
-
209
188
## References
210
189
211
190
-[Linking artifacts together (Rust compiler documentation)](https://doc.rust-lang.org/reference/linkage.html)
0 commit comments