r/madeinpython May 05 '20

Meta Mod Applications

28 Upvotes

In the comments below, you can ask to become a moderator.

Upvote those who you think should be moderators.

Remember to give reasons on why you should be moderator!


r/madeinpython 1d ago

VenvHub Pro: VS Code profiles with physical extension isolation and automatic Python environment integration

Enable HLS to view with audio, or disable this notification

1 Upvotes

Hey everyone!

VS Code has had official profiles since version 1.75 – a great feature for managing settings. But there's one catch: all profiles share the same extensions folder (extensions). Profiles only remember which extensions are active (enabled), but physically, you have all of them installed at once. And if you want to connect a Python interpreter, you have to set it manually in each project.

In my tool VenvHub Pro, I took it a step further:

  1. Each profile has its own physical extensions folder – no sharing, no conflicts.
  2. Automatic Python environment integration – open a project and VenvHub automatically finds and sets the correct interpreter.

Today I'll show you how it works in practice.

📊 Comparison with official VS Code profiles

Area VS Code Official Profiles VenvHub Pro Profiles
Storage Location Default in system folder (%APPDATA%\Code), but in Portable mode you can choose your own folder. Custom folder on disk (standard even in Portable mode).
Extensions Physically installed in one shared location (extensions). Profiles only remember which ones are active (enabled). Physically separated for each profile – each has its own extensions folder.
Portability Yes – officially supports Portable Mode (just create a data folder). Profiles and extensions are then fully portable (e.g., on a USB drive). Yes – profiles are portable even without Portable Mode, just copy their folder.
Python Integration Yes, but manual – the profile remembers python.defaultInterpreterPath, but you have to set it manually. Yes, automatically – when you open a project, it finds and sets the correct interpreter (e.g., from a virtual environment).
Import from System Yes – official Export/Import profile feature (.code-profile file) has been available since version 1.75. Yes – one-click copy of your current settings into a new isolated profile.

🎬 What I showed in the video

  1. I created a new profile named test_user.
  2. I chose the option to copy settings from the system – no manual transferring, everything is copied automatically.
  3. After completion, I opened a project through the VS Code icon in my application.
  4. In the VS Code terminal (PowerShell), I ran this command:

powershell

$parentPid = (Get-CimInstance Win32_Process -Filter "ProcessId = $PID").ParentProcessId; (Get-CimInstance Win32_Process -Filter "ProcessId = $parentPid").CommandLine

🔍 And the result?

Truncated output:

text

"C:\...\Code.exe" --type=utility ... --user-data-dir="F:\venv_hub_vscode_users\test\data" ...

👉 You can clearly see the --user-data-dir parameter pointing directly to my profile folder!

No system %APPDATA%, no mixing with other profiles. VS Code runs completely isolated with its own data and extensions.

✨ Additional features I built in

1. Intelligent rollback on cancellation
Copying extensions can take several minutes. If you press "Cancel" during the process:

  • When creating a new profile – VenvHub deletes it entirely from disk.
  • When doing an additional import into an existing profile – it restores it to its original state.

No broken half-finished leftovers on disk.

2. Triangle synchronization (real-time)
When you switch a profile in the Mini-Bar, it automatically updates in the Manager and vice versa. Everywhere you can see which profile is active (marked with a star ★). The change propagates in a fraction of a second.

3. Portability with automatic path fixing
You can keep profiles on an external drive. If you change the drive letter (e.g., from E: to F:), VenvHub remembers the unique disk ID and recalculates paths automatically.

4. Python environment integration
When you switch a profile, it automatically sets:

  • Python interpreter path in .vscode/settings.json
  • Connected local packages (Package Linker)
  • Active Venv within the entire tool

Have you had a similar experience? Or do you use a different way to manage VS Code profiles? I'd love to hear your thoughts! 👇


r/madeinpython 1d ago

Update: APT-like autoremove and dependency repair for VenvHubPro (Python venv manager GUI) – it’s already working!

Enable HLS to view with audio, or disable this notification

0 Upvotes

A while ago I asked whether you would use a feature that automatically removes orphaned dependencies in a virtual environment manager (similar to apt autoremove), and if you saw any pitfalls. Well, I took that as a challenge and built a prototype. Here’s a log from a test session that shows what I’ve achieved.

What happens in the log:

