5.2. pythonids.pythondist

The module ‘pythondist’ provides the class for the representation of the release parameters for the Python distribution. The pythondist module provides the runtime identifiers of Python distributions. The aquisition of the iderntifiers is implemented by the scan of the current instance and the one-time calculation of the hexadecimal labels for the continued fast processing.

5.2.1. Module

The values f the distribution identifier are either scanned by scan() method of the current instance

1
2
3
4
5
from pythonids.pythondist import PythonDist

x = PythonDist()    # creates an empty object
x.scan()            # scans the Python instance
print(str(x))       # prints display-format, see also 'repr', 'json', 'bashvars' and 'basharray'

or provided as call parameters for predictive cross-platform operations by offline evaluation. For example with the following public attributes. The values are defined as numeric bit field within 32-bit integer values, thus are shifted to their defined positions, see also Python Categorization :

  • Python-2.7.15 - CPython:

    category         = PYE_PYTHON           # python
    disttype       = PYE_PYTHON27           # python-2.7.15
    dist             = PYE_CPYTHON          # CPython
    distrel          = bitmask(2, 7, 15)    # python2.7 - here same as syntax version
    hexrelease       = bitmask()            # overall bitmask
    
  • Python-2.7.13 - PyPy-5.8.0:

    category         = PYE_PYTHON           # python
    disttype       = bitmask(2, 7)          # python-2.7.13
    dist             = PYE_PYPY             # PyPy
    distrel          = bitmask(5, 8, 0)     # pypy5.8
    hexrelease       = bitmask()            # overall bitmask
    

pythonids.pythondist provides information about the Python implementation.

Raises ‘pythonids.PythonIDsImplementationError’ when implementation is not supported.

5.2.2. Constants

5.2.2.1. Python Distributions

The representation of the Python distribution parameter is an int used as bit-array for binary logic operations. This comprises the disttype, the dist, and the distrel fields encoded as subsections of the complete bitmask. For details see Python Categorization.

The following predefined constants are available.

  • Enum Values:

    • Base type blocks:

      CPython is basically the reference implementation of the Python Foundation @python.org, thus the distribution release is identical to the syntax release.

      • PYE_PYTHON - Python

      • PYE_PYTHON_PRETTY - Python as string ‘Python’

      • PYE_PYTHON_NAME - Python name as string ‘python’

    • disttype:

      The specific syntax variant including the standard libraries. The standard libraries are in particular changing in the Python3.X releases, even for micro reelases Python3.X.Z.

      • PYE_PYTHON27 - Python-2.7

      • PYE_PYTHON35 - Python-3.5

      • PYE_PYTHON36 - Python-3.6

      • PYE_PYTHON37 - Python-3.7

    • dist:

      The specific implementation for a given base syntax. While the base syntax is mostly complied thoroughly, the provided standard libraries frequently vary.

      A special case is here Cython, which provides a compiler - or basically a pre-processor - for the Python syntax extended by C related syntax elements.

    • dist as special syntax and package variants for small SoCs with small footprints:

  • Control Variables:

    • PYDIST: Current Python distribution

For the complete list refer to the sources [pythonids.__init__.py] and [pythonids/pythondist.py].

5.2.2.2. Bitmask Helper

The following constants provide the extraction of subfields for logic operations by bitmasks. The bitmasks used for pythonids are semantically separative, thus the value of the field itself is valid, even though e.g. a specific version may not be actually available for the distribution. Thus the logical layers are in a hierarchical order, but the type of the content is not cumulative, though formally not bound to it’s upper layer. The bit values are kept by the bitmask decomposition at their original positions.

  • Syntax type bits:

    • PYE_SYNTAXTYPE - extracts a single value for major and minor version

    • PYE_SYNTAXTYPE_MAJOR - extracts the major only

    • PYE_SYNTAXTYPE_MINOR - extracts the minor only

  • Distribution type bits

    • PYE_DIST - extracts dist enum only

  • Distribution release version bits:

    • PYE_DISTREL - extracts the combined value for major, minor, and micro version

    • PYE_DISTREL_MAJOR - extracts the major only

    • PYE_DISTREL_MINOR - extracts the minor only

    • PYE_DISTREL_MICRO - extracts the micro only

