Skip to content

Commit 1e5d362

Browse files
authored
feat: Support large zip files (#3118)
Exposes zip's large file support through a new cli arg `--compression-enable-large-file-support`. This supports use cases where the zip's content is larger than 4GB. ``` 💥 maturin failed Caused by: Failed to write to zip archive for "wheel/abc.abi3.so" Caused by: Large file option has not been set ``` Looks like the readmes where not up to date, so the diff is a bit larger than just the compression option.
1 parent 062bea7 commit 1e5d362

File tree

6 files changed

+85
-23
lines changed

6 files changed

+85
-23
lines changed

guide/src/distribution.md

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,21 @@ Arguments:
3939
Rustc flags
4040
4141
Options:
42-
--strip
43-
Strip the library for minimum file size
42+
--strip [<STRIP>]
43+
Strip the library for minimum file size. Can be set to `true` or `false`, or used as a flag (`--strip` implies `true`)
4444
45-
--include-debuginfo
46-
Include debug info files (.pdb on Windows, .dSYM on macOS, .dwp on Linux) in the wheel.
47-
When enabled, maturin automatically configures split-debuginfo=packed so that separate
48-
debug info files are produced. Cannot be used with --strip.
45+
[env: MATURIN_STRIP=]
46+
[possible values: true, false]
4947
5048
--sdist
51-
Build a source distribution
49+
Build a source distribution and build wheels from it.
5250
53-
--compatibility [<compatibility>...]
54-
Control platform tags. Use `pypi` to ensure PyPI compatibility, or specify platform-specific
55-
tags like `manylinux2014`, `musllinux_1_2`, or `linux`.
51+
This verifies that the source distribution is complete and can be used to build the project from source.
52+
53+
--pgo
54+
Build with Profile-Guided Optimization (PGO).
5655
57-
The default is the lowest compatible `manylinux` tag, or plain `linux` if nothing matched
56+
Requires `pgo-command` to be set in `[tool.maturin]` in pyproject.toml. This performs a three-phase build: instrumented build, profile training, and optimized rebuild.
5857
5958
-i, --interpreter [<INTERPRETER>...]
6059
The python versions to build wheels for, given as the executables of interpreters such as `python3.9` or `/usr/bin/python3.8`
@@ -67,8 +66,17 @@ Options:
6766
6867
[possible values: pyo3, pyo3-ffi, cffi, uniffi, bin]
6968
70-
-o, --out <OUT>
71-
The directory to store the built wheels in. Defaults to a new "wheels" directory in the project's target directory
69+
--compatibility [<compatibility>...]
70+
Control the platform tag and PyPI compatibility.
71+
72+
This options offers both fine-grained control over the linux libc tag and a more automatic PyPI-compatibility option.
73+
74+
The `pypi` option applies on all platforms and ensure that only tags that can be uploaded to PyPI are used. The linux-specific options are `manylinux` tags (for example `manylinux2014`/`manylinux_2_24`) or `musllinux` tags (for example `musllinux_1_2`), and `linux` for the native linux tag. They are
75+
ignored on non-linux platforms.
76+
77+
Note that `manylinux1` and `manylinux2010` are unsupported by the rust compiler. Wheels with the native `linux` tag will be rejected by pypi, unless they are separately validated by `auditwheel`.
78+
79+
The default is the lowest compatible `manylinux` tag, or plain `linux` if nothing matched.
7280
7381
--auditwheel <AUDITWHEEL>
7482
Audit wheel for manylinux compliance
@@ -85,6 +93,15 @@ Options:
8593
8694
Make sure you installed zig with `pip install maturin[zig]`
8795
96+
-o, --out <OUT>
97+
The directory to store the built wheels in. Defaults to a new "wheels" directory in the project's target directory
98+
99+
--include-debuginfo
100+
Include debug info files (.pdb on Windows, .dSYM on macOS, .dwp on Linux) in the wheel. When enabled, maturin automatically configures split-debuginfo=packed so that separate debug info files are produced
101+
102+
--sbom-include <SBOM_INCLUDE>...
103+
Additional SBOM files to include in the `.dist-info/sboms` directory. Can be specified multiple times
104+
88105
-q, --quiet
89106
Do not print cargo log messages
90107
@@ -107,14 +124,24 @@ Options:
107124
Outputs a future incompatibility report at the end of the build (unstable)
108125
109126
--compression-method <COMPRESSION_METHOD>
110-
Zip compression method to use
111-
112-
[default: deflated]
127+
Zip compression method. Only Stored and Deflated are currently compatible with all package managers
113128
114129
Possible values:
115-
- deflated: Deflate compression
130+
- deflated: Deflate compression (levels 0-9, default 6)
116131
- stored: No compression
117-
- zstd: Zstandard compression
132+
- bzip2: BZIP2 compression (levels 0-9, default 6)
133+
- zstd: Zstandard compression (supported from Python 3.14; levels -7-22, default 3)
134+
135+
[default: deflated]
136+
137+
--compression-level <COMPRESSION_LEVEL>
138+
Zip compression level. Defaults to method default
139+
140+
--compression-enable-large-file-support
141+
Whether to use large file support for ZIP files. Defaults to false
142+
143+
--generate-stubs
144+
Auto generate Python type stubs by introspecting the binary. Requires PyO3 and its "experimental-inspect" feature
118145
119146
-h, --help
120147
Print help (see a summary with '-h')

guide/src/local_development.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ Options:
2828
2929
Use as `--extras=extra1,extra2`
3030
31+
-G, --group <GROUP>
32+
Install dependency groups defined in pyproject.toml (PEP 735)
33+
34+
Use as `--group=test,docs`
35+
3136
--skip-install
3237
Skip installation, only build the extension module inplace
3338
@@ -63,14 +68,24 @@ Options:
6368
Use `uv` to install packages instead of `pip`
6469
6570
--compression-method <COMPRESSION_METHOD>
66-
Zip compression method to use
67-
68-
[default: deflated]
71+
Zip compression method. Only Stored and Deflated are currently compatible with all package managers
6972
7073
Possible values:
71-
- deflated: Deflate compression
74+
- deflated: Deflate compression (levels 0-9, default 6)
7275
- stored: No compression
73-
- zstd: Zstandard compression
76+
- bzip2: BZIP2 compression (levels 0-9, default 6)
77+
- zstd: Zstandard compression (supported from Python 3.14; levels -7-22, default 3)
78+
79+
[default: deflated]
80+
81+
--compression-level <COMPRESSION_LEVEL>
82+
Zip compression level. Defaults to method default
83+
84+
--compression-enable-large-file-support
85+
Whether to use large file support for ZIP files. Defaults to false
86+
87+
--generate-stubs
88+
Auto generate Python type stubs by introspecting the binary. Requires PyO3 and its "experimental-inspect" feature
7489
7590
-h, --help
7691
Print help (see a summary with '-h')

src/compression.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ pub struct CompressionOptions {
5858
/// Zip compression level. Defaults to method default.
5959
#[arg(long, allow_negative_numbers = true)]
6060
pub compression_level: Option<i64>,
61+
62+
/// Whether to use large file support for ZIP files. Defaults to false.
63+
#[arg(
64+
long = "compression-enable-large-file-support",
65+
default_value_t = false
66+
)]
67+
pub large_file: bool,
6168
}
6269
impl CompressionOptions {
6370
/// Validate arguments, exit on error
@@ -83,6 +90,7 @@ impl CompressionOptions {
8390
Self {
8491
compression_method: method,
8592
compression_level: Some(method.default_level()),
93+
large_file: Default::default(),
8694
}
8795
}
8896

@@ -105,6 +113,9 @@ impl CompressionOptions {
105113
} else {
106114
Some(self.compression_level.unwrap_or(method.default_level()))
107115
});
116+
117+
options = options.large_file(self.large_file);
118+
108119
options
109120
}
110121
}

