DEV Community

Amir mohamad
Amir mohamad

Posted on

Building a .pypkg Package Runner for Windows with Python 3.14 / 3.8 Auto-Selection

Hey devs! 👋

I recently built Python EnterPlase — a small PyQt5 desktop application
for Windows that runs .pypkg package files. I want to share what it does
and the interesting technical challenges I ran into.

The Problem

When you want to distribute a Python-based installer, you usually tell users:

"First install Python 3.x, then run these commands..."

This is fine for developers, but for non-technical users, it's a pain.

The Solution

Python EnterPlase handles this automatically. You give it a .pypkg file —
a simple text file with a header and a list of shell commands — and it:

  1. Detects your Windows version

    • Windows 10/11 → uses Python 3.14
    • Windows 8.1 and below → uses Python 3.8
  2. Prefers an already-installed Python

    • Checks py -3.XX launcher
    • Checks C:\PythonXXX\, Program Files, %LOCALAPPDATA%\Programs\Python
    • Checks PATH
    • Only downloads the official embeddable package if nothing is found
  3. Blocks dangerous commands

    • Registry edits (reg add, regedit)
    • Disk operations (format, diskpart)
    • bcdedit, vssadmin, net user, sc create, and more
    • With 3 layers of protection: preview, confirmation dialog, runtime block
  4. Shows everything before running

    • Developer name
    • SHA256 / SHA1 hashes (with copy button)
    • Plain-English description of every command

The .pypkg Format

It's just plain text:

Commander:cmd
Developer:YourName
DS:pip,storage
SHA256:pass
SHA1:pass
pip install --upgrade pip
pip install ursina
python "C:/install.py"
=END=
Enter fullscreen mode Exit fullscreen mode

Technical Challenges

1. Running commands safely on Windows

Early versions used shell=True with a string command. This broke with
quoted paths. The fix was to build the command as a list and pass it
directly to subprocess.run:


python
# Bad
subprocess.run(f'"{python_exe}" -m pip install ursina', shell=True)

# Good
subprocess.run([python_exe, "-m", "pip", "install", "ursina"])
2. Detecting Python without false positives
Just checking shutil.which("python") isn't enough — it might be the wrong
version. I ended up checking multiple sources in order of reliability.

3. Windows subprocess encoding
text=True alone uses the system default (cp1252). This breaks with
non-ASCII output. The fix:

python
subprocess.run(..., text=True, encoding="utf-8", errors="replace")
4. Unicode-safe GUI messages
Even the error messages can crash your app if they contain characters the
font can't render. Using errors="replace" everywhere helped.

Stack
Python 3.14 (or 3.8 on older Windows)

PyQt5 for the GUI

Nuitka for compilation (much harder to decompile than PyInstaller)

Try it out
Download: PythonEnterPlase.exe

Website: fjfycfgdy.github.io/Python-EnterPlase

It's free to use but proprietary (source not published). I'd love feedback
on the .pypkg format, the command-blocking rules, or anything else!

Have you ever built a Windows installer? How did you handle Python
version detection? Let me know in the comments!
Enter fullscreen mode Exit fullscreen mode

Top comments (0)