[Python-Dev] PEP about sys.implementation and implementation specific user site directory (original) (raw)

Christian Heimes lists at cheimes.de
Sat Oct 10 01:29:55 CEST 2009


Fellow Python developers!

In the light of our recent discussion about implementation specific information and user site directory I like to start a new PEP. Much to my regret I wasn't able to contribute to Python core development over the past months. I hope I can find some free time over the next weeks.

Before I start with the PEP I like to reach consensus over the goal. Alternative implementations of our beloved programming languages are becoming more important every day. Although IronPython, Jython and PyPy are trying hard to get as compatible to CPython as possible there are numerous reasons for conditional code. General Python unit tests vs. CPython specific unit tests are one reasons, implementation specific module search paths are another. At the moment Python has no easy way to inspect the implementation besides some code in the platform module.

I'm proposing two new attributes in the sys module: sys.implementation and sys.userdirsuffix.

sys.implementation

(Proposed by Nick, MAL and others.)

sys.implementation is a PyStructSequence that contains various information about the current implementation. Some fields are required to be present on every implementation. Implementations may choose to add additional fields as they see fit. Some fields like compiler are useful for introspection and are already part of sys.version. I like to include them for the sake of completeness.

id (required): lower case identifier, for example "cpython", "ironpython", "jython", "pypy"

name (required): mixed case name of the implementation, for example "CPython", "IronPython", "Jython", "PyPy"

platform (required): platform or language of the implementation, for example "C", ".NET", "Java"

runtime (required): lower case runtime library of the implementation, for example "libc", "msvcrt90", "java6", ".net"

compiler (required): verbose name of the compiler, for example "GCC 4.3.3", "Java HotSpot(TM) Client VM (Apple Inc.)", "Mono JIT compiler version 2.0.1"

...

sys.userdirsuffix

sys.userdirsuffix is an implementation and platform specific string that is used to construct the path for the user site directory as explained in PEP 370. The string contains the implementation name as well as the version number of Python.

Examples: python2.6 (CPython, Unix) Python26 (CPython, Windows) ironpython2.6 (IronPython, Unix) IronPython26 (IronPython, Windows) ...

Comments?

Christian



More information about the Python-Dev mailing list