Debian Codegraph @

guide/src/local_development.md

raw
1 # Local Development
2
3 ## `maturin develop` command
4
5 For local development, the `maturin develop` command can be used to quickly
6 build a package in debug mode by default and install it to virtualenv.
7
8 ```
9 Usage: maturin develop [OPTIONS] [ARGS]...
10
11 Arguments:
12 [ARGS]...
13 Rustc flags
14
15 Options:
16 -b, --bindings <BINDINGS>
17 Which kind of bindings to use
18
19 [possible values: pyo3, pyo3-ffi, cffi, uniffi, bin]
20
21 --strip
22 Strip the library for minimum file size
23
24 -E, --extras <EXTRAS>
25 Install extra requires aka. optional dependencies
26
27 Use as `--extras=extra1,extra2`
28
29 --skip-install
30 Skip installation, only build the extension module inplace
31
32 Only works with mixed Rust/Python project layout
33
34 --pip-path <PIP_PATH>
35 Use a specific pip installation instead of the default one.
36
37 This can be used to supply the path to a pip executable when the current virtualenv does not provide one.
38
39 -q, --quiet
40 Do not print cargo log messages
41
42 --ignore-rust-version
43 Ignore `rust-version` specification in packages
44
45 -v, --verbose...
46 Use verbose output (-vv very verbose/build.rs output)
47
48 --color <WHEN>
49 Coloring: auto, always, never
50
51 --config <KEY=VALUE>
52 Override a configuration value (unstable)
53
54 -Z <FLAG>
55 Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
56
57 --future-incompat-report
58 Outputs a future incompatibility report at the end of the build (unstable)
59
60 --uv
61 Use `uv` to install packages instead of `pip`
62
63 --compression-method <COMPRESSION_METHOD>
64 Zip compresson method to use
65
66 [default: deflated]
67
68 Possible values:
69 - deflated: Deflate compression
70 - stored: No compression
71 - zstd: Zstandard compression
72
73 -h, --help
74 Print help (see a summary with '-h')
75
76 Compilation Options:
77 -r, --release
78 Pass --release to cargo
79
80 -j, --jobs <N>
81 Number of parallel jobs, defaults to # of CPUs
82
83 --profile <PROFILE-NAME>
84 Build artifacts with the specified Cargo profile
85
86 --target <TRIPLE>
87 Build for the target triple
88
89 [env: CARGO_BUILD_TARGET=]
90
91 --target-dir <DIRECTORY>
92 Directory for all generated artifacts
93
94 --timings=<FMTS>
95 Timing output formats (unstable) (comma separated): html, json
96
97 Feature Selection:
98 -F, --features <FEATURES>
99 Space or comma separated list of features to activate
100
101 --all-features
102 Activate all available features
103
104 --no-default-features
105 Do not activate the `default` feature
106
107 Manifest Options:
108 -m, --manifest-path <PATH>
109 Path to Cargo.toml
110
111 --frozen
112 Require Cargo.lock and cache are up to date
113
114 --locked
115 Require Cargo.lock is up to date
116
117 --offline
118 Run without accessing the network
119 ```
120
121 ## PEP 660 Editable Installs
122
123 Maturin supports [PEP 660](https://www.python.org/dev/peps/pep-0660/) editable installs since v0.12.0.
124 You need to add `maturin` to `build-system` section of `pyproject.toml` to use it:
125
126 ```toml
127 [build-system]
128 requires = ["maturin>=1.0,<2.0"]
129 build-backend = "maturin"
130 ```
131
132 Editable installs can be used with mixed Rust/Python projects so you
133 don't have to recompile and reinstall when only Python source code changes.
134 They can also be used with mixed and pure projects together with the
135 [import hook](./import_hook.md) so that recompilation/re-installation
136 occurs automatically when Python or Rust source code changes.
137
138 To install a package in editable mode with pip:
139
140 ```bash
141 cd my-project
142 pip install -e .
143 ```
144
145 or
146
147 ```bash
148 cd my-project
149 maturin develop
150 ```
151
152 Then Python source code changes will take effect immediately because the interpreter looks
153 for the modules directly in the project source tree.