11
votes
What's the current state-of-the-art in Python package creation/distribution?
I've been thinking on and off about packaging up a few simple Python utilities I've written to stick up on Github for people to use if they want, but, every time I go to check out how one goes about managing dependencies and all that for a project, I run into a whole wall of options. Does anyone better versed in all of this have any recommendations for me?
I’m going to offer a shoutout to my former colleague Greg, who just released PyOxidizer last year.
EDIT: The elevator pitch for this is that it generates a single executable binary that embeds the interpreter, your project, and all its dependencies.
A way to package up a python application pretty much exactly like that is something I have wanted for a while. Definitely going to try this out!
Please forgive my ignorance, but how is different from pyinstaller?
I have no idea TBH; I am not very well versed in the Python ecosystem.
If you want to build something you can put on PyPI and have people install with
pip install yourpackage, Poetry is rapidly gaining popularity and is really lovely to work with. It's also useful for things where you're making an end product that gets packaged in a Dockerfile, because it uses lock files.I'd be curious to know as well. Most of the time I see Python programs distributed as source files. That's fine for programmers, but less-so for regular people.
I played around with some tools to generate executables about 10 years ago, but didn't love any of them. Maybe things have improved since then.
A way to generate wasm files would be even more impressive. Assuming the gc problems have been solved.
I think Python is in a bit of a weird position there. It's interpreted, but it's also known by so many people as their main/first language that there's a strong desire to write stuff like CLI tools in it and pass them around as you might a grep executable or something. Tough to standardize a way to pass around a self-contained binary for something that runs on an interpreter :(
I mean it wouldn't really be possible to generate wasm files unless you packaged the entire python runtime in there.
Pip is pretty standard, while a Conda package is pretty nice to have too (especially if you require any precompiled binaries or interfaces to C/CXX codes).
This is a good place to start:
https://packaging.python.org/tutorials/packaging-projects/
Poetry is my new go-to tool for package setup but I tell users to use pipx to install the package
https://poetry.eustace.io/
https://pypi.org/project/pipx/
Pipx installs the entry points user-wide on the command line, but isolates each tool and its dependencies into a virtual environment automatically.