5.2.2.3. ISINT

Provides a tuple of valid integer types. This is required in particular for Jython, due to it’s use of the type long for numeric values with 32 or more bits. The long type is not supported by the syntax releases Python3 and Python2 - not specified in the grammar specification [Python2]/[Python3], but actually understood by CPython2.7.15.

for Jyhton: ISINT = (int, long,)  # long for values of 32bits and more
else:       ISINT = (int,)

For the application by in:

if type(s) in ISINT:
    ...

5.2.2.4. ISNUM

Provides a tuple of valid numeric types. This is required in particular for Jython, due to it’s use of the type long for numeric values with 32 or more bits. The long type is not supported by the syntax releases Python3 and Python2 - not specified in the grammar specification [Python2]/[Python3], but actually understood by CPython2.7.15.

for Jyhton: ISNUM = (int, float, long,)  # long for values of 32bits and more
else:       ISNUM = (int, float,)

For the application by in:

if type(s) in ISNUM:
    ...

5.2.3. Variables

5.2.3.1. PYDIST

pythonids.pythondist.PYDIST

Sets the hex value for fast access based on PYDIST_DATA, The bit encoded Python distribution identifier of current executable for bit mask operations.

1
2
3
4
5
6
7
8
9
PYDIST = encode_pysyntax_to_16bit(*sys.version_info[:3])

e.g. for Python-3.6.5

xxx:      011
yyyyy:    00110
zzzzzzzz: 00000101

PYVxyz = 0b0110011000000101 = 0x6605 = 26117

Du to the static nature of the version number code dependencies the reference values could be provided as integer constants when frequent evaluation is required.

5.2.3.2. PYDIST_DATA

pythonids.pythondist.PYDIST_DATA

Creates the object for the current runtime environment and scans the parameters. A global object of pythonids.pythondist.PythonDist initialized with the data of the current runtime environment. The default is with core attributes only - which almost for sure must not raise exceptions at all.

5.2.3.3. isJython

Provides a boolean value of the detection status of Jython.

isJython =: (True | False)

5.2.3.4. Maps

The followin maps provide the data for shell scripting.

bash_map

The corresponding bash environment names.
bash_map = {
    'category': "PYDIST_CATEGORY",
    'disttype': "PYDIST_DISTTYPE",
    'dist': "PYDIST_DIST",
    'distrel': "PYDIST_DISTREL",
    'hexrelease': "PYDIST_DISTREL_HEXVERSION",
    'compiler': "PYDIST_COMPILER",
    'compiler_version': "PYDIST_COMPILER_VERSION",
    'c_libc_version': "PYDIST_C_LIBC_VERSION",
    'c_compiler': "PYDIST_C_COMPILER",
    'c_compiler_version': "PYDIST_C_COMPILER_VERSION",
}

attribute_map

The mapping of attributes to values.
attribute_map = {
    'category': "category",
    'disttype': "disttype",
    'dist': "dist",
    'distrel': "distrel",
    'hexrelease': "hexrelease",
    'compiler': "compiler",
    'compiler_version': "compiler_version",
    'c_libc_version': "c_libc_version",
    'c_compiler': "c_compiler",
    'c_compiler_version': "c_compiler_version",
}

5.2.4. decode_pydist_32bit_to_tuple_segments

pythonids.pythondist.decode_pydist_32bit_to_tuple_segments(ddat=0)[source]

Decodes the 32bit hex representation of the Python distribution into a dict structure with str names and numeric release vectors.

Parameters

ddat – The 32bit value.

Returns

PyDist = namedtuple('PyDist', ('category', 'disttype', 'dist', 'distrel'))

result := PyDist(
   PYE_PYTHON, (<syntax-major>,<syntax-minor>), <32bit-dist>, (<dist-major>, <dist-minor>, <dist-micro>)
 )

PYE_PYTHON:            32bit-enum for category
32bit-syntax-release:  32bit-value for syntax release
32bit-dist:            32bit-enum for distribution
32bit-dist-release:    32bit-value for distribution release