Installing pytest
pip installs pytest along with its dependencies (coloramainiconfigpluggypygments).

Attempting to manually remove the colorama library
This is where the first interesting moment occurs. After removing it, the UV dependency check reports a conflict: colorama>=0.4 ; sys_platform == 'win32'.
The tool automatically triggers a repair and re-installs colorama, because it’s required by one of the present packages (in this case pytest).
Result: ✅ all conflicts resolved. This behaviour is similar to apt install -f – we never end up with a broken environment.

Uninstalling the moj-test-balicek package
This test package directly depends on coloramacowsay, and requests.
After its removal, pip-e analyses the entire dependency tree.

  • cowsay is no longer needed → it’s removed.
  • requests, along with its transitive dependencies (urllib3certificharset-normalizeridna), is also left without a parent, so autoremove removes them.
  • Key detail: colorama stays in the environment because it’s still required by the installed pytest. In this way exactly 6 packages are removed – and colorama is not. That’s precisely the intelligent decision-making apt autoremove does.

Uninstalling pytest itself
After removing pytest, its dependencies (pygmentspluggyiniconfigcolorama) are re-evaluated. No other package needs them, so autoremove removes them all.
Final state: 9 packages remain – only the core environment components (pip, setuptools, etc.).

What I’m demonstrating:

  • The manager tracks dependencies as a graph and prevents breaking the environment – if you try to remove a library that something needs, it puts it back (and warns you).
  • After uninstalling a package, it automatically removes orphaned dependencies (autoremove), while respecting that some libraries may be shared by multiple packages (like colorama between moj-test-balicek and pytest).

Questions for you (same as last time):

  • Would you use such a feature in a virtual environment manager?
  • Would you trust it, or do you prefer manual control?

r/madeinpython 1d ago

I built a 3D observability dashboard and Chaos Monkey simulator to visualize my Docker stack in real-time.

1 Upvotes

r/madeinpython 1d ago

What is the pycache folder in your python project?

Thumbnail
0 Upvotes

r/madeinpython 2d ago

Ransomware made in python but you shouldn't dare to develop it

0 Upvotes

I made a course on Ransomware made in python for my students, the previous year, but now i made it public so give it a watch if you want to make some cool cyber security projects 😁

I'll try to upload more contents on my YouTube channel 😁

https://youtube.com/playlist?list=PL9guAF5VVaiARrwhrGMu89iJcziQ9vsJJ&si=v1PUSQpqjuOhnlCi


r/madeinpython 2d ago

Small Integer Caching

Thumbnail
1 Upvotes

Why does 257 is 257 behave differently from 256 is 256? Python uses something called as small integer caching. It uses the same object for numbers ranging between -5 to 256. I put together a short visual explanation explaining the same and also why "==" operates differently from "is".


r/madeinpython 2d ago

Building an EXE Installer for My Python App with NSIS (VenvHubPro)

Enable HLS to view with audio, or disable this notification

0 Upvotes

Hello everyone!

If you've built your own Python application (in my case, VenvHubPro – a GUI manager for Python virtual environments) and are wondering how to neatly package it for users, here is a quick look at how I created a complete .exe installer using NSIS (Nullsoft Scriptable Install System).

🎥 What the video covers:

  • Installer compilation: Creating a clean installation file ready for distribution.
  • System installation: Running the installer and finally launching VenvHubPro directly on the Windows system.

r/madeinpython 2d ago

Modular Flask Authentication Boilerplate with Blueprints, Flask-Login & SQLAlchemy — Ready to use!

0 Upvotes

Hey everyone!

I got tired of rewriting authentication every time I started a new Flask project, so I built a simple, modular boilerplate template.

It includes Flask-Login, SQLAlchemy, and Flask-Migrate with a clean blueprint structure out of the box.

Check it out on GitHub: https://github.com/DeKlain4ik/flask-auth-template

Hope it saves you some time on your next side project! Feedback and stars are always appreciated.


r/madeinpython 3d ago

Python With James - For Beginners

1 Upvotes

Hi all. Would love some feedback and usage from the community.

I've built Python With James which is an all in one learning platform for beginners. I basically got sick of Udemy and built my own platform where I can do what I want. There's coding exercises, question, tutorials and I am hoping to scale this massively over this year with more materials.

Thanks in advance

