[python2] Support UNIX (#18219)

* [python2] Support UNIX

* update baseline

* Update version record
This commit is contained in:
Jack·Boos·Yu 2021-06-11 07:10:50 +08:00 committed by GitHub
parent 4ea49a1cf8
commit 42f2d6f4d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 64 additions and 38 deletions

View File

@ -1,3 +0,0 @@
Source: python2
Version: 2.7.18
Description: The Python programming language as an embeddable library

View File

@ -13,6 +13,14 @@ set(PYTHON_VERSION_PATCH 18)
set(PYTHON_VERSION ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.${PYTHON_VERSION_PATCH})
set(_PYTHON_PATCHES "")
if (VCPKG_TARGET_IS_WINDOWS)
list(APPEND _PYTHON_PATCHES
${CMAKE_CURRENT_LIST_DIR}/001-build-msvc.patch
${CMAKE_CURRENT_LIST_DIR}/002-build-msvc.patch
${CMAKE_CURRENT_LIST_DIR}/003-build-msvc.patch
)
endif()
if (VCPKG_LIBRARY_LINKAGE STREQUAL static)
list(APPEND _PYTHON_PATCHES
${CMAKE_CURRENT_LIST_DIR}/004-static-library-msvc.patch
@ -23,6 +31,12 @@ if (VCPKG_CRT_LINKAGE STREQUAL static)
list(APPEND _PYTHON_PATCHES ${CMAKE_CURRENT_LIST_DIR}/005-static-crt-msvc.patch)
endif()
if (VCPKG_TARGET_IS_WINDOWS)
list(APPEND _PYTHON_PATCHES
${CMAKE_CURRENT_LIST_DIR}/007-fix-build-path.patch
)
endif()
vcpkg_download_distfile(ARCHIVE
URLS https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz
@ -33,43 +47,48 @@ vcpkg_download_distfile(ARCHIVE
vcpkg_extract_source_archive_ex(
OUT_SOURCE_PATH SOURCE_PATH
ARCHIVE ${ARCHIVE}
PATCHES
PATCHES
${CMAKE_CURRENT_LIST_DIR}/001-build-msvc.patch
${CMAKE_CURRENT_LIST_DIR}/002-build-msvc.patch
${CMAKE_CURRENT_LIST_DIR}/003-build-msvc.patch
${_PYTHON_PATCHES}
${CMAKE_CURRENT_LIST_DIR}/007-fix-build-path.patch
PATCHES ${_PYTHON_PATCHES}
)
if (VCPKG_TARGET_ARCHITECTURE MATCHES "x86")
set(BUILD_ARCH "Win32")
set(OUT_DIR "win32")
elseif (VCPKG_TARGET_ARCHITECTURE MATCHES "x64")
set(BUILD_ARCH "x64")
set(OUT_DIR "amd64")
if (VCPKG_TARGET_IS_WINDOWS)
if (VCPKG_TARGET_ARCHITECTURE MATCHES "x86")
set(BUILD_ARCH "Win32")
set(OUT_DIR "win32")
elseif (VCPKG_TARGET_ARCHITECTURE MATCHES "x64")
set(BUILD_ARCH "x64")
set(OUT_DIR "amd64")
else()
message(FATAL_ERROR "Unsupported architecture: ${VCPKG_TARGET_ARCHITECTURE}")
endif()
vcpkg_build_msbuild(
PROJECT_PATH ${SOURCE_PATH}/PCBuild/pythoncore.vcxproj
PLATFORM ${BUILD_ARCH}
)
vcpkg_copy_pdbs()
file(GLOB HEADERS ${SOURCE_PATH}/Include/*.h)
file(COPY ${HEADERS} ${SOURCE_PATH}/PC/pyconfig.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
file(COPY ${SOURCE_PATH}/Lib DESTINATION ${CURRENT_PACKAGES_DIR}/share/python${PYTHON_VERSION_MAJOR})
file(COPY ${SOURCE_PATH}/PCBuild/${OUT_DIR}/python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}.lib DESTINATION ${CURRENT_PACKAGES_DIR}/lib)
file(COPY ${SOURCE_PATH}/PCBuild/${OUT_DIR}/python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}_d.lib DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib)
if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
file(COPY ${SOURCE_PATH}/PCBuild/${OUT_DIR}/python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}.dll DESTINATION ${CURRENT_PACKAGES_DIR}/bin)
file(COPY ${SOURCE_PATH}/PCBuild/${OUT_DIR}/python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}_d.dll DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin)
endif()
else()
message(FATAL_ERROR "Unsupported architecture: ${VCPKG_TARGET_ARCHITECTURE}")
endif()
vcpkg_configure_make(
SOURCE_PATH ${SOURCE_PATH}
)
vcpkg_build_msbuild(
PROJECT_PATH ${SOURCE_PATH}/PCBuild/pythoncore.vcxproj
PLATFORM ${BUILD_ARCH})
vcpkg_install_make()
file(GLOB HEADERS ${SOURCE_PATH}/Include/*.h)
file(COPY ${HEADERS} ${SOURCE_PATH}/PC/pyconfig.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
file(COPY ${SOURCE_PATH}/Lib DESTINATION ${CURRENT_PACKAGES_DIR}/share/python${PYTHON_VERSION_MAJOR})
file(COPY ${SOURCE_PATH}/PCBuild/${OUT_DIR}/python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}.lib DESTINATION ${CURRENT_PACKAGES_DIR}/lib)
file(COPY ${SOURCE_PATH}/PCBuild/${OUT_DIR}/python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}_d.lib DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib)
if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
file(COPY ${SOURCE_PATH}/PCBuild/${OUT_DIR}/python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}.dll DESTINATION ${CURRENT_PACKAGES_DIR}/bin)
file(COPY ${SOURCE_PATH}/PCBuild/${OUT_DIR}/python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}_d.dll DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_DIR}/debug/share")
endif()
# Handle copyright
file(COPY ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/python${PYTHON_VERSION_MAJOR})
file(RENAME ${CURRENT_PACKAGES_DIR}/share/python${PYTHON_VERSION_MAJOR}/LICENSE ${CURRENT_PACKAGES_DIR}/share/python${PYTHON_VERSION_MAJOR}/copyright)
vcpkg_copy_pdbs()

7
ports/python2/vcpkg.json Normal file
View File

@ -0,0 +1,7 @@
{
"name": "python2",
"version": "2.7.18",
"port-version": 1,
"description": "The Python programming language as an embeddable library",
"homepage": "https://www.python.org"
}

View File

@ -1280,8 +1280,6 @@ protobuf-c:arm64-windows=fail
protobuf-c:arm-uwp=fail
python2:arm64-windows=fail
python2:arm-uwp=fail
python2:x64-linux=fail
python2:x64-osx=fail
python2:x64-uwp=fail
# Not yet ready for these platforms.
qbittorrent:x64-osx=fail

View File

@ -5030,7 +5030,7 @@
},
"python2": {
"baseline": "2.7.18",
"port-version": 0
"port-version": 1
},
"python3": {
"baseline": "3.9.5",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "052ef22af59535134ca2944cfd8e7e7d3ea24d67",
"version": "2.7.18",
"port-version": 1
},
{
"git-tree": "b187917ff4190f5989d395a9abe3bdae93e0ee95",
"version-string": "2.7.18",