Dictionary with components:

result := {
   'category': 'python',
   'styntaxtype': (<syntax-major>,<syntax-minor>),
   'dist': <dist-name>,
   'distrel': (<dist-major>, <dist-minor>, <dist-micro>)
}

category:      canonical str name
syntax-major:  int value
syntax-minor:  int value
dist:          canonical str name
dist-major:    int value
dist-minor:    int value
dist-micro:    int value

Return type

Nametupel with the components

Raises

pass-through

Example:

example\_ = pythonids.pythondist.decode_pydist_32bit_to_tuple_segments(
   0xa38421cf
   )

example == {
   'category': 1,             # Python
   'disttype': (2, 7),        # Python release: 2.7
   'dist': 1,                 # CPython
   'distrel': (2, 7, 15)      # CPython release: 2.7.15
}

5.2.5. decode_pydist_32bit_to_tuple_str

pythonids.pythondist.decode_pydist_32bit_to_tuple_str(ddat=0)[source]

Decodes the 32bit hex representation of the Python distribution into a dict structure with str names and str representation of releases.

Parameters

ddat – The 32bit value.

Returns

result := {
   'category': 'python',
   'styntaxtype': <str-syntax-release>,
   'dist': <dist-name>,
   'distrel': <str-dist-release>
}

category:            canonical str name
str-syntax-release:  string representation
dist:                canonical str name
str-dist-release:    string representation

Return type

Dictionary with components

Raises

pass-through

Example:

example\_ = pythonids.pythondist.decode_pydist_32bit_to_tuple_str(
   0xa38421cf
   )

example = {
   'category': 'python',      # Python
   'disttype': 'python2.7',   # Python release: 2.7
   'dist': 'cpython',         # CPython
   'distrel': '2.7.15'        # CPython release: 2.7.15
}

5.2.6. decode_pydist_32bit_to_tuple

pythonids.pythondist.decode_pydist_32bit_to_tuple(ddat=0)[source]

Decodes the 32bit hex representation of the Python distribution into a flat tuple of numbers.

Parameters

ddat – The 32bit value.

Returns

PyDist = namedtuple('PyDist', ('category', 'disttype', 'dist', 'distrel'))

result := PyDist(
   PYE_PYTHON, <32bit-syntax-release>, <32bit-dist>, <32bit-dist-release>
 )

PYE_PYTHON:            32bit-enum for category
32bit-syntax-release:  32bit-value for syntax release
32bit-dist:            32bit-enum for distribution
32bit-dist-release:    32bit-value for distribution release

Return type

Nametupel with the components

Raises

pass-through

Example:

example\_ = pythonids.pythondist.decode_pydist_32bit_to_tuple_str(
   0xa38421cf
   )

example = (
   2147483648,               # PYE_PYTHON
   595591168,                # PYE_PYTHON27
   262144,                   # PYE_CPYTHON
   8655                      # 2.7.15
)

5.2.7. encode_pydist_to_32bit

pythonids.pythondist.encode_pydist_to_32bit(d=0, dx=0, dy=0, dz=0, sma=0, smi=0)[source]

Encodes the Python distribution by calculating the 32bit integer bitmask for the provided Python distribution and syntax release information.

Parameters
  • d – The numeric enum value of the distribution with original bit-positions.

  • dx – The major distribution version number.

  • dy – The minor distribution version number.

  • dz – The micro distribution version number.

  • sma – The major syntax version number.

  • smi – The minor syntax version number.

Returns

The 32bit bitmask.

Raises

pass-through

Example:

For details refer to the component distrel of Bit Mask Layout.

example_ = pythonids.pythondist.encode_pydist_to_32bit(
   pythonids.pythondist.PYE_CPYTHON,
   2, 7, 15,
   2,7,
   )

example = 0xa38421cf = PYE_PYDIST_CPYTHON2715

5.2.8. encode_pydist_segments_to_32bit

pythonids.pythondist.encode_pydist_segments_to_32bit(**kargs)[source]

Encodes the 32bit bitmask of the compressed platform information by the provided values of the sub fields. Non-provided values are set to 0, and though ignored.