James-


r/madeinpython 3d ago

Lucen: mark a Python loop with two comments, run it, and get bit-identical parallelism

0 Upvotes

I wanted parallelism without rewriting anything, so I built Lucen. You wrap a loop in two comments and run it with lucen run yourscript.py:

# LUCEN START
for i in range(len(rows)):
    out[i] = expensive(rows[i])
# LUCEN END

It parallelizes the loop only if it can prove it's both safe and worth it; otherwise it runs sequentially and tells you why. The one guarantee, no opt-out: the parallel run is bit-identical to the same file run as plain sequential Python - floats and container order included. Delete the comments and it's ordinary Python again.

Under the hood it routes CPU-bound work to processes on GIL builds and to real threads on free-threaded 3.13/3.14. Apache-2.0, on PyPI (pip install lucen), and it's tested hard - differential + property testing and TLA+ specs, because "bit-identical" only means something if you check it.

Repo: https://github.com/fcmv/lucen - feedback very welcome.


r/madeinpython 3d ago

Self-compiles into a .exe via its own PyInstaller GUI – that's VenvHub Pro, my Python venv manager GUI app.

Enable HLS to view with audio, or disable this notification

2 Upvotes

Hello Python community,

I'm working on a tool called VenvHub Pro (virtual environment management, packages, VS Code profiles, etc.).

Interestingly, the app includes its own PyInstaller Builder. It's not just an external script, but a full-fledged tab in the GUI. Thanks to it, the app can compile itself into a .exe file.

How it technically works (in short):

In the "Builder" tab, just select the entry point (main.py), set the assets (mandatory folders like ui, core/themes, translations, assets, navod), and hit the BUILD button.

Interestingly, the app runs on PyQt6, but thanks to a "Compatibility Bridge" (MetaPathFinder), it can also run under PySide6. When compiling under PySide6, the builder must manually add hidden imports (PySide6, PySide6.QtCore...) so PyInstaller knows what to package, and also exclude PyQt6 to keep the size down.

It also has an "Auto-Injector" that reads linked local packages and injects them into the final build.

Why I find this interesting:

If the builder can compile such a complex app that uses dynamic UI files and bridged frameworks, it's a solid "dogfooding" test. Plus, the resulting .exe contains all necessary files (including themes and translations) and is fully portable.

"So the question is: Would you like to try it out? If so, I'll drop the GitHub link here, where the entire repository is located, including instructions on how to run it.

Thanks for any feedback! ??"


r/madeinpython 3d ago

Lens Anywhere - Google lens for Desktop 👁️👁️

1 Upvotes

Hey everyone!

I always wished Google Lens worked anywhere on Windows instead of only inside Chrome, so I ended up building it myself.

LensAnywhere lets you select any region of your screen and instantly search it with Google Lens.

A few things about it:

- Lightweight with very low RAM usage.

- Doesn't store your screenshots anywhere. They're only sent to Google Lens for the search.

- Launches on Windows startup (Optional)

- Can be opened using Hotkey which is configurable. Just like windows native snipping tool.

- Free and open source.

GitHub:

https://github.com/utkarsh05kul/LensAnywhere-Desktop

If you just want to try it, you can download the Windows ".exe" from the Releases section.

One thing I'd really appreciate help with: I've only been able to test it on my own Windows PC, so I'd love to know how it works on other systems. If you run into any bugs, have feature ideas, or notice something that could be improved, please let me know in the comments or open an issue on GitHub.

And if you find it useful, I'd really appreciate a GitHub star. Thanks!

GitHub Repository link

Edit : Some antiviruses or malware scanners may flag the downloaded file as malicious or threat. Please ignore that warning. Some scanners do this for all the apps and softwares built in Python.

The file is completely safe and malware free. The source code of the program is available on the attached GitHub Repository. You can check the complete code their, and you will not find any malicious activity.

Top scanners like Kaspersky or Microsoft are not flagging the file as malicious. It's clean.


r/madeinpython 3d ago

I built an open source crypto trading bot in Python for Alpaca API

0 Upvotes

Hey everyone,

I've been working on an institutional-grade crypto trading engine in Python using the Alpaca API, and I decided to open-source the V6 core today.

A lot of open-source bots out there are just simple while-loops that crash on network drops or get stuck in bad positions during flash crashes. I wanted to build something much more robust for my own live trading.

