Skip to content

Shared Layer

Configuration dataclasses and exception hierarchy for EzCompiler.

The shared layer contains data structures and exceptions used across all layers of the framework.


Configuration

CompilerConfig

Main configuration dataclass containing all compilation settings.

CompilerConfig dataclass

CompilerConfig(version: str, project_name: str, main_file: str, include_files: dict[str, list[str]], output_folder: Path, version_filename: str = 'version_info.txt', project_description: str = '', company_name: str = '', author: str = '', icon: str = '', packages: list[str] = list(), includes: list[str] = list(), excludes: list[str] = list(), console: bool = True, compiler: str = 'auto', zip_needed: bool = True, repo_needed: bool = False, upload_structure: str = 'disk', repo_path: str = 'releases', server_url: str = '', optimize: bool = True, strip: bool = False, debug: bool = False, compiler_options: dict[str, Any] = dict())

Configuration class for project compilation.

Centralizes all configuration parameters needed for project compilation, version generation, packaging, and distribution. Validates configuration on initialization and provides helper properties for file paths.

Attributes:

Name Type Description
version str

Project version (e.g., "1.0.0")

project_name str

Name of the project

main_file str

Path to main Python file

include_files dict[str, list[str]]

Dict with 'files' and 'folders' lists

output_folder Path

Path to output directory

version_filename str

Name of version info file (default: "version_info.txt")

project_description str

Project description

company_name str

Company or organization name

author str

Project author

icon str

Path to project icon

packages list[str]

List of Python packages to include

includes list[str]

List of modules to include

excludes list[str]

List of modules to exclude

console bool

Show console window in compiled app (default: True)

compiler str

Compiler to use - "auto", "Cx_Freeze", "PyInstaller", "Nuitka"

zip_needed bool

Create zip archive (default: True)

repo_needed bool

Use repository (default: False)

upload_structure str

Upload target - "disk" or "server"

repo_path str

Repository path (default: "releases")

server_url str

Server upload URL

optimize bool

Optimize code (default: True)

strip bool

Strip debug info (default: False)

debug bool

Enable debug mode (default: False)

compiler_options dict[str, Any]

Compiler-specific options dict (default: {})

Example

config = CompilerConfig( ... version="1.0.0", ... project_name="MyApp", ... main_file="main.py", ... include_files={"files": ["config.yaml"], "folders": ["lib"]}, ... output_folder=Path("dist") ... ) config_dict = config.to_dict()

version_file property

version_file: Path

Get the full path to the version file.

Returns:

Name Type Description
Path Path

Full path to version_info.txt in output folder

zip_file_path property

zip_file_path: Path

Get the path to the zip file.

Uses the project name as the zip filename, placed next to the output folder (e.g., dist/MyApp.zip).

Returns:

Name Type Description
Path Path

Path to the zip archive file

to_dict

to_dict() -> dict[str, Any]

Convert configuration to dictionary.

Creates a comprehensive dictionary representation of the configuration with nested structures for compilation, upload, and advanced settings.

Returns:

Type Description
dict[str, Any]

dict[str, Any]: Configuration as nested dictionary

Example

config = CompilerConfig(...) config_dict = config.to_dict() print(config_dict["version"]) '1.0.0'

from_dict classmethod

from_dict(config_dict: dict[str, Any]) -> CompilerConfig

Create configuration from dictionary.

Flattens nested structures (compilation, upload, advanced) and creates a new CompilerConfig instance. Handles backward compatibility for 'version_file' key.

Parameters:

Name Type Description Default
config_dict dict[str, Any]

Configuration dictionary with nested structures

required

Returns:

Name Type Description
CompilerConfig CompilerConfig

New configuration instance

Raises:

Type Description
ConfigurationError

If required fields are missing or invalid

Example

config_dict = { ... "version": "1.0.0", ... "project_name": "MyApp", ... "main_file": "main.py", ... "include_files": {"files": [], "folders": []}, ... "output_folder": "dist" ... } config = CompilerConfig.from_dict(config_dict)


Exceptions

Base Exceptions

EzCompilerError

Base exception class for all EzCompiler errors.

EzCompilerError

Bases: Exception

Base exception for all EzCompiler utils errors.


Service Exceptions

Exceptions raised by service layer components.

CompilationError

Exception raised when compilation fails.

CompilationError

Bases: CompilerServiceError

Raised when project compilation fails.


ConfigurationError

Exception raised when configuration is invalid.

ConfigurationError

Bases: CompilerServiceError

Raised when configuration is invalid or missing.


TemplateServiceError

Exception raised when template processing fails.

TemplateServiceError

Bases: EzCompilerServiceError

Base exception for template service operations.


UploaderServiceError

Exception raised when upload operations fail.

UploaderServiceError

Bases: EzCompilerServiceError

Base exception for uploader service operations.


CompilerServiceError

Exception raised when compiler service operations fail.

CompilerServiceError

Bases: EzCompilerServiceError

Base exception for compiler service operations.


Utils Exceptions

Exceptions raised by utility modules.

ValidationError

Exception raised when validation fails.

ValidationError

Bases: EzCompilerError

Base exception for validation errors.


FileError

Exception raised when file operations fail.

FileError

Bases: EzCompilerError

Base exception for file operation errors.


ConfigError

Exception raised when configuration parsing fails.

ConfigError

Bases: EzCompilerError

Base exception for configuration errors.


ZipError

Exception raised when ZIP operations fail.

ZipError

Bases: EzCompilerError

Base exception for ZIP operation errors.


TemplateProcessingError

Exception raised when template operations fail.

TemplateProcessingError

Bases: EzCompilerError

Base exception for template processing errors.


UploadError

Exception raised when uploader operations fail.

UploadError

Bases: EzCompilerError

Base exception for upload operation errors.


CompilerError

Exception raised when compiler operations fail.

CompilerError

Bases: EzCompilerError

Base exception for compiler operation errors.