|
5 | 5 | //! (either `python3.dll` or `python3y.dll`) |
6 | 6 | //! for MinGW-w64 and MSVC (cross-)compile targets. |
7 | 7 | //! |
8 | | -//! See <https://docs.python.org/3/c-api/stable.html> for the Stable ABI details. |
9 | | -//! |
10 | 8 | //! This crate **does not require** Python 3 distribution files |
11 | 9 | //! to be present on the (cross-)compile host system. |
12 | 10 | //! |
13 | | -//! **Note:** MSVC cross-compile targets require LLVM binutils |
14 | | -//! to be available on the host system. |
| 11 | +//! **Note:** MSVC cross-compile targets require either LLVM binutils |
| 12 | +//! or Zig to be available on the host system. |
15 | 13 | //! More specifically, `python3-dll-a` requires `llvm-dlltool` executable |
16 | 14 | //! to be present in `PATH` when targeting `*-pc-windows-msvc` from Linux. |
17 | 15 | //! |
| 16 | +//! Alternatively, `ZIG_COMMAND` environment variable may be set to e.g. "zig" |
| 17 | +//! or "python -m ziglang", then `zig dlltool` will be used in place |
| 18 | +//! of `llvm-dlltool` (or MinGW binutils). |
| 19 | +//! |
18 | 20 | //! PyO3 integration |
19 | 21 | //! ---------------- |
20 | 22 | //! |
|
42 | 44 | //! |
43 | 45 | //! The examples below assume using an older version of PyO3. |
44 | 46 | //! |
45 | | -//! ### Example `build.rs` script |
| 47 | +//! ### Example `build.rs` script for an `abi3` PyO3 extension |
46 | 48 | //! |
47 | 49 | //! The following cargo build script can be used to cross-compile Stable ABI |
48 | 50 | //! PyO3 extension modules for Windows (64/32-bit x86 or 64-bit ARM) |
|
72 | 74 | //! ```sh |
73 | 75 | //! PYO3_CROSS_LIB_DIR=target/python3-dll cargo build --target x86_64-pc-windows-gnu |
74 | 76 | //! ``` |
| 77 | +//! |
| 78 | +//! Generating version-specific `python3y.dll` import libraries |
| 79 | +//! ----------------------------------------------------------- |
| 80 | +//! |
| 81 | +//! As an advanced feature, `python3-dll-a` can generate Python version |
| 82 | +//! specific import libraries such as `python39.lib`. |
| 83 | +//! |
| 84 | +//! See the [`ImportLibraryGenerator`] builder API description for details. |
75 | 85 |
|
76 | 86 | #![deny(missing_docs)] |
77 | 87 | #![allow(clippy::needless_doctest_main)] |
@@ -105,6 +115,35 @@ const LIB_MSVC: &str = "lib.exe"; |
105 | 115 | /// |
106 | 116 | /// Generates `python3.dll` or `pythonXY.dll` import library directly from the |
107 | 117 | /// embedded Python ABI definitions data for the specified compile target. |
| 118 | +/// |
| 119 | +/// Example usage |
| 120 | +/// ------------- |
| 121 | +/// |
| 122 | +/// ```no_run |
| 123 | +/// # use std::path::Path; |
| 124 | +/// # use python3_dll_a::ImportLibraryGenerator; |
| 125 | +/// // Generate `python3.dll.a` in "target/python3-dll-a" |
| 126 | +/// ImportLibraryGenerator::new("x86_64", "gnu") |
| 127 | +/// .generate(Path::new("target/python3-dll-a")) |
| 128 | +/// .unwrap(); |
| 129 | +/// |
| 130 | +/// // Generate `python3.lib` in "target/python3-lib" |
| 131 | +/// ImportLibraryGenerator::new("x86_64", "msvc") |
| 132 | +/// .generate(Path::new("target/python3-lib")) |
| 133 | +/// .unwrap(); |
| 134 | +/// |
| 135 | +/// // Generate `python39.dll.a` in "target/python3-dll-a" |
| 136 | +/// ImportLibraryGenerator::new("x86_64", "gnu") |
| 137 | +/// .version(Some((3, 9))) |
| 138 | +/// .generate(Path::new("target/python3-dll-a")) |
| 139 | +/// .unwrap(); |
| 140 | +/// |
| 141 | +/// // Generate `python38.lib` in "target/python3-lib" |
| 142 | +/// ImportLibraryGenerator::new("x86_64", "msvc") |
| 143 | +/// .version(Some((3, 8))) |
| 144 | +/// .generate(Path::new("target/python3-lib")) |
| 145 | +/// .unwrap(); |
| 146 | +/// ``` |
108 | 147 | #[derive(Debug, Clone)] |
109 | 148 | pub struct ImportLibraryGenerator { |
110 | 149 | /// The compile target architecture name (as in `CARGO_CFG_TARGET_ARCH`) |
|
0 commit comments