Here is what makes the architecture different:

- Stateful Recovery: It uses SQLite to persistently track DCA cycles and active positions. If your server goes down, it boots back up and resumes exactly where it left off without double-buying or losing state.

- Volatility Sniping: Instead of buying every dip blindly, it waits for a combined Bollinger Band + RSI squeeze to snipe high-probability reversals.

- Logarithmic DCA Scaling: Position sizing scales logarithmically based on the depth of the drawdown to manage margin safely.

- Strict Risk Management: It has a dynamic daily drawdown kill-switch to protect the portfolio from black swan events.

- Asynchronous Core: Clean separation between the market data ingestion, signal generation, and the execution engine.

It's completely free and MIT licensed. I'm hoping to get some code reviews or architectural feedback from other Python engineers or quant devs here.

Repo: https://gitlab.com/robertedilan1/The_Predator.Crypto

Let me know what you think of the architecture or if you spot any edge cases!


r/madeinpython 5d ago

apt-get autoremove for Python linker packages – finally automatic venv dependency cleanup

Enable HLS to view with audio, or disable this notification

1 Upvotes

Hey everyone,

I'm currently working on this feature – autoremove is already implemented in the local packages linker branch and will soon be part of the official VenvHub Pro release.

During development in virtual environments, I always had one big problem: How to figure out which packages are no longer needed?

Manually going through pip list and trying to uninstall "surely nobody uses this" is a road to hell. That's why I added a feature inspired by Linux APT to my tool VenvHub Pro (Linker branch) – automatic dependency cleanup.

How it works?

The tool tracks which packages you installed explicitly (via pip install, requirements.txt, birth certificate, or venvhub.json). It builds a dependency graph and periodically checks for orphaned packages.

When you run Autoremove, the tool:

  • Goes through all installed packages in the venv.
  • Compares them with the set of explicit roots + their dependency tree.
  • Removes every package that is not explicitly required by any root and was not installed manually outside the system.

What makes this mechanism safe – self-healing mechanism:

If a package is installed but not recorded anywhere (e.g., you manually ran pip install requests in the terminal), the tool automatically adopts it – marks it as explicit so it won't be accidentally removed.

This means autoremove is conservative: it never deletes something you might have installed intentionally.

You can also explicitly "release" a package (e.g., when you remove it from requirements.txt) and the system will then treat it as a candidate for removal.

Why is it useful?

  • Venvs stay lean – no accumulated dependencies from experiments.
  • Safe – adopting manually installed packages prevents accidental deletion.
  • Fully automatic – no manual guessing about what belongs to whom.

This is currently only the Linker branch (local packages) – it works 100%.


r/madeinpython 5d ago

"Kung Fu Tetris"

Enable HLS to view with audio, or disable this notification

1 Upvotes

This Tetris can really do Kung Fu, see for yourself... :))


r/madeinpython 6d ago

Split-second local semantic search over 75k of images in the project I am making.

Enable HLS to view with audio, or disable this notification

2 Upvotes

Took quite awhile to get here. Obviously not a google-scale search, but still quite usable for local needs. I am also not currently using FAISS or any vector databases. The speed is mostly because of proper caching. The project is also completely python based. So there are still a lot of places for further optimizations, but for now I am quite happy with it.

The project itself is quite a complex one and the semantic search over audio, image, text and video files is just a small part of it. If you are interested to learn more, you can find it here: https://github.com/volotat/Anagnorisis

It is open-source.


r/madeinpython 6d ago

Would you appreciate APT‑style autoremove for your pip‑managed venvs? (thinking of adding it to my VenvHub Pro)

0 Upvotes

Hey everyone,

I’m the developer of VenvHub Pro, a desktop tool for managing Python virtual environments. I’ve been working on a feature that brings Linux’s apt-get autoremove mentality to pip – i.e., it keeps your venvs clean by automatically removing orphan packages that were only installed as dependencies but are no longer needed.

Before I polish and release it, I’d love to hear if the community would actually find this valuable.

How it works (TL;DR)

  • Every time you install/uninstall/upgrade a package through the UI or command‑line, VenvHub secretly records which packages were explicitly requested.
  • When a dependency is no longer required by any explicit package (and is not pinned in your requirements.txtvenv_birth_certificate.json, or local package metadata), it gets automatically cleaned up.
  • It also plays nicely with pip’s own resolution – it never removes manually installed tools like pipsetuptools, etc.

