1
0
mirror of https://github.com/danog/PrimeModule.git synced 2024-11-26 20:34:37 +01:00

PHP 8.1 support

This commit is contained in:
Daniil Gentili 2022-12-03 21:53:15 +01:00
parent 0d5006daf0
commit 2328b1ec43
2 changed files with 5 additions and 17 deletions

View File

@ -89,10 +89,10 @@ class PrimeModule
public static function python_single($what)
{
if (function_exists('shell_exec')) {
$res = trim(shell_exec('timeout 10 python2 '.__DIR__.'/prime.py '.$what.' 2>&1'));
$res = trim(shell_exec('timeout 10 python2 '.__DIR__.'/prime.py '.$what.' 2>&1') ?? '');
if ($res == '' || is_null($res) || !is_numeric($res)) {
copy(__DIR__.'/prime.py', getcwd().'/.prime.py');
$res = trim(shell_exec('timeout 10 python2 '.getcwd().'/.prime.py '.$what.' 2>&1'));
$res = trim(shell_exec('timeout 10 python2 '.getcwd().'/.prime.py '.$what.' 2>&1') ?? '');
unlink(getcwd().'/.prime.py');
if ($res == '' || is_null($res) || !is_numeric($res)) {
return false;
@ -128,10 +128,10 @@ class PrimeModule
public static function python_single_alt($what)
{
if (function_exists('shell_exec')) {
$res = trim(shell_exec('python '.__DIR__.'/alt_prime.py '.$what.' 2>&1'));
$res = trim(shell_exec('python '.__DIR__.'/alt_prime.py '.$what.' 2>&1') ?? '');
if ($res == '' || is_null($res) || !is_numeric($res)) {
copy(__DIR__.'/alt_prime.py', getcwd().'/.alt_prime.py');
$res = trim(shell_exec('python '.getcwd().'/.alt_prime.py '.$what.' 2>&1'));
$res = trim(shell_exec('python '.getcwd().'/.alt_prime.py '.$what.' 2>&1') ?? '');
unlink(getcwd().'/.alt_prime.py');
if ($res == '' || is_null($res) || !is_numeric($res)) {
return false;

View File

@ -1,17 +1,5 @@
#!/bin/bash
export PATH=$PATH:~/.phpenv/versions/$(phpenv version-name)/bin
cd /tmp &&
git clone https://github.com/CopernicaMarketingSoftware/PHP-CPP &&
cd PHP-CPP &&
make -j16 &&
sudo make install &&
cd ../ &&
git clone https://github.com/danog/PrimeModule-ext &&
cd PrimeModule-ext &&
make -j16 &&
echo "extension=$PWD/primemodule.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini &&
cd ..
sudo apt-get install build-essential && git clone https://github.com/danog/PrimeModule-ext && cd PrimeModule-ext && make -j$(nproc) && sudo make install
exit 0