This function is mainly designed and foreseen for cache preparation and test environments, though it inherently requires some of the systems performance. Thus do not use it within repetitive calls for performance critical large scale loops with small code sections.

Parameters

kargs

category:

The category. The only and one permitted is Python:

category := (
       PYE_PYTHON  # enum
     | 'Python'    # Pretty name
     | 'python'    # key
     | 0           # None
)

default := 0

dist:

The dist:

dist := (
       PYE_CPYTHON | PYE_IPYTHON | PYE_IRONPYTHON
     | PYE_JYTHON  | PYE_PYPY
     | PYE_CIRCUITPYTHON | PYE_MICROPYTHON
     | <known-name-of-dist>
     | 0
)
known-name-of-dist := "case insensitive name or pretty name of the distribution"
0 := None

default:=0

distrel:

The distrel:

distrel := (
       <int-val>
     | (<major>, <minor>, <micro>)
     | 0
)
int-val := the relative integer value of the distrel bits
(<major>, <minor>, <micro>):= the tuple of the Python distribution release
0 := None

default := 0

disttype:

The disttype:

disttype := (
       <int-val>
     | (<major>, <minor>)
     | 0
)
int-val := the relative integer value of the disttype bits
(<major>, <minor>) := the tuple of Python syntax version
0 := None

default := 0

Returns

The 32bit compressed bitmask of the of the distribution.

Raises

pass-through

Example:

For details refer to the component distrel of Bit Mask Layout.

example_ = pythonids.pythondist.encode_pydist_to_32bit(
   category='python',
   dist='cpython',
   distrel=(2, 7, 15),
   disttype=(2, 7),
   )

example = 0xa38421cf = PYE_PYDIST_CPYTHON2715

5.2.9. PythonDist

The class PythonDist provides the representation of Python distributions. The data contains either the current runtime environment, or a user provided platform by parameters. The automatic scan of the current runtime environment has to be triggered explicitly by the method pythonids.PythonDist.scan(). The call replaces all attribute values of the current instance by the detected values.

class pythonids.pythondist.PythonDist(*args, **kargs)[source]

The provided public attributes are:

  • category:

    The 32-bit enum of category of the syntax. Here the only value is PYE_PYTHON.

  • disttype:

    The 32-bit encoded major and minor version of the Python syntax definition - PEP440 - finalrelease (2-value).

  • dist:

    The 32-bit encoded enum of the Python distribution.

  • distrel:

    The 32-bit encoded major, minor, and micro version of the Python interpreter/compiler distribution.

  • hexrelease:

    The numeric 32-bit bitmask for the complete set of information.
    hexrelease = (category | disttype | dist | distrel)
    

    See bitmasks.

The following extra attributes are optional and not yet reliable on all OS platforms at production degree. These are scanned only when the attribute forceall is set to True. This is not the case for the global default object.

Anyhow, in some cases such as PyPy it is implemented in combination with the distrel information and … :-).

  • c_compiler:

    The lower case name of the compiler for the dist.

  • c_compiler_version:

    The 3-value integer version tuple of the compiler.

  • c_libc_version:

    The tuple of the name and 3-value integer version tuple of the C-library from platform.libc_ver.

5.2.9.1. Attributes

The following public attributes are provided for the hierachical platform categorization

category

The 32bit encoded type of operating system.

category := PYE_PYTHON

disttype

The 32bit encoded value of the Python syntax release. See bitmasks:

disttype := (<disttype-major>, < disttype-minor>)

Predefined values are:

PYE_PYTHON27, PYE_PYTHON35, PYE_PYTHON36, PYE_PYTHON37

dist

The 32bit encoded enum of the distribution. See bitmasks:

dist := (
     PYE_CPYTHON
   | PYE_IPYTHON
   | PYE_IRONPYTHON
   | PYE_JYTHON
   | PYE_PYPY
   #
   # experimental
   #
   | PYE_CIRCUITPYTHON  # experimental
   | PYE_MICROPYTHON    # experimental
)

distrel

The 32bit encoded value of the implementation release. See bitmasks:

distrel := (<distrel-major>, <distrel-minor>, <distrel-micro>)

