Metadata-Version: 2.4
Name: maketool
Version: 1.2.4
Summary: Python Automation tool for building PySide6 UI and PyInstaller EXE.
Author-email: Alan Lilly <panofish@gmail.com>
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Requires-Dist: psutil

![PyPI](https://img.shields.io/pypi/v/maketool)
![Python](https://img.shields.io/badge/python-3.7%2B-blue)
![PySide6](https://img.shields.io/badge/PySide6-6.x-41CD52?logo=qt&logoColor=white)
![Platform](https://img.shields.io/badge/platform-Windows-lightgrey)
![License](https://img.shields.io/badge/license-MIT-green)

## Contents
- [Installation](#install)
- [Why Use maketool?](#why-use-maketool)
- [Commands](#commands)
  - [run](#1-run) · [clean](#2-clean) · [compile](#3-compile) · [sublime](#4-sublime) · [refscan](#5-refscan) · [unused](#6-unused)
- [Changelog](#changelog)

---
# Installation
Install maketool helper from PyPI with following command:
```
pip install maketool
```

Requires Python 3.7+, PySide6, and PyInstaller 5.8+

---
# Why Use maketool?
**maketool** is a command-line utility and helper module that simplifies running and building PySide6 Python 3.7+ applications into EXE using PyInstaller 5.8.0.  Note: Windows only

If you build windows desktop apps using PySide6, then maketool can save you a lot of time:

- Automates repetitive tasks like running, compiling, cleanup and more
- Greatly simplifies EXE creation of your python program (uses PyInstaller with no need to create tedious spec file)
- Automatically converts all `.ui` and `.qrc` files recursively when running or compiling.
- Command-line interface for `.bat` or `.sh` workflow automation
- Supports custom `.ico` icons for your EXE
- Supports optional resource embedding so you can embed extra files your EXE may need (ie. images, dlls, etc)
- Supports EXE version stamping
- Define pyside6 dlls to exclude from EXE in order to minimize EXE size

---
# Commands
## 1. run
Purpose: Compile .ui and .qrc files recursively (using pyside6-uic.exe and pyside6-rcc.exe), then run the Python program using pythonw.exe.

ONLY out-of-date pyside components are rebuilt, so we don't waste time rebuilding ui/qrc files if they are unchanged.


```
Usage:
    maketool-run [-h] file

Parameters:
    file        python file to run
    -h, --help  show this help message and exit
```

---
## 2. clean
Purpose: Remove build artifacts, caches, generated UI files, PyInstaller output, and spec files.

Removes:
- __pycache__ folders
- *_ui.py, *_rc.py, *.pyc, *.pyo
- PyInstaller build/ and dist/ folders
- .spec files in the current directory

Usage:
    maketool-clean

---
## 3. compile
Purpose: Build an EXE using PyInstaller, including UI/QRC compilation, icon embedding, version stamping, and resource embedding.

Features:
- Supports onefile/onedir/console modes
- Auto-generates a PyInstaller .spec file
- Handles .ui/.qrc compilation automatically
- Supports embedding arbitrary files (DLLs, images, data assets, etc.)


```
Usage:
    maketool-compile [-h] --file FILE --type {onefile,onedir,console}
                     [--icon ICON] [--embed EMBED]
                     [--exclude EXCLUDE]

Parameters:
    -h, --help            show this help message and exit
    --file FILE           python file to compile to EXE
    --type {onefile,onedir,console}
                          type of EXE to build
    --icon ICON           ico file
    --embed EMBED         comma delimited list of files to embed
    --exclude EXCLUDE     comma-delimited list of DLLs to exclude.
                          "" means exclude nothing.
                          If omitted, maketool uses its internal default list.
```


### Exclude:
PyInstaller often bundles Qt/OpenSSL DLLs that your application never actually touches at runtime. This is a well-known PySide6/PyInstaller pain point and can significantly inflate the size of your final EXE.

To address this, maketool-compile uses an internal list of commonly unused PySide6/Qt/OpenSSL DLLs and excludes them by default.
This can dramatically shrink the size of the generated EXE.

If your EXE crashes or is strangely missing functionality, try --exclude="" so nothing is excluded.  If your EXE still crashes then the bug is in your code.

### Version:
You can define your EXE version using `__version__` in your Python code. (optional)
```
__version__ = "3.7.2"
```

### Exclude Default
If --exclude parameter is not defined, then the following DLLs are automatically excluded:
```
qdirect2d.dll,qpdf.dll,opengl32sw.dll,Qt6Network.dll,Qt6Pdf.dll,Qt6QmlModels.dll,Qt6Qml.dll,libssl-3.dll,Qt6Quick.dll,Qt6Svg.dll,libcrypto-3.dll,QtNetwork.pyd,Qt6VirtualKeyboard.dll,qtuiotouchplugin.dll,qsvgicon.dll,qnetworklistmanager.dll,qtvirtualkeyboardplugin.dll,qwindowsvistastyle.dll,qcertonlybackend.dll,qopensslbackend.dll,qschannelbackend.dll,Qt6OpenGL.dll

```

### Exclude nothing (keep all DLLs that PyInstaller bundles for PySide6)
```
--exclude=""  
```

### Exclude only specified dlls
```
--exclude="Qt6Svg.dll,Qt6Qml.dll"
```

---
# Extras
## 4. sublime
**WARNING**: This will overwrite existing custom key bindings. 

Purpose: Install custom Sublime Text 4 shortcuts and commands.  
Future: planned support of vscode editor.

Shortcuts installed:
- CTRL+BACKSPACE - delete line
- CTRL+ALT+E - open windows explorer where current file is located
- CTRL+0 - reset font size
- F1 - insert print statement for variable where cursor is located
- F5 - run pyflakes on current python source
- F6 - maketool-refscan - scan for unused/orphan files in the project
- F7 - build (runs maketool-run on current script via the build system)
- F10 - maketool-unused - scan current python source for unused functions

```
Usage:
    maketool-sublime [-h] --path PATH

Parameters:
    -h, --help            show this help message and exit
    --path PATH           sublime text - data/package/user path
```

---

## 5. refscan
Purpose: Scan for unused/orphan files using string-based heuristics.
This is especially useful for catching forgotten assets like `.ui`, `.qss`, `.ico`, images, etc.
"Unused" means "no string reference found anywhere in .py files".

```
Default behavior:
    maketool-refscan

Show both used and unused:
    maketool-refscan --show-used

Write a CSV report:
    maketool-refscan --csv refscan-report.csv
```

Notes:
- This is heuristic (string-based). It may miss dynamically constructed paths/imports and may produce false positives.
- For best results, run it from your project root.

---

## 6. unused
Purpose: Statically scan a Python file (or all `.py` files in a directory) for functions and methods that are defined but never referenced elsewhere in that file — a quick way to spot dead code.

Output is formatted to match Sublime Text's `file_regex` build-result pattern, so each result line is double-clickable and jumps straight to the file and line in the editor.

```
Usage:
    maketool-unused [-h] [path]

Parameters:
    path        python file or directory to scan (default: current working directory)
    -h, --help  show this help message and exit
```

Bound to **F10** by `maketool-sublime`, so you can run it on the current file with a single keypress and click through the results.

Notes:
- Dunder methods (`__init__`, `__str__`, etc.) are always treated as used, since the interpreter calls them implicitly.
- Names listed in a module-level `__all__` are treated as used (exported API).
- `main()` and functions decorated with things like `@app.route`, `@pytest.fixture`, `@property`, `@staticmethod`, etc. are reported separately as "possibly framework-invoked" rather than flagged as dead code, since these are typically called implicitly.
- This is single-file static analysis. It won't detect usage from other modules, `getattr`/reflection, or dynamic dispatch by string name — treat results as a starting point for review, not a definitive dead-code list.

---
# Changelog

## [1.1.0] - 2026-07-23
- Initial release

## [1.0.2] - 2026-03-02
- `maketool-refscan` command for detecting unused/orphan project files

## [1.0.1] - 2026-01-20
- Fixed `maketool-clean` not removing `.spec` files in nested directories

## [1.2.1] - 2026-08-04
- Added `maketool-unused` for finding unused functions in python source
- Rebound F10 in `maketool-sublime` from "insert current date/day" to run `maketool-unused` on the current file

---

# License

MIT License  
Copyright 2026 Alan Lilly
