Playing nice with external package managers

Resurrecting an old thread to cross-link a new discussion: https://discuss.python.org/t/updating-pep-376-making-record-optional-in-installed-dist-info/

Rather than adding a new file to indicate that an installation is externally managed, PEP 627 instead proposes that external management be indicated by leaving out the RECORD file from the installed dist-info directory. This actively makes life easier for system package managers, so it’s an approach they have strong incentives to adopt.

@ncoghlan Your link is broken. It says “Oops! That page doesn’t exist or is private.”

It’s title was prefixed by the PEP

1 Like

While PEP 627 helps a bit, there is still a way to go.
I got back to this topic when reviewing Fedora’s patch that adds a warning when pip install is run under root. (sudo pip install still appears in variuos tutorials, and still usually a bad idea. Except in some cases, like containers.)
We had a brief discussion with @dstufft on IRC, where we essentially rehashed ideas from this discussion before we remembered the discussion already exists.

FWIW, Fedora:

  • splits /usr (system packages) and /usr/local (pip-installed packages)
  • runs most system-installed software in Python’s isolated mode (so it ignores /usr/local)
  • also adds a warning for sudo pip install under root

Donald summarized what I think is the best plan:

I think the “right” solution is teach distro tooling to emit MANAGED-BY, and teach python tooling that MANAGED-BY means “don’t touch”, then get a Debian style split where distros install to /usr and pip installs to /usr/local (and then each distro can decide if they want to exclude /usr/local from sys.path when running system provided tools or not)
But devil is in the details, and I think someone needs to write those PEPs.

1 Like

Relevant discussion in the pip bugtracker

I think many of the folks on this thread have seen it, but we had some further discussions on the topic at this year’s PyCon, which has resulted in a new PEP that hopefully addresses this in a little more general way: