Skip to content

Commit

Permalink
[python3] Update to Python 3.8 (#11708)
Browse files Browse the repository at this point in the history
* [python3] Update to Python 3.8.3.

[vtk] Update to Python 3.8 and fix improper Python3 artifact
specification.

* [python3] Fix static linking, broken in 121faf2.

* [hyperscan] Add missing build dependency (fixes CI on macOS).
  • Loading branch information
Hoikas committed Jun 12, 2020
1 parent ca52d42 commit e1783c6
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 40 deletions.
4 changes: 2 additions & 2 deletions ports/hyperscan/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: hyperscan
Version: 5.2.1
Version: 5.2.1-1
Homepage: https://www.hyperscan.io
Description: A regular expression library with O(length of input) match times that takes advantage of Intel hardware to provide blazing speed.
Build-Depends: boost-array, boost-chrono, boost-config, boost-core, boost-crc, boost-detail, boost-functional, boost-regex, boost-system, boost-thread, boost-type-traits, boost-unordered, boost-utility, boost-dynamic-bitset, boost-random, boost-graph, boost-multi-array, boost-icl, boost-ptr-container, python3, ragel
Build-Depends: boost-array, boost-chrono, boost-config, boost-core, boost-crc, boost-detail, boost-functional, boost-regex, boost-system, boost-thread, boost-type-traits, boost-unordered, boost-utility, boost-dynamic-bitset, boost-random, boost-graph, boost-multi-array, boost-icl, boost-ptr-container, pcre, python3, ragel
46 changes: 46 additions & 0 deletions ports/python3/0001-static-library.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
diff --git a/PC/pyconfig.h b/PC/pyconfig.h
index b6b8d44586..35b329f307 100644
--- a/PC/pyconfig.h
+++ b/PC/pyconfig.h
@@ -257,6 +257,7 @@ typedef int pid_t;

/* For Windows the Python core is in a DLL by default. Test
Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
+#define Py_NO_ENABLE_SHARED
#if !defined(MS_NO_COREDLL) && !defined(Py_NO_ENABLE_SHARED)
# define Py_ENABLE_SHARED 1 /* standard symbol for shared library */
# define MS_COREDLL /* deprecated old symbol */
@@ -282,6 +283,11 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
# endif /* _DEBUG */
# endif /* _MSC_VER */
# endif /* Py_BUILD_CORE */
+#else
+ /* So MSVC users need not specify the .lib file in their own config */
+# pragma comment(lib, "version.lib")
+# pragma comment(lib, "shlwapi.lib")
+# pragma comment(lib, "ws2_32.lib")
#endif /* MS_COREDLL */

#if defined(MS_WIN64)
diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj
index 0666b90f66..eb5ecffe71 100644
--- a/PCbuild/pythoncore.vcxproj
+++ b/PCbuild/pythoncore.vcxproj
@@ -73,7 +73,7 @@
<Import Project="python.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <ConfigurationType>StaticLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@@ -102,7 +102,7 @@
<AdditionalOptions>/Zm200 %(AdditionalOptions)</AdditionalOptions>
<AdditionalIncludeDirectories>$(PySourcePath)Python;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="$(IncludeExternals)">$(zlibDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_USRDLL;Py_BUILD_CORE;Py_BUILD_CORE_BUILTIN;Py_ENABLE_SHARED;MS_DLL_ID="$(SysWinVer)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>_USRDLL;Py_BUILD_CORE;Py_BUILD_CORE_BUILTIN;MS_DLL_ID="$(SysWinVer)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="$(IncludeExternals)">_Py_HAVE_ZLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
15 changes: 15 additions & 0 deletions ports/python3/0002-static-crt.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj
index eb5ecffe71..2a7c819533 100644
--- a/PCbuild/pythoncore.vcxproj
+++ b/PCbuild/pythoncore.vcxproj
@@ -104,6 +104,10 @@
<AdditionalIncludeDirectories Condition="$(IncludeExternals)">$(zlibDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_USRDLL;Py_BUILD_CORE;Py_BUILD_CORE_BUILTIN;MS_DLL_ID="$(SysWinVer)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="$(IncludeExternals)">_Py_HAVE_ZLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">MultiThreadedDebug</RuntimeLibrary>
+ <RuntimeLibrary Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">MultiThreadedDebug</RuntimeLibrary>
+ <RuntimeLibrary Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MultiThreaded</RuntimeLibrary>
+ <RuntimeLibrary Condition="'$(Configuration)|$(Platform)'=='Release|x64'">MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<AdditionalDependencies>version.lib;shlwapi.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
5 changes: 2 additions & 3 deletions ports/python3/CONTROL
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
Source: python3
Version: 3.7.3-3
Version: 3.8.3
Homepage: https://github.com/python/cpython
Description: The Python programming language as an embeddable library
Build-Depends: libffi, openssl
Build-Depends: libffi, openssl, zlib (!uwp&!windows)

Feature: enable-shared
Description: Build shared libraries in addition to static ones built by default
Build-Depends: zlib (!uwp&!windows)
35 changes: 20 additions & 15 deletions ports/python3/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,26 @@ if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic AND VCPKG_CRT_LINKAGE STREQUAL static
endif()

set(PYTHON_VERSION_MAJOR 3)
set(PYTHON_VERSION_MINOR 7)
set(PYTHON_VERSION_MINOR 8)
set(PYTHON_VERSION_PATCH 3)
set(PYTHON_VERSION ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.${PYTHON_VERSION_PATCH})

if(VCPKG_TARGET_IS_WINDOWS)
if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
list(APPEND PATCHES ${CMAKE_CURRENT_LIST_DIR}/0001-static-library.patch)
endif()
if (VCPKG_CRT_LINKAGE STREQUAL static)
list(APPEND PATCHES ${CMAKE_CURRENT_LIST_DIR}/0002-static-crt.patch)
endif()
endif()

vcpkg_from_github(
OUT_SOURCE_PATH TEMP_SOURCE_PATH
REPO python/cpython
REF v${PYTHON_VERSION}
SHA512 023960a2f570fe7178d3901df0c3c33346466906b6d55c73ef7947c19619dbab62efc42c7262a0539bc5e31543b1113eb7a088d4615ad7557a0707bdaca27940
SHA512 eb264a858ef55f2f61b53f663454be6e99ffe9035d8fcdb3366d7a08fd3b295613e5d15e93e2e4b9b18ad297d8c17139bde5e90e396db04fe04c6f441a443fd2
HEAD_REF master
PATCHES ${PATCHES}
)

if("enable-shared" IN_LIST FEATURES)
Expand All @@ -33,9 +43,6 @@ if (VCPKG_TARGET_IS_WINDOWS)
file(REMOVE_RECURSE ${SOURCE_PATH})
file(RENAME "${TEMP_SOURCE_PATH}" ${SOURCE_PATH})

# We need per-triplet directories because we need to patch the project files differently based on the linkage
# Because the patches patch the same file, they have to be applied in the correct order

if (VCPKG_TARGET_ARCHITECTURE MATCHES "x86")
set(BUILD_ARCH "Win32")
set(OUT_DIR "win32")
Expand All @@ -50,12 +57,11 @@ if (VCPKG_TARGET_IS_WINDOWS)
PROJECT_PATH ${SOURCE_PATH}/PCBuild/pythoncore.vcxproj
PLATFORM ${BUILD_ARCH})

file(GLOB HEADERS ${SOURCE_PATH}/Include/*.h)
file(INSTALL
${HEADERS}
"${SOURCE_PATH}/Include/"
"${SOURCE_PATH}/PC/pyconfig.h"
DESTINATION
"${CURRENT_PACKAGES_DIR}/include/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}"
DESTINATION "${CURRENT_PACKAGES_DIR}/include/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}"
FILES_MATCHING PATTERN *.h
)
file(INSTALL
"${SOURCE_PATH}/Lib"
Expand Down Expand Up @@ -149,10 +155,9 @@ elseif (VCPKG_TARGET_IS_LINUX OR VCPKG_TARGET_IS_OSX)
)

message(STATUS "Installing ${TARGET_TRIPLET}-rel headers...")
file(GLOB HEADERS
${OUT_PATH_RELEASE}/include/*)
file(INSTALL ${HEADERS} DESTINATION ${CURRENT_PACKAGES_DIR}/include
PATTERN "*__pycache__*" EXCLUDE
file(INSTALL "${OUT_PATH_RELEASE}/include/"
DESTINATION ${CURRENT_PACKAGES_DIR}/include
FILES_MATCHING PATTERN *.h
)

message(STATUS "Installing ${TARGET_TRIPLET}-rel lib files...")
Expand All @@ -173,7 +178,7 @@ elseif (VCPKG_TARGET_IS_LINUX OR VCPKG_TARGET_IS_OSX)

message(STATUS "Installing ${TARGET_TRIPLET}-rel Python library files...")
file(GLOB LIBS
${OUT_PATH_RELEASE}/lib/libpython${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}m.*)
${OUT_PATH_RELEASE}/lib/libpython${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.*)
file(INSTALL ${LIBS} DESTINATION ${CURRENT_PACKAGES_DIR}/lib
PATTERN "*.pyc" EXCLUDE
PATTERN "*__pycache__*" EXCLUDE
Expand Down Expand Up @@ -227,7 +232,7 @@ elseif (VCPKG_TARGET_IS_LINUX OR VCPKG_TARGET_IS_OSX)

message(STATUS "Installing ${TARGET_TRIPLET}-dbg Python library files...")
file(GLOB LIBS
${OUT_PATH_DEBUG}/lib/libpython${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}dm.*)
${OUT_PATH_DEBUG}/lib/libpython${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}d.*)
file(INSTALL ${LIBS} DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib
PATTERN "*.pyc" EXCLUDE
PATTERN "*__pycache__*" EXCLUDE
Expand Down
2 changes: 1 addition & 1 deletion ports/vtk/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: vtk
Version: 9.0-1
Version: 9.0-2
Description: Software system for 3D computer graphics, image processing, and visualization
Homepage: https://github.com/Kitware/VTK
Build-Depends: zlib, libpng, tiff, libxml2, jsoncpp, glew, freetype, expat, hdf5[core], libjpeg-turbo, proj4, lz4, liblzma, libtheora, eigen3, double-conversion, pugixml, libharu[notiffsymbols], sqlite3, netcdf-c, utfcpp, libogg, pegtl-2
Expand Down
14 changes: 4 additions & 10 deletions ports/vtk/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,11 @@ if("python" IN_LIST FEATURES)
)

if(VCPKG_TARGET_IS_WINDOWS)
list(APPEND ADDITIONAL_OPTIONS "-DPython3_LIBRARY_RELEASE:PATH=${CURRENT_INSTALLED_DIR}/lib/python37.lib"
"-DPython3_LIBRARY_DEBUG:PATH=${CURRENT_INSTALLED_DIR}/debug/lib/python37_d.lib"
"-DPython3_LIBRARIES:STRING=debug\\\\\\\;${CURRENT_INSTALLED_DIR}/debug/lib/python37_d.lib\\\\\\\;optimized\\\\\\\;${CURRENT_INSTALLED_DIR}/lib/python37.lib"
"-DPYTHON_DEBUG_LIBRARY:PATH=${CURRENT_INSTALLED_DIR}/debug/lib/python37_d.lib"
"-DPython3_INCLUDE_DIR:PATH=${CURRENT_INSTALLED_DIR}/include/python3.7")
list(APPEND ADDITIONAL_OPTIONS "-DPython3_LIBRARY:PATH=${CURRENT_INSTALLED_DIR}/lib/python38.lib"
"-DPython3_INCLUDE_DIR:PATH=${CURRENT_INSTALLED_DIR}/include/python3.8")
elseif(VCPKG_TARGET_IS_LINUX)
list(APPEND ADDITIONAL_OPTIONS "-DPython3_LIBRARY_RELEASE:PATH=${CURRENT_INSTALLED_DIR}/lib/libpython37m.a"
"-DPython3_LIBRARY_DEBUG:PATH=${CURRENT_INSTALLED_DIR}/debug/lib/libpython37md.a"
"-DPython3_LIBRARIES:STRING=debug\\\\\\\;${CURRENT_INSTALLED_DIR}/debug/lib/libpython37md.a\\\\\\\;optimized\\\\\\\;${CURRENT_INSTALLED_DIR}/lib/libpython37m.a"
"-DPYTHON_DEBUG_LIBRARY:PATH=${CURRENT_INSTALLED_DIR}/debug/lib/libpython37md.a"
"-DPython3_INCLUDE_DIR:PATH=${CURRENT_INSTALLED_DIR}/include/python3.7m")
list(APPEND ADDITIONAL_OPTIONS "-DPython3_LIBRARY:PATH=${CURRENT_INSTALLED_DIR}/lib/libpython38.a"
"-DPython3_INCLUDE_DIR:PATH=${CURRENT_INSTALLED_DIR}/include/python3.8")
elseif(VCPKG_TARGET_IS_OSX)
#Need Python3 information on OSX within VCPKG
endif()
Expand Down
18 changes: 9 additions & 9 deletions scripts/cmake/vcpkg_find_acquire_program.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,18 @@ function(vcpkg_find_acquire_program VAR)
if(CMAKE_HOST_WIN32)
set(PROGNAME python)
if (VCPKG_TARGET_ARCHITECTURE STREQUAL x86)
set(SUBDIR "python-3.7.3-x86")
set(URL "https://www.python.org/ftp/python/3.7.3/python-3.7.3-embed-win32.zip")
set(ARCHIVE "python-3.7.3-embed-win32.zip")
set(HASH 2c1b1f0a29d40a91771ae21a5f733eedc10984cd182cb10c2793bbd24191a89f20612a3f23c34047f37fb06369016bfd4a52915ed1b4a56f8bd2b4ca6994eb31)
set(SUBDIR "python-3.8.3-x86")
set(URL "https://www.python.org/ftp/python/3.8.3/python-3.8.3-embed-win32.zip")
set(ARCHIVE "python-3.8.3-embed-win32.zip")
set(HASH 8c9078f55b1b5d694e0e809eee6ccf8a6e15810dd4649e8ae1209bff30e102d49546ce970a5d519349ca7759d93146f459c316dc440737171f018600255dcd0a)
else()
set(SUBDIR "python-3.7.3-x64")
set(URL "https://www.python.org/ftp/python/3.7.3/python-3.7.3-embed-amd64.zip")
set(ARCHIVE "python-3.7.3-embed-amd64.zip")
set(HASH 4b3e0067b5e8d00b1cac5d556ab4fbd71df2a1852afb3354ee62363aabc8801aca84da09dbd26125527ae54b50488f808c1d82abf18969c23a51dcd57576885f)
set(SUBDIR "python-3.8.3-x64")
set(URL "https://www.python.org/ftp/python/3.8.3/python-3.8.3-embed-amd64.zip")
set(ARCHIVE "python-3.8.3-embed-amd64.zip")
set(HASH a322fc925167edb1897764297cf47e294ad3f52c109a05f8911412807eb83e104f780e9fe783b17fe0d9b18b7838797c15e9b0805dab759829f77a9bc0159424)
endif()
set(PATHS ${DOWNLOADS}/tools/python/${SUBDIR})
set(POST_INSTALL_COMMAND ${CMAKE_COMMAND} -E remove python37._pth)
set(POST_INSTALL_COMMAND ${CMAKE_COMMAND} -E remove python38._pth)
else()
set(PROGNAME python3)
set(BREW_PACKAGE_NAME "python")
Expand Down

0 comments on commit e1783c6

Please sign in to comment.