[Python-ideas] PEP: Distributing a Subset of the Standard Library

Ethan Furman ethan at stoneleaf.us
Mon Nov 28 21:21:30 EST 2016


On 11/28/2016 05:46 PM, Random832 wrote:
> On Mon, Nov 28, 2016, at 15:05, Ethan Furman wrote:

>> Because it is unfriendly.  Helpful error messages are a great tool to
>> both beginner and seasoned programmers.
>
> There won't be a helpful error message unless the distributor writes
> one.

The purpose of this PEP, if I understand correctly, is to settle on a standard for the location of that distributor written helpful error message.  As a bonus, cpython itself can use the same mechanism for modules that are possible to build in the stdlib, but weren't.  This would be useful for folks that build their own version.

> Whatever the standard method is, it has to be something we can direct
> distributors to modify, it's simply not something Python can do on its
> own.

<smart alec>
---
Yo, Distributor!  If you move tkinter to a separate module, please add a tkinter.missing file in your main python package where tkinter is supposed to be; this file should contain a helpful message on how to install the tkinter package!
---

There.  Done.
</smart alec>

>  The default exception hook is as good a place as any. Maybe write
> most of the logic and get the distributors to just populate an
> empty-by-default array of structs with the module name and error message
> (and what about localization?)

This might handle the stdlib portion, but the PEP's solution could be easily extended to handle any Python application that is installable in pieces.  As far as localization -- it's a small text file, surely there are mechanisms already to deal with that?  (I don't know, it's not a problem I have to deal with.)

> And the idea that building a ".missing.py" for every optional module
> that's disabled is going to adequate is a bit naive.

Who said disabled?  The PEP says missing, as in not there -- not disabled, as in there but ... what? not able to be used?

> For one thing, they're not going to *be* disabled,

Ah, whew -- we agree on something! ;)

> the distributors are going to build
> the whole thing and break up the installed files into packages. And
> you've still got to get the distributors to actually put their friendly
> error message in those files,

No, we don't.  We provide a mechanism for them to use, and they use it or don't at their whim.  It's a quality-of-implementation issue.

> and the missing.py files are build
> artifacts instead of a source file that they can patch.

They are the ones that decide how to segment the stdlib, so they get to do the work.  I would imagine, or at least hope, that they have the build and segmentation code under version control -- they can patch that.

--
~Ethan~


More information about the Python-ideas mailing list