mirror of https://github.com/microsoft/vcpkg.git
[python3] Do not ensurepip. Provide venv instructions. (#24906)
* [python3] Bootstrap pip with ${CURRENT_INSTALLED_DIR}
* [python3] Disable ensurepip -- add venv usage instructions
Co-authored-by: Max Khon <fjoe@samodelkin.net>
This commit is contained in:
parent
145848fb45
commit
f78f4440df
|
|
@ -0,0 +1,11 @@
|
|||
--- 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)
|
||||
|
|
@ -29,8 +29,9 @@ elseif(VCPKG_TARGET_IS_WINDOWS AND CMAKE_SYSTEM_VERSION EQUAL 6.1)
|
|||
message(FATAL_ERROR "python3 requires the feature deprecated-win7-support when building on Windows 7.")
|
||||
endif()
|
||||
|
||||
# The Windows 11 SDK has a problem that causes it to error on the resource files, so we patch that.
|
||||
if(VCPKG_TARGET_IS_WINDOWS OR VCPKG_TARGET_IS_UWP)
|
||||
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" PYTHON_ALLOW_EXTENSIONS)
|
||||
# The Windows 11 SDK has a problem that causes it to error on the resource files, so we patch that.
|
||||
vcpkg_get_windows_sdk(WINSDK_VERSION)
|
||||
if("${WINSDK_VERSION}" VERSION_GREATER_EQUAL "10.0.22000")
|
||||
list(APPEND PATCHES "0007-workaround-windows-11-sdk-rc-compiler-error.patch")
|
||||
|
|
@ -70,7 +71,6 @@ endfunction()
|
|||
if(VCPKG_TARGET_IS_WINDOWS OR VCPKG_TARGET_IS_UWP)
|
||||
# Due to the way Python handles C extension modules on Windows, a static python core cannot
|
||||
# load extension modules.
|
||||
string(COMPARE EQUAL ${VCPKG_LIBRARY_LINKAGE} "dynamic" PYTHON_ALLOW_EXTENSIONS)
|
||||
if(PYTHON_ALLOW_EXTENSIONS)
|
||||
find_library(BZ2_RELEASE NAMES bz2 PATHS "${CURRENT_INSTALLED_DIR}/lib" NO_DEFAULT_PATH)
|
||||
find_library(BZ2_DEBUG NAMES bz2d PATHS "${CURRENT_INSTALLED_DIR}/debug/lib" NO_DEFAULT_PATH)
|
||||
|
|
@ -171,15 +171,6 @@ if(VCPKG_TARGET_IS_WINDOWS OR VCPKG_TARGET_IS_UWP)
|
|||
file(GLOB PYTHON_INSTALLERS "${CURRENT_PACKAGES_DIR}/tools/${PORT}/wininst-*.exe")
|
||||
file(REMOVE ${PYTHON_LIBS} ${PYTHON_INSTALLERS})
|
||||
|
||||
# The generated python executable must match the host arch
|
||||
if(PYTHON_ALLOW_EXTENSIONS AND NOT VCPKG_CROSSCOMPILING)
|
||||
message(STATUS "Bootstrapping pip")
|
||||
vcpkg_execute_required_process(COMMAND python -m ensurepip
|
||||
WORKING_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/${PORT}"
|
||||
LOGNAME "ensurepip-${TARGET_TRIPLET}"
|
||||
)
|
||||
endif()
|
||||
|
||||
# pkg-config files
|
||||
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
|
||||
make_python_pkgconfig(FILE python.pc INSTALL_ROOT ${CURRENT_PACKAGES_DIR}
|
||||
|
|
@ -215,7 +206,7 @@ if(VCPKG_TARGET_IS_WINDOWS OR VCPKG_TARGET_IS_UWP)
|
|||
else()
|
||||
set(OPTIONS
|
||||
"--with-openssl=${CURRENT_INSTALLED_DIR}"
|
||||
"--with-ensurepip"
|
||||
"--without-ensurepip"
|
||||
"--with-suffix="
|
||||
"--with-system-expat"
|
||||
"--without-readline"
|
||||
|
|
@ -255,7 +246,17 @@ else()
|
|||
vcpkg_fixup_pkgconfig()
|
||||
endif()
|
||||
|
||||
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
|
||||
file(READ "${CMAKE_CURRENT_LIST_DIR}/usage" usage)
|
||||
if(VCPKG_TARGET_IS_WINDOWS)
|
||||
if(PYTHON_ALLOW_EXTENSIONS)
|
||||
file(READ "${CMAKE_CURRENT_LIST_DIR}/usage.win" usage_extra)
|
||||
else()
|
||||
set(usage_extra "")
|
||||
endif()
|
||||
else()
|
||||
file(READ "${CMAKE_CURRENT_LIST_DIR}/usage.unix" usage_extra)
|
||||
endif()
|
||||
file(WRITE "${CURRENT_PACKAGES_DIR}/share/${PORT}/usage" "${usage}\n${usage_extra}")
|
||||
|
||||
function(_generate_finder)
|
||||
cmake_parse_arguments(PythonFinder "NO_OVERRIDE" "DIRECTORY;PREFIX" "" ${ARGN})
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
The package python3 provides a python interpreter that supports virtual environments:
|
||||
|
||||
$ tools/python3/python3.10 -m venv /path/to/venv
|
||||
$ export VIRTUAL_ENV=/path/to/venv
|
||||
$ export PATH=/path/to/venv/bin:$PATH
|
||||
$ export -n PYTHONHOME
|
||||
$ unset PYTHONHOME
|
||||
|
||||
See https://docs.python.org/3/library/venv.html for more details.
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
The package python3 provides a python interpreter that supports virtual environments:
|
||||
|
||||
>tools\python3\python3.10 -m venv c:\path\to\venv
|
||||
>set VIRTUAL_ENV=c:\path\to\venv
|
||||
>set PATH=c:\path\to\venv\bin;%PATH%
|
||||
>set PYTHONHOME=
|
||||
|
||||
See https://docs.python.org/3/library/venv.html for more details.
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "python3",
|
||||
"version": "3.10.2",
|
||||
"port-version": 1,
|
||||
"port-version": 2,
|
||||
"description": "The Python programming language",
|
||||
"homepage": "https://github.com/python/cpython",
|
||||
"license": "Python-2.0",
|
||||
|
|
|
|||
|
|
@ -5658,7 +5658,7 @@
|
|||
},
|
||||
"python3": {
|
||||
"baseline": "3.10.2",
|
||||
"port-version": 1
|
||||
"port-version": 2
|
||||
},
|
||||
"qca": {
|
||||
"baseline": "2.3.4",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
{
|
||||
"versions": [
|
||||
{
|
||||
"git-tree": "30321893b72abb4b682e3b66f75c54c1df3051c9",
|
||||
"version": "3.10.2",
|
||||
"port-version": 2
|
||||
},
|
||||
{
|
||||
"git-tree": "4e348bd50d8c4252bda83903ce22f1e60d34be88",
|
||||
"version": "3.10.2",
|
||||
|
|
|
|||
Loading…
Reference in New Issue