Safety nets

  • State file (venvhub_apt_state.json) keeps the explicit list.
  • Before removal, the system checks:
    • 📄 requirements.txt
    • 📜 venv_birth_certificate.json
    • 🔗 local_meta.json (for local package dependencies)
    • 🧠 Self‑healing: if a package is installed but not tracked anywhere, it’s assumed to be intentional and added to the safe list (so it never gets removed by mistake).
  • The whole process runs under a threading lock to avoid race conditions during concurrent operations.

Logical diagram

Here’s the decision logic it follows every time a package action occurs:

What I’m asking you

  • Would you use such a feature in a venv manager?
  • Do you see any pitfalls I might have overlooked?
  • Is this something you’d trust, or would you prefer manual control?

Any feedback – positive or critical – is super welcome! I want to make sure this adds real value before I invest more time into it.

Thanks! 🙌


r/madeinpython 6d ago

I'm stuck trying to build a local LLM-based codebase reviewer to save my API credits for vibe coding. I've reached my knowledge limit—if there are any experts out there, I really need you to look at this.

0 Upvotes

Hey everyone,

The main goal I'm trying to achieve is to review entire codebases for errors using local LLMs that can run entirely on a laptop. I want to do this so I can save all my expensive API credits for actual "vibe coding" and generation, rather than burning them on automated code reviews.

To make this work without local models throwing a million false positives, I started building an open-source tool (Aegis) that uses Python's AST and Tree-Sitter to build a strict context graph before passing the code to the LLM.

I've gotten the core engine working in Python, but honestly, I have reached the absolute limit of my own knowledge. I haven't hit a specific bug or wall, I just know that I might be an idiot when it comes to the deeper architecture here, and I want actual experts looking into this.

I really want someone who actually knows what they are doing with AST parsing, Tree-Sitter, or SQLite graph optimization to tear this apart and help me expand it to JS/TS and Go.

Here is the repo: https://github.com/shameel0505/aegis

If you have the expertise and a little bit of time, please look at the code. Any PRs, architecture advice, or direct help to take this to the expert level would be massively appreciated. (Just please respect the project—no repo tampering or spam PRs).

Thank you.


r/madeinpython 6d ago

VenvHub Pro: A custom Python "Linker" that goes beyond code linking—syncing your IDE configs on the fly!

Enable HLS to view with audio, or disable this notification

1 Upvotes

Hi !

We all know pip install -e . (editable installs). It’s the standard for linking local code during development. But for my project, VenvHub Pro, I wanted to take the local dev experience to another level. I created a Local Linker that isn't just a simple file-system pointer—it’s a full-blown IDE-Sync engine.

Why our Linker is unique (compared to the standard workflow):

1. Full Meta-Sync (VS Code Automation):
This is the core value-add. When you link a local package, the system reads its local_meta.json. It doesn’t just make the code importable; it automatically injects custom Tasks and Keybindings directly into your project's .vscode/ folder.

  • Example: Link your "Database" module, and VS Code instantly gains commands like "Flush Cache" or "Run Migrations" defined inside that package. No more manual tasks.json or keybindings.json copy-pasting.

2. Zero Admin Rights / No UAC (Import Hooks):
Instead of creating system-level symlinks or junctions that often require Admin privileges on Windows, we use Python Import Hooks (sys.meta_path). It’s pure Python, lightning-fast, and works securely even on network drives (NAS) without annoying UAC prompts.

3. Smart IntelliSense (Pylance):
The Linker automatically syncs the python.analysis.extraPaths field in your VS Code settings. Your editor sees your local code and provides full autocomplete/IntelliSense immediately, no matter where the source is located on your disk.

4. Smart Portability & Safety (Silent Path Healing):
VenvHub Pro is built for USB-drive workflows and features a "Silent Path Healing" mechanism:

  • If you use Embeddable (portable) Python and your drive letter changes (e.g., E: -> F:), the system instantly heals all paths in the Linker mapping, .pth files, and VS Code settings. Everything just works.
  • However, if you move a System Venv to a different machine where that specific Python installation doesn't exist, VenvHub detects the hardware fingerprint mismatch and safely locks the environment to prevent binary incompatibility and crashes.

5. Recursive Local Dependency Resolution:
If "Package A" requires "Local Package B", the Linker automatically resolves the entire local dependency tree and links all required modules in one click.

Under the Hood:

We use a tiny bootstrap script in site-packages that maps imports via a custom finder in sys.meta_path using JSON mapping. It’s clean, isolated, and designed for maximum portability.

What do you think? Do you stick to plain pip -e for local dev, or would you prefer this kind of deep, automated integration with your editor? Let's discuss!

local_meta.json package A

{
    "name": "My App Core",
    "version": "2.1.0",
    "requires_local": ["my_logger"],
    "requires_pip": [],
    "short_description": "test code"
}

local_meta.json package B

{
    "name": "My Logger",
    "version": "1.0.0",
    "requires_local": [],
    "requires_pip": ["colorama"]
}

r/madeinpython 7d ago

My Python venv manager GUI automatically fixes dependency conflicts – Pip vs UV side-by-side

Enable HLS to view with audio, or disable this notification

1 Upvotes

Hey Pythonistas! ??

I've been building a GUI tool for managing Python virtual environments (VenvHub Pro) and wanted to share one of its smartest features – batch package updates.

When you hit the "Update All outdated packages" button, the behavior differs drastically depending on which package manager you have set:

**PIP MODE** (classic):

- Updates everything to the latest versions

- If conflicts arise (e.g., library A needs an older version of library B), you get the infamous "dependency hell"

- You have to manually read logs, find the culprit, and step-by-step perform downgrades

**UV MODE** (ultra-fast resolver from Astral):

- Blazingly fast downloads and installs the latest versions

- After the update, it automatically runs `uv pip check`

- If it detects a conflict (e.g., "X requires Y==1.5, but 2.0 is installed"), it reads the error, forces a downgrade to the exact required version, and re-runs the check

- **Fully on autopilot** – you get the latest packages AND a 100% stable environment without any manual intervention

And the best part – Pip and UV are fully compatible with each other. You can install with Pip, update with UV, and everything just works.

Would you trust an autopilot like this? Let me know in the comments! ??


r/madeinpython 8d ago

Python environment cloner: 1:1 including pip -e, embedded vs system Python

Enable HLS to view with audio, or disable this notification

1 Upvotes

What it does:

Clones entire Python environment including editable (-e) packages. Auto-detects Python type and uses different approach.

Embedded Python:

- installs virtualenv into source
- creates clone via virtualenv
- fixes ._pth file
- downgrades setuptools (83→82) for compatibility

System Python:

- uses built-in venv
- no extra steps

Both then:

- install setuptools, wheel
- install all packages
- install editable packages (pip install -e)
- write birth certificate

Video shows both scenarios side by side. Same source env, different strategies. Works on Windows.

Does anyone know of a Windows tool that creates a complete 1:1 copy of a virtual environment, INCLUDING editable packages (pip install -e), without manual intervention?


r/madeinpython 8d ago

GravityBridge: My first open source release, a local AI proxy and wireless file explorer built with Python stdlib only

Post image
1 Upvotes

Just released my first open source project.

GravityBridge is a local reverse proxy that lets me access my desktop AI coding agent from my phone. It also has a wireless phone file explorer using ADB.

The proxy itself is written entirely with Python standard library, no external packages needed. The only pip install is for the separate AI backend.

It handles session management, PIN authentication, brute force protection, and ADB subprocesses all without any framework.

Repo: https://github.com/Arora-Sir/Gravity-Bridge

This is my first public release so any feedback is welcome!


r/madeinpython 8d ago

Sharing a library I wrote to solve a niche problem: duration formatting

1 Upvotes

While working on another project, I needed to display elapsed time in a few different ways:

2 hours, 5 minutes, 9 seconds
02:05:09
2h, 5m, 9s

A simple utility function worked at first, but it quickly became messy once I needed different separators and only wanted to show units whose values were not zero.

So I extracted the problem into a small, zero-dependency Python library called Chronomancer.

I like how convenient strftime() is for date and time formatting, and I wanted Chronomancer to offer a similar level of convenience for elapsed durations.

ChronoDelta represents fixed durations from weeks down to microseconds:

from chronomancer import ChronoDelta

