diff --git a/recipes/cpython/all/conandata.yml b/recipes/cpython/all/conandata.yml index f9fd51067c8b3..09f7230ee9229 100644 --- a/recipes/cpython/all/conandata.yml +++ b/recipes/cpython/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "3.10.3": + url: "https://www.python.org/ftp/python/3.10.3/Python-3.10.3.tgz" + sha256: "5a3b029bad70ba2a019ebff08a65060a8b9b542ffc1a83c697f1449ecca9813b" "3.10.0": url: "https://www.python.org/ftp/python/3.10.0/Python-3.10.0.tgz" sha256: "c4e0cbad57c90690cb813fb4663ef670b4d0f587d8171e2c42bd4c9245bd2758" @@ -11,20 +14,37 @@ sources: "3.7.12": url: "https://www.python.org/ftp/python/3.7.12/Python-3.7.12.tgz" sha256: "33b4daaf831be19219659466d12645f87ecec6eb21d4d9f9711018a7b66cce46" - "2.7.18": - url: "https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz" - sha256: "da3080e3b488f648a3d7a4560ddee895284c3380b11d6de75edb986526b9a814" +# "2.7.18": +# url: "https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz" +# sha256: "da3080e3b488f648a3d7a4560ddee895284c3380b11d6de75edb986526b9a814" patches: + "3.10.3": + - patch_file: "patches/3.10.3-0001-msvc.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.9.7-0002-_msi-vcxproj.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.10.3-0003-_ctypes-ffi.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.10.3-0004-setup.py-pass-CFLAGS-CPPFLAGS.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.10.3-0005-do-not-search-for-system-tkinter.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.10.3-0006-restore-support-for-windows-7.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.x-0001-relocatable-python-config.patch" + base_path: "source_subfolder" "3.10.0": - - patch_file: "patches/3.10.0-0001-msvc.patch" + - patch_file: "patches/3.10.3-0001-msvc.patch" base_path: "source_subfolder" - patch_file: "patches/3.9.7-0002-_msi-vcxproj.patch" base_path: "source_subfolder" - - patch_file: "patches/3.10.0-0003-_ctypes-ffi.patch" + - patch_file: "patches/3.10.3-0003-_ctypes-ffi.patch" base_path: "source_subfolder" - patch_file: "patches/3.10.0-0004-setup.py-pass-CFLAGS-CPPFLAGS.patch" base_path: "source_subfolder" - - patch_file: "patches/3.10.0-0005-disable-macos-tcltk.patch" + - patch_file: "patches/3.10.0-0005-do-not-search-for-system-tkinter.patch" + base_path: "source_subfolder" + - patch_file: "patches/3.10.0-0006-restore-support-for-windows-7.patch" base_path: "source_subfolder" - patch_file: "patches/3.x-0001-relocatable-python-config.patch" base_path: "source_subfolder" diff --git a/recipes/cpython/all/conanfile.py b/recipes/cpython/all/conanfile.py index 4fa1d1da6334e..b6bd0101146a3 100644 --- a/recipes/cpython/all/conanfile.py +++ b/recipes/cpython/all/conanfile.py @@ -1,5 +1,5 @@ from conans import AutoToolsBuildEnvironment, ConanFile, MSBuild, tools -from conans.errors import ConanInvalidConfiguration +from conans.errors import ConanInvalidConfiguration, ConanException from io import StringIO import os import re @@ -36,6 +36,7 @@ class CPythonConan(ConanFile): "with_bsddb": [True, False], # Python 3 options "with_lzma": [True, False], + "win7_support": [True, False], # options that don't change package id "env_vars": [True, False], # set environment variables @@ -59,6 +60,7 @@ class CPythonConan(ConanFile): "with_bsddb": False, # True, # FIXME: libdb package missing (#5309/#5392) # Python 3 options "with_lzma": True, + "win7_support": False, # options that don't change package id "env_vars": True, @@ -111,10 +113,13 @@ def config_options(self): if self._is_py2: # Python 2.xx does not support following options del self.options.with_lzma + del self.options.win7_support elif self._is_py3: # Python 3.xx does not support following options del self.options.with_bsddb del self.options.unicode + if self.version < "3.10.0": + del self.options.win7_support del self.settings.compiler.libcxx del self.settings.compiler.cppstd @@ -134,6 +139,10 @@ def configure(self): self.generators.append("MSBuildDeps") def validate(self): + # FIXME + if self.settings.os == "Macos": + raise ConanInvalidConfiguration("XXX") + if self.options.shared: if self.settings.compiler == "Visual Studio" and "MT" in self.settings.compiler.runtime: raise ConanInvalidConfiguration("cpython does not support MT(d) runtime when building a shared cpython library") @@ -178,7 +187,7 @@ def requirements(self): self.requires("openssl/1.1.1l") self.requires("expat/2.4.1") if self._with_libffi: - self.requires("libffi/3.2.1") + self.requires("libffi/3.4.2") if tools.Version(self._version_number_only) < "3.8": self.requires("mpdecimal/2.4.2") elif tools.Version(self._version_number_only) < "3.10": @@ -263,8 +272,17 @@ def _configure_autotools(self): return self._autotools def _patch_sources(self): - for patch in self.conan_data.get("patches",{}).get(self.version, []): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + if "restore-support-for-windows-7" in patch["patch_file"] \ + and not self.options.get_safe("win7_support", False): + continue tools.patch(**patch) + if self.settings.compiler == "apple-clang": + # https://bugs.python.org/issue45405 + tools.replace_in_file(os.path.join(self._source_subfolder, "configure"), + "MULTIARCH=$($CC --print-multiarch 2>/dev/null)", + "MULTIARCH=") + if self._is_py3 and tools.Version(self._version_number_only) < "3.10": tools.replace_in_file(os.path.join(self._source_subfolder, "setup.py"), ":libmpdec.so.2", "mpdec") @@ -290,6 +308,24 @@ def _patch_sources(self): tools.replace_in_file(os.path.join(self._source_subfolder, "setup.py"), "curses_libs = ", "curses_libs = {} #".format(repr(self.deps_cpp_info["ncurses"].libs + self.deps_cpp_info["ncurses"].system_libs))) + else: + tools.replace_in_file( + os.path.join(self._source_subfolder, "setup.py"), + "curses_library.startswith('ncurses')", + "False" + ) + try: + tools.replace_in_file( + os.path.join(self._source_subfolder, "setup.py"), + "curses_library == 'curses' and not MACOS", + "False" + ) + except ConanException: + tools.replace_in_file( + os.path.join(self._source_subfolder, "setup.py"), + "curses_library == 'curses' and host_platform != 'darwin'", + "False" + ) # Enable static MSVC cpython if not self.options.shared: @@ -402,7 +438,8 @@ def _msvc_build(self): for project_i, project in enumerate(projects, 1): self.output.info("[{}/{}] Building project '{}'...".format(project_i, len(projects), project)) project_file = os.path.join(self._source_subfolder, "PCbuild", project + ".vcxproj") - self._upgrade_single_project_file(project_file) + if not tools.get_env("CONAN_SKIP_VS_PROJECTS_UPGRADE", False): + self._upgrade_single_project_file(project_file) msbuild.build(project_file, upgrade_project=False, build_type="Debug" if self.settings.build_type == "Debug" else "Release", platforms=self._msvc_archs, properties=msbuild_properties) @@ -416,16 +453,22 @@ def build(self): if tools.Version(self.deps_cpp_info["mpdecimal"].version) < "2.5.0": raise ConanInvalidConfiguration("cpython 3.9.0 (and newer) requires (at least) mpdecimal 2.5.0") - if self._with_libffi: - if tools.Version(self.deps_cpp_info["libffi"].version) >= "3.3" and self.settings.compiler == "Visual Studio" and "d" in str(self.settings.compiler.runtime): - raise ConanInvalidConfiguration("libffi versions >= 3.3 cause 'read access violations' when using a debug runtime (MTd/MDd)") - self._patch_sources() if self.settings.compiler == "Visual Studio": self._msvc_build() else: - autotools = self._configure_autotools() - autotools.make() + env = {} + if self.settings.compiler == "apple-clang": # how to compute the right value? + env["MACOSX_DEPLOYMENT_TARGET"] = "10.3" # FIXME : clang: error: invalid version number in 'MACOSX_DEPLOYMENT_TARGET=11.6' + with tools.environment_append(env): + try: + autotools = self._configure_autotools() + autotools.make() + except Exception as e: + config_log = os.path.join(self.build_folder, "config.log") + if os.path.isfile: + self.run('cat %s' % config_log) + raise e @property def _msvc_artifacts_path(self): @@ -659,16 +702,19 @@ def package_info(self): self.cpp_info.components["_python_copy"].names["pkg_config"] = "python{}".format(py_version.major) self.cpp_info.components["_python_copy"].requires = ["python"] self.cpp_info.components["_python_copy"].libdirs = [] + self.cpp_info.components["_python_copy"].includedirs = [] # embed component: "Embed Python into an application" self.cpp_info.components["embed"].libs = [self._lib_name] self.cpp_info.components["embed"].libdirs = [libdir] + self.cpp_info.components["embed"].includedirs = [] self.cpp_info.components["embed"].names["pkg_config"] = "python-{}.{}-embed".format(py_version.major, py_version.minor) self.cpp_info.components["embed"].requires = ["python"] self.cpp_info.components["_embed_copy"].requires = ["embed"] self.cpp_info.components["_embed_copy"].names["pkg_config"] = ["python{}-embed".format(py_version.major)] self.cpp_info.components["_embed_copy"].libdirs = [] + self.cpp_info.components["_embed_copy"].includedirs = [] if self._supports_modules: # hidden components: the C extensions of python are built as dynamically loaded shared libraries. @@ -699,6 +745,7 @@ def package_info(self): if self.options.get_safe("with_tkinter"): self.cpp_info.components["_hidden"].requires.append("tk::tk") self.cpp_info.components["_hidden"].libdirs = [] + self.cpp_info.components["_hidden"].includedirs = [] if self.options.env_vars: bindir = os.path.join(self.package_folder, "bin") diff --git a/recipes/cpython/all/patches/3.10.0-0005-disable-macos-tcltk.patch b/recipes/cpython/all/patches/3.10.0-0005-disable-macos-tcltk.patch deleted file mode 100644 index ec23890e0a717..0000000000000 --- a/recipes/cpython/all/patches/3.10.0-0005-disable-macos-tcltk.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- setup.py -+++ setup.py -@@ -2094,8 +2094,8 @@ - # Rather than complicate the code below, detecting and building - # AquaTk is a separate method. Only one Tkinter will be built on - # Darwin - either AquaTk, if it is found, or X11 based Tk. -- if (MACOS and self.detect_tkinter_darwin()): -- return True -+ #if (MACOS and self.detect_tkinter_darwin()): -+ # return True - - # Assume we haven't found any of the libraries or include files - # The versions with dots are used on Unix, and the versions without diff --git a/recipes/cpython/all/patches/3.10.0-0005-do-not-search-for-system-tkinter.patch b/recipes/cpython/all/patches/3.10.0-0005-do-not-search-for-system-tkinter.patch new file mode 100644 index 0000000000000..54f3048795ab8 --- /dev/null +++ b/recipes/cpython/all/patches/3.10.0-0005-do-not-search-for-system-tkinter.patch @@ -0,0 +1,11 @@ +--- setup.py ++++ setup.py +@@ -2090,7 +2090,7 @@ + # and _TCLTK_LIBS environment variables. + if self.detect_tkinter_fromenv(): + return True +- ++ return False + # Rather than complicate the code below, detecting and building + # AquaTk is a separate method. Only one Tkinter will be built on + # Darwin - either AquaTk, if it is found, or X11 based Tk. diff --git a/recipes/cpython/all/patches/3.10.0-0006-restore-support-for-windows-7.patch b/recipes/cpython/all/patches/3.10.0-0006-restore-support-for-windows-7.patch new file mode 100644 index 0000000000000..1d1c9590bd960 --- /dev/null +++ b/recipes/cpython/all/patches/3.10.0-0006-restore-support-for-windows-7.patch @@ -0,0 +1,187 @@ +From e30a560527d17ae81685dd11d3268bc982af2048 Mon Sep 17 00:00:00 2001 +From: Adam Johnson +Date: Tue, 16 Feb 2021 18:03:07 -0500 +Subject: [PATCH 7/7] restore support for windows 7 + +this backports the windows 7 compatible fix for bpo-39401 from gh-18234, +originally authored by Steve Dower, and removes explicit dependencies on +pathcch. + +The same mechanism is applied to fix posixmodule.c +--- +index 25ddc82..ff51042 100644 +diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c +--- a/Modules/posixmodule.c ++++ b/Modules/posixmodule.c +@@ -20,7 +20,7 @@ + + FSCTL_GET_REPARSE_POINT is not exported with WIN32_LEAN_AND_MEAN. */ + # include +-# include ++# include + #endif + + #ifdef __VXWORKS__ +@@ -4410,6 +4410,10 @@ os__getvolumepathname_impl(PyObject *module, path_t *path) + return result; + } + ++static int _PathCchSkipRoot_Initialized = 0; ++typedef HRESULT (__stdcall *PPathCchSkipRoot) (PCWSTR pszPath, PCWSTR *ppszRootEnd); ++static PPathCchSkipRoot _PathCchSkipRoot; ++ + + /*[clinic input] + os._path_splitroot +@@ -4428,6 +4432,19 @@ os__path_splitroot_impl(PyObject *module, path_t *path) + PyObject *result = NULL; + HRESULT ret; + ++ if (_PathCchSkipRoot_Initialized == 0) { ++ HMODULE pathapi = LoadLibraryExW(L"api-ms-win-core-path-l1-1-0.dll", NULL, ++ LOAD_LIBRARY_SEARCH_SYSTEM32); ++ ++ if (pathapi) { ++ _PathCchSkipRoot = (PPathCchSkipRoot)GetProcAddress(pathapi, "PathCchSkipRoot"); ++ } else { ++ _PathCchSkipRoot = NULL; ++ } ++ ++ _PathCchSkipRoot_Initialized = 1; ++ } ++ + buffer = (wchar_t*)PyMem_Malloc(sizeof(wchar_t) * (wcslen(path->wide) + 1)); + if (!buffer) { + return NULL; +@@ -4438,7 +4455,14 @@ os__path_splitroot_impl(PyObject *module, path_t *path) + } + + Py_BEGIN_ALLOW_THREADS +- ret = PathCchSkipRoot(buffer, &end); ++ if (_PathCchSkipRoot) { ++ ret = _PathCchSkipRoot(buffer, &end); ++ } else { ++ end = PathSkipRootW(buffer); ++ if (!end) { ++ ret = E_FAIL; ++ } ++ } + Py_END_ALLOW_THREADS + if (FAILED(ret)) { + result = Py_BuildValue("sO", "", path->object); +diff --git a/PC/getpathp.c b/PC/getpathp.c +index 53da3a6..3d58bbf 100644 +--- a/PC/getpathp.c ++++ b/PC/getpathp.c +@@ -90,7 +90,7 @@ + #endif + + #include +-#include ++ + #include + + #ifdef HAVE_SYS_TYPES_H +@@ -250,14 +250,43 @@ ismodule(wchar_t *filename, int update_filename) + stuff as fits will be appended. + */ + ++ ++static int _PathCchCombineEx_Initialized = 0; ++typedef HRESULT(__stdcall *PPathCchCombineEx) (PWSTR pszPathOut, size_t cchPathOut, ++ PCWSTR pszPathIn, PCWSTR pszMore, ++ unsigned long dwFlags); ++static PPathCchCombineEx _PathCchCombineEx; ++ + static void + join(wchar_t *buffer, const wchar_t *stuff) + { +- if (FAILED(PathCchCombineEx(buffer, MAXPATHLEN+1, buffer, stuff, 0))) { +- Py_FatalError("buffer overflow in getpathp.c's join()"); ++ if (_PathCchCombineEx_Initialized == 0) { ++ HMODULE pathapi = LoadLibraryExW(L"api-ms-win-core-path-l1-1-0.dll", NULL, ++ LOAD_LIBRARY_SEARCH_SYSTEM32); ++ if (pathapi) { ++ _PathCchCombineEx = (PPathCchCombineEx)GetProcAddress(pathapi, "PathCchCombineEx"); ++ } ++ else { ++ _PathCchCombineEx = NULL; ++ } ++ _PathCchCombineEx_Initialized = 1; ++ } ++ if (_PathCchCombineEx) { ++ if (FAILED(_PathCchCombineEx(buffer, MAXPATHLEN+1, buffer, stuff, 0))) { ++ Py_FatalError("buffer overflow in getpathp.c's join()"); ++ } ++ } else { ++ if (!PathCombineW(buffer, buffer, stuff)) { ++ Py_FatalError("buffer overflow in getpathp.c's join()"); ++ } + } + } + ++static int _PathCchCanonicalizeEx_Initialized = 0; ++typedef HRESULT(__stdcall *PPathCchCanonicalizeEx) (PWSTR pszPathOut, size_t cchPathOut, ++ PCWSTR pszPathIn, unsigned long dwFlags); ++static PPathCchCanonicalizeEx _PathCchCanonicalizeEx; ++ + /* Call PathCchCanonicalizeEx(path): remove navigation elements such as "." + and ".." to produce a direct, well-formed path. */ + static PyStatus +@@ -267,8 +296,26 @@ canonicalize(wchar_t *buffer, const wchar_t *path) + return _PyStatus_NO_MEMORY(); + } + +- if (FAILED(PathCchCanonicalizeEx(buffer, MAXPATHLEN + 1, path, 0))) { +- return INIT_ERR_BUFFER_OVERFLOW(); ++ if (_PathCchCanonicalizeEx_Initialized == 0) { ++ HMODULE pathapi = LoadLibraryExW(L"api-ms-win-core-path-l1-1-0.dll", NULL, ++ LOAD_LIBRARY_SEARCH_SYSTEM32); ++ if (pathapi) { ++ _PathCchCanonicalizeEx = (PPathCchCanonicalizeEx)GetProcAddress(pathapi, "PathCchCanonicalizeEx"); ++ } ++ else { ++ _PathCchCanonicalizeEx = NULL; ++ } ++ _PathCchCanonicalizeEx_Initialized = 1; ++ } ++ if (_PathCchCanonicalizeEx) { ++ if (FAILED(_PathCchCanonicalizeEx(buffer, MAXPATHLEN + 1, path, 0))) { ++ return INIT_ERR_BUFFER_OVERFLOW(); ++ } ++ } ++ else { ++ if (!PathCanonicalizeW(buffer, path)) { ++ return INIT_ERR_BUFFER_OVERFLOW(); ++ } + } + return _PyStatus_OK(); + } +diff --git a/PC/pyconfig.h b/PC/pyconfig.h +index d7d3cf0..6e9c090 100644 +--- a/PC/pyconfig.h ++++ b/PC/pyconfig.h +@@ -136,8 +136,8 @@ WIN32 is still required for the locale module. + + /* set the version macros for the windows headers */ + /* Python 3.9+ requires Windows 8 or greater */ +-#define Py_WINVER 0x0602 /* _WIN32_WINNT_WIN8 */ +-#define Py_NTDDI NTDDI_WIN8 ++#define Py_WINVER 0x0601 /* _WIN32_WINNT_WIN7 */ ++#define Py_NTDDI NTDDI_WIN7 + + /* We only set these values when building Python - we don't want to force + these values on extensions, as that will affect the prototypes and +diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj +index c39ba3e1a9..0ef3a05fb6 100644 +--- a/PCbuild/pythoncore.vcxproj ++++ b/PCbuild/pythoncore.vcxproj +@@ -106,7 +106,7 @@ + _Py_HAVE_ZLIB;%(PreprocessorDefinitions) + + +- version.lib;shlwapi.lib;ws2_32.lib;pathcch.lib;%(AdditionalDependencies) ++ version.lib;ws2_32.lib;shlwapi.lib;%(AdditionalDependencies) + + + diff --git a/recipes/cpython/all/patches/3.10.0-0001-msvc.patch b/recipes/cpython/all/patches/3.10.3-0001-msvc.patch similarity index 100% rename from recipes/cpython/all/patches/3.10.0-0001-msvc.patch rename to recipes/cpython/all/patches/3.10.3-0001-msvc.patch diff --git a/recipes/cpython/all/patches/3.10.0-0003-_ctypes-ffi.patch b/recipes/cpython/all/patches/3.10.3-0003-_ctypes-ffi.patch similarity index 100% rename from recipes/cpython/all/patches/3.10.0-0003-_ctypes-ffi.patch rename to recipes/cpython/all/patches/3.10.3-0003-_ctypes-ffi.patch diff --git a/recipes/cpython/all/patches/3.10.3-0004-setup.py-pass-CFLAGS-CPPFLAGS.patch b/recipes/cpython/all/patches/3.10.3-0004-setup.py-pass-CFLAGS-CPPFLAGS.patch new file mode 100644 index 0000000000000..76e51cf2d3b49 --- /dev/null +++ b/recipes/cpython/all/patches/3.10.3-0004-setup.py-pass-CFLAGS-CPPFLAGS.patch @@ -0,0 +1,15 @@ +--- Makefile.pre.in ++++ Makefile.pre.in +@@ -626,10 +626,10 @@ + *\ -s*|s*) quiet="-q";; \ + *) quiet="";; \ + esac; \ +- echo "$(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ ++ echo "$(RUNSHARED) CC='$(CC) $(CONFIGURE_CFLAGS) $(CONFIGURE_CPPFLAGS)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ + _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \ + $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build"; \ +- $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ ++ $(RUNSHARED) CC='$(CC) $(CONFIGURE_CFLAGS) $(CONFIGURE_CPPFLAGS)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ + _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \ + $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build + diff --git a/recipes/cpython/all/patches/3.10.3-0005-do-not-search-for-system-tkinter.patch b/recipes/cpython/all/patches/3.10.3-0005-do-not-search-for-system-tkinter.patch new file mode 100644 index 0000000000000..65bc27cbe7d59 --- /dev/null +++ b/recipes/cpython/all/patches/3.10.3-0005-do-not-search-for-system-tkinter.patch @@ -0,0 +1,11 @@ +--- setup.py ++++ setup.py +@@ -2105,7 +2105,7 @@ + # and _TCLTK_LIBS environment variables. + if self.detect_tkinter_fromenv(): + return True +- ++ return False + # Rather than complicate the code below, detecting and building + # AquaTk is a separate method. Only one Tkinter will be built on + # Darwin - either AquaTk, if it is found, or X11 based Tk. diff --git a/recipes/cpython/all/patches/3.10.3-0006-restore-support-for-windows-7.patch b/recipes/cpython/all/patches/3.10.3-0006-restore-support-for-windows-7.patch new file mode 100644 index 0000000000000..c94b5c3087065 --- /dev/null +++ b/recipes/cpython/all/patches/3.10.3-0006-restore-support-for-windows-7.patch @@ -0,0 +1,187 @@ +From e30a560527d17ae81685dd11d3268bc982af2048 Mon Sep 17 00:00:00 2001 +From: Adam Johnson +Date: Tue, 16 Feb 2021 18:03:07 -0500 +Subject: [PATCH 7/7] restore support for windows 7 + +this backports the windows 7 compatible fix for bpo-39401 from gh-18234, +originally authored by Steve Dower, and removes explicit dependencies on +pathcch. + +The same mechanism is applied to fix posixmodule.c +--- +index 25ddc82..ff51042 100644 +diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c +--- a/Modules/posixmodule.c ++++ b/Modules/posixmodule.c +@@ -20,7 +20,7 @@ + + FSCTL_GET_REPARSE_POINT is not exported with WIN32_LEAN_AND_MEAN. */ + # include +-# include ++# include + #endif + + #ifdef __VXWORKS__ +@@ -4410,6 +4410,10 @@ os__getvolumepathname_impl(PyObject *module, path_t *path) + return result; + } + ++static int _PathCchSkipRoot_Initialized = 0; ++typedef HRESULT (__stdcall *PPathCchSkipRoot) (PCWSTR pszPath, PCWSTR *ppszRootEnd); ++static PPathCchSkipRoot _PathCchSkipRoot; ++ + + /*[clinic input] + os._path_splitroot +@@ -4428,6 +4432,19 @@ os__path_splitroot_impl(PyObject *module, path_t *path) + PyObject *result = NULL; + HRESULT ret; + ++ if (_PathCchSkipRoot_Initialized == 0) { ++ HMODULE pathapi = LoadLibraryExW(L"api-ms-win-core-path-l1-1-0.dll", NULL, ++ LOAD_LIBRARY_SEARCH_SYSTEM32); ++ ++ if (pathapi) { ++ _PathCchSkipRoot = (PPathCchSkipRoot)GetProcAddress(pathapi, "PathCchSkipRoot"); ++ } else { ++ _PathCchSkipRoot = NULL; ++ } ++ ++ _PathCchSkipRoot_Initialized = 1; ++ } ++ + buffer = (wchar_t*)PyMem_Malloc(sizeof(wchar_t) * (wcslen(path->wide) + 1)); + if (!buffer) { + return NULL; +@@ -4438,7 +4455,14 @@ os__path_splitroot_impl(PyObject *module, path_t *path) + } + + Py_BEGIN_ALLOW_THREADS +- ret = PathCchSkipRoot(buffer, &end); ++ if (_PathCchSkipRoot) { ++ ret = _PathCchSkipRoot(buffer, &end); ++ } else { ++ end = PathSkipRootW(buffer); ++ if (!end) { ++ ret = E_FAIL; ++ } ++ } + Py_END_ALLOW_THREADS + if (FAILED(ret)) { + result = Py_BuildValue("sO", "", path->object); +diff --git a/PC/getpathp.c b/PC/getpathp.c +index 53da3a6..3d58bbf 100644 +--- a/PC/getpathp.c ++++ b/PC/getpathp.c +@@ -90,7 +90,7 @@ + #endif + + #include +-#include ++#include + + #ifdef HAVE_SYS_TYPES_H + #include +@@ -249,14 +249,43 @@ ismodule(wchar_t *filename, int update_filename) + stuff as fits will be appended. + */ + ++ ++static int _PathCchCombineEx_Initialized = 0; ++typedef HRESULT(__stdcall *PPathCchCombineEx) (PWSTR pszPathOut, size_t cchPathOut, ++ PCWSTR pszPathIn, PCWSTR pszMore, ++ unsigned long dwFlags); ++static PPathCchCombineEx _PathCchCombineEx; ++ + static void + join(wchar_t *buffer, const wchar_t *stuff) + { +- if (FAILED(PathCchCombineEx(buffer, MAXPATHLEN+1, buffer, stuff, 0))) { +- Py_FatalError("buffer overflow in getpathp.c's join()"); ++ if (_PathCchCombineEx_Initialized == 0) { ++ HMODULE pathapi = LoadLibraryExW(L"api-ms-win-core-path-l1-1-0.dll", NULL, ++ LOAD_LIBRARY_SEARCH_SYSTEM32); ++ if (pathapi) { ++ _PathCchCombineEx = (PPathCchCombineEx)GetProcAddress(pathapi, "PathCchCombineEx"); ++ } ++ else { ++ _PathCchCombineEx = NULL; ++ } ++ _PathCchCombineEx_Initialized = 1; ++ } ++ if (_PathCchCombineEx) { ++ if (FAILED(_PathCchCombineEx(buffer, MAXPATHLEN+1, buffer, stuff, 0))) { ++ Py_FatalError("buffer overflow in getpathp.c's join()"); ++ } ++ } else { ++ if (!PathCombineW(buffer, buffer, stuff)) { ++ Py_FatalError("buffer overflow in getpathp.c's join()"); ++ } + } + } + ++static int _PathCchCanonicalizeEx_Initialized = 0; ++typedef HRESULT(__stdcall *PPathCchCanonicalizeEx) (PWSTR pszPathOut, size_t cchPathOut, ++ PCWSTR pszPathIn, unsigned long dwFlags); ++static PPathCchCanonicalizeEx _PathCchCanonicalizeEx; ++ + /* Call PathCchCanonicalizeEx(path): remove navigation elements such as "." + and ".." to produce a direct, well-formed path. */ + static PyStatus +@@ -266,8 +295,26 @@ canonicalize(wchar_t *buffer, const wchar_t *path) + return _PyStatus_NO_MEMORY(); + } + +- if (FAILED(PathCchCanonicalizeEx(buffer, MAXPATHLEN + 1, path, 0))) { +- return INIT_ERR_BUFFER_OVERFLOW(); ++ if (_PathCchCanonicalizeEx_Initialized == 0) { ++ HMODULE pathapi = LoadLibraryExW(L"api-ms-win-core-path-l1-1-0.dll", NULL, ++ LOAD_LIBRARY_SEARCH_SYSTEM32); ++ if (pathapi) { ++ _PathCchCanonicalizeEx = (PPathCchCanonicalizeEx)GetProcAddress(pathapi, "PathCchCanonicalizeEx"); ++ } ++ else { ++ _PathCchCanonicalizeEx = NULL; ++ } ++ _PathCchCanonicalizeEx_Initialized = 1; ++ } ++ if (_PathCchCanonicalizeEx) { ++ if (FAILED(_PathCchCanonicalizeEx(buffer, MAXPATHLEN + 1, path, 0))) { ++ return INIT_ERR_BUFFER_OVERFLOW(); ++ } ++ } ++ else { ++ if (!PathCanonicalizeW(buffer, path)) { ++ return INIT_ERR_BUFFER_OVERFLOW(); ++ } + } + return _PyStatus_OK(); + } +diff --git a/PC/pyconfig.h b/PC/pyconfig.h +index d7d3cf0..6e9c090 100644 +--- a/PC/pyconfig.h ++++ b/PC/pyconfig.h +@@ -136,8 +136,8 @@ WIN32 is still required for the locale module. + + /* set the version macros for the windows headers */ + /* Python 3.9+ requires Windows 8 or greater */ +-#define Py_WINVER 0x0602 /* _WIN32_WINNT_WIN8 */ +-#define Py_NTDDI NTDDI_WIN8 ++#define Py_WINVER 0x0601 /* _WIN32_WINNT_WIN7 */ ++#define Py_NTDDI NTDDI_WIN7 + + /* We only set these values when building Python - we don't want to force + these values on extensions, as that will affect the prototypes and +diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj +index c39ba3e1a9..0ef3a05fb6 100644 +--- a/PCbuild/pythoncore.vcxproj ++++ b/PCbuild/pythoncore.vcxproj +@@ -106,7 +106,7 @@ + _Py_HAVE_ZLIB;%(PreprocessorDefinitions) + + +- version.lib;ws2_32.lib;pathcch.lib;%(AdditionalDependencies) ++ version.lib;ws2_32.lib;shlwapi.lib;%(AdditionalDependencies) + + + diff --git a/recipes/cpython/all/test_package/CMakeLists.txt b/recipes/cpython/all/test_package/CMakeLists.txt index 525329324757f..a41a356fac26e 100644 --- a/recipes/cpython/all/test_package/CMakeLists.txt +++ b/recipes/cpython/all/test_package/CMakeLists.txt @@ -15,7 +15,10 @@ message("Using Python_ADDITIONAL_VERSIONS: ${Python_ADDITIONAL_VERSIONS}") find_package(PythonInterp REQUIRED) find_package(PythonLibs REQUIRED) -string(FIND "${PYTHON_EXECUTABLE}" "${CONAN_CPYTHON_ROOT}" ROOT_SUBPOS) +string(TOLOWER "${CONAN_CPYTHON_ROOT}" CONAN_CPYTHON_ROOT_LOWERCASE) +string(TOLOWER "${PYTHON_EXECUTABLE}" PYTHON_EXECUTABLE_LOWERCASE) + +string(FIND "${PYTHON_EXECUTABLE_LOWERCASE}" "${CONAN_CPYTHON_ROOT_LOWERCASE}" ROOT_SUBPOS) if(ROOT_SUBPOS EQUAL -1) message(FATAL_ERROR "found wrong python interpreter: ${PYTHON_EXECUTABLE}") endif() diff --git a/recipes/cpython/all/test_package/setup.py b/recipes/cpython/all/test_package/setup.py index cd1754cef8131..b29cc6d577489 100644 --- a/recipes/cpython/all/test_package/setup.py +++ b/recipes/cpython/all/test_package/setup.py @@ -24,7 +24,6 @@ setup( name="test_package", version="1.0", - use_2to3=True, ext_modules=[ Extension("spam", [os.path.join(subdir, "test_module.c")]), ], diff --git a/recipes/cpython/config.yml b/recipes/cpython/config.yml index e3abf3ec8acb2..cb7912c607835 100644 --- a/recipes/cpython/config.yml +++ b/recipes/cpython/config.yml @@ -1,4 +1,6 @@ versions: + "3.10.3": + folder: "all" "3.10.0": folder: "all" "3.9.7": @@ -7,5 +9,5 @@ versions: folder: "all" "3.7.12": folder: "all" - "2.7.18": - folder: "all" +# "2.7.18": +# folder: "all"