The State of Python Packaging
bernat.tech
bernat.tech
My favorite vote for “Completely break backwards compatibility in python4” is packaging. Tear it all out in one go and completely forget it then start fresh with one and only one way to do it, under completely new names kill pip, setup.py and everything connected to them and let the Phoenix rise again under a new name. Google is a graveyard of the last 6 different “the new way of doing it” and everyone learns by doing it “wrong” 3-4 different ways before they get even close to what’s considered “the right way” this quarter... and then they bikeshed their own “fix” over that and share it on their blog to confuse everyone else. It’s frustrating to no end.
All that and we havn’t even touched on distributing projects that mix in c++/c, or just pure python projects that need to be compiled to an executable pyinstaller works great for that though! Until it doesn’t for some obscure unknown reason you’ll then have to figure out.
Building c++ projects is an absolute breeze compared to the hell that is Python.
To elaborate on my current situation. With Elixir, I run mix new <project-name> and I get 1) a project structure, including test helpers, config stubs, formatter config, gitignore, and a mix.ex file where I can add dependencies. With some flags, I can get a supervised setup (for long-running stuff, basically), or an umbrella app that allows me to put multiple projects under one 'umbrella project'.
Aside from potential issues where the apps in an umbrella rely on different version of the same package, dependency is local to the project and doesn't conflict with another. I also get formatting and test 'tasks', with DocTest support.
I have the impression that conda and specifically how Python, Python packages, and native (e.g. C/C++) libraries interact is still an important problem not yet perfectly solved.
But most system package managers are platform specific, which is not really suitable to be adopted officially by cross-platform languages like Python. I mean, Python can't adopt Guix as "the" Python package manager since Guix has no Windows support.
Yes. I have always found it odd to distinguish between "package managers" and "build systems", let alone the (seemingly more recent?) distinction between "system package manager" and "language-specific package manager". These are all doing essentially the same job: run some commands, based on dependencies, to ensure some desired files are in the desired place.
I think the problem stems from Make being so baroque and unmodular/composable: it became widespread (probably via Worse Is Better) and was just about usable for individual applications (where the Makefile and source code are maintained by the same people). Yet it was hopeless for building an OS/distro, since:
- The distro's Makefiles would be maintained by different people to the applications', causing fragility
- Users want a lot of flexibility from their chosen distro, in terms of what gets installed, what versions, etc.
I think of Nix/Guix as "Make done right": their foundation is simple, logical, consistent, modular and composable, which makes them usable for defining everything from a small project's build script, up to whole OS configurations or cloud deployments.
> as long as the development material (e.g. a Python library) is available to the package repo
It depends what you mean by "the package repo". Nix and Guix can import definitions from anywhere, e.g. from files included with a project, or downloaded from a URL, or cloned from a particular revision of a git repo, etc. There just-so-happen to be some quite large repos out there (e.g. "nixpkgs") which define a whole load of packages, as well as utility functions for packaging or overriding certain languages, etc.
> or the package manager is able to use the language-specific repo (e.g. Pypi)
Yes, Nix and Guix can fetch data from arbitrary places (like Pypi) and run arbitrary code (like setup.py) as part of the build. The big package repos already contain reusable functions which do this, e.g. 'fetchPypi', 'buildPythonPackage', etc.
https://github.com/NixOS/nixpkgs/blob/master/doc/languages-f...
> But most system package managers are platform specific, which is not really suitable to be adopted officially by cross-platform languages like Python
Nix and Guix are cross-platform. They have been used to define whole OSes, but they also work standalone on any Linux distro and macOS.
> Guix has no Windows support
I've been following discussions about this, at least on the Nix side. I've not used Windows in decades, but apparently:
- Nix works in "Windows Subsystem for Linux" ( https://github.com/NixOS/nixpkgs/issues/30391 )
- Nix works on Cygwin (not sure what the latest info is, but I came across https://ternaris.com/lab/nix-on-windows.html )
- There's been some work on building/running with mingw, but it seems to be painful due to things like Windows' limitations on path names ( https://github.com/NixOS/nix/issues/1320 )
- Nix and Guix can be used to cross-compile standalone packages, e.g. developing on Linux or Cygwin but building artefacts which will run on Windows without external DLLs, etc.
The groups maintaining and promulgating 'bad' packages would have to relinquish control over some of the dependencies they're currently venturing in or statically linking, or packagers have to reverse engineer their build systems, do that work themselves, and maintain it going forward.
pip install numpy
should work on most platforms.
Nevertheless, there’re problems (that might be confusing to non-Python authors since they are not viewed as problems) like pip not installing system dependencies (e.g. matplotlib doesn’t install freetype).
I do rather like how more contemporary package managers just tend to install things locally (Node, Elixir, etc.), and I'm curious how things have evolved in the Ruby (and Python) ecosystems.
Especially the whole packaging thing with cargo makes so much sense. Compiling your application on a new machine is a breeze, you just need cargo and the rest happens automatically.
In the meantime I always find myself wondern how I was meant to do dependency managment again in python. Moving projects between machines can be a horror compared to Rust.
pipenv is a step forward, but nowhere near enough. We need something that just works and is part of python.
Another resource might be https://hynek.me/articles/testing-packaging/
With the Python-module(s)-under-"src/" option, where do people usually place their C extension code?
It's clear that I could use any name, like "pysrc", and not just "src/" for the Python code. What I'm asking about is if there is a growing consensus about how to organize a package with both Python and C modules.
matplotlib: src/ contains C code while lib/ contains Python
cffi: c/ contains C code, there is no lib/
numpy: contains C code in many places, like numpy/core/src/ ; no lib/
pyzmq: contains C code mostly under zmq/core/ ; no lib/
python-cdb: contains C code under src/ ; no lib/
Checking a few other packages: pycuda: contains C code under src/ ; no lib/
Pillow: contains C code under src/ ; no lib/
tornado: the one C file is under tornado/ ; no lib/ or src/
Caffe: C++ code under src/ ; no lib/
That is, I haven't found any packages which put C extension code under lib/ .Which packages are you thinking of?
Also I may have confused this with the src/ layout in the past and put my own C extensions into lib/. Thanks for the survey, I think I've been harboring this misconception for a while now.
Also keep in mind it is only for python packages, not applications--the primary benefit is that it is impossible for the tests to access files that are not part of the package build.
You can also just scroll down on the ranking page. Well worth reading. He laments that we as a society have lost our appetite for great media. Adroit exploration of a conceptual space, which is what One Punch Man does so incredibly well, is a feature of goodness, but it needs more to elevate it to true greatness. I agree with this.
My position however is that the economics of media production ensure that very little of it will ever be great. Greatness must be driven by vision, and placing mountains of resources at the sole command of one dictatorial visionary will always be a hard sell, and doesn't even ensure that you'll end up with actual greatness. For every Stanley Kubrick you have a dozen Michael Bays.
so 'azure-pipelines.yml' is not operating-system specific ?