2012-04-27 17:32:38 -04:00
|
|
|
|
PEP: 421
|
|
|
|
|
Title: Adding sys.implementation
|
|
|
|
|
Version: $Revision$
|
|
|
|
|
Last-Modified: $Date$
|
|
|
|
|
Author: Eric Snow <ericsnowcurrently@gmail.com>
|
2012-05-25 14:15:20 -04:00
|
|
|
|
BDFL-Delegate: Barry Warsaw
|
2012-06-04 17:49:40 -04:00
|
|
|
|
Status: Final
|
2012-04-27 17:32:38 -04:00
|
|
|
|
Type: Standards Track
|
|
|
|
|
Content-Type: text/x-rst
|
2021-02-09 11:54:26 -05:00
|
|
|
|
Created: 26-Apr-2012
|
2012-04-27 17:32:38 -04:00
|
|
|
|
Post-History: 26-April-2012
|
2017-06-11 15:02:39 -04:00
|
|
|
|
Resolution: https://mail.python.org/pipermail/python-dev/2012-May/119683.html
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Abstract
|
|
|
|
|
========
|
|
|
|
|
|
2012-05-01 02:51:22 -04:00
|
|
|
|
This PEP introduces a new attribute for the ``sys`` module:
|
|
|
|
|
``sys.implementation``. The attribute holds consolidated information
|
|
|
|
|
about the implementation of the running interpreter. Thus
|
|
|
|
|
``sys.implementation`` is the source to which the standard library may
|
|
|
|
|
look for implementation-specific information.
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
|
|
|
|
The proposal in this PEP is in line with a broader emphasis on making
|
|
|
|
|
Python friendlier to alternate implementations. It describes the new
|
|
|
|
|
variable and the constraints on what that variable contains. The PEP
|
|
|
|
|
also explains some immediate use cases for ``sys.implementation``.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Motivation
|
|
|
|
|
==========
|
|
|
|
|
|
|
|
|
|
For a number of years now, the distinction between Python-the-language
|
|
|
|
|
and CPython (the reference implementation) has been growing. Most of
|
|
|
|
|
this change is due to the emergence of Jython, IronPython, and PyPy as
|
|
|
|
|
viable alternate implementations of Python.
|
|
|
|
|
|
|
|
|
|
Consider, however, the nearly two decades of CPython-centric Python
|
2012-05-15 11:04:25 -04:00
|
|
|
|
(i.e. most of its existence). That focus has understandably
|
2012-05-01 02:51:22 -04:00
|
|
|
|
contributed to quite a few CPython-specific artifacts both in the
|
|
|
|
|
standard library and exposed in the interpreter. Though the core
|
|
|
|
|
developers have made an effort in recent years to address this, quite
|
|
|
|
|
a few of the artifacts remain.
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
2012-05-01 02:51:22 -04:00
|
|
|
|
Part of the solution is presented in this PEP: a single namespace in
|
2012-04-27 17:32:38 -04:00
|
|
|
|
which to consolidate implementation specifics. This will help focus
|
2012-05-01 02:51:22 -04:00
|
|
|
|
efforts to differentiate the implementation specifics from the
|
|
|
|
|
language. Additionally, it will foster a multiple-implementation
|
|
|
|
|
mindset.
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Proposal
|
|
|
|
|
========
|
|
|
|
|
|
2012-05-06 05:17:25 -04:00
|
|
|
|
We will add a new attribute to the ``sys`` module, called
|
2012-05-12 10:27:18 -04:00
|
|
|
|
``sys.implementation``, as an object with attribute-access (as opposed
|
2012-05-25 14:13:23 -04:00
|
|
|
|
to a mapping). It will contain implementation-specific information.
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
2012-05-06 05:17:25 -04:00
|
|
|
|
The attributes of this object will remain fixed during interpreter
|
2012-04-27 17:32:38 -04:00
|
|
|
|
execution and through the course of an implementation version. This
|
2012-05-01 02:51:22 -04:00
|
|
|
|
ensures behaviors don't change between versions which depend on
|
2012-05-12 10:27:18 -04:00
|
|
|
|
attributes of ``sys.implementation``.
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
2012-05-15 11:04:25 -04:00
|
|
|
|
The object has each of the attributes described in the `Required
|
2012-05-12 10:27:18 -04:00
|
|
|
|
Attributes`_ section below. Those attribute names will never start
|
|
|
|
|
with an underscore. The standard library and the language definition
|
|
|
|
|
will rely only on those required attributes.
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
2012-05-12 10:27:18 -04:00
|
|
|
|
This proposal takes a conservative approach in requiring only a small
|
|
|
|
|
number of attributes. As more become appropriate, they may be added
|
|
|
|
|
with discretion, as described in `Adding New Required Attributes`_.
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
2012-05-12 10:27:18 -04:00
|
|
|
|
While this PEP places no other constraints on ``sys.implementation``,
|
|
|
|
|
it also recommends that no one rely on capabilities outside those
|
|
|
|
|
described here. The only exception to that recommendation is for
|
2012-05-25 14:13:23 -04:00
|
|
|
|
attributes starting with an underscore. Implementers may use those
|
2012-05-12 10:27:18 -04:00
|
|
|
|
as appropriate to store per-implementation data.
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
|
|
|
|
|
2012-05-12 10:27:18 -04:00
|
|
|
|
Required Attributes
|
|
|
|
|
-------------------
|
|
|
|
|
|
|
|
|
|
These are attributes in ``sys.implementation`` on which the standard
|
|
|
|
|
library and language definition will rely, meaning implementers must
|
|
|
|
|
define them:
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
2012-05-01 02:51:22 -04:00
|
|
|
|
**name**
|
2012-05-25 14:13:23 -04:00
|
|
|
|
A lower-case identifier representing the implementation. Examples
|
2012-05-12 10:27:18 -04:00
|
|
|
|
include 'pypy', 'jython', 'ironpython', and 'cpython'.
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
2012-05-01 02:51:22 -04:00
|
|
|
|
**version**
|
2012-05-12 10:27:18 -04:00
|
|
|
|
The version of the implementation, as opposed to the version of the
|
|
|
|
|
language it implements. This value conforms to the format described
|
|
|
|
|
in `Version Format`_.
|
|
|
|
|
|
|
|
|
|
**hexversion**
|
|
|
|
|
The version of the implementation in the same hexadecimal format as
|
|
|
|
|
``sys.hexversion``.
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
2012-05-01 02:51:22 -04:00
|
|
|
|
**cache_tag**
|
2022-01-21 06:03:51 -05:00
|
|
|
|
A string used for the :pep:`3147` cache tag. It would
|
2012-05-06 05:17:25 -04:00
|
|
|
|
normally be a composite of the name and version (e.g. 'cpython-33'
|
|
|
|
|
for CPython 3.3). However, an implementation may explicitly use a
|
|
|
|
|
different cache tag. If ``cache_tag`` is set to None, it indicates
|
|
|
|
|
that module caching should be disabled.
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
|
|
|
|
|
2012-05-06 05:17:25 -04:00
|
|
|
|
Adding New Required Attributes
|
|
|
|
|
------------------------------
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
2012-05-12 10:27:18 -04:00
|
|
|
|
In time more required attributes will be added to
|
|
|
|
|
``sys.implementation``. However, each must have a meaningful use case
|
|
|
|
|
across all Python implementations in order to be considered. This is
|
|
|
|
|
made most clear by a use case in the standard library or language
|
|
|
|
|
specification.
|
|
|
|
|
|
|
|
|
|
All proposals for new required attributes will go through the normal
|
2012-05-15 11:04:25 -04:00
|
|
|
|
PEP process. Such a PEP need not be long, just long enough. It will
|
|
|
|
|
need to sufficiently spell out the rationale for the new attribute,
|
|
|
|
|
its use cases, and the impact it will have on the various Python
|
2012-05-25 14:13:23 -04:00
|
|
|
|
implementations.
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Version Format
|
|
|
|
|
--------------
|
|
|
|
|
|
2012-05-01 02:51:22 -04:00
|
|
|
|
A main point of ``sys.implementation`` is to contain information that
|
|
|
|
|
will be used internally in the standard library. In order to
|
2012-05-12 10:27:18 -04:00
|
|
|
|
facilitate the usefulness of the version attribute, its value should
|
|
|
|
|
be in a consistent format across implementations.
|
2012-05-01 02:51:22 -04:00
|
|
|
|
|
2012-05-12 10:27:18 -04:00
|
|
|
|
As such, the format of ``sys.implementation.version`` will follow that
|
2012-05-06 05:17:25 -04:00
|
|
|
|
of ``sys.version_info``, which is effectively a named tuple. It is a
|
|
|
|
|
familiar format and generally consistent with normal version format
|
|
|
|
|
conventions.
|
2012-05-01 02:51:22 -04:00
|
|
|
|
|
2012-05-06 05:17:25 -04:00
|
|
|
|
|
2012-04-27 17:32:38 -04:00
|
|
|
|
Rationale
|
|
|
|
|
=========
|
|
|
|
|
|
|
|
|
|
The status quo for implementation-specific information gives us that
|
2012-05-06 05:17:25 -04:00
|
|
|
|
information in a more fragile, harder to maintain way. It is spread
|
2012-05-01 02:51:22 -04:00
|
|
|
|
out over different modules or inferred from other information, as we
|
2012-05-06 05:17:25 -04:00
|
|
|
|
see with `platform.python_implementation()`_.
|
2012-05-01 02:51:22 -04:00
|
|
|
|
|
|
|
|
|
This PEP is the main alternative to that approach. It consolidates
|
|
|
|
|
the implementation-specific information into a single namespace and
|
|
|
|
|
makes explicit that which was implicit.
|
|
|
|
|
|
|
|
|
|
|
2012-05-12 10:27:18 -04:00
|
|
|
|
Type Considerations
|
|
|
|
|
-------------------
|
2012-05-01 02:51:22 -04:00
|
|
|
|
|
2012-05-12 10:27:18 -04:00
|
|
|
|
It's very easy to get bogged down in discussions about the type of
|
|
|
|
|
``sys.implementation``. However, its purpose is to support the
|
|
|
|
|
standard library and language definition. As such, there isn't much
|
2012-05-15 11:04:25 -04:00
|
|
|
|
that really matters regarding its type, as opposed to a feature that
|
|
|
|
|
would be more generally used. Thus characteristics like immutability
|
|
|
|
|
and sequence-ness have been disregarded.
|
2012-05-06 05:17:25 -04:00
|
|
|
|
|
2012-05-15 11:04:25 -04:00
|
|
|
|
The only real choice has been between an object with attribute access
|
|
|
|
|
and a mapping with item access. This PEP espouses dotted access to
|
|
|
|
|
reflect the relatively fixed nature of the namespace.
|
2012-05-01 02:51:22 -04:00
|
|
|
|
|
|
|
|
|
|
2012-05-12 10:27:18 -04:00
|
|
|
|
Non-Required Attributes
|
|
|
|
|
-----------------------
|
2012-05-01 02:51:22 -04:00
|
|
|
|
|
2012-05-12 10:27:18 -04:00
|
|
|
|
Earlier versions of this PEP included a required attribute called
|
|
|
|
|
``metadata`` that held any non-required, per-implementation data
|
|
|
|
|
[#Nick]_. However, this proved to be an unnecessary addition
|
|
|
|
|
considering the purpose of ``sys.implementation``.
|
2012-05-06 05:17:25 -04:00
|
|
|
|
|
2012-05-12 10:27:18 -04:00
|
|
|
|
Ultimately, non-required attributes are virtually ignored in this PEP.
|
|
|
|
|
They have no impact other than that careless use may collide with
|
|
|
|
|
future required attributes. That, however, is but a marginal concern
|
|
|
|
|
for ``sys.implementation``.
|
2012-05-01 02:51:22 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Why a Part of ``sys``?
|
|
|
|
|
----------------------
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
2012-05-15 11:04:25 -04:00
|
|
|
|
The ``sys`` module holds the new namespace because ``sys`` is the depot
|
|
|
|
|
for interpreter-centric variables and functions. Many
|
2012-05-12 10:27:18 -04:00
|
|
|
|
implementation-specific attributes are already found in ``sys``.
|
2012-05-01 02:51:22 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Why Strict Constraints on Any of the Values?
|
|
|
|
|
--------------------------------------------
|
|
|
|
|
|
|
|
|
|
As already noted in `Version Format`_, values in
|
|
|
|
|
``sys.implementation`` are intended for use by the standard library.
|
|
|
|
|
Constraining those values, essentially specifying an API for them,
|
|
|
|
|
allows them to be used consistently, regardless of how they are
|
2012-05-15 11:04:25 -04:00
|
|
|
|
otherwise implemented. However, care should be take to not
|
|
|
|
|
over-specify the constraints.
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Discussion
|
|
|
|
|
==========
|
|
|
|
|
|
2012-05-01 02:51:22 -04:00
|
|
|
|
The topic of ``sys.implementation`` came up on the python-ideas list
|
2012-05-06 05:17:25 -04:00
|
|
|
|
in 2009, where the reception was broadly positive [#original]_. I
|
|
|
|
|
revived the discussion recently while working on a pure-python
|
|
|
|
|
``imp.get_tag()`` [#revived]_. Discussion has been ongoing
|
|
|
|
|
[#feedback]_. The messages in `issue #14673`_ are also relevant.
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
2012-05-15 11:04:25 -04:00
|
|
|
|
A good part of the recent discussion centered on the type to use for
|
2012-05-12 10:27:18 -04:00
|
|
|
|
``sys.implementation``.
|
|
|
|
|
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
|
|
|
|
Use-cases
|
|
|
|
|
=========
|
|
|
|
|
|
2012-05-06 05:17:25 -04:00
|
|
|
|
platform.python_implementation()
|
|
|
|
|
--------------------------------
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
|
|
|
|
"explicit is better than implicit"
|
|
|
|
|
|
2012-05-08 12:37:14 -04:00
|
|
|
|
The ``platform`` module determines the python implementation by looking
|
|
|
|
|
for clues in a couple different ``sys`` variables [#guess]_. However,
|
|
|
|
|
this approach is fragile, requiring changes to the standard library
|
|
|
|
|
each time an implementation changes. Beyond that, support in
|
2012-05-06 05:17:25 -04:00
|
|
|
|
``platform`` is limited to those implementations that core developers
|
|
|
|
|
have blessed by special-casing them in the ``platform`` module.
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
|
|
|
|
With ``sys.implementation`` the various implementations would
|
2012-05-01 02:51:22 -04:00
|
|
|
|
*explicitly* set the values in their own version of the ``sys``
|
|
|
|
|
module.
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
2012-05-06 05:17:25 -04:00
|
|
|
|
Another concern is that the ``platform`` module is part of the stdlib,
|
2012-05-15 11:04:25 -04:00
|
|
|
|
which ideally should minimize implementation details such as would be
|
2012-05-06 05:17:25 -04:00
|
|
|
|
moved to ``sys.implementation``.
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
2012-05-01 02:51:22 -04:00
|
|
|
|
Any overlap between ``sys.implementation`` and the ``platform`` module
|
|
|
|
|
would simply defer to ``sys.implementation`` (with the same interface
|
|
|
|
|
in ``platform`` wrapping it).
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Cache Tag Generation in Frozen Importlib
|
|
|
|
|
----------------------------------------
|
|
|
|
|
|
2022-01-21 06:03:51 -05:00
|
|
|
|
:pep:`3147` defined the use of a module cache and cache tags for file
|
2012-05-01 02:51:22 -04:00
|
|
|
|
names. The importlib bootstrap code, frozen into the Python binary as
|
|
|
|
|
of 3.3, uses the cache tags during the import process. Part of the
|
2012-05-06 05:17:25 -04:00
|
|
|
|
project to bootstrap importlib has been to clean code out of
|
|
|
|
|
`Python/import.c`_ that did not need to be there any longer.
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
2022-01-21 06:03:51 -05:00
|
|
|
|
The cache tag defined in ``Python/import.c`` was
|
|
|
|
|
:pep:`hard-coded <3147#proposal>`
|
|
|
|
|
to ``"cpython" MAJOR MINOR``. For importlib the options are
|
2012-05-06 05:17:25 -04:00
|
|
|
|
either hard-coding it in the same way, or guessing the implementation
|
|
|
|
|
in the same way as does ``platform.python_implementation()``.
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
2012-05-06 05:17:25 -04:00
|
|
|
|
As long as the hard-coded tag is limited to CPython-specific code, it
|
|
|
|
|
is livable. However, inasmuch as other Python implementations use the
|
|
|
|
|
importlib code to work with the module cache, a hard-coded tag would
|
|
|
|
|
become a problem.
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
2012-05-01 02:51:22 -04:00
|
|
|
|
Directly using the ``platform`` module in this case is a non-starter.
|
|
|
|
|
Any module used in the importlib bootstrap must be built-in or frozen,
|
|
|
|
|
neither of which apply to the ``platform`` module. This is the point
|
|
|
|
|
that led to the recent interest in ``sys.implementation``.
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
2012-05-01 02:51:22 -04:00
|
|
|
|
Regardless of the outcome for the implementation name used, another
|
|
|
|
|
problem relates to the version used in the cache tag. That version is
|
|
|
|
|
likely to be the implementation version rather than the language
|
|
|
|
|
version. However, the implementation version is not readily
|
2012-04-27 17:32:38 -04:00
|
|
|
|
identified anywhere in the standard library.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Implementation-Specific Tests
|
|
|
|
|
-----------------------------
|
|
|
|
|
|
2012-05-01 02:51:22 -04:00
|
|
|
|
Currently there are a number of implementation-specific tests in the
|
|
|
|
|
test suite under ``Lib/test``. The test support module
|
|
|
|
|
(`Lib/test/support.py`_) provides some functionality for dealing with
|
|
|
|
|
these tests. However, like the ``platform`` module, ``test.support``
|
|
|
|
|
must do some guessing that ``sys.implementation`` would render
|
|
|
|
|
unnecessary.
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Jython's ``os.name`` Hack
|
|
|
|
|
-------------------------
|
|
|
|
|
|
2012-05-06 05:17:25 -04:00
|
|
|
|
In Jython, ``os.name`` is set to 'java' to accommodate special
|
|
|
|
|
treatment of the java environment in the standard library [#os_name]_
|
|
|
|
|
[#javatest]_. Unfortunately it masks the os name that would otherwise
|
|
|
|
|
go there. ``sys.implementation`` would help obviate the need for this
|
2012-05-12 10:27:18 -04:00
|
|
|
|
special case. Currently Jython sets ``os._name`` for the normal
|
|
|
|
|
``os.name`` value.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The Problem With ``sys.(version|version_info|hexversion)``
|
|
|
|
|
----------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
Earlier versions of this PEP made the mistake of calling
|
|
|
|
|
``sys.version_info`` (and friends) the version of the Python language,
|
|
|
|
|
in contrast to the implementation. However, this is not the case.
|
2012-05-25 14:13:23 -04:00
|
|
|
|
Instead, it is the version of the CPython implementation. Incidentally,
|
2012-05-12 10:27:18 -04:00
|
|
|
|
the first two components of ``sys.version_info`` (major and minor) also
|
|
|
|
|
reflect the version of the language definition.
|
|
|
|
|
|
|
|
|
|
As Barry Warsaw noted, the "semantics of sys.version_info have been
|
|
|
|
|
sufficiently squishy in the past" [#Barry]_. With
|
2012-05-15 11:04:25 -04:00
|
|
|
|
``sys.implementation`` we have the opportunity to improve this
|
2012-05-12 10:27:18 -04:00
|
|
|
|
situation by first establishing an explicit location for the version of
|
|
|
|
|
the implementation.
|
|
|
|
|
|
|
|
|
|
This PEP makes no other effort to directly clarify the semantics of
|
|
|
|
|
``sys.version_info``. Regardless, having an explicit version for the
|
|
|
|
|
implementation will definitely help to clarify the distinction from the
|
|
|
|
|
language version.
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
|
|
|
|
|
2012-05-25 14:13:23 -04:00
|
|
|
|
Feedback From Other Python Implementers
|
2012-05-01 02:51:22 -04:00
|
|
|
|
=======================================
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
|
|
|
|
IronPython
|
|
|
|
|
----------
|
|
|
|
|
|
2012-05-08 12:37:14 -04:00
|
|
|
|
Jeff Hardy responded to a request for feedback [#ironpython]_. He
|
|
|
|
|
said, "I'll probably add it the day after it's approved"
|
|
|
|
|
[#jeff_hardy_2012]_. He also gave useful feedback on both the type of
|
2012-05-15 11:04:25 -04:00
|
|
|
|
``sys.implementation`` and on the ``metadata`` attribute (which has
|
|
|
|
|
since been removed from the PEP).
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
|
|
|
|
Jython
|
|
|
|
|
------
|
|
|
|
|
|
2012-05-08 12:37:14 -04:00
|
|
|
|
In 2009 Frank Wierzbicki said this (relative to Jython implementing the
|
|
|
|
|
required attributes) [#frank_wierzbicki_2009]_::
|
|
|
|
|
|
|
|
|
|
Speaking for Jython, so far it looks like something we would adopt
|
|
|
|
|
soonish after it was accepted (it looks pretty useful to me).
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
|
|
|
|
PyPy
|
|
|
|
|
----
|
|
|
|
|
|
2012-05-08 12:37:14 -04:00
|
|
|
|
Some of the PyPy developers have responded to a request for feedback
|
|
|
|
|
[#pypy]_. Armin Rigo said the following [#armin_rigo_2012]_::
|
|
|
|
|
|
|
|
|
|
For myself, I can only say that it looks like a good idea, which we
|
|
|
|
|
will happily adhere to when we migrate to Python 3.3.
|
|
|
|
|
|
|
|
|
|
He also expressed support for keeping the required list small. Both
|
2012-05-12 10:27:18 -04:00
|
|
|
|
Armin and Laura Creighton indicated that an effort to better catalog
|
|
|
|
|
Python's implementation would be welcome. Such an effort, for which
|
|
|
|
|
this PEP is a small start, will be considered separately.
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Past Efforts
|
|
|
|
|
============
|
|
|
|
|
|
2022-01-21 06:03:51 -05:00
|
|
|
|
PEP 3139
|
|
|
|
|
--------
|
2012-05-01 02:51:22 -04:00
|
|
|
|
|
2022-01-21 06:03:51 -05:00
|
|
|
|
:pep:`3139`, from 2008, recommended a clean-up of the ``sys`` module in
|
2012-05-01 02:51:22 -04:00
|
|
|
|
part by extracting implementation-specific variables and functions
|
2022-01-21 06:03:51 -05:00
|
|
|
|
into a separate module. :pep:`421` is less ambitious version of that
|
|
|
|
|
idea. While :pep:`3139` was rejected, its goals are reflected in :pep:`421`
|
2012-05-01 02:51:22 -04:00
|
|
|
|
to a large extent, though with a much lighter approach.
|
|
|
|
|
|
|
|
|
|
|
2022-01-21 06:03:51 -05:00
|
|
|
|
PEP 399
|
|
|
|
|
-------
|
2012-05-01 02:51:22 -04:00
|
|
|
|
|
2022-01-21 06:03:51 -05:00
|
|
|
|
:pep:`399` dictates policy regarding the standard library, helping to make
|
|
|
|
|
it friendlier to alternate implementations. :pep:`421` is proposed in
|
2012-05-15 11:04:25 -04:00
|
|
|
|
that same spirit.
|
2012-05-01 02:51:22 -04:00
|
|
|
|
|
|
|
|
|
|
2012-05-08 12:37:14 -04:00
|
|
|
|
The Bigger Picture
|
|
|
|
|
==================
|
|
|
|
|
|
|
|
|
|
It's worth noting again that this PEP is a small part of a larger
|
|
|
|
|
on-going effort to identify the implementation-specific parts of Python
|
2012-05-15 11:04:25 -04:00
|
|
|
|
and mitigate their impact on alternate implementations.
|
2012-05-08 12:37:14 -04:00
|
|
|
|
|
|
|
|
|
``sys.implementation`` is a focal point for implementation-specific
|
|
|
|
|
data, acting as a nexus for cooperation between the language, the
|
|
|
|
|
standard library, and the different implementations. As time goes by
|
|
|
|
|
it is feasible that ``sys.implementation`` will assume current
|
|
|
|
|
attributes of ``sys`` and other builtin/stdlib modules, where
|
2022-01-21 06:03:51 -05:00
|
|
|
|
appropriate. In this way, it is a :pep:`3137`-lite, but starting as
|
2012-05-08 12:37:14 -04:00
|
|
|
|
small as possible.
|
|
|
|
|
|
|
|
|
|
However, as already noted, many other efforts predate
|
|
|
|
|
``sys.implementation``. Neither is it necessarily a major part of the
|
|
|
|
|
effort. Rather, consider it as part of the infrastructure of the
|
2012-05-25 14:13:23 -04:00
|
|
|
|
effort to make Python friendlier to alternate implementations.
|
2012-05-08 12:37:14 -04:00
|
|
|
|
|
|
|
|
|
|
2012-05-01 02:51:22 -04:00
|
|
|
|
Alternatives
|
|
|
|
|
============
|
|
|
|
|
|
2012-05-06 05:17:25 -04:00
|
|
|
|
Since the single-namespace-under-sys approach is relatively
|
|
|
|
|
straightforward, no alternatives have been considered for this PEP.
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
|
|
|
|
|
2012-05-12 10:27:18 -04:00
|
|
|
|
Examples of Other Attributes
|
|
|
|
|
============================
|
|
|
|
|
|
2012-05-15 11:04:25 -04:00
|
|
|
|
These are examples only and not part of the proposal. Most of them
|
|
|
|
|
were suggested during previous discussions, but did not fit into the
|
|
|
|
|
goals of this PEP. (See `Adding New Required Attributes`_ if they get
|
|
|
|
|
you excited.)
|
2012-05-12 10:27:18 -04:00
|
|
|
|
|
|
|
|
|
**common_name**
|
|
|
|
|
The case-sensitive name by which the implementation is known.
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
2012-05-12 10:27:18 -04:00
|
|
|
|
**vcs_url**
|
|
|
|
|
A URL for the main VCS repository for the implementation project.
|
2012-05-06 05:17:25 -04:00
|
|
|
|
|
2012-05-12 10:27:18 -04:00
|
|
|
|
**vcs_revision_id**
|
|
|
|
|
A value that identifies the VCS revision of the implementation.
|
2012-05-06 05:17:25 -04:00
|
|
|
|
|
2012-05-12 10:27:18 -04:00
|
|
|
|
**build_toolchain**
|
|
|
|
|
The tools used to build the interpreter.
|
2012-05-06 05:17:25 -04:00
|
|
|
|
|
2012-05-12 10:27:18 -04:00
|
|
|
|
**build_date**
|
|
|
|
|
The timestamp of when the interpreter was built.
|
2012-05-06 05:17:25 -04:00
|
|
|
|
|
2012-05-12 10:27:18 -04:00
|
|
|
|
**homepage**
|
|
|
|
|
The URL of the implementation's website.
|
2012-05-01 02:51:22 -04:00
|
|
|
|
|
2012-05-12 10:27:18 -04:00
|
|
|
|
**site_prefix**
|
|
|
|
|
The preferred site prefix for the implementation.
|
2012-05-01 02:51:22 -04:00
|
|
|
|
|
2012-05-12 10:27:18 -04:00
|
|
|
|
**runtime**
|
|
|
|
|
The run-time environment in which the interpreter is running, as
|
|
|
|
|
in "Common Language *Runtime*" (.NET CLR) or "Java *Runtime*
|
|
|
|
|
Executable".
|
2012-05-01 02:51:22 -04:00
|
|
|
|
|
2012-05-12 10:27:18 -04:00
|
|
|
|
**gc_type**
|
|
|
|
|
The type of garbage collection used, like "reference counting" or
|
|
|
|
|
"mark and sweep".
|
2012-05-06 05:17:25 -04:00
|
|
|
|
|
|
|
|
|
|
2012-05-12 10:27:18 -04:00
|
|
|
|
Open Issues
|
|
|
|
|
===========
|
|
|
|
|
|
|
|
|
|
Currently none.
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Implementation
|
|
|
|
|
==============
|
|
|
|
|
|
2012-05-01 02:51:22 -04:00
|
|
|
|
The implementation of this PEP is covered in `issue #14673`_.
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
References
|
|
|
|
|
==========
|
|
|
|
|
|
2012-05-06 05:17:25 -04:00
|
|
|
|
.. [#original] The 2009 sys.implementation discussion:
|
2017-06-11 15:02:39 -04:00
|
|
|
|
https://mail.python.org/pipermail/python-dev/2009-October/092893.html
|
2012-05-06 05:17:25 -04:00
|
|
|
|
|
|
|
|
|
.. [#revived] The initial 2012 discussion:
|
2017-06-11 15:02:39 -04:00
|
|
|
|
https://mail.python.org/pipermail/python-ideas/2012-March/014555.html
|
|
|
|
|
(and https://mail.python.org/pipermail/python-ideas/2012-April/014878.html)
|
2012-05-06 05:17:25 -04:00
|
|
|
|
|
|
|
|
|
.. [#feedback] Feedback on the PEP:
|
2017-06-11 15:02:39 -04:00
|
|
|
|
https://mail.python.org/pipermail/python-ideas/2012-April/014954.html
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
2012-05-08 12:37:14 -04:00
|
|
|
|
.. [#ironpython] Feedback from the IronPython developers:
|
2017-06-11 15:02:39 -04:00
|
|
|
|
https://mail.python.org/pipermail/ironpython-users/2012-May/015980.html
|
2012-05-08 12:37:14 -04:00
|
|
|
|
|
|
|
|
|
.. [#dino_viehland_2009] (2009) Dino Viehland offers his opinion:
|
2017-06-11 15:02:39 -04:00
|
|
|
|
https://mail.python.org/pipermail/python-dev/2009-October/092894.html
|
2012-05-08 12:37:14 -04:00
|
|
|
|
|
|
|
|
|
.. [#jeff_hardy_2012] (2012) Jeff Hardy offers his opinion:
|
2017-06-11 15:02:39 -04:00
|
|
|
|
https://mail.python.org/pipermail/ironpython-users/2012-May/015981.html
|
2012-05-08 12:37:14 -04:00
|
|
|
|
|
|
|
|
|
.. [#jython] Feedback from the Jython developers:
|
|
|
|
|
???
|
|
|
|
|
|
|
|
|
|
.. [#frank_wierzbicki_2009] (2009) Frank Wierzbicki offers his opinion:
|
2017-06-11 15:02:39 -04:00
|
|
|
|
https://mail.python.org/pipermail/python-dev/2009-October/092974.html
|
2012-05-08 12:37:14 -04:00
|
|
|
|
|
|
|
|
|
.. [#pypy] Feedback from the PyPy developers:
|
2017-06-11 15:02:39 -04:00
|
|
|
|
https://mail.python.org/pipermail/pypy-dev/2012-May/009883.html
|
2012-05-08 12:37:14 -04:00
|
|
|
|
|
|
|
|
|
.. [#armin_rigo_2012] (2012) Armin Rigo offers his opinion:
|
2017-06-11 15:02:39 -04:00
|
|
|
|
https://mail.python.org/pipermail/pypy-dev/2012-May/009884.html
|
2012-05-08 12:37:14 -04:00
|
|
|
|
|
2012-05-06 05:17:25 -04:00
|
|
|
|
.. [#guess] The ``platform`` code which divines the implementation name:
|
|
|
|
|
http://hg.python.org/cpython/file/2f563908ebc5/Lib/platform.py#l1247
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
2012-05-06 05:17:25 -04:00
|
|
|
|
.. [#tag_impl] The original implementation of the cache tag in CPython:
|
|
|
|
|
http://hg.python.org/cpython/file/2f563908ebc5/Python/import.c#l121
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
2012-05-06 05:17:25 -04:00
|
|
|
|
.. [#tests] Examples of implementation-specific handling in test.support:
|
|
|
|
|
* http://hg.python.org/cpython/file/2f563908ebc5/Lib/test/support.py#l509
|
|
|
|
|
* http://hg.python.org/cpython/file/2f563908ebc5/Lib/test/support.py#l1246
|
|
|
|
|
* http://hg.python.org/cpython/file/2f563908ebc5/Lib/test/support.py#l1252
|
|
|
|
|
* http://hg.python.org/cpython/file/2f563908ebc5/Lib/test/support.py#l1275
|
2012-05-01 02:51:22 -04:00
|
|
|
|
|
2012-05-06 05:17:25 -04:00
|
|
|
|
.. [#os_name] The standard library entry for os.name:
|
|
|
|
|
http://docs.python.org/3.3/library/os.html#os.name
|
|
|
|
|
|
|
|
|
|
.. [#javatest] The use of ``os.name`` as 'java' in the stdlib test suite.
|
|
|
|
|
http://hg.python.org/cpython/file/2f563908ebc5/Lib/test/support.py#l512
|
|
|
|
|
|
|
|
|
|
.. [#Nick] Nick Coghlan's proposal for ``sys.implementation.metadata``:
|
2017-06-11 15:02:39 -04:00
|
|
|
|
https://mail.python.org/pipermail/python-ideas/2012-May/014984.html
|
2012-05-01 02:51:22 -04:00
|
|
|
|
|
2012-05-12 10:27:18 -04:00
|
|
|
|
.. [#Barry] Feedback from Barry Warsaw:
|
2017-06-11 15:02:39 -04:00
|
|
|
|
https://mail.python.org/pipermail/python-dev/2012-May/119374.html
|
2012-05-12 10:27:18 -04:00
|
|
|
|
|
2012-04-27 17:32:38 -04:00
|
|
|
|
.. _issue #14673: http://bugs.python.org/issue14673
|
|
|
|
|
|
2012-05-01 02:51:22 -04:00
|
|
|
|
.. _Lib/test/support.py: http://hg.python.org/cpython/file/2f563908ebc5/Lib/test/support.py
|
|
|
|
|
|
2012-05-06 05:17:25 -04:00
|
|
|
|
.. _Python/import.c: http://hg.python.org/cpython/file/2f563908ebc5/Python/import.c
|
|
|
|
|
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
|
|
|
|
Copyright
|
|
|
|
|
=========
|
|
|
|
|
|
2012-05-01 02:54:55 -04:00
|
|
|
|
This document has been placed in the public domain.
|
2012-04-27 17:32:38 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-01 02:54:55 -04:00
|
|
|
|
..
|
|
|
|
|
Local Variables:
|
|
|
|
|
mode: indented-text
|
|
|
|
|
indent-tabs-mode: nil
|
|
|
|
|
sentence-end-double-space: t
|
|
|
|
|
fill-column: 70
|
|
|
|
|
coding: utf-8
|
|
|
|
|
End:
|