32 lines
808 B
PHP
32 lines
808 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
header('Content-Type: text/plain; charset=utf-8');
|
|
|
|
$candidates = PHP_OS_FAMILY === 'Windows'
|
|
? ['python', 'py']
|
|
: ['/usr/bin/python3', '/usr/bin/python', 'python3', 'python'];
|
|
|
|
$probe = <<<'PY'
|
|
import platform
|
|
import sys
|
|
|
|
print(sys.version)
|
|
print(sys.executable)
|
|
print("machine=" + platform.machine())
|
|
print("system=" + platform.system())
|
|
print("platform=" + platform.platform())
|
|
PY;
|
|
|
|
foreach ($candidates as $pythonBinary) {
|
|
$command = $pythonBinary . ' -c ' . escapeshellarg($probe);
|
|
$output = [];
|
|
$resultCode = 0;
|
|
exec($command . ' 2>&1', $output, $resultCode);
|
|
|
|
echo "Kandidat: " . $pythonBinary . PHP_EOL;
|
|
echo "Exit-Code: " . $resultCode . PHP_EOL;
|
|
echo implode(PHP_EOL, $output) . PHP_EOL;
|
|
echo str_repeat('-', 60) . PHP_EOL;
|
|
}
|