Skip to content

Commit

Permalink
update python3 build config
Browse files Browse the repository at this point in the history
  • Loading branch information
jingjingxyk committed Nov 12, 2024
1 parent f70e28a commit 679e6d5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion ext/swoole
Submodule swoole updated 104 files
4 changes: 2 additions & 2 deletions sapi/src/builder/extension/phpy.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
$p->addExtension($ext);

$p->withBeforeConfigureScript('phpy', function (Preprocessor $p) {
$php_src = $p->getPhpSrcDir();
$php_src = $p->getWorkDir();
$cmd = <<<EOF
cd {$php_src}/
Expand All @@ -53,5 +53,5 @@

$libs = $p->isMacos() ? '-lc++' : ' -lstdc++ ';
$p->withVariable('LIBS', '$LIBS ' . $libs);
$p->withVariable('CPPFLAGS', '$CPPFLAGS -I' . $p->getPhpSrcDir() . '/ext/phpy/include');
$p->withVariable('CPPFLAGS', '$CPPFLAGS -I' . $p->getWorkDir() . '/ext/phpy/include');
};
30 changes: 21 additions & 9 deletions sapi/src/builder/library/python3.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,19 @@
->withUrl('https://www.python.org/ftp/python/3.12.2/Python-3.12.2.tgz')
->withPrefix($python3_prefix)
->withBuildCached(false)
//->withInstallCached(false)
->withInstallCached(false)
->withBuildScript(
<<<EOF
./configure --help
sed -i.backup 's/py_cv_module__ctypes=yes/py_cv_module__ctypes=disabled/' ./configure
sed -i.backup 's/py_cv_module_xxlimited=yes/py_cv_module_xxlimited=disabled/' ./configure
sed -i.backup 's/py_cv_module_xxlimited_35=yes/py_cv_module_xxlimited_35=disabled/' ./configure
sed -i.backup 's/py_cv_module__scproxy=yes/py_cv_module__scproxy=disabled/' ./configure
sed -i.backup 's/py_cv_module__tkinter=missing/py_cv_module__tkinter=disabled/' ./configure
PACKAGES='openssl '
PACKAGES="\$PACKAGES zlib"
PACKAGES="\$PACKAGES sqlite3"
Expand All @@ -39,7 +46,7 @@
PACKAGES="\$PACKAGES libmpdec"
PACKAGES="\$PACKAGES libb2"
# -Wl,–no-export-dynamic
CFLAGS="-DOPENSSL_THREADS {$static_flag} -fPIC -DCONFIG_64=1"
CPPFLAGS="$(pkg-config --cflags-only-I --static \$PACKAGES) {$static_flag} "
LDFLAGS="$(pkg-config --libs-only-L --static \$PACKAGES) {$static_flag} "
Expand Down Expand Up @@ -74,22 +81,24 @@
--with-readline=readline \
--with-openssl={$openssl_prefix} \
--with-ssl-default-suites=openssl \
--with-builtin-hashlib-hashes=md5,sha1,sha2,sha3,blake2 \
--without-valgrind \
--without-dtrace \
--with-ensurepip=install
# 只能动态构建的扩展 请查看 Modules/Setup.stdlib 描述,找到并注释
# ctypes 、xxlimited 、scproxy(onliy macos) 、tkinter
# 注释方法: sed -i 's/^pattern/;\1/' file.txt
# \1 表示匹配到的内容
# sed -i.backup "s/^\*shared\*/\*static\*/g" Modules/Setup.stdlib
sed -i.backup 's/^_ctypes _ctypes\/_ctypes\.c/# \1/' Modules/Setup.stdlib
sed -i.backup 's/^_scproxy _scproxy\.c/# \1/' Modules/Setup.stdlib
# sed -i.backup 's/^_ctypes _ctypes\/_ctypes\.c/# \1/' Modules/Setup.stdlib
# sed -i.backup 's/^_scproxy _scproxy\.c/# \1/' Modules/Setup.stdlib
sed -i.backup 's/^xxlimited xxlimited\.c/# \1/' Modules/Setup.stdlib
sed -i.backup 's/^xxlimited_35 xxlimited_35\.c/# \1/' Modules/Setup.stdlib
# sed -i.backup 's/^xxlimited xxlimited\.c/# \1/' Modules/Setup.stdlib
# sed -i.backup 's/^xxlimited_35 xxlimited_35\.c/# \1/' Modules/Setup.stdlib
cp -f Modules/Setup.stdlib Modules/Setup.local
Expand All @@ -103,6 +112,8 @@
make install
cp -f Modules/_hacl/libHacl_Hash_SHA2.a {$python3_prefix}/lib/
{$python3_prefix}/bin/python3 -E -c 'import sys ; from sysconfig import get_platform ; print("%s-%d.%d" % (get_platform(), *sys.version_info[:2])) ; '
{$python3_prefix}/bin/python3 -E -c 'import sys ; print(sys.modules) ; '
{$python3_prefix}/bin/python3 -E -c 'import sys ; print(dir(sys)) ; '
Expand All @@ -127,7 +138,7 @@
EOF
)
->withPkgName('python3-embed')
->withPkgName('python3')
//->withPkgName('python3')
->withDependentLibraries(
'zlib',
'openssl',
Expand All @@ -146,12 +157,13 @@
$p->addLibrary($lib);

if ($p->isMacos()) {
$p->withVariable('LDFLAGS', '$LDFLAGS -framework CoreFoundation ');
//$p->withVariable('LDFLAGS', '$LDFLAGS -framework CoreFoundation ');

//module _scproxy needs SystemConfiguration and CoreFoundation framework
//$p->withVariable('LDFLAGS', '$LDFLAGS -framework SystemConfiguration -framework CoreFoundation ');
}

//libHacl_Hash_SHA2.a
$p->withVariable('LIBS', '$LIBS -lHacl_Hash_SHA2 ');
};
# 构建独立版本 python 参考
# https://github.com/indygreg/python-build-standalone.git
Expand Down

0 comments on commit 679e6d5

Please sign in to comment.