Every line of 'pythonpath linux' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
10 def get_python3_path(): 11 # If it is not working, Please replace python3_path with your local python3 path. shell: which python3 12 if (platform.system() == "Darwin"): 13 # which python3 14 path = "/usr/local/bin/python3" 15 if platform.system() == "Windows": 16 path = "python" 17 if platform.system() == "Linux": 18 path = "/usr/bin/python3" 19 return path
14 def is_python(path): 15 '''Whether the given file is Python.''' 16 if path is not None: 17 return run(['file', path]).find('Python') >= 0 18 else: 19 return False
34 def python_binary(platform=None): 35 if platform == "windows": 36 return "python.exe" 37 if platform == "macos": 38 return "python3.7" 39 return "python3.6"
30 def get_python_executable() -> str: 31 ''' 32 Gets the absolute path of the executable binary for the Python interpreter. 33 ''' 34 if not sys.executable: 35 raise RuntimeError('Unable to get the path to the Python executable.') 36 return sys.executable
54 def find_python_executable(python_major): 55 # type: (int) -> str 56 """ 57 Find the relevant python executable that is of the given python major version. 58 Will test, in decreasing priority order: 59 * the current Python interpreter 60 * 'pythonX' executable in PATH (with X the given major version) if available 61 * 'python' executable in PATH if available 62 * Windows Python launcher 'py' executable in PATH if available 63 Incompatible python versions for Certbot will be evicted (eg. Python < 3.5 on Windows) 64 :param int python_major: the Python major version to target (2 or 3) 65 :rtype: str 66 :return: the relevant python executable path 67 :raise RuntimeError: if no relevant python executable path could be found 68 """ 69 python_executable_path = None 70 71 # First try, current python executable 72 if _check_version('{0}.{1}.{2}'.format( 73 sys.version_info[0], sys.version_info[1], sys.version_info[2]), python_major): 74 return sys.executable 75 76 # Second try, with python executables in path 77 versions_to_test = ['2.7', '2', ''] if python_major == 2 else ['3', ''] 78 for one_version in versions_to_test: 79 try: 80 one_python = 'python{0}'.format(one_version) 81 output = subprocess.check_output([one_python, '--version'], 82 universal_newlines=True, stderr=subprocess.STDOUT) 83 if _check_version(output.strip().split()[1], python_major): 84 return subprocess.check_output([one_python, '-c', 85 'import sys; sys.stdout.write(sys.executable);'], 86 universal_newlines=True) 87 except (subprocess.CalledProcessError, OSError): 88 pass 89 90 # Last try, with Windows Python launcher 91 try: 92 env_arg = '-{0}'.format(python_major) 93 output_version = subprocess.check_output(['py', env_arg, '--version'], 94 universal_newlines=True, stderr=subprocess.STDOUT) 95 if _check_version(output_version.strip().split()[1], python_major): 96 return subprocess.check_output(['py', env_arg, '-c', 97 'import sys; sys.stdout.write(sys.executable);'], 98 universal_newlines=True) 99 except (subprocess.CalledProcessError, OSError): 100 pass 101 102 if not python_executable_path: 103 raise RuntimeError('Error, no compatible Python {0} executable for Certbot could be found.' 104 .format(python_major))
82 def _linux(): 83 platform = PLATFORM_LINUX 84 85 from ctypes.util import find_library 86 from os import environ 87 acc = False 88 try: 89 with open('/proc/modules', 'r') as f: 90 for l in f.readlines(): 91 if l.startswith('vc4'): 92 acc = True 93 break 94 except: 95 pass # main reason to fail is /proc/modules not there so acc False 96 97 bcm_name = find_library('bcm_host') 98 if bcm_name and not acc: 99 platform = PLATFORM_PI 100 bcm = _load_library(bcm_name) 101 else: 102 bcm = None 103 104 if environ.get('ANDROID_APP_PATH'): 105 platform = PLATFORM_ANDROID 106 opengles = _load_library('/system/lib/libGLESv2.so') 107 openegl = _load_library('/system/lib/libEGL.so') 108 else: 109 import os 110 if not acc and os.path.isfile('/opt/vc/lib/libGLESv2.so'): # raspbian before stretch release 111 opengles = _load_library('/opt/vc/lib/libGLESv2.so') 112 openegl = _load_library('/opt/vc/lib/libEGL.so') 113 elif not acc and os.path.isfile('/opt/vc/lib/libbrcmGLESv2.so'): # raspbian after stretch release 114 opengles = _load_library('/opt/vc/lib/libbrcmGLESv2.so') 115 openegl = _load_library('/opt/vc/lib/libbrcmEGL.so') 116 elif not acc and os.path.isfile('/usr/lib/libGLESv2.so'): # ubuntu MATE (but may catch others - monitor problems) 117 opengles = _load_library('/usr/lib/libGLESv2.so') 118 openegl = _load_library('/usr/lib/libEGL.so') 119 else: 120 opengles = _load_library(find_library('GLESv2')) # has to happen first 121 openegl = _load_library(find_library('EGL')) # otherwise missing symbol on pi loading egl 122 123 return platform, bcm, openegl, opengles # opengles now determined by platform
9 @utils.memoized 10 def getNeededPythonPath(): 11 testDir = os.path.dirname(__file__) 12 base = os.path.dirname(testDir) 13 vdsmModPath = os.path.join(base, 'lib') 14 vdsmPath = os.path.join(base, 'vdsm') 15 cliPath = os.path.join(base, 'client') 16 pyPath = "PYTHONPATH=" + ':'.join([base, vdsmPath, cliPath, vdsmModPath]) 17 return pyPath