The values are for the reference implementation CPython the same as the syntax release, but differ for other implementations.

hexrelease

The 32bit numeric bitmask of the release version representing all previous attributes within one value. See bitmasks.

The presented values are optional and may change unnoticed. These are primarily intended for the test of the pythonids itself. Due to the amout of possible versions these have to be calculated dynamically.

distrel := (
     PYE_PYDIST_CPYTHON2715    # 0xa38421cf - CPython-2.7.15   - Python2.7
   | PYE_PYDIST_CPYTHON372     # 0xb38431c2 - CPython-3.7.2    - Python3.7
   | PYE_PYDIST_IPYTHON550     # 0xA3905140 - IPython-5.5.0    - Python2.7
   | PYE_PYDIST_IPYTHON560     # 0xA3905180 - IPython-5.6.0    - Python2.7
   | PYE_PYDIST_IRONPYTHON277  # 0xA39421C7 - IRonPython-2.7.7 - Python2.7
   | PYE_PYDIST_IRONPYTHON279  # 0xA39421C9 - IRonPython-2.7.9 - Python2.7
   | PYE_PYDIST_JYTHON270      # 0xA39821C0 - Jython-2.7.0     - Python2.7
   | PYE_PYDIST_JYTHON271      # 0xA39821C1 - Jython-2.7.1     - Python2.7
   | PYE_PYDIST_PYPY580        # 0xA3A05200 - PyPy-5.8.0       - Python2.7
   | PYE_PYDIST_PYPY60027      # 0xA3A06000 - PyPy-6.0.0       - Python2.7
   | PYE_PYDIST_PYPY60035      # 0xB2A06000 - PyPy-6.0.0       - Python3.5
   | PYE_PYDIST_PYPY70036      # 0xB3207000 - PyPy-7.0.0       - Python3.6
)

forceall

Controls the scan of the compiler and libc information when set to True. Is by default False, thus in global instance too.

c_libc_version

The version of the used libc.

c_compiler

The name of the used compiler.

c_compiler_version

The version of the used compiler.

5.2.9.2. __init__

PythonDist.__init__(*args, **kargs)[source]

Creates an empty object. The instance could be either initialized by the provided parameters, or remains empty - which is zero 0.

Provides PythonDist.scan() for the readout of the implementation information. The scan() is not called automatic. Each call of scan() replaces the previous values.

Parameters
  • args

    Optional positional parameters in the following order. The corresponding keyword-arguments dominate.

    *args := [category [, disttype [, dist [, distrel]]]]
    

  • kargs

    category:

    The registered category for initialization.

    default := 0

    disttype:

    The registered disttype for initialization.

    default := 0

    dist:

    The registered dist for initialization.

    default := 0

    distrel:

    The registered distrel for initialization.

    default := 0

    forceall:

    Controls the default for the scan of content:

    forceall := (
         True    # scan distribution and compiler
       | False   # scan distribution only
    )
    

    default := False

    valuetype:

    Defines the representation of the values - where possible:

    valuetype := (
          raw   # original internal value
        | hex   # as hex
        | sym   # mapped to symbolic names
    )
    
    default := sym
    

Returns

Initial instance, optionally initialized by the provided parameters.

Raises

5.2.9.3. __and__

PythonDist.__and__(other)[source]

The & operator for the resulting hexversion:

self-bitmask & other-bitmask
Parameters

other

The bitmask for operations.

other := (
     <int-16bit-mask>                   # compare with hexversion
   | <dictionary>)                      # compare keys only
   | <tuple>)                           # compare key-index only
   | <instance-of-PythonDist>     # compare both hexversions
)

Returns

The resulting bitmask as numeric value.

Raises

pass-through

5.2.9.4. __eq__

PythonDist.__eq__(other)[source]

Supports standard comparison with the types PythonDist, and dict. In case of a dict the attributes are used as keys literally.

Synchronizes the hex-value of the release, and compares it with the resulting value from other.

Parameters

other

The instannce to be compared.

other := (
     <int-16bit-mask>                   # compare with hexversion
   | <dictionary>)                      # compare keys only
   | <tuple>)                           # compare key-index only
   | <instance-of-PythonDist>           # compare both hexversions
)

