build.pep517¶
Private Methods
Private methods, if any (those starting with _), are documented
for completeness but do not offer any stability guarantees.
They may change or be removed at any time without notice.
PEP 517 build hooks for Polytropos.
This module generates __manifest__.py from pyproject.toml configuration
and builds wheels using manifestoo-core for metadata generation.
Only functions required by PEP 517 are public.
_add_directory(tar, dir_path, arcname_prefix, exclude)
¶
Recursively add directory to tar archive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tar
|
TarFile
|
TarFile object to add files to |
required |
dir_path
|
Path
|
Directory to add |
required |
arcname_prefix
|
str
|
Prefix for the archive name |
required |
exclude
|
set[str]
|
Set of patterns to exclude |
required |
Source code in src/polytropos/build/pep517.py
_apply_editable_side_effects(addon_dir, pyproject_data, generated_manifest, file_maps, root, odoo_release)
¶
Apply side effects needed for editable install.
Writes manifest, PKG-INFO, applies file maps, and checks data files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
addon_dir
|
Path
|
Addon directory (project src dir or root) |
required |
pyproject_data
|
dict[str, Any]
|
Parsed pyproject.toml data |
required |
generated_manifest
|
dict[str, Any]
|
Generated manifest dictionary |
required |
file_maps
|
list[dict[str, Any]]
|
File maps to apply |
required |
root
|
Path
|
Project root directory |
required |
odoo_release
|
str
|
Odoo release string |
required |
Source code in src/polytropos/build/pep517.py
_copy_project_to_addon_dir(src, dst, generated_manifest, src_subdir=None, file_maps=None, odoo_release='')
¶
Copy project files to addon directory for building.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src
|
Path
|
Source project directory |
required |
dst
|
Path
|
Destination addon directory (named after the addon) |
required |
generated_manifest
|
dict[str, Any]
|
Generated manifest content |
required |
src_subdir
|
str | None
|
Optional subdirectory containing module files (e.g., "src") |
None
|
file_maps
|
list[dict[str, Any]] | None
|
Optional file maps to apply after copy |
None
|
odoo_release
|
str
|
Odoo release string for conditional rendering |
''
|
Source code in src/polytropos/build/pep517.py
_create_sdist_archive(root, sdist_path, sdist_name, exclude)
¶
Create sdist tarball from project files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
Path
|
Project root directory |
required |
sdist_path
|
Path
|
Path for the output sdist archive |
required |
sdist_name
|
str
|
Name for the sdist archive |
required |
exclude
|
set[str]
|
Set of patterns to exclude |
required |
Source code in src/polytropos/build/pep517.py
_get_editable_cache_dir(addon_dir, dist_name, version)
¶
Get the directory path for editable install symlinks.
The directory name includes the addon name, version, and a hash of the absolute addon path, making it human-identifiable while staying unique per source location.
Source code in src/polytropos/build/pep517.py
_iter_file_map_entries(addon_dir, file_maps)
¶
Yield file map entries with validated source paths.
Supports two modes: - src_files + dst_dir: each globbed file is mapped to dst_dir - src_dir + dst_dir: the entire src_dir is mapped as a single symlink to dst_dir
Source code in src/polytropos/build/pep517.py
_prepare_editable_build(config_settings)
¶
Common setup for editable builds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_settings
|
dict[str, Any] | None
|
PEP 517 config_settings |
required |
Returns:
| Type | Description |
|---|---|
tuple[Path, dict[str, Any], str, str | None, dict[str, Any], list[dict[str, Any]]]
|
Tuple of (root, pyproject_data, odoo_release, src_dir, generated_manifest, file_maps) |
Source code in src/polytropos/build/pep517.py
_prepare_target(target, addon_dir, is_dir_mode)
¶
Prepare target location. Returns False if the target should be skipped.
Source code in src/polytropos/build/pep517.py
_render_dir_contents(src, target, odoo_release)
¶
Render all XML files from source directory to target directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src
|
Path
|
Source directory path |
required |
target
|
Path
|
Target directory path |
required |
odoo_release
|
str
|
Odoo release string for conditional rendering |
required |
Source code in src/polytropos/build/pep517.py
_validate_data_files(addon_dir, generated_manifest)
¶
Validate that all data files referenced in manifest exist.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
addon_dir
|
Path
|
Base directory for data file lookup |
required |
generated_manifest
|
dict[str, Any]
|
Generated manifest dictionary |
required |
Source code in src/polytropos/build/pep517.py
_validate_readme_in_metadata(wheel_path, readme_info, root, src_dir=None)
¶
Validate readme file if specified.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wheel_path
|
Path
|
Path to the built wheel |
required |
readme_info
|
tuple[str, str, str | None] | None
|
Tuple of (readme_filename, content_type, description) or None |
required |
root
|
Path
|
Project root directory |
required |
src_dir
|
str | None
|
Source directory relative to root (optional) |
None
|
Source code in src/polytropos/build/pep517.py
_write_pkg_info(addon_dir, pyproject_data, version)
¶
Write PKG-INFO to addon directory for metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
addon_dir
|
Path
|
Path to the addon directory |
required |
pyproject_data
|
dict[str, Any]
|
Parsed pyproject.toml data |
required |
version
|
str
|
Version string for the package |
required |
Source code in src/polytropos/build/pep517.py
build_editable(editable_directory, config_settings=None, _metadata_directory=None)
¶
Build an editable install for the Odoo module.
PEP 660 hook.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
editable_directory
|
str
|
Directory to place editable install files |
required |
config_settings
|
dict[str, Any] | None
|
Build configuration |
None
|
_metadata_directory
|
str | None
|
Metadata directory (unused) |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Basename of the built wheel |
Source code in src/polytropos/build/pep517.py
build_sdist(sdist_directory, config_settings=None)
¶
Build a source distribution for the Odoo module.
PEP 517 mandatory hook.
The sdist is version-independent - it contains pyproject.toml and source files,
but NOT a version-specific __manifest__.py. The manifest is generated at build time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sdist_directory
|
str
|
Directory to place the sdist in |
required |
config_settings
|
dict[str, Any] | None
|
PEP 517 config_settings (unused) |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Path to the built sdist archive |
Source code in src/polytropos/build/pep517.py
build_wheel(wheel_directory, config_settings=None, _metadata_directory=None)
¶
Build a wheel for the Odoo module.
PEP 517 mandatory hook.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wheel_directory
|
str
|
Directory to place the wheel in |
required |
config_settings
|
dict[str, Any] | None
|
PEP 517 config_settings |
None
|
_metadata_directory
|
str | None
|
Unused, PEP 517 requirement |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Path to the built wheel file |
Source code in src/polytropos/build/pep517.py
prepare_metadata_for_build_editable(metadata_directory, config_settings=None)
¶
Prepare metadata for editable build.
PEP 660 optional hook. Builds editable wheel in a temp dir to avoid redundant work during the actual editable install, then extracts .dist-info metadata into the metadata_directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metadata_directory
|
str
|
Directory to place metadata |
required |
config_settings
|
dict[str, Any] | None
|
Build configuration |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Basename of the .dist-info directory |