Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions scripts/update_python_zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
The port's version, source checksum and patches are read at that vcpkg tag, so the zip matches the
Python that vcpkg builds. Run it with that Python minor version (e.g. `uv run --python 3.12`), or
have `uv` on PATH and the script re-runs itself under the right version.

The Windows builds of MREmbeddedPython run it with vcpkg's python.exe to put the zip next to
python3XY.dll; the repository no longer stores it.
"""
import argparse
import hashlib
Expand Down
19 changes: 14 additions & 5 deletions source/MREmbeddedPython/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,7 @@ IF(MR_PCH)
target_precompile_headers(${PROJECT_NAME} REUSE_FROM MRPch)
ENDIF()

# On Windows, copy the zipped Python environment to the output directory.
IF(WIN32)
file(
COPY ${MESHLIB_THIRDPARTY_DIR}/python/python${Python_VERSION_MAJOR}${Python_VERSION_MINOR}.zip
DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
)
# The standard library's extension modules (_socket, _ssl, _sqlite3, ...) go to DLLs/, which Python puts on sys.path;
# the DLLs they need go next to the executable, where most of them already are and the loader finds them
IF(DEFINED VCPKG_INSTALLED_DIR AND DEFINED VCPKG_TARGET_TRIPLET)
Expand All @@ -49,6 +44,20 @@ IF(WIN32)
file(GLOB PYTHON_EXTENSION_DEPENDENCIES ${PYTHON_DLLS_DIR}/*.dll)
file(COPY ${PYTHON_EXTENSION_MODULES} DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/DLLs)
file(COPY ${PYTHON_EXTENSION_DEPENDENCIES} DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})

# The pure-Python standard library, python3XY.zip, built from the CPython sources of vcpkg's python3 port
# by that port's own python.exe; rebuilt only when the script or that Python changes
set(VCPKG_PYTHON ${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/tools/python3/python.exe)
ENDIF()
IF(DEFINED VCPKG_PYTHON AND EXISTS ${VCPKG_PYTHON})
set(PYTHON_ZIP_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/update_python_zip.py)
set(PYTHON_ZIP ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/python${Python_VERSION_MAJOR}${Python_VERSION_MINOR}.zip)
add_custom_command(
OUTPUT ${PYTHON_ZIP}
COMMAND ${VCPKG_PYTHON} ${PYTHON_ZIP_SCRIPT} --output ${PYTHON_ZIP}
DEPENDS ${PYTHON_ZIP_SCRIPT} ${VCPKG_PYTHON}
)
add_custom_target(MREmbeddedPythonZip ALL DEPENDS ${PYTHON_ZIP})
ENDIF()
ENDIF()

Expand Down
11 changes: 8 additions & 3 deletions source/MREmbeddedPython/MREmbeddedPython.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<CopyFileToFolders Include="$(ProjectDir)..\..\thirdparty\python\python$(PythonVersion).zip">
<FileType>Document</FileType>
</CopyFileToFolders>
<!-- The standard library's extension modules (_socket, _ssl, _sqlite3, ...) go to DLLs\, which Python puts on sys.path; -->
<!-- the DLLs they need go next to the executable, where most of them already are and the loader finds them -->
<CopyFileToFolders Include="$(VcpkgCurrentInstalledDir)\tools\python3\DLLs\*.pyd">
Expand Down Expand Up @@ -140,6 +137,14 @@
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<!-- The pure-Python standard library, python3XY.zip, built from the CPython sources of vcpkg's python3 port
by that port's own python.exe; rebuilt only when the script or that Python changes -->
<Target Name="BuildPythonZip" AfterTargets="Build"
Condition="Exists('$(VcpkgCurrentInstalledDir)\tools\python3\python.exe')"
Inputs="$(ProjectDir)..\..\scripts\update_python_zip.py;$(VcpkgCurrentInstalledDir)\tools\python3\python.exe"
Outputs="$(OutDir)python$(PythonVersion).zip">
<Exec Command="&quot;$(VcpkgCurrentInstalledDir)\tools\python3\python.exe&quot; &quot;$(ProjectDir)..\..\scripts\update_python_zip.py&quot; --output &quot;$(OutDir)python$(PythonVersion).zip&quot;" />
</Target>
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
11 changes: 6 additions & 5 deletions thirdparty/licenses/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -411,13 +411,14 @@
"upstream": "https://www.python.org",
"license_source": "https://raw.githubusercontent.com/python/cpython/3.12/LICENSE",
"source": {
"type": "hash",
"track": [
"thirdparty/python/python311.zip",
"thirdparty/python/python312.zip"
"type": "vcpkg-registry",
"ports": [
"python3"
]
},
"version": "35ba61c359222abe"
"version": {
"python3": "3.12.13#1"
}
},
{
"id": "pybind11",
Expand Down
Binary file removed thirdparty/python/python311.zip
Binary file not shown.
Binary file removed thirdparty/python/python312.zip
Binary file not shown.
2 changes: 0 additions & 2 deletions thirdparty/python/readme.md

This file was deleted.

Loading