Returns

True or False.

Raises
  • KeyError

  • AttributeError

5.2.9.5. __ge__

PythonDist.__ge__(other)[source]

The >= operator for the resulting hexversion:

self-bitmask >= other-bitmask
Parameters

other

The bitmask for operations.

other := (
     <int-16bit-mask>               # compare with hexversion
   | <dictionary>)                  # compare keys only
   | <tuple>)                       # compare key-index only
   | <instance-of-PythonDist>       # compare both hexversions
)

Returns

True or False.

Raises

pass-through

5.2.9.6. __getattr__

PythonDist.__getattr__(name)[source]

Gets the selected attribute.

5.2.9.7. __getitem__

PythonDist.__getitem__(key)[source]

5.2.9.8. __gt__

PythonDist.__gt__(other)[source]

The > operator for the resulting hexversion:

self-bitmask > other-bitmask
Parameters

other

The bitmask for operations.

other := (
     <int-16bit-mask>               # compare with hexversion
   | <dictionary>)                  # compare keys only
   | <tuple>)                       # compare key-index only
   | <instance-of-PythonDist>       # compare both hexversions
)

Returns

True or False.

Raises

pass-through

5.2.9.9. __iand__

PythonDist.__iand__(other)[source]

The in-place & operator for the resulting hexversion:

self-bitmask &= other-bitmask
Parameters

other

The bitmask for operations.

other := (
     <int-16bit-mask>               # compare with hexversion
   | <dictionary>)                  # compare keys only
   | <tuple>)                       # compare key-index only
   | <instance-of-PythonDist>       # compare both hexversions
)

Returns

The resulting bitmask as numeric value.

Raises

pass-through

5.2.9.10. __int__

PythonDist.__int__()[source]

The cast operator into the bitmask which is the hexrelease. The cache is used without new calculation if self.hexrelease is present, else created by calling get_hexrelease. For the forced calculation only use get_hexrelease.

int(self) == self-bitmask
Parameters

none

Returns

The resulting bitmask of self as numeric value.

Raises

pass-through

5.2.9.11. __ior__

PythonDist.__ior__(other)[source]

The in-place | operator for the resulting hexversion:

self-bitmask |= other-bitmask
Parameters

other

The bitmask for operations.

other := (
     <int-16bit-mask>               # compare with hexversion
   | <dictionary>)                  # compare keys only
   | <tuple>)                       # compare key-index only
   | <instance-of-PythonDist>       # compare both hexversions
)

Returns

The resulting bitmask as numeric value.

Raises

pass-through

5.2.9.12. __iter__

PythonDist.__iter__()[source]

Iterates the non-private attribute names.

5.2.9.13. __le__

PythonDist.__le__(other)[source]

The <= operator for the resulting hexversion:

self-bitmask <= other-bitmask
Parameters

other

The bitmask for operations.

other := (
     <int-16bit-mask>               # compare with hexversion
   | <dictionary>)                  # compare keys only
   | <tuple>)                       # compare key-index only
   | <instance-of-PythonDist>       # compare both hexversions
)

Returns

The resulting bitmask as numeric value.

Raises

pass-through

5.2.9.14. __lt__

PythonDist.__lt__(other)[source]

The < operator for the resulting hexversion:

self-bitmask < other-bitmask
Parameters

other

The bitmask for operations.

other := (
     <int-16bit-mask>               # compare with hexversion
   | <dictionary>)                  # compare keys only
   | <tuple>)                       # compare key-index only
   | <instance-of-PythonDist>       # compare both hexversions
)

Returns

True or False.

Raises

pass-through

5.2.9.15. __ne__

PythonDist.__ne__(other)[source]

See __eq__.

5.2.9.16. __or__

PythonDist.__or__(other)[source]

The | operator for the resulting hexversion:

self-bitmask | other-bitmask
Parameters

other

The bitmask for operations.

other := (
     <int-16bit-mask>               # compare with hexversion
   | <dictionary>)                  # compare keys only
   | <tuple>)                       # compare key-index only
   | <instance-of-PythonDist>       # compare both hexversions
)

Returns

The resulting bitmask as numeric value.

Raises

pass-through

5.2.9.17. __rand__

PythonDist.__rand__(other)[source]

The r-side & operator for the resulting hexversion:

other-bitmask & self-bitmask
Parameters

other

The bitmask for operations.

other := (
     <int-16bit-mask>               # compare with hexversion
   | <dictionary>)                  # compare keys only
   | <tuple>)                       # compare key-index only
   | <instance-of-PythonDist>       # compare both hexversions
)

Returns

The resulting bitmask as numeric value.

Raises

pass-through

5.2.9.18. __repr__

PythonDist.__repr__()[source]

The standard representation. The contained attributes are represented as numeric 32bit-enums and values, for example:

res = {"category": 2147483648, "disttype": 0, "dist": 0, "distrel": 595591168, "hexrelease": 2743074816}

5.2.9.19. __ror__

PythonDist.__ror__(other)[source]

The right-side | operator for the resulting hexversion:

other-bitmask | self-bitmask
Parameters

other

The bitmask for operations.

other := (
     <int-16bit-mask>               # compare with hexversion
   | <dictionary>)                  # compare keys only
   | <tuple>)                       # compare key-index only
   | <instance-of-PythonDist>       # compare both hexversions
)

Returns

The resulting bitmask as numeric value.

Raises

pass-through

5.2.9.20. __setattr__

PythonDist.__setattr__(name, value)[source]

Sets the selected attribute and synchronizes dependent.

5.2.9.21. __setitem__

PythonDist.__setitem__(key, value)[source]

Sets the selected attribute and synchronizes dependent.

5.2.9.22. __str__

PythonDist.__str__()[source]

5.2.9.23. get_distribution

PythonDist.get_distribution(rtype=<class 'pythonids.pythondist.PyDist'>)[source]

Reads out the distribution data into a tuple of selected type.

Parameters

rtype

The return type:

rtype := (
     PyDist
   | PyDistSegments
   | PyDistStr
   | tuple
   | <user-defined-tuple-type>
)

default := PyDist

Returns

(
   category,
   disttype,
   dist,
   distrel
)

Return type

Returns a tuple of the provided attributes

Raises

pass-through

5.2.9.24. get_hexrelease

PythonDist.get_hexrelease()[source]

Returns the dynamically calculated hex version resulting from current values of the member attributes. When not all present, uses the available stack attributes. Does not use cached values, nor stores the result. For the use and recreation of cached values call __int__.

5.2.9.25. items

PythonDist.items()[source]

Gets the list of key-value tupels.

5.2.9.26. keys

PythonDist.keys()[source]

Gets the list of attribute names.

5.2.9.27. scan

PythonDist.scan(forceall=None)[source]

Scans local platform for attributes specifying the platform. Supports:

CPython, iPython, IronPython, Jython, PyPy
Parameters

forceall

Controls the scan content:

forceall := (
     True    # scan distribution and compiler
   | False   # scan distribution only
)

default := None

Returns

  • The tuple of Python identifiers:

    category
    disttype
    dist
    distrel
    
  • Additional shortcuts prepared for direct processing:

    hexrelease
    
  • In addition the optional, but strongly supported attributes. These are scanned only in case of forceall==True.

    c_libc_version
    c_compiler
    c_compiler_version
    

    Returns the value of hexrelease.

Return type

Superposes the following mandatory attributes by the scanned values

Raises

PythonDistError

5.2.9.28. values

PythonDist.values()[source]

Gets the list of attribute values.

5.2.10. PyDist

class pythonids.pythondist.PyDist(category, disttype, dist, distrel)

Named tuple for structured results. See collections.namedtuple.

5.2.11. PyDistSegments

class pythonids.pythondist.PyDistSegments(category, disttype, dist, distrel)

Named tuple for structured results as sub-parts. See collections.namedtuple.

5.2.12. PyDistStr

class pythonids.pythondist.PyDistStr(category, disttype, dist, distrel)

Named tuple for structured results as str. See collections.namedtuple.

5.2.13. Exceptions

exception pythonids.pythondist.PythonDistError[source]