tests/cmd/build.stdout

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ Options:
120120
--compression-level <COMPRESSION_LEVEL>
121121
Zip compression level. Defaults to method default
122122

123+
--compression-enable-large-file-support
124+
Whether to use large file support for ZIP files. Defaults to false
125+
123126
--generate-stubs
124127
Auto generate Python type stubs by introspecting the binary. Requires PyO3 and its
125128
"experimental-inspect" feature

tests/cmd/develop.stdout

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ Options:
7575
--compression-level <COMPRESSION_LEVEL>
7676
Zip compression level. Defaults to method default
7777

78+
--compression-enable-large-file-support
79+
Whether to use large file support for ZIP files. Defaults to false
80+
7881
--generate-stubs
7982
Auto generate Python type stubs by introspecting the binary. Requires PyO3 and its
8083
"experimental-inspect" feature

tests/cmd/publish.stdout

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ Options:
158158
--compression-level <COMPRESSION_LEVEL>
159159
Zip compression level. Defaults to method default
160160

161+
--compression-enable-large-file-support
162+
Whether to use large file support for ZIP files. Defaults to false
163+
161164
--generate-stubs
162165
Auto generate Python type stubs by introspecting the binary. Requires PyO3 and its
163166
"experimental-inspect" feature

0 commit comments

Comments
 (0)