Many of you may know a Python can be as simple as a single script file and perhaps add on a requirements file (or PEP 723 – Inline script metadata | peps.python.org) if you have external dependencies.
When it comes to sharing your code, the commonly recommended route is to make a standard package[1]. You guys here at the pyOpenSci forum are very familiar with this and its pain.
However, there’s a disparity between the first two paragraphs above. With just a script and requirements file, I can run my python code. If I give them this, can’t someone else also do the same? Why can’t this be a form of sharing code? Isn’t this much easier than learning the PyPA packaging ecosystem? We see evidence of this in repositories that have not yet adopted packaging: a repository of python files and a requirements file. Alongside specifying the right Python version, is there no way I can have a tool that takes this information and just run the code?
This idea is not for every type of Python code. A Python library is code that are meant for other code to use (e.g., import numpy
) and packaging is a great solution for sharing this kind of code. On the other hand, packaging is not a good solution for most Python applications—code that is meant to be ran (e.g., Python websites flask app.py
, Jupyter notebooks, TUIs like Textual, WASM/pyodide websites, and at often times, ran reproducibly. In discussion elsewhere, this use case is sometimes called the “application project”, “application workflow”, “application-first projects”, “projects that aren’t meant to be packaged as a wheel”, etc.
This is getting too long and I haven’t gotten to what’s missing in the Python world and what can be done. I really like to open up this discussion beyond what’s being discussed at the Python forum and at PyCon. I’m looking around for communities that are interested in this problem. I’d love to open this up in-person (SciPy?) or other opportunities.
Upshot/TLDR: Python lacks support for application project. Applications makes up the majority of Python code out there, not libraries[2]. Packaging does not solve this.
There are many forms of packaging, but a standard package refers to the PyPA specification: a wheel file and/or a source distribution that can be uploaded to PyPI. ↩︎
I bet. If anyone has data please come talk to me! ↩︎