"Fossies" - the Fresh Open Source Software Archive

Member "Plone-5.2.5-UnifiedInstaller-1.0/helper_scripts/checkPython.py" (13 Sep 2021, 1905 Bytes) of package /linux/www/Plone-5.2.5-UnifiedInstaller-1.0.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "checkPython.py" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 5.2.2-UnifiedInstaller_vs_5.2.4-UnifiedInstaller-1.0.

    1 # Test the invoking Python to see if it's a good candidate
    2 # for running Zope 2.12.x / Plone 4.2.x.
    3 #
    4 
    5 from distutils.sysconfig import get_python_inc
    6 from i18n import _print
    7 
    8 import sys
    9 import os.path
   10 
   11 passed = True
   12 
   13 # check version
   14 vi = sys.version_info[:3]
   15 if vi[0] == 2 and vi < (2, 7, 9) or vi[0] == 3 and vi < (3, 6, 0):
   16     _print("Failed: Python version must be 2.7.9+ or 3.6.0+.")
   17     # not much point in further testing.
   18     sys.exit(1)
   19 
   20 include_dir = os.path.join(get_python_inc(plat_specific=1))
   21 if not os.path.isfile(os.path.join(include_dir, "Python.h")):
   22     _print("Failed: We need to be able to use Python.h, which is missing.")
   23     _print("You may be able to resolve this by installing the python-dev package.")
   24     passed = False
   25 
   26 try:
   27     import xml.parsers.expat
   28 
   29     xml.parsers.expat
   30 except ImportError:
   31     _print("Failed: Python must include xml.parsers.expat module.")
   32     _print("This is a separate package on some platforms.\n")
   33     passed = False
   34 
   35 try:
   36     import zlib
   37 
   38     zlib
   39     try:
   40         zlib.compress(b"test")
   41     except LookupError:
   42         _print("Failed: Python zlib is not working.\n")
   43         passed = False
   44 except ImportError:
   45     _print("Failed: Python must include zlib module.\n")
   46     passed = False
   47 
   48 try:
   49     import _ssl
   50 
   51     _ssl
   52 except ImportError:
   53     if "--without-ssl=yes" in sys.argv:
   54         _print("Warning: This Python does not have ssl support.")
   55     else:
   56         _print("Failed: This Python does not have ssl support.")
   57         _print("If you want to disable this check, add --without-ssl=yes")
   58         _print("to the command line.")
   59         passed = False
   60 
   61 try:
   62     import readline
   63 
   64     readline
   65 except ImportError:
   66     _print("Warning: This Python does not have readline support.")
   67     _print(
   68         "It may still be usable for Zope, but interacting directly with Python will be painful.\n"
   69     )
   70 
   71 if not passed:
   72     sys.exit(1)
   73 
   74 sys.exit(0)