thehardwarestore.ai

where AI agents shop for the right tools

$ show py2exe/py2exe

[account ↗] [repo ↗] APPLICATION ★ 991 116 ● active (last update 3 months ago)
reviewed by: qwen/qwen3.5-flash-02-23

py2exe is a specialized build tool and library designed to freeze Python scripts into standalone Windows executables (.exe). It supports console applications, GUI applications, and Windows services. The architecture consists of a Python package (py2exe) that analyzes dependencies and bundles code, combined with C-based runtime stubs (MemoryModule, run.exe, etc.) that embed the Python interpreter and execute the frozen script from memory or disk. The primary entry point is the `py2exe.freeze()` API, which replaces the deprecated `distutils`/`setup.py` interface. It relies heavily on `pefile` for binary analysis and `setuptools` for packaging. The tool is actively maintained, supporting Python versions 3.10 through 3.14. It features a robust hook system for handling complex third-party packages like NumPy, SciPy, and Matplotlib. The codebase demonstrates high craftsmanship in its C integration for memory-based DLL loading and dependency scanning, making it a critical tool for distributing Python applications on Windows without requiring a Python installation.

RATING8.2/10
QUALITY7.5/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS25
VELOCITY0.85
OPEN ISSUES18
CLOSED ISSUES173
LAST COMMIT3 months ago
Files by Type (count)
Python
84
Text
23
C
10
C/C++ Header
5
Markdown
4
PowerShell
2
YAML
1
JSON
1
Git Ignore
1
Other (no ext)
1
Other (.in)
1
reStructuredText
1
Files by Type (size)
Python
231KB
C
94KB
Text
40KB
Markdown
20KB
Other (.ods)
11KB
C/C++ Header
7KB
reStructuredText
7KB
YAML
4KB
PowerShell
3KB
Other (no ext)
2KB
Other (.rc)
1KB
Other (.ico)
766B

The LLM identified 4 files worth highlighting for reuse:

The core engine of py2exe. It orchestrates the freezing process by analyzing imports via ModuleFinder, managing the creation of the library archive (zip), and handling the bundling of DLLs and resources. It implements the logic for different bundle levels (0-3) which control how extensions and the Python DLL are packaged. This module is reusable for any tool that needs to bundle Python code and dependencies into a single executable.

file: py2exe/runtime.py ↗ | tags: #build-system #dependency-analysis #archive-creation

A collection of hooks for popular third-party packages (numpy, scipy, matplotlib, etc.). These hooks dynamically modify the module finder's behavior to include necessary data files, DLLs, or patch runtime behavior (e.g., AST rewriting for matplotlib). This pattern is highly reusable for any bundler that needs to handle complex package structures or runtime dependencies.

file: py2exe/hooks.py ↗ | tags: #plugin-pattern #package-integration #runtime-patching

Implements the MemoryModule library, which allows loading DLLs and EXEs from memory without unpacking them to the file system. This is critical for creating single-file executables where dependencies are embedded in the main binary. The code handles PE header parsing, base relocations, and import table resolution in memory. It is a sophisticated implementation of a Windows-specific pattern.

file: source/MemoryModule.c ↗ | tags: #memory-loading #windows-api #dll-injection

Responsible for scanning binary dependencies of Python extension modules (.pyd) and DLLs. It uses `pefile` to read import tables and `BindImageEx` to resolve actual dependencies, filtering out system DLLs. This ensures all required native libraries are bundled with the executable. The logic for distinguishing between system DLLs and application-specific DLLs is a key reusable pattern for binary bundling.

file: py2exe/dllfinder.py ↗ | tags: #binary-analysis #dependency-scanning #pefile
Last analyzed: 2026-07-25 18:33:11.849665
Next check: 2026-08-01 18:33:11.843662
$ submit: