Cool Python libraries I want to try in 2022

Cool Python libraries I want to try in 2022

This isn't a post about my favourite Python libraries (iPython and Jupyter, pipx). Instead, I want to talk about cool Python libraries I've been hearing about, and want to try out

In no particular order:

The BeeWare Tools:

https://docs.beeware.org/en/latest/

I have been aware of BeeWare tools for a long time, but only recently have I've been hearing of people using them in real projects (mainly in forums).

BeeWare tools allow you to create cross-platform GUI apps you can run everywhere, from Windows to Android to iPhones.

My PyQt GUI blog is one of my most popular ones, which means many people have this need; and while PyQt does build cross platform tools, it isn't an easy tool to get started with, and I'm not sure you can build phone apps with it (at least not without a lot of work).

BeeWare tools, at least from what I've seen, make this process easy.

I'd like to build a non-toy app using Python and BeeWare and actually deploy it on a phone.

Update and warning about the Beeware libraries, from reddit user czaki:

The problem is that their application build environment does not contain all required libraries and if you try to run such applimage on one of the last releases it fails with information that some of the required libraries are not available.
If you go working configuration for briefcase you will try not touch it (most often after update of briefcase everything stop working). They do not support standard method of doing something in python world (you need to put requirements in special section in pyproject.tom, cannot use requirements.txt, you need to manually assign version, cannot use this from setp.cfg or use setuptools_scp, etc)  which introduce many of obsolete and dummy steps of maintenance.
You may get it working from your case, but it may happen that accidentally, when you change something in your program it will stop working without proper error message.
And if I good remember there is no simple way to sign such application to start if without warning about untrusted source.

So it looks like Beeware isn't ready for primetime, though you can try it for simple hobby projects.

shiv

https://shiv.readthedocs.io/en/latest/index.html

Not named for the Hindu God of Death, rather Shiv in American slang means a small knife, usually handmade, in prisons.

I've talked about this before, but Python packaging sucks. It's very hard to distribute Python code, especially for end users. There are many ways around this, including converting Python code to an executable. There are dozens of options, each with their own gotchas.

shiv is a tool I've been hearing good things about. It basically zips up your python execution environment, so the final user gets (very roughly) the environment you tested your code in. It also saves you messing with the system python environment.

Poetry

Related to the above, one major issue in sharing your code via virtual environments: in your pip file, you can lock your library versions, but not the dependencies. This can lead to a situation where people might get different versions of dependencies based on which order they installed the libraries. And this can cause issues if different libraries have different bugs.

These types of bugs are very to debug, as they will depend on the system where code is running.

Poetry aims to fix this problem by pinning the versions of all dependencies as well. But Poetry is more than that. You can use it to create virtual environments, install libraries etc. And it's very useful if you are creating libraries for distribution (via pip, for example).

Poetry is a complete tool for managing environments, installing libraries, sharing your code with others, creating pip packages etc.

Why poetry (instead of related tools)? Because after looking at comments on Reddit/Hacker News for the last 2-3 years, Poetry keeps getting recommended; which means it is working for many people.

Doit

https://pydoit.org/

I just recently heard about DoIt, as a replacement for make files. DoIt lets you run any commands (build, test, copy), but everything is written in Python and so very flexible. If you've ever tried to work with a complex Makefile, you know how painful trying to force complex logic in Makefiles syntax is. Python is infinitely easier to work with.

You don't even need to replace makefiles, doit can call make for you.

Another use case for doit, as described in the official docs, replace complex commands with one short one. So something like:

aws s3 sync _built/html s3://buck/et --exclude "*" --include "*.html"

can be replaced by:

doit publish

This is one of the tools I want to try, to create commands for some of the boring/repeated things I do everyday.

Textual and Rich

https://github.com/Textualize/rich
https://github.com/Textualize/textual

Textual is a TUI (Text User Interface) written with rich. While the libraries are independent, they were written by the same author, and I'd like to play with both.

Rich allows you to print colourful rich text on the commandline

Textual is a beautiful TUI app-building library

TUIs are not as popular as GUI or web based UI, but they are very popular in the coder/devops/sysadmin segment,  or anyone who works on the commandline a lot.

Update 19/1/22:

Dear PyGui

Reddit user python_rocks recommend Dear PyGui

https://github.com/hoffstadt/DearPyGui

I had heard of PyGui, but mistakenly assumed you needed a GPU for it. But from what I'm hearing, it'll work fine on a normal laptop.

It is cross-platform, fast and easy to use, so will certainly be on my list.

What are your favourites? Anything cool I should know about / try? Let me know

(or discuss on Reddit here: https://old.reddit.com/r/Python/comments/s727d5/cool_python_libraries_i_want_to_try_in_2022/)