Python Build Utils Modules¶
This module provides a command-line interface (CLI) for Python build utilities.
It uses the click
library to create a CLI group and add commands for renaming
wheel files and removing tarballs.
Functions:
Name | Description |
---|---|
cli |
Defines the CLI group and adds commands for renaming wheel files and removing tarballs. |
Commands: rename_wheel_files: Command to rename wheel files. remove_tarballs: Command to remove tarballs.
cli()
¶
A collection of CLI tools for Python build utilities.
Source code in src\python_build_utils\cli_tools.py
22 23 24 25 |
|
This module provides functionality to create a wheel file from a .pyd file.
Classes:
Name | Description |
---|---|
PydFileFormatError |
Exception raised for errors in the .pyd file format. |
Functions:
Name | Description |
---|---|
pyd2wheel |
Path, package_version: Optional[str | None] = None, abi_tag=Optional[str | None]) -> Path: CLI interface for converting a .pyd file to a wheel file. |
convert_pyd_to_wheel |
Path, package_version: str | None = None, abi_tag: str | None = None) -> Path: |
_create_metadata_file(dist_info, name, package_version)
¶
Create the METADATA file.
Source code in src\python_build_utils\pyd2wheel.py
200 201 202 203 204 205 |
|
_create_record_file(root_folder, dist_info)
¶
Create the RECORD file.
Source code in src\python_build_utils\pyd2wheel.py
215 216 217 218 219 220 |
|
_create_wheel_archive(pyd_file, wheel_file_name, root_folder)
¶
Create the .whl file by zipping the contents of the temporary directory.
Source code in src\python_build_utils\pyd2wheel.py
223 224 225 226 227 228 229 230 231 232 233 |
|
_create_wheel_file(dist_info, python_version, abi_tag, platform)
¶
Create the WHEEL file.
Source code in src\python_build_utils\pyd2wheel.py
208 209 210 211 212 |
|
_display_wheel_info(name, package_version, python_version, platform, abi_tag)
¶
Display the wheel information.
Source code in src\python_build_utils\pyd2wheel.py
171 172 173 174 175 176 177 178 179 180 181 182 |
|
_extract_pyd_file_info(pyd_file)
¶
Extract the name, version, python version, and platform from the pyd file name.
Source code in src\python_build_utils\pyd2wheel.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
_get_package_version(package_version, version_from_filename)
¶
Get the package version from the provided version or the pyd file name.
Source code in src\python_build_utils\pyd2wheel.py
160 161 162 163 164 165 166 167 168 |
|
_make_metadata_content(name, version)
¶
Create the metadata for the wheel file.
Source code in src\python_build_utils\pyd2wheel.py
84 85 86 87 88 89 |
|
_make_record_content(root_folder)
¶
Create the RECORD file content for the wheel.
RECORD is a list of (almost) all the files in the wheel and their secure hashes.
Source code in src\python_build_utils\pyd2wheel.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
|
_make_wheel_content(python_version, abi_tag, platform)
¶
Create the wheel data for the wheel file.
Source code in src\python_build_utils\pyd2wheel.py
92 93 94 95 96 97 98 99 |
|
convert_pyd_to_wheel(pyd_file, package_version=None, abi_tag=None)
¶
Creates a wheel from a .pyd file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pyd_file
|
Path
|
The path to the .pyd file. |
required |
package_version
|
str | None
|
The version of the package. If not provided, it will be extracted from the filename. Defaults to None. |
None
|
abi_tag
|
str | None
|
The ABI tag for the wheel. If not provided, defaults to "none". |
None
|
Returns:
Name | Type | Description |
---|---|---|
Path |
Path | None
|
The path to the created wheel file. |
Source code in src\python_build_utils\pyd2wheel.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
create_dist_info_directory(root_folder, name, package_version)
¶
Create the .dist-info directory.
Source code in src\python_build_utils\pyd2wheel.py
193 194 195 196 197 |
|
create_temp_directory(pyd_file)
¶
Create a temporary directory to store the contents of the wheel file.
Source code in src\python_build_utils\pyd2wheel.py
185 186 187 188 189 190 |
|
pyd2wheel(pyd_file, package_version=None, abi_tag=None)
¶
Create a wheel from a compiled python *.pyd file.
Source code in src\python_build_utils\pyd2wheel.py
26 27 28 29 30 31 32 33 34 |
|
Remove the tar.gz files from the dist build folder.
remove_tarballs(dist_dir)
¶
Remove tarball files from dist.
This function removes tarball files from the given distribution directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dist_dir
|
str
|
The directory containing the tarball files to be removed. |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Example
remove_tarballs("dist")
Source code in src\python_build_utils\remove_tarballs.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
Rename wheel files in the dist folder of your python build directory to include platform and python version tags.
rename_wheel_files(dist_dir, python_version_tag, platform_tag, wheel_tag)
¶
Rename wheel files in the dist folder.
This function renames wheel files in the given distribution directory by
replacing the "py3-none-any" tag with a custom build version tag. The
build version tag is constructed using the provided python_version_tag
,
platform_tag
, and wheel_tag
. If wheel_tag
is provided, it is used
directly as the build version tag. Otherwise, the build version tag is
constructed using the python_version_tag
and platform_tag
.
Args:
dist_dir (str): The directory containing the wheel files to be renamed.
Default is 'dist'.
python_version_tag (str): The Python version tag to be included in the
new file name. Default is cp{major}{minor}.
platform_tag (str): The platform tag to be included in the new file
name. Default is sysconfig.get_platform().
wheel_tag (str): The custom wheel tag to be used as the build version
tag. If this is provided, it is used directly as the build version tag
and the other tags are ignored. If this is not provided, the build
tag is constructed using the `python_version_tag` and `platform_tag` as
described above.
Returns:
Type | Description |
---|---|
None
|
None |
Example
rename_wheel_files("dist", "cp39", "win_amd64", "")
Source code in src\python_build_utils\rename_wheel_files.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
|