[python3] x64-linux-dynamic fixes (#25995)

* [python3] x64-linux-dynamic fixes

* Fix custom post-build checks

* Clarify comment.

Co-authored-by: Osyotr <8740768+Osyotr@users.noreply.github.com>
Co-authored-by: Billy O'Neal <bion@microsoft.com>
This commit is contained in:
Osyotr 2022-08-04 23:49:06 +03:00 committed by GitHub
parent 97f26935db
commit e2213266cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 196 additions and 14 deletions

View File

@ -1,11 +0,0 @@
--- a/Lib/ensurepip/__init__.py 2021-10-05 00:40:46.000000000 +0700
+++ b/Lib/ensurepip/__init__.py 2022-01-11 15:22:54.001498300 +0700
@@ -86,6 +86,8 @@
code = f"""
import runpy
import sys
+import os
+sys.executable = os.path.dirname(os.path.realpath(__file__))
sys.path = {additional_paths or []} + sys.path
sys.argv[1:] = {args}
runpy.run_module("pip", run_name="__main__", alter_sys=True)

View File

@ -0,0 +1,158 @@
diff --git a/setup.py b/setup.py
index 61b3266..4c2cfb4 100644
--- a/setup.py
+++ b/setup.py
@@ -1153,6 +1153,7 @@ def detect_readline_curses(self):
self.add(Extension('readline', ['readline.c'],
library_dirs=['/usr/lib/termcap'],
extra_link_args=readline_extra_link_args,
+ runtime_library_dirs=self.lib_dirs,
libraries=readline_libs))
else:
self.missing.append('readline')
@@ -1189,6 +1190,7 @@ def detect_readline_curses(self):
extra_compile_args=['-DPy_BUILD_CORE_MODULE'],
include_dirs=curses_includes,
define_macros=curses_defines,
+ runtime_library_dirs=self.lib_dirs,
libraries=curses_libs))
elif curses_library == 'curses' and not MACOS:
# OSX has an old Berkeley curses, not good enough for
@@ -1203,6 +1205,7 @@ def detect_readline_curses(self):
self.add(Extension('_curses', ['_cursesmodule.c'],
extra_compile_args=['-DPy_BUILD_CORE_MODULE'],
define_macros=curses_defines,
+ runtime_library_dirs=self.lib_dirs,
libraries=curses_libs))
else:
curses_enabled = False
@@ -1216,6 +1219,7 @@ def detect_readline_curses(self):
self.add(Extension('_curses_panel', ['_curses_panel.c'],
include_dirs=curses_includes,
define_macros=curses_defines,
+ runtime_library_dirs=self.lib_dirs,
libraries=[panel_library, *curses_libs]))
elif not skip_curses_panel:
self.missing.append('_curses_panel')
@@ -1234,7 +1238,7 @@ def detect_crypt(self):
else:
libs = []
- self.add(Extension('_crypt', ['_cryptmodule.c'], libraries=libs))
+ self.add(Extension('_crypt', ['_cryptmodule.c'], runtime_library_dirs=self.lib_dirs, libraries=libs))
def detect_socket(self):
# socket(2)
@@ -1525,6 +1529,7 @@ class db_found(Exception): pass
libraries=dblibs)
break
if dbmext is not None:
+ dbmext.runtime_library_dirs = self.lib_dirs
self.add(dbmext)
else:
self.missing.append('_dbm')
@@ -1533,6 +1538,7 @@ class db_found(Exception): pass
if ('gdbm' in dbm_order and
self.compiler.find_library_file(self.lib_dirs, 'gdbm')):
self.add(Extension('_gdbm', ['_gdbmmodule.c'],
+ runtime_library_dirs=self.lib_dirs,
libraries=['gdbm']))
else:
self.missing.append('_gdbm')
@@ -1645,6 +1651,7 @@ def detect_sqlite(self):
define_macros=sqlite_defines,
include_dirs=include_dirs,
library_dirs=sqlite_libdir,
+ runtime_library_dirs=self.lib_dirs,
extra_link_args=sqlite_extra_link_args,
libraries=["sqlite3",]))
else:
@@ -1710,6 +1717,7 @@ def detect_compress_exts(self):
zlib_extra_link_args = ()
self.add(Extension('zlib', ['zlibmodule.c'],
libraries=['z'],
+ runtime_library_dirs=self.lib_dirs,
extra_link_args=zlib_extra_link_args))
have_zlib = True
else:
@@ -1732,6 +1740,7 @@ def detect_compress_exts(self):
self.add(Extension('binascii', ['binascii.c'],
extra_compile_args=extra_compile_args,
libraries=libraries,
+ runtime_library_dirs=self.lib_dirs,
extra_link_args=extra_link_args))
# Gustavo Niemeyer's bz2 module.
@@ -1742,6 +1751,7 @@ def detect_compress_exts(self):
bz2_extra_link_args = ()
self.add(Extension('_bz2', ['_bz2module.c'],
libraries=['bz2'],
+ runtime_library_dirs=self.lib_dirs,
extra_link_args=bz2_extra_link_args))
elif (self.compiler.find_library_file(self.lib_dirs, 'bz2d')):
if MACOS:
@@ -1750,6 +1760,7 @@ def detect_compress_exts(self):
bz2_extra_link_args = ()
self.add(Extension('_bz2', ['_bz2module.c'],
libraries=['bz2d'],
+ runtime_library_dirs=self.lib_dirs,
extra_link_args=bz2_extra_link_args))
else:
self.missing.append('_bz2')
@@ -1757,6 +1768,7 @@ def detect_compress_exts(self):
# LZMA compression support.
if self.compiler.find_library_file(self.lib_dirs, 'lzma'):
self.add(Extension('_lzma', ['_lzmamodule.c'],
+ runtime_library_dirs=self.lib_dirs,
libraries=['lzma']))
else:
self.missing.append('_lzma')
@@ -1819,6 +1831,7 @@ def detect_expat_elementtree(self):
extra_compile_args=extra_compile_args,
include_dirs=expat_inc,
libraries=expat_lib,
+ runtime_library_dirs=self.lib_dirs,
sources=['pyexpat.c'] + expat_sources,
depends=expat_depends))
@@ -1831,6 +1844,7 @@ def detect_expat_elementtree(self):
define_macros=define_macros,
include_dirs=expat_inc,
libraries=expat_lib,
+ runtime_library_dirs=self.lib_dirs,
sources=['_elementtree.c'],
depends=['pyexpat.c', *expat_sources,
*expat_depends]))
@@ -1883,6 +1897,7 @@ def detect_uuid(self):
else:
uuid_libs = []
self.add(Extension('_uuid', ['_uuidmodule.c'],
+ runtime_library_dirs=self.lib_dirs,
libraries=uuid_libs))
else:
self.missing.append('_uuid')
@@ -2319,6 +2334,7 @@ def detect_ctypes(self):
ext.extra_compile_args.append("-DHAVE_FFI_CLOSURE_ALLOC=1")
ext.include_dirs.append(ffi_inc)
+ ext.runtime_library_dirs = self.lib_dirs
ext.libraries.append(ffi_lib)
self.use_system_libffi = True
@@ -2485,7 +2501,7 @@ def split_var(name, sep):
include_dirs=openssl_includes,
library_dirs=openssl_libdirs,
libraries=openssl_libs,
- runtime_library_dirs=runtime_library_dirs,
+ runtime_library_dirs=self.lib_dirs,
)
# This static linking is NOT OFFICIALLY SUPPORTED.
@@ -2639,6 +2655,7 @@ def detect_nis(self):
self.add(Extension('nis', ['nismodule.c'],
libraries=libs,
library_dirs=library_dirs,
+ runtime_library_dirs=self.lib_dirs,
include_dirs=includes_dirs))

View File

@ -15,6 +15,7 @@ set(PATCHES
0005-only-build-required-projects.patch 0005-only-build-required-projects.patch
0009-python.pc.patch 0009-python.pc.patch
0010-bz2d.patch 0010-bz2d.patch
0011-dont-skip-rpath.patch
) )
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
list(PREPEND PATCHES 0001-static-library.patch) list(PREPEND PATCHES 0001-static-library.patch)
@ -204,6 +205,11 @@ if(VCPKG_TARGET_IS_WINDOWS OR VCPKG_TARGET_IS_UWP)
endif() endif()
endif() endif()
else() else()
# The Python Stable ABI, `libpython3.so` is not produced by the upstream build system with --with-pydebug option
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic" AND NOT VCPKG_BUILD_TYPE)
set(VCPKG_POLICY_MISMATCHED_NUMBER_OF_BINARIES enabled)
endif()
set(OPTIONS set(OPTIONS
"--with-openssl=${CURRENT_INSTALLED_DIR}" "--with-openssl=${CURRENT_INSTALLED_DIR}"
"--without-ensurepip" "--without-ensurepip"
@ -244,6 +250,26 @@ else()
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME "copyright") file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME "copyright")
vcpkg_fixup_pkgconfig() vcpkg_fixup_pkgconfig()
# Perform some post-build checks on modules
file(GLOB python_libs_dynload_debug LIST_DIRECTORIES false "${CURRENT_PACKAGES_DIR}/debug/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/lib-dynload/*.so*")
file(GLOB python_libs_dynload_release LIST_DIRECTORIES false "${CURRENT_PACKAGES_DIR}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/lib-dynload/*.so*")
set(python_libs_dynload_failed_debug ${python_libs_dynload_debug})
set(python_libs_dynload_failed_release ${python_libs_dynload_release})
list(FILTER python_libs_dynload_failed_debug INCLUDE REGEX ".*_failed\.so.*")
list(FILTER python_libs_dynload_failed_release INCLUDE REGEX ".*_failed\.so.*")
if(python_libs_dynload_failed_debug OR python_libs_dynload_failed_release)
list(JOIN python_libs_dynload_failed_debug "\n" python_libs_dynload_failed_debug_str)
list(JOIN python_libs_dynload_failed_release "\n" python_libs_dynload_failed_release_str)
message(FATAL_ERROR "There should be no modules with \"_failed\" suffix:\n${python_libs_dynload_failed_debug_str}\n${python_libs_dynload_failed_release_str}")
endif()
if(NOT VCPKG_BUILD_TYPE)
list(LENGTH python_libs_dynload_release python_libs_dynload_release_length)
list(LENGTH python_libs_dynload_debug python_libs_dynload_debug_length)
if(NOT python_libs_dynload_release_length STREQUAL python_libs_dynload_debug_length)
message(FATAL_ERROR "Mismatched number of modules: ${python_libs_dynload_debug_length} in debug, ${python_libs_dynload_release_length} in release")
endif()
endif()
endif() endif()
file(READ "${CMAKE_CURRENT_LIST_DIR}/usage" usage) file(READ "${CMAKE_CURRENT_LIST_DIR}/usage" usage)

View File

@ -1,7 +1,7 @@
{ {
"name": "python3", "name": "python3",
"version": "3.10.5", "version": "3.10.5",
"port-version": 1, "port-version": 2,
"description": "The Python programming language", "description": "The Python programming language",
"homepage": "https://github.com/python/cpython", "homepage": "https://github.com/python/cpython",
"license": "Python-2.0", "license": "Python-2.0",
@ -28,6 +28,10 @@
"name": "liblzma", "name": "liblzma",
"platform": "!(windows & static)" "platform": "!(windows & static)"
}, },
{
"name": "libuuid",
"platform": "!osx & !windows"
},
{ {
"name": "openssl", "name": "openssl",
"platform": "!(windows & static)" "platform": "!(windows & static)"

View File

@ -5742,7 +5742,7 @@
}, },
"python3": { "python3": {
"baseline": "3.10.5", "baseline": "3.10.5",
"port-version": 1 "port-version": 2
}, },
"qca": { "qca": {
"baseline": "2.3.4", "baseline": "2.3.4",

View File

@ -1,5 +1,10 @@
{ {
"versions": [ "versions": [
{
"git-tree": "6e7ddcd01a8341a906d5dde6b3d221c955571684",
"version": "3.10.5",
"port-version": 2
},
{ {
"git-tree": "c345c4a8ad91847522188517c68e8f83637f4440", "git-tree": "c345c4a8ad91847522188517c68e8f83637f4440",
"version": "3.10.5", "version": "3.10.5",