Skip to content

Commit

Permalink
[python2] Support UNIX (microsoft#18219)
Browse files Browse the repository at this point in the history
* [python2] Support UNIX

* update baseline

* Update version record
  • Loading branch information
JackBoosY authored Jun 10, 2021
1 parent 4ea49a1 commit 42f2d6f
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 38 deletions.
3 changes: 0 additions & 3 deletions ports/python2/CONTROL

This file was deleted.

83 changes: 51 additions & 32 deletions ports/python2/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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")
else()
message(FATAL_ERROR "Unsupported architecture: ${VCPKG_TARGET_ARCHITECTURE}")
endif()

vcpkg_build_msbuild(
PROJECT_PATH ${SOURCE_PATH}/PCBuild/pythoncore.vcxproj
PLATFORM ${BUILD_ARCH})

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})
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}
)

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)
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()
vcpkg_configure_make(
SOURCE_PATH ${SOURCE_PATH}
)

vcpkg_install_make()

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 changes: 7 additions & 0 deletions ports/python2/vcpkg.json
Original file line number Diff line number Diff line change
@@ -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"
}
2 changes: 0 additions & 2 deletions scripts/ci.baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -5030,7 +5030,7 @@
},
"python2": {
"baseline": "2.7.18",
"port-version": 0
"port-version": 1
},
"python3": {
"baseline": "3.9.5",
Expand Down
5 changes: 5 additions & 0 deletions versions/p-/python2.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "052ef22af59535134ca2944cfd8e7e7d3ea24d67",
"version": "2.7.18",
"port-version": 1
},
{
"git-tree": "b187917ff4190f5989d395a9abe3bdae93e0ee95",
"version-string": "2.7.18",
Expand Down

0 comments on commit 42f2d6f

Please sign in to comment.