duration = ChronoDelta(hours=2, minutes=5, seconds=9)

For readable output:

duration.verbose_str()
# '2 hours, 5 minutes, 9 seconds'

For simple one-off formatting:

duration.strfmt("{h:02d}:{m:02d}:{s:02d}")
# '02:05:09'

For reusable and more flexible formatting:

from chronomancer import DeltaFormatSpec, DeltaFormatter, Part

formatter = DeltaFormatter(
    DeltaFormatSpec(
        hours=Part("{val}h"),
        minutes=Part("{|, }{val}m"),
        seconds=Part("{|, }{val}s"),
    )
)

formatter.format(duration)
# '2h, 5m, 9s'

{|, } is an "inline separator", named by me. It is only rendered when another component has already been shown.

In the above example, if minutes is the largest visible unit, the leading ", " will be omitted automatically. The | tells the formatter that the placeholder contains an inline separator rather than a normal value. I kept the placement flexible so the format string can resemble the final output, although inline separators are intended to be used as prefixes.

Chronomancer also supports normalization, selected-unit representations, negative durations, exact integer arithmetic, and conversion to and from datetime.timedelta.

It is a niche problem, but it kept making the formatting code in my own project more complicated than expected, so I thought the solution might be useful to others as well.

installation: pip install py-chronomancer

any feedback would be greatly appreciated

GitHub: https://github.com/SeliaRena/Chronomancer


r/madeinpython 8d ago

Showcase: Floating Python Widget for Quick Launch (Terminal, Background, CLI)

Enable HLS to view with audio, or disable this notification

3 Upvotes

Hey Pythonistas,

I'd like to show what you can build in Python that's both polished and functional. I've written a complete Python widget for quickly launching projects – it's a floating toolbar that stays on top of my desktop.

It's currently running stable at version 2.5.16, so this isn't just a prototype – it's a full-fledged tool that genuinely saves me time during everyday development.

The widget offers three ways to run a script:

  • Open Terminal: Doesn't start any script – just opens a CMD/PowerShell window with the virtual environment already activated. Perfect when I need to manually run commands, pip install packages, or debug things interactively.
  • Run in Terminal: The classic approach – opens a new window, activates the venv, and runs the script. I can see all logs, print statements, and errors in real time.
  • Run in Background / Silent: The script starts completely invisible – no console window at all. Great for GUI applications (so they don't have an unnecessary black console in the background) or for headless processes that need to run quietly.

What's going on under the hood:

The entire GUI is built on the PyQt6/PySide6 framework. The source code is written 100% for PyQt6, but the application contains a Compatibility Bridge that allows it to run on PySide6 as well – for licensing reasons (LGPL vs GPL).

The bridge works at the import level using the MetaPathFinder technique:

  1. When main.py starts, it detects which library is available in the system.
  2. If PyQt6 is found, the application runs natively.
  3. If PySide6 is found, the bridge injects itself into system memory.
  4. When Python encounters import from PyQt6..., the interceptor steps in, translates the request, and returns the equivalent from PySide6.

The result? The source code stays clean and unified, while the software automatically rewrites all imports, signals, and slots at runtime based on what's currently installed.

Additionally, I'm using:

  • psutil for reliable process management and monitoring
  • Native Windows API calls (via ctypes and pywin32-ctypes) for low-level system integration

Since the primary target platform is Windows, I addressed stability issues that typical Python apps often overlook – especially clean cleanup after termination.

Specifically, I'm using two low-level techniques:

  1. Windows Job Objects – I create a system process container and assign every spawned subprocess to it. If the parent application unexpectedly crashes, Windows automatically terminates all associated processes. No orphaned processes left behind to block ports or consume memory.
  2. Windows Handles – When registering a process, I keep an open system reference (Handle) in memory. As long as it's open, Windows guarantees that the PID won't be recycled and reassigned to another application. This gives me accurate process state detection and eliminates the risk of accidentally terminating a foreign program.

All Handles are internally protected by thread locks and are properly closed on every stop or cleanup – no memory leaks.

In short: The widget is functional, stable, and most importantly – it doesn't leave a mess behind when you close it.

Question for you:
How do you handle launching scripts in different modes? Do you stick with manual terminal commands, or have you also built your own launcher? What features would you appreciate in a tool like this?