[Python-ideas] Defining an easily installable "Recommended baseline package set"

Nick Coghlan ncoghlan at gmail.com
Sat Oct 28 23:57:01 EDT 2017


Over on python-dev, the question of recommending MRAB's "regex" module over
the standard library's "re" module for more advanced regular expressions
recently came up again.

Because of various logistical issues and backwards compatibility risks,
it's highly unlikely that we'll ever be able to swap out the current _sre
based re module implementation in the standard library for an
implementation based on the regex module.

At the same time, it would be beneficial to have a way to offer an even
stronger recommendation to redistributors that we think full-featured
general purpose Python scripting environments should offer the regex module
as an opt-in alternative to the baseline re feature set, since that would
also help with other currently difficult cases like the requests module.

What I'm thinking is that we could make some relatively simple additions to
the `ensurepip` and `venv` modules to help with this:

1. Add a ensurepip.RECOMMENDED_PACKAGES mapping keyed by standard library
module names containing dependency specifiers for recommended third party
packages for particular tasks (e.g. "regex" as an enhanced alternative to
"re", "requests" as an enhanced HTTPS-centric alternative to
"urllib.request")

2. Add a new `install_recommended` boolean flag to ensurepip.bootstrap

3. Add a corresponding `--install-recommended flag to the `python -m
ensurepip` CLI

4. Add a corresponding `--install-recommended flag to the `python -m venv`
CLI (when combined with `--without-pip`, this would run pip directly from
the bundled wheel file to do the installations)

We'd also need either a new informational PEP or else a section in the
developer guide to say that the contents of
`ensurepip.RECOMMENDED_PACKAGES` are up to the individual module
maintainers (hence keying the mapping by standard library module name,
rather than having a single flat list for the entire standard library).

For redistributors with weak dependency support, these reference
interpreter level recommendations could become redistributor level
recommendations. Redistributors without weak dependency support could still
make a distinction between "default" installations (which would include
them) and "minimal" installations (which would exclude them).

Folks writing scripts and example code for independent distribution (i.e.
no explicitly declared dependencies) could then choose between relying on
just the standard library (as now), or on the standard library plus
independently versioned recommended packages.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20171029/e776f45f/attachment.html>


More information about the Python-ideas mailing list