Skip to content

Commit efffc7e

Browse files
authored
Add documentation on improving python build times (#11407)
This is a minor documentation update on how to improve build times when creating python packages.
1 parent f42d292 commit efffc7e

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

BUILD.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,50 @@ rustflags = [
242242
"split-debuginfo=packed",
243243
]
244244
```
245+
246+
### Python build variables (macOS or linux)
247+
248+
When building the python package you can greatly speed up your rebuilding
249+
by defining a `PYO3_CONFIG_FILE` environment variable pointing to a file
250+
that contains your build environment. You will need to update this file if
251+
there are major changes to your build, including when there are version
252+
changes in the [PyO3](https://pyo3.rs/) dependencies.
253+
254+
To set this variable, first run the following command:
255+
256+
```shell
257+
PYO3_PRINT_CONFIG=1 cargo build
258+
```
259+
260+
It should include an output similar to the following:
261+
262+
```
263+
implementation=CPython
264+
version=3.9
265+
shared=true
266+
abi3=true
267+
lib_name=python3.12
268+
lib_dir=/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.12/lib
269+
executable=/Users/myusername/src/datafusion-python/.venv/bin/python
270+
pointer_width=64
271+
build_flags=
272+
suppress_build_script_link_lines=false
273+
```
274+
275+
Copy the output in your terminal into a file and set this environment variable.
276+
277+
```shell
278+
export PYO3_CONFIG_FILE="/Users/myusername/some/path/pyo3_build.config"
279+
```
280+
281+
If you are using VS Code for your IDE you may need to set these variables in
282+
your settings:
283+
284+
```json
285+
"rust-analyzer.cargo.extraEnv": {
286+
"PYO3_CONFIG_FILE": "/Users/myusername/some/path/pyo3_build.config"
287+
},
288+
"rust-analyzer.runnables.extraEnv": {
289+
"PYO3_CONFIG_FILE": "/Users/myusername/some/path/pyo3_build.config"
290+
}
291+
```

0 commit comments

Comments
 (0)