Package pythonids :: Module pythondist

Module pythondist

source code

pythonids.pythondist provides information about the Python implementation.

Raises 'pythonids.PythonIDsImplementationError' when implementation is not supported.


Version: 0.1.35

Author: Arno-Can Uestuensoez

Copyright: Copyright (C) 2010-2018 Arno-Can Uestuensoez @Ingenieurbuero Arno-Can Uestuensoez

License: Artistic-License-2.0 + Forced-Fairplay-Constraints

Functions
 
decode_pydist_32bit_to_tuple(ddat=0)
Decodes the 32bit hex representation of the Python distribution into a flat tuple of numbers.
source code
 
decode_pydist_32bit_to_tuple_segments(ddat=0)
Decodes the 32bit hex representation of the Python distribution into a dict structure with str names and numeric release vectors.
source code
 
decode_pydist_32bit_to_tuple_str(ddat=0)
Decodes the 32bit hex representation of the Python distribution into a dict structure with str names and str representation of releases.
source code
 
encode_pydist_segments_to_32bit(**kargs)
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.
source code
 
encode_pydist_to_32bit(d=0, dx=0, dy=0, dz=0, sma=0, smi=0)
Encodes the Python distribution by calculating the 32bit integer bitmask for the provided Python distribution and syntax release information.
source code
Variables
  ISINT = (<class 'int'>)
  ISNUM = (<class 'int'>, <class 'float'>)
  ISSTR = (<class 'str'>, <class 'bytes'>)
  PYDIST = 3020173824
  PYDIST_DATA = {"category": 0x80000000, "disttype": 0x34000000,...
  PYE_CATEGORY = 2147483648
  PYE_CIRCUITPYTHON = 524288
  PYE_CIRCUITPYTHON_NAME = 'b'circuitpython''
  PYE_CIRCUITPYTHON_PRETTY = 'b'CircuitPython''
  PYE_CPYTHON = 262144
  PYE_CPYTHON_NAME = 'b'cpython''
  PYE_CPYTHON_PRETTY = 'b'CPython''
  PYE_CYTHON = 786432
  PYE_CYTHON_NAME = 'b'cython''
  PYE_CYTHON_PRETTY = 'b'Cython''
  PYE_DIST = 8126464
  PYE_DISTREL = 262143
  PYE_DISTREL_MAJOR = 258048
  PYE_DISTREL_MICRO = 63
  PYE_DISTREL_MINOR = 4032
  PYE_EMPTY = 0
  PYE_IPYTHON = 1048576
  PYE_IPYTHON_NAME = 'b'ipython''
  PYE_IPYTHON_PRETTY = 'b'iPython''
  PYE_IRONPYTHON = 1310720
  PYE_IRONPYTHON_NAME = 'b'ironpython''
  PYE_IRONPYTHON_PRETTY = 'b'IronPython''
  PYE_JYTHON = 1572864
  PYE_JYTHON_NAME = 'b'jython''
  PYE_JYTHON_PRETTY = 'b'Jython''
  PYE_MICROPYTHON = 1835008
  PYE_MICROPYTHON_NAME = 'b'micropython''
  PYE_MICROPYTHON_PRETTY = 'b'MicroPython''
  PYE_PYDIST_CPYTHON2715 = 2743345615
  PYE_PYDIST_CPYTHON372 = 3011785154
  PYE_PYDIST_IPYTHON550 = 2744144192
  PYE_PYDIST_IPYTHON560 = 2744144256
  PYE_PYDIST_IRONPYTHON277 = 2744394183
  PYE_PYDIST_IRONPYTHON279 = 2744394185
  PYE_PYDIST_JYTHON270 = 2744656320
  PYE_PYDIST_JYTHON271 = 2744656321
  PYE_PYDIST_PYPY580 = 2745192960
  PYE_PYDIST_PYPY60027 = 2745196544
  PYE_PYDIST_PYPY60035 = 2996854784
  PYE_PYDIST_PYPY70036 = 3005247488
  PYE_PYPY = 2097152
  PYE_PYPY_NAME = 'b'pypy''
  PYE_PYPY_PRETTY = 'b'PyPy''
  PYE_PYTHON = 2147483648
  PYE_PYTHON27 = 595591168
  PYE_PYTHON35 = 847249408
  PYE_PYTHON36 = 855638016
  PYE_PYTHON37 = 864026624
  PYE_PYTHON38 = 872415232
  PYE_PYTHON39 = 880803840
  PYE_PYTHON_NAME = 'b'python''
  PYE_PYTHON_PRETTY = 'b'Python''
  PYE_SYNTAXTYPE = 2139095040
  PYE_SYNTAXTYPE_MAJOR = 1879048192
  PYE_SYNTAXTYPE_MINOR = 260046848
  PyDist = <class 'pythonids.pythondist.PyDist'>
  PyDistSegments = <class 'pythonids.pythondist.PyDistSegments'>
  PyDistStr = <class 'pythonids.pythondist.PyDistStr'>
  PythonDist = <class 'pythonids.pythondist.PythonDist'>
  PythonDistError = <class 'pythonids.pythondist.PythonDistError'>
  PythonIDsError = <class 'pythonids.PythonIDsError'>
  SPLITVERS = re.compile('(?s)(^[0-9]+)[.]([0-9]*)[.]([0-9]*).*'...
  SPLITVERS2 = re.compile('(?s)(^[0-9]+)[.]([0-9]*).*', re.DOTALL)
  STR2DISTREL = re.compile('([0-9.]*)[^0-9]*')
  __cached__ = 'b'/local/hd1/home1/data/acue/rd/p-open-deploy/py...
  __loader__ = <_frozen_importlib_external.SourceFileLoader obje...
  __package__ = 'b'pythonids''
  __spec__ = ModuleSpec(name='pythonids.pythondist', loader=<_fr...
  __uuid__ = 'b'5624dc41-775a-4d17-ac42-14a0d5c41d1a''
  attribute_map = {'b'c_compiler'': 'b'c_compiler'', 'b'c_compil...
  bash_map = {'b'c_compiler'': 'b'PYDIST_C_COMPILER'', 'b'c_comp...
  dist2num = {524288: 524288, 'b'circuitpython'': 524288, 'b'Cir...
  isJython = False
  num2name = {0: 'b''', 262144: 'b'cpython'', 1048576: 'b'ipytho...
  num2pretty = {0: 'b''', 262144: 'b'CPython'', 1048576: 'b'iPyt...
Function Details

decode_pydist_32bit_to_tuple(ddat=0)

source code 

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

Args:

ddat:

The 32bit value.

Returns:

Nametupel with the components:

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

Raises:

pass-through

decode_pydist_32bit_to_tuple_segments(ddat=0)

source code 

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

Args:

ddat:

The 32bit value.

Returns:

Nametupel with the components:

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

Raises:

pass-through

decode_pydist_32bit_to_tuple_str(ddat=0)

source code 

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

Args:

ddat:

The 32bit value.

Returns:

Dictionary with components:

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

Raises:

pass-through

encode_pydist_segments_to_32bit(**kargs)

source code 

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.

Args:

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

encode_pydist_to_32bit(d=0, dx=0, dy=0, dz=0, sma=0, smi=0)

source code 

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

Args:
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.

See Python Distribution Categorization.

Raises:

pass-through

Variables Details

PYDIST_DATA

Value:
{"category": 0x80000000, "disttype": 0x34000000, "dist": 0x00040000, "\
distrel": 0x00003200, "hexrelease": 0xb4043200, "compiler": "GCC", "co\
mpiler_version": "7.3.1"}

SPLITVERS

Value:
re.compile('(?s)(^[0-9]+)[.]([0-9]*)[.]([0-9]*).*', re.DOTALL)

__cached__

Value:
'b'/local/hd1/home1/data/acue/rd/p-open-deploy/pythonids/repos/sourcef\
orge.net/pythonids/pythonids/__pycache__/pythondist.cpython-38.pyc''

__loader__

Value:
<_frozen_importlib_external.SourceFileLoader object at 0x7f51ac065850>

__spec__

Value:
ModuleSpec(name='pythonids.pythondist', loader=<_frozen_importlib_exte\
rnal.SourceFileLoader object at 0x7f51ac065850>, origin='/local/hd1/ho\
me1/data/acue/rd/p-open-deploy/pythonids/repos/sourceforge.net/pythoni\
ds/pythonids/pythondist.py')

attribute_map

Value:
{'b'c_compiler'': 'b'c_compiler'',
 'b'c_compiler_version'': 'b'c_compiler_version'',
 'b'c_libc_version'': 'b'c_libc_version'',
 'b'category'': 'b'category'',
 'b'compiler'': 'b'compiler'',
 'b'compiler_version'': 'b'compiler_version'',
 'b'dist'': 'b'dist'',
 'b'distrel'': 'b'distrel'',
...

bash_map

Value:
{'b'c_compiler'': 'b'PYDIST_C_COMPILER'',
 'b'c_compiler_version'': 'b'PYDIST_C_COMPILER_VERSION'',
 'b'c_libc_version'': 'b'PYDIST_C_LIBC_VERSION'',
 'b'category'': 'b'PYDIST_CATEGORY'',
 'b'compiler'': 'b'PYDIST_COMPILER'',
 'b'compiler_version'': 'b'PYDIST_COMPILER_VERSION'',
 'b'dist'': 'b'PYDIST_DIST'',
 'b'distrel'': 'b'PYDIST_DISTREL'',
...

dist2num

Value:
{524288: 524288,
 'b'circuitpython'': 524288,
 'b'CircuitPython'': 524288,
 262144: 262144,
 'b'cpython'': 262144,
 'b'CPython'': 262144,
 786432: 786432,
 'b'cython'': 786432,
...

num2name

Value:
{0: 'b''',
 262144: 'b'cpython'',
 1048576: 'b'ipython'',
 1310720: 'b'ironpython'',
 1572864: 'b'jython'',
 2097152: 'b'pypy'',
 595591168: 'b'python2.7'',
 847249408: 'b'python3.5'',
...

num2pretty

Value:
{0: 'b''',
 262144: 'b'CPython'',
 1048576: 'b'iPython'',
 1310720: 'b'IronPython'',
 1572864: 'b'Jython'',
 2097152: 'b'PyPy'',
 595591168: 'b'Python-2.7'',
 847249408: 'b'Python-3.5'',
...