maturin 0.12.19__py3-none-win_amd64.whl → 1.11.4__py3-none-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
maturin/__init__.py CHANGED
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env python3
2
1
  """
3
2
  maturin's implementation of the PEP 517 interface. Calls maturin through subprocess
4
3
 
@@ -9,61 +8,113 @@ even though the terminal supports utf8. Writing directly to the binary stdout bu
9
8
  maturin's emojis.
10
9
  """
11
10
 
11
+ from __future__ import annotations
12
+
12
13
  import os
14
+ import platform
13
15
  import shlex
14
16
  import shutil
17
+ import struct
15
18
  import subprocess
16
19
  import sys
17
20
  from subprocess import SubprocessError
18
- from typing import Dict
19
-
20
- try:
21
- import tomllib
22
- except ModuleNotFoundError:
23
- import tomli as tomllib
21
+ from typing import Any, Dict, Mapping, List, Optional
24
22
 
25
23
 
26
24
  def get_config() -> Dict[str, str]:
25
+ try:
26
+ import tomllib
27
+ except ModuleNotFoundError:
28
+ import tomli as tomllib # type: ignore
29
+
27
30
  with open("pyproject.toml", "rb") as fp:
28
31
  pyproject_toml = tomllib.load(fp)
29
32
  return pyproject_toml.get("tool", {}).get("maturin", {})
30
33
 
31
34
 
32
- def get_maturin_pep517_args():
33
- args = shlex.split(os.getenv("MATURIN_PEP517_ARGS", ""))
35
+ def get_maturin_pep517_args(config_settings: Optional[Mapping[str, Any]] = None) -> List[str]:
36
+ build_args = None
37
+ if config_settings:
38
+ # TODO: Deprecate and remove build-args in favor of maturin.build-args in maturin 2.0
39
+ build_args = config_settings.get("maturin.build-args", config_settings.get("build-args"))
40
+ if build_args is None:
41
+ env_args = os.getenv("MATURIN_PEP517_ARGS", "")
42
+ args = shlex.split(env_args)
43
+ elif isinstance(build_args, str):
44
+ args = shlex.split(build_args)
45
+ else:
46
+ args = build_args
34
47
  return args
35
48
 
36
49
 
50
+ def _get_sys_executable() -> str:
51
+ executable = sys.executable
52
+ if os.getenv("MATURIN_PEP517_USE_BASE_PYTHON") in {"1", "true"} or get_config().get("use-base-python"):
53
+ # Use the base interpreter path when running inside a venv to avoid recompilation
54
+ # when switching between venvs
55
+ base_executable = getattr(sys, "_base_executable")
56
+ if base_executable and os.path.exists(base_executable):
57
+ executable = os.path.realpath(base_executable)
58
+ return executable
59
+
60
+
61
+ def _additional_pep517_args() -> List[str]:
62
+ # Support building for 32-bit Python on x64 Windows
63
+ if platform.system().lower() == "windows" and platform.machine().lower() == "amd64":
64
+ pointer_width = struct.calcsize("P") * 8
65
+ if pointer_width == 32:
66
+ return ["--target", "i686-pc-windows-msvc"]
67
+ return []
68
+
69
+
70
+ def _get_env() -> Optional[Dict[str, str]]:
71
+ if not os.environ.get("MATURIN_NO_INSTALL_RUST") and not shutil.which("cargo"):
72
+ from puccinialin import setup_rust
73
+
74
+ print("Rust not found, installing into a temporary directory")
75
+ extra_env = setup_rust()
76
+ return {**os.environ, **extra_env}
77
+ else:
78
+ return None
79
+
80
+
37
81
  # noinspection PyUnusedLocal
38
82
  def _build_wheel(
39
- wheel_directory, config_settings=None, metadata_directory=None, editable=False
40
- ):
83
+ wheel_directory: str,
84
+ config_settings: Optional[Mapping[str, Any]] = None,
85
+ metadata_directory: Optional[str] = None,
86
+ editable: bool = False,
87
+ ) -> str:
41
88
  # PEP 517 specifies that only `sys.executable` points to the correct
42
89
  # python interpreter
43
- command = [
90
+ base_command = [
44
91
  "maturin",
45
92
  "pep517",
46
93
  "build-wheel",
47
94
  "-i",
48
- sys.executable,
49
- "--compatibility",
50
- "off",
95
+ _get_sys_executable(),
51
96
  ]
97
+ options = _additional_pep517_args()
52
98
  if editable:
53
- command.append("--editable")
54
- pep517_args = get_maturin_pep517_args()
99
+ options.append("--editable")
100
+
101
+ pep517_args = get_maturin_pep517_args(config_settings)
55
102
  if pep517_args:
56
- command.extend(pep517_args)
103
+ options.extend(pep517_args)
104
+
105
+ if "--compatibility" not in options and "--manylinux" not in options:
106
+ # default to off if not otherwise specified
107
+ options = ["--compatibility", "off", *options]
108
+
109
+ command = [*base_command, *options]
57
110
 
58
111
  print("Running `{}`".format(" ".join(command)))
59
112
  sys.stdout.flush()
60
- result = subprocess.run(command, stdout=subprocess.PIPE)
113
+ result = subprocess.run(command, stdout=subprocess.PIPE, env=_get_env())
61
114
  sys.stdout.buffer.write(result.stdout)
62
115
  sys.stdout.flush()
63
116
  if result.returncode != 0:
64
- sys.stderr.write(
65
- f"Error: command {command} returned non-zero exit status {result.returncode}\n"
66
- )
117
+ sys.stderr.write(f"Error: command {command} returned non-zero exit status {result.returncode}\n")
67
118
  sys.exit(1)
68
119
  output = result.stdout.decode(errors="replace")
69
120
  wheel_path = output.strip().splitlines()[-1]
@@ -73,41 +124,48 @@ def _build_wheel(
73
124
 
74
125
 
75
126
  # noinspection PyUnusedLocal
76
- def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
127
+ def build_wheel(
128
+ wheel_directory: str,
129
+ config_settings: Optional[Mapping[str, Any]] = None,
130
+ metadata_directory: Optional[str] = None,
131
+ ) -> str:
77
132
  return _build_wheel(wheel_directory, config_settings, metadata_directory)
78
133
 
79
134
 
80
135
  # noinspection PyUnusedLocal
81
- def build_sdist(sdist_directory, config_settings=None):
136
+ def build_sdist(sdist_directory: str, config_settings: Optional[Mapping[str, Any]] = None) -> str:
82
137
  command = ["maturin", "pep517", "write-sdist", "--sdist-directory", sdist_directory]
83
138
 
84
139
  print("Running `{}`".format(" ".join(command)))
85
140
  sys.stdout.flush()
86
- result = subprocess.run(command, stdout=subprocess.PIPE)
141
+ result = subprocess.run(command, stdout=subprocess.PIPE, env=_get_env())
87
142
  sys.stdout.buffer.write(result.stdout)
88
143
  sys.stdout.flush()
89
144
  if result.returncode != 0:
90
- sys.stderr.write(
91
- f"Error: command {command} returned non-zero exit status {result.returncode}\n"
92
- )
145
+ sys.stderr.write(f"Error: command {command} returned non-zero exit status {result.returncode}\n")
93
146
  sys.exit(1)
94
147
  output = result.stdout.decode(errors="replace")
95
148
  return output.strip().splitlines()[-1]
96
149
 
97
150
 
98
151
  # noinspection PyUnusedLocal
99
- def get_requires_for_build_wheel(config_settings=None):
152
+ def get_requires_for_build_wheel(config_settings: Optional[Mapping[str, Any]] = None) -> List[str]:
100
153
  if get_config().get("bindings") == "cffi":
101
- return ["cffi"]
154
+ requirements = ["cffi"]
102
155
  else:
103
- return []
156
+ requirements = []
157
+ if not os.environ.get("MATURIN_NO_INSTALL_RUST") and not shutil.which("cargo"):
158
+ requirements += ["puccinialin"]
159
+ return requirements
104
160
 
105
161
 
106
162
  # noinspection PyUnusedLocal
107
- def build_editable(wheel_directory, config_settings=None, metadata_directory=None):
108
- return _build_wheel(
109
- wheel_directory, config_settings, metadata_directory, editable=True
110
- )
163
+ def build_editable(
164
+ wheel_directory: str,
165
+ config_settings: Optional[Mapping[str, Any]] = None,
166
+ metadata_directory: Optional[str] = None,
167
+ ) -> str:
168
+ return _build_wheel(wheel_directory, config_settings, metadata_directory, editable=True)
111
169
 
112
170
 
113
171
  # Requirements to build an editable are the same as for a wheel
@@ -115,18 +173,21 @@ get_requires_for_build_editable = get_requires_for_build_wheel
115
173
 
116
174
 
117
175
  # noinspection PyUnusedLocal
118
- def get_requires_for_build_sdist(config_settings=None):
119
- return []
176
+ def get_requires_for_build_sdist(config_settings: Optional[Mapping[str, Any]] = None) -> List[str]:
177
+ requirements = []
178
+ if not os.environ.get("MATURIN_NO_INSTALL_RUST") and not shutil.which("cargo"):
179
+ requirements += ["puccinialin"]
180
+ return requirements
120
181
 
121
182
 
122
183
  # noinspection PyUnusedLocal
123
- def prepare_metadata_for_build_wheel(metadata_directory, config_settings=None):
184
+ def prepare_metadata_for_build_wheel(
185
+ metadata_directory: str, config_settings: Optional[Mapping[str, Any]] = None
186
+ ) -> str:
124
187
  print("Checking for Rust toolchain....")
125
188
  is_cargo_installed = False
126
189
  try:
127
- output = subprocess.check_output(["cargo", "--version"]).decode(
128
- "utf-8", "ignore"
129
- )
190
+ output = subprocess.check_output(["cargo", "--version"], env=_get_env()).decode("utf-8", "ignore")
130
191
  if "cargo" in output:
131
192
  is_cargo_installed = True
132
193
  except (FileNotFoundError, SubprocessError):
@@ -149,21 +210,22 @@ def prepare_metadata_for_build_wheel(metadata_directory, config_settings=None):
149
210
  # PEP 517 specifies that only `sys.executable` points to the correct
150
211
  # python interpreter
151
212
  "--interpreter",
152
- sys.executable,
213
+ _get_sys_executable(),
153
214
  ]
154
- pep517_args = get_maturin_pep517_args()
215
+ command.extend(_additional_pep517_args())
216
+ pep517_args = get_maturin_pep517_args(config_settings)
155
217
  if pep517_args:
156
218
  command.extend(pep517_args)
157
219
 
158
220
  print("Running `{}`".format(" ".join(command)))
159
221
  try:
160
- output = subprocess.check_output(command)
222
+ _output = subprocess.check_output(command, env=_get_env())
161
223
  except subprocess.CalledProcessError as e:
162
224
  sys.stderr.write(f"Error running maturin: {e}\n")
163
225
  sys.exit(1)
164
- sys.stdout.buffer.write(output)
226
+ sys.stdout.buffer.write(_output)
165
227
  sys.stdout.flush()
166
- output = output.decode(errors="replace")
228
+ output = _output.decode(errors="replace")
167
229
  return output.strip().splitlines()[-1]
168
230
 
169
231
 
maturin/__main__.py ADDED
@@ -0,0 +1,50 @@
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ import sys
5
+ from pathlib import Path
6
+ import sysconfig
7
+ from typing import Optional
8
+
9
+
10
+ def get_maturin_path() -> Optional[Path]:
11
+ SCRIPT_NAME = "maturin"
12
+
13
+ def script_dir(scheme: str) -> str:
14
+ return sysconfig.get_path("scripts", scheme)
15
+
16
+ def script_exists(dir: str) -> bool:
17
+ for _, _, files in os.walk(dir):
18
+ for f in files:
19
+ name, *_ = os.path.splitext(f)
20
+ if name == SCRIPT_NAME:
21
+ return True
22
+
23
+ return False
24
+
25
+ paths = list(
26
+ filter(
27
+ script_exists,
28
+ filter(os.path.exists, map(script_dir, sysconfig.get_scheme_names())),
29
+ )
30
+ )
31
+
32
+ if paths:
33
+ return Path(paths[0]) / SCRIPT_NAME
34
+
35
+ return None
36
+
37
+
38
+ if __name__ == "__main__":
39
+ maturin = get_maturin_path()
40
+ if maturin is None:
41
+ print("Unable to find `maturin` script")
42
+ exit(1)
43
+
44
+ if sys.platform == "win32":
45
+ import subprocess
46
+
47
+ code = subprocess.call([str(maturin)] + sys.argv[1:])
48
+ sys.exit(code)
49
+ else:
50
+ os.execv(maturin, [str(maturin)] + sys.argv[1:])
maturin/bootstrap.py ADDED
@@ -0,0 +1,31 @@
1
+ """Support installing rust before compiling (bootstrapping) maturin.
2
+
3
+ Installing a package that uses maturin as build backend on a platform without maturin
4
+ binaries, we install rust in a cache directory if the user doesn't have a rust
5
+ installation already. Since this bootstrapping requires more dependencies but is only
6
+ required if rust is missing, we check if cargo is present before requesting those
7
+ dependencies.
8
+
9
+ https://setuptools.pypa.io/en/stable/build_meta.html#dynamic-build-dependencies-and-other-build-meta-tweaks
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ import os
15
+ import shutil
16
+ from typing import Any
17
+
18
+ # noinspection PyUnresolvedReferences
19
+ from setuptools.build_meta import * # noqa:F403
20
+
21
+
22
+ def get_requires_for_build_wheel(config_settings: dict[str, Any] | None = None) -> list[str]:
23
+ if not os.environ.get("MATURIN_NO_INSTALL_RUST") and not shutil.which("cargo"):
24
+ return ["puccinialin>=0.1,<0.2"]
25
+ return []
26
+
27
+
28
+ def get_requires_for_build_sdist(config_settings: dict[str, Any] | None = None) -> list[str]:
29
+ if not os.environ.get("MATURIN_NO_INSTALL_RUST") and not shutil.which("cargo"):
30
+ return ["puccinialin>=0.1,<0.2"]
31
+ return []
@@ -0,0 +1,303 @@
1
+ Metadata-Version: 2.4
2
+ Name: maturin
3
+ Version: 1.11.4
4
+ Classifier: Topic :: Software Development :: Build Tools
5
+ Classifier: Programming Language :: Rust
6
+ Classifier: Programming Language :: Python :: Implementation :: CPython
7
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
8
+ Classifier: Programming Language :: Python :: Implementation :: GraalPy
9
+ Requires-Dist: tomli>=1.1.0 ; python_full_version < '3.11'
10
+ Requires-Dist: patchelf ; extra == 'patchelf'
11
+ Requires-Dist: ziglang>=0.10.0,<0.13.0 ; extra == 'zig'
12
+ Provides-Extra: patchelf
13
+ Provides-Extra: zig
14
+ License-File: license-mit
15
+ License-File: license-apache
16
+ Summary: Build and publish crates with pyo3, cffi and uniffi bindings as well as rust binaries as python packages
17
+ Home-Page: https://github.com/pyo3/maturin
18
+ Author-email: konstin <konstin@mailbox.org>
19
+ License-Expression: MIT OR Apache-2.0
20
+ Requires-Python: >=3.7
21
+ Description-Content-Type: text/markdown
22
+ Project-URL: Changelog, https://maturin.rs/changelog.html
23
+ Project-URL: Documentation, https://maturin.rs
24
+ Project-URL: Issues, https://github.com/PyO3/maturin/issues
25
+ Project-URL: Source Code, https://github.com/PyO3/maturin
26
+
27
+ # Maturin
28
+
29
+ _formerly pyo3-pack_
30
+
31
+ [![Maturin User Guide](https://img.shields.io/badge/user-guide-brightgreen?logo=readthedocs&style=flat-square)](https://maturin.rs)
32
+ [![Crates.io](https://img.shields.io/crates/v/maturin.svg?logo=rust&style=flat-square)](https://crates.io/crates/maturin)
33
+ [![PyPI](https://img.shields.io/pypi/v/maturin.svg?logo=python&style=flat-square)](https://pypi.org/project/maturin)
34
+ [![discord server](https://img.shields.io/discord/1209263839632424990?logo=discord&style=flat-square)](https://discord.gg/33kcChzH7f)
35
+
36
+ Build and publish crates with [pyo3, cffi and uniffi bindings](https://maturin.rs/bindings) as well as rust binaries as python packages with minimal configuration.
37
+ It supports building wheels for python 3.8+ on Windows, Linux, macOS and FreeBSD, can upload them to [pypi](https://pypi.org/) and has basic PyPy and GraalPy support.
38
+
39
+ Check out the [User Guide](https://maturin.rs/)!
40
+
41
+ ## Usage
42
+
43
+ You can either download binaries from the [latest release](https://github.com/PyO3/maturin/releases/latest) or install it with [pipx](https://pypa.github.io/pipx/) or [uv](https://github.com/astral-sh/uv):
44
+
45
+ ```shell
46
+ # pipx
47
+ pipx install maturin
48
+ # uv
49
+ uv tool install maturin
50
+ ```
51
+
52
+ > [!NOTE]
53
+ >
54
+ > `pip install maturin` should also work if you don't want to use pipx.
55
+
56
+ There are three main commands:
57
+
58
+ - `maturin new` creates a new cargo project with maturin configured.
59
+ - `maturin build` builds the wheels and stores them in a folder (`target/wheels` by default), but doesn't upload them. It's recommended to publish packages with [uv](https://github.com/astral-sh/uv) using `uv publish`.
60
+ - `maturin develop` builds the crate and installs it as a python module directly in the current virtualenv. Note that while `maturin develop` is faster, it doesn't support all the feature that running `pip install` after `maturin build` supports.
61
+
62
+ maturin doesn't need extra configuration files and doesn't clash with an existing setuptools-rust configuration.
63
+ You can even integrate it with testing tools such as [tox](https://tox.readthedocs.io/en/latest/).
64
+ There are examples for the different bindings in the `test-crates` folder.
65
+
66
+ The name of the package will be the name of the cargo project, i.e. the name field in the `[package]` section of `Cargo.toml`.
67
+ The name of the module, which you are using when importing, will be the `name` value in the `[lib]` section (which defaults to the name of the package). For binaries, it's simply the name of the binary generated by cargo.
68
+
69
+ When using `maturin build` and `maturin develop` commands, you can compile a performance-optimized program by adding the `-r` or `--release` flag.
70
+
71
+ ## Python packaging basics
72
+
73
+ Python packages come in two formats:
74
+ A built form called wheel and source distributions (sdist), both of which are archives.
75
+ A wheel can be compatible with any python version, interpreter (cpython and pypy, mainly), operating system and hardware architecture (for pure python wheels),
76
+ can be limited to a specific platform and architecture (e.g. when using ctypes or cffi) or to a specific python interpreter and version on a specific architecture and operating system (e.g. with pyo3).
77
+
78
+ When using `pip install` on a package, pip tries to find a matching wheel and install that. If it doesn't find one, it downloads the source distribution and builds a wheel for the current platform,
79
+ which requires the right compilers to be installed. Installing a wheel is much faster than installing a source distribution as building wheels is generally slow.
80
+
81
+ When you publish a package to be installable with `pip install`, you upload it to [pypi](https://pypi.org/), the official package repository.
82
+ For testing, you can use [test pypi](https://test.pypi.org/) instead, which you can use with `pip install --index-url https://test.pypi.org/simple/`.
83
+ Note that for [publishing for linux](#manylinux-and-auditwheel), you need to use the manylinux docker container or zig, while for publishing from your repository you can use the [PyO3/maturin-action](https://github.com/PyO3/maturin-action) github action.
84
+
85
+ ## Mixed rust/python projects
86
+
87
+ To create a mixed rust/python project, create a folder with your module name (i.e. `lib.name` in Cargo.toml) next to your Cargo.toml and add your python sources there:
88
+
89
+ ```
90
+ my-project
91
+ ├── Cargo.toml
92
+ ├── my_project
93
+ │   ├── __init__.py
94
+ │   └── bar.py
95
+ ├── pyproject.toml
96
+ ├── README.md
97
+ └── src
98
+    └── lib.rs
99
+ ```
100
+
101
+ You can specify a different python source directory in `pyproject.toml` by setting `tool.maturin.python-source`, for example
102
+
103
+ **pyproject.toml**
104
+
105
+ ```toml
106
+ [tool.maturin]
107
+ python-source = "python"
108
+ module-name = "my_project._lib_name"
109
+ ```
110
+
111
+ then the project structure would look like this:
112
+
113
+ ```
114
+ my-project
115
+ ├── Cargo.toml
116
+ ├── python
117
+ │ └── my_project
118
+ │ ├── __init__.py
119
+ │ └── bar.py
120
+ ├── pyproject.toml
121
+ ├── README.md
122
+ └── src
123
+    └── lib.rs
124
+ ```
125
+
126
+ > [!NOTE]
127
+ >
128
+ > This structure is recommended to avoid [a common `ImportError` pitfall](https://github.com/PyO3/maturin/issues/490)
129
+
130
+ maturin will add the native extension as a module in your python folder. When using develop, maturin will copy the native library and for cffi also the glue code to your python folder. You should add those files to your gitignore.
131
+
132
+ With cffi you can do `from .my_project import lib` and then use `lib.my_native_function`, with pyo3 you can directly `from .my_project import my_native_function`.
133
+
134
+ Example layout with pyo3 after `maturin develop`:
135
+
136
+ ```
137
+ my-project
138
+ ├── Cargo.toml
139
+ ├── my_project
140
+ │   ├── __init__.py
141
+ │   ├── bar.py
142
+ │   └── _lib_name.cpython-36m-x86_64-linux-gnu.so
143
+ ├── README.md
144
+ └── src
145
+    └── lib.rs
146
+ ```
147
+
148
+ When doing this also be sure to set the module name in your code to match the last part of `module-name` (don't include the package path):
149
+
150
+ ```rust
151
+ #[pymodule]
152
+ #[pyo3(name="_lib_name")]
153
+ fn my_lib_name(m: &Bound<'_, PyModule>) -> PyResult<()> {
154
+ m.add_class::<MyPythonRustClass>()?;
155
+ Ok(())
156
+ }
157
+ ```
158
+
159
+ ## Python metadata
160
+
161
+ maturin supports [PEP 621](https://www.python.org/dev/peps/pep-0621/), you can specify python package metadata in `pyproject.toml`.
162
+ maturin merges metadata from `Cargo.toml` and `pyproject.toml`, `pyproject.toml` takes precedence over `Cargo.toml`.
163
+
164
+ To specify python dependencies, add a list `dependencies` in a `[project]` section in the `pyproject.toml`. This list is equivalent to `install_requires` in setuptools:
165
+
166
+ ```toml
167
+ [project]
168
+ name = "my-project"
169
+ dependencies = ["flask~=1.1.0", "toml>=0.10.2,<0.11.0"]
170
+ ```
171
+
172
+ You can add so called console scripts, which are shell commands that execute some function in your program in the `[project.scripts]` section.
173
+ The keys are the script names while the values are the path to the function in the format `some.module.path:class.function`, where the `class` part is optional. The function is called with no arguments. Example:
174
+
175
+ ```toml
176
+ [project.scripts]
177
+ get_42 = "my_project:DummyClass.get_42"
178
+ ```
179
+
180
+ You can also specify [trove classifiers](https://pypi.org/classifiers/) in your `pyproject.toml` under `project.classifiers`:
181
+
182
+ ```toml
183
+ [project]
184
+ name = "my-project"
185
+ classifiers = ["Programming Language :: Python"]
186
+ ```
187
+
188
+ ## Source distribution
189
+
190
+ maturin supports building through `pyproject.toml`. To use it, create a `pyproject.toml` next to your `Cargo.toml` with the following content:
191
+
192
+ ```toml
193
+ [build-system]
194
+ requires = ["maturin>=1.0,<2.0"]
195
+ build-backend = "maturin"
196
+ ```
197
+
198
+ If a `pyproject.toml` with a `[build-system]` entry is present, maturin can build a source distribution of your package when `--sdist` is specified.
199
+ The source distribution will contain the same files as `cargo package`. To only build a source distribution, pass `--interpreter` without any values.
200
+
201
+ You can then e.g. install your package with `pip install .`. With `pip install . -v` you can see the output of cargo and maturin.
202
+
203
+ You can use the options `compatibility`, `skip-auditwheel`, `bindings`, `strip` and common Cargo build options such as `features` under `[tool.maturin]` the same way you would when running maturin directly.
204
+ The `bindings` key is required for cffi and bin projects as those can't be automatically detected. Currently, all builds are in release mode (see [this thread](https://discuss.python.org/t/pep-517-debug-vs-release-builds/1924) for details).
205
+
206
+ For a non-manylinux build with cffi bindings you could use the following:
207
+
208
+ ```toml
209
+ [build-system]
210
+ requires = ["maturin>=1.0,<2.0"]
211
+ build-backend = "maturin"
212
+
213
+ [tool.maturin]
214
+ bindings = "cffi"
215
+ compatibility = "linux"
216
+ ```
217
+
218
+ `manylinux` option is also accepted as an alias of `compatibility` for backward compatibility with old version of maturin.
219
+
220
+ To include arbitrary files in the sdist for use during compilation specify `include` as an array of `path` globs with `format` set to `sdist`:
221
+
222
+ ```toml
223
+ [tool.maturin]
224
+ include = [{ path = "path/**/*", format = "sdist" }]
225
+ ```
226
+
227
+ There's a `maturin sdist` command for only building a source distribution as workaround for [pypa/pip#6041](https://github.com/pypa/pip/issues/6041).
228
+
229
+ ## Manylinux and auditwheel
230
+
231
+ For portability reasons, native python modules on linux must only dynamically link a set of very few libraries which are installed basically everywhere, hence the name manylinux.
232
+ The pypa offers special docker images and a tool called [auditwheel](https://github.com/pypa/auditwheel/) to ensure compliance with the [manylinux rules](https://peps.python.org/pep-0599/#the-manylinux2014-policy).
233
+ If you want to publish widely usable wheels for linux pypi, **you need to use a manylinux docker image or build with zig**.
234
+
235
+ The Rust compiler since version 1.64 [requires at least glibc 2.17](https://blog.rust-lang.org/2022/08/01/Increasing-glibc-kernel-requirements.html), so you need to use at least manylinux2014.
236
+ For publishing, we recommend enforcing the same manylinux version as the image with the manylinux flag, e.g. use `--manylinux 2014` if you are building in `quay.io/pypa/manylinux2014_x86_64`.
237
+ The [PyO3/maturin-action](https://github.com/PyO3/maturin-action) github action already takes care of this if you set e.g. `manylinux: 2014`.
238
+
239
+ maturin contains a reimplementation of auditwheel automatically checks the generated library and gives the wheel the proper platform tag.
240
+ If your system's glibc is too new or you link other shared libraries, it will assign the `linux` tag.
241
+ You can also manually disable those checks and directly use native linux target with `--manylinux off`.
242
+
243
+ For full manylinux compliance you need to compile in a CentOS docker container. The [pyo3/maturin](https://ghcr.io/pyo3/maturin) image is based on the manylinux2014 image,
244
+ and passes arguments to the `maturin` binary. You can use it like this:
245
+
246
+ ```
247
+ docker run --rm -v $(pwd):/io ghcr.io/pyo3/maturin build --release # or other maturin arguments
248
+ ```
249
+
250
+ Note that this image is very basic and only contains python, maturin and stable rust. If you need additional tools, you can run commands inside the manylinux container.
251
+ See [konstin/complex-manylinux-maturin-docker](https://github.com/konstin/complex-manylinux-maturin-docker) for a small educational example or [nanoporetech/fast-ctc-decode](https://github.com/nanoporetech/fast-ctc-decode/blob/b226ea0f2b2f4f474eff47349703d57d2ea4801b/.github/workflows/publish.yml) for a real world setup.
252
+
253
+ maturin itself is manylinux compliant when compiled for the musl target.
254
+
255
+ ## Examples
256
+
257
+ - [agg-python-bindings](https://pypi.org/project/agg-python-bindings) - A Python Library that binds to Asciinema Agg terminal record renderer and Avt terminal emulator
258
+ - [ballista-python](https://github.com/apache/arrow-ballista-python) - A Python library that binds to Apache Arrow distributed query engine Ballista
259
+ - [bleuscore](https://github.com/shenxiangzhuang/bleuscore) - A BLEU score calculation library, written in pure Rust
260
+ - [chardetng-py](https://github.com/john-parton/chardetng-py) - Python binding for the chardetng character encoding detector.
261
+ - [connector-x](https://github.com/sfu-db/connector-x/tree/main/connectorx-python) - ConnectorX enables you to load data from databases into Python in the fastest and most memory efficient way
262
+ - [datafusion-python](https://github.com/apache/arrow-datafusion-python) - a Python library that binds to Apache Arrow in-memory query engine DataFusion
263
+ - [deltalake-python](https://github.com/delta-io/delta-rs/tree/main/python) - Native Delta Lake Python binding based on delta-rs with Pandas integration
264
+ - [opendal](https://github.com/apache/incubator-opendal/tree/main/bindings/python) - OpenDAL Python Binding to access data freely
265
+ - [orjson](https://github.com/ijl/orjson) - A fast, correct JSON library for Python
266
+ - [polars](https://github.com/pola-rs/polars/tree/master/py-polars) - Fast multi-threaded DataFrame library in Rust | Python | Node.js
267
+ - [pydantic-core](https://github.com/pydantic/pydantic-core) - Core validation logic for pydantic written in Rust
268
+ - [pyrus-cramjam](https://github.com/milesgranger/pyrus-cramjam) - Thin Python wrapper to de/compression algorithms in Rust
269
+ - [pyxel](https://github.com/kitao/pyxel) - A retro game engine for Python
270
+ - [roapi](https://github.com/roapi/roapi) - ROAPI automatically spins up read-only APIs for static datasets without requiring you to write a single line of code
271
+ - [robyn](https://github.com/sansyrox/robyn) - A fast and extensible async python web server with a Rust runtime
272
+ - [ruff](https://github.com/charliermarsh/ruff) - An extremely fast Python linter, written in Rust
273
+ - [rnet](https://github.com/0x676e67/rnet) - Asynchronous Python HTTP Client with Black Magic
274
+ - [rustpy-xlsxwriter](https://github.com/rahmadafandi/rustpy-xlsxwriter): A high-performance Python library for generating Excel files, utilizing the [rust_xlsxwriter](https://github.com/jmcnamara/rust_xlsxwriter) crate for efficient data handling.
275
+ - [tantivy-py](https://github.com/quickwit-oss/tantivy-py) - Python bindings for Tantivy
276
+ - [tpchgen-cli](https://github.com/clflushopt/tpchgen-rs/tree/main/tpchgen-cli) - Python CLI binding for `tpchgen`, a blazing fast TPC-H benchmark data generator built in pure Rust with zero dependencies.
277
+ - [watchfiles](https://github.com/samuelcolvin/watchfiles) - Simple, modern and high performance file watching and code reload in python
278
+ - [wonnx](https://github.com/webonnx/wonnx/tree/master/wonnx-py) - Wonnx is a GPU-accelerated ONNX inference run-time written 100% in Rust
279
+
280
+ ## Contributing
281
+
282
+ Everyone is welcomed to contribute to maturin! There are many ways to support the project, such as:
283
+
284
+ - help maturin users with issues on GitHub and Gitter
285
+ - improve documentation
286
+ - write features and bugfixes
287
+ - publish blogs and examples of how to use maturin
288
+
289
+ Our [contributing notes](https://github.com/PyO3/maturin/blob/main/guide/src/contributing.md) have more resources if you wish to volunteer time for maturin and are searching where to start.
290
+
291
+ If you don't have time to contribute yourself but still wish to support the project's future success, some of our maintainers have GitHub sponsorship pages:
292
+
293
+ - [messense](https://github.com/sponsors/messense)
294
+
295
+ ## License
296
+
297
+ Licensed under either of:
298
+
299
+ - Apache License, Version 2.0, ([LICENSE-APACHE](https://github.com/PyO3/maturin/blob/main/license-apache) or http://www.apache.org/licenses/LICENSE-2.0)
300
+ - MIT license ([LICENSE-MIT](https://github.com/PyO3/maturin/blob/main/license-mit) or http://opensource.org/licenses/MIT)
301
+
302
+ at your option.
303
+
@@ -0,0 +1,9 @@
1
+ maturin\__init__.py,sha256=tmumBl4GgA-QUC-ObzHYLKQ-9JQ7m5NbzP-OpWmAjDs,8345
2
+ maturin\__main__.py,sha256=UxDvFV1Hhu0gW_Jvb6Kzdc78gg7zjUUiZBhWrpLi5YU,1195
3
+ maturin\bootstrap.py,sha256=UJX3a3qom4hOf8S4u6RnQPxE7ryTaZHKhRDWvbgFgVA,1203
4
+ maturin-1.11.4.data\scripts\maturin.exe,sha256=UJJiqmnyEjo8ucOjq0EZG8Ld48-brjIOGAUZSxrKI_A,23134208
5
+ maturin-1.11.4.dist-info\METADATA,sha256=SKb3oxrduBKBXTvSFQxozBZfNK1405tb9DzUthnWIxg,16938
6
+ maturin-1.11.4.dist-info\WHEEL,sha256=hhuDfKhPIdoq9ysh1ECp2NTjQKFHwXNZaTMv0v1fH54,94
7
+ maturin-1.11.4.dist-info\licenses\license-apache,sha256=fP1zjFPWHHnwfjSPYiv3cHyQhCNwVNN_vgd4inX1iBw,11048
8
+ maturin-1.11.4.dist-info\licenses\license-mit,sha256=wxQ4V_npq8yxG5GzJOXtW7v4FLAIvyJJxDkw66h_CTs,1076
9
+ maturin-1.11.4.dist-info\RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: maturin (0.12.19)
2
+ Generator: maturin (1.11.4)
3
3
  Root-Is-Purelib: false
4
4
  Tag: py3-none-win_amd64