Skip to content

Commit

Permalink
Merge pull request #1420 from colincornaby/bare-apple-client
Browse files Browse the repository at this point in the history
Bare apple client
  • Loading branch information
colincornaby authored Aug 15, 2023
2 parents 3df3f2c + 84dfebf commit e9b5125
Show file tree
Hide file tree
Showing 70 changed files with 5,419 additions and 66 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE STRING "")
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14" CACHE STRING "Minimum OS X deployment version")

# CMake 3.22 changes cmake_dependent_option from doing `if(${CONDITION})` to actually evaulating
# The cmake code `if(<condition>)` using cmake_language(EVAL). That's a breaking change that warns
# if we don't explicitly set the policy. We prefer the OLD policy to avoid surprises. The NEW policy
Expand Down
57 changes: 57 additions & 0 deletions Scripts/Ports/python3/0001-only-build-required-projects.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
From 6492277e39dbe7dd77d32fdc9ae4b989213ef3c6 Mon Sep 17 00:00:00 2001
From: Adam Johnson <AdamJohnso@gmail.com>
Date: Wed, 9 Sep 2020 20:15:58 -0400
Subject: [PATCH 5/6] only build required projects

strips out tests and unsupported externals (eg tkinter).
---
PCbuild/_ssl.vcxproj | 2 +-
PCbuild/pcbuild.proj | 14 +++++++-------
2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/PCbuild/_ssl.vcxproj b/PCbuild/_ssl.vcxproj
index 4dffa202b7..e661cb6fb6 100644
--- a/PCbuild/_ssl.vcxproj
+++ b/PCbuild/_ssl.vcxproj
@@ -111,7 +111,7 @@
<Project>{cf7ac3d1-e2df-41d2-bea6-1e2556cdea26}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
- <ProjectReference Include="_socket.vcxproj">
+ <ProjectReference Condition="false" Include="_socket.vcxproj">
<Project>{86937f53-c189-40ef-8ce8-8759d8e7d480}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
diff --git a/PCbuild/pcbuild.proj b/PCbuild/pcbuild.proj
index 4d416c589e..ede9868a8f 100644
--- a/PCbuild/pcbuild.proj
+++ b/PCbuild/pcbuild.proj
@@ -49,17 +49,17 @@
<!-- python3.dll -->
<Projects Include="python3dll.vcxproj" />
<!-- py[w].exe -->
- <Projects Include="pylauncher.vcxproj;pywlauncher.vcxproj" />
+ <Projects Include="pylauncher.vcxproj;pywlauncher.vcxproj" Condition="false" />
<!-- pyshellext.dll -->
- <Projects Include="pyshellext.vcxproj" />
+ <Projects Include="pyshellext.vcxproj" Condition="false" />
<!-- Extension modules -->
<ExtensionModules Include="_asyncio;_zoneinfo;_decimal;_elementtree;_msi;_multiprocessing;_overlapped;pyexpat;_queue;select;unicodedata;winsound;_uuid" />
<ExtensionModules Include="_ctypes" Condition="$(IncludeCTypes)" />
<!-- Extension modules that require external sources -->
<ExternalModules Include="_bz2;_lzma;_sqlite3" />
<!-- venv launchers -->
- <Projects Include="venvlauncher.vcxproj;venvwlauncher.vcxproj" />
- <!-- _ssl will build _socket as well, which may cause conflicts in parallel builds -->
- <ExtensionModules Include="_socket" Condition="!$(IncludeSSL) or !$(IncludeExternals)" />
- <ExternalModules Include="_ssl;_hashlib" Condition="$(IncludeSSL)" />
+ <Projects Include="venvlauncher.vcxproj;venvwlauncher.vcxproj" Condition="false" />
+ <!-- _ssl will NOT build _socket as well -->
+ <ExtensionModules Include="_socket" Condition="true" />
+ <ExternalModules Include="_ssl;_hashlib" Condition="true" />
<ExternalModules Include="_tkinter" Condition="$(IncludeTkinter) and $(Platform) != 'ARM' and $(Platform) != 'ARM64'" />
<ExtensionModules Include="@(ExternalModules->'%(Identity)')" Condition="$(IncludeExternals)" />
<Projects Include="@(ExtensionModules->'%(Identity).vcxproj')" Condition="$(IncludeExtensions)" />
--
2.28.0.windows.1

90 changes: 90 additions & 0 deletions Scripts/Ports/python3/0002-static-library.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
From 14d91e4f4a9377f47cc4cc33faeeb7c82f64b176 Mon Sep 17 00:00:00 2001
From: Adam Johnson <AdamJohnso@gmail.com>
Date: Thu, 28 May 2020 17:25:21 -0400
Subject: [PATCH 1/7] static library

builds the pythoncore as a static library instead of a DLL
---
PC/pyconfig.h | 9 +++++++++
PCbuild/pythoncore.vcxproj | 4 ++--
2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/PC/pyconfig.h b/PC/pyconfig.h
index d7d3cf081e..34269f0b75 100644
--- a/PC/pyconfig.h
+++ b/PC/pyconfig.h
@@ -251,6 +251,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 */
@@ -276,6 +277,14 @@ 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")
+# if Py_WINVER > 0x0601
+# pragma comment(lib, "pathcch.lib")
+# endif /* Py_WINVER */
#endif /* MS_COREDLL */

#if defined(MS_WIN64)
diff --git a/PCbuild/pcbuild.proj b/PCbuild/pcbuild.proj
index 70c336a9d3..ba797e8afd 100644
--- a/PCbuild/pcbuild.proj
+++ b/PCbuild/pcbuild.proj
@@ -45,7 +45,7 @@
<BuildInParallel>false</BuildInParallel>
</Projects>
<!-- python3.dll -->
- <Projects Include="python3dll.vcxproj" />
+ <Projects Include="python3dll.vcxproj" Condition="false" />
<!-- py[w].exe -->
<Projects Include="pylauncher.vcxproj;pywlauncher.vcxproj" Condition="false" />
<!-- pyshellext.dll -->
diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj
index 2625d0293d..2f8bdaa931 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>
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index ac49f7867a..f3583345ff 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -2804,6 +2804,9 @@ _PySys_InitCore(PyThreadState *tstate, PyObject *sysdict
#ifdef MS_COREDLL
SET_SYS("dllhandle", PyLong_FromVoidPtr(PyWin_DLLhModule));
SET_SYS_FROM_STRING("winver", PyWin_DLLVersionString);
+#elif defined(MS_WINDOWS)
+ SET_SYS("dllhandle", PyLong_FromVoidPtr(NULL));
+ SET_SYS_FROM_STRING("winver", MS_DLL_ID);
#endif
#ifdef ABIFLAGS
SET_SYS_FROM_STRING("abiflags", ABIFLAGS);
--
2.28.0.windows.1

39 changes: 39 additions & 0 deletions Scripts/Ports/python3/0003-use-vcpkg-zlib.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
From 196555707236f4387875749f66620fb519166963 Mon Sep 17 00:00:00 2001
From: Adam Johnson <AdamJohnso@gmail.com>
Date: Wed, 9 Sep 2020 15:20:36 -0400
Subject: [PATCH 2/6] use vcpkg zlib

building without zlib is not a supported configuration, per the warning
messages.
---
PCbuild/pythoncore.vcxproj | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj
index dbe236829a..5f30a35eb3 100644
--- a/PCbuild/pythoncore.vcxproj
+++ b/PCbuild/pythoncore.vcxproj
@@ -507,8 +507,10 @@
<ClCompile Include="..\Python\thread.c" />
<ClCompile Include="..\Python\traceback.c" />
</ItemGroup>
- <ItemGroup Condition="$(IncludeExternals)">
+ <ItemGroup>
<ClCompile Include="..\Modules\zlibmodule.c" />
+ </ItemGroup>
+ <ItemGroup Condition="false">
<ClCompile Include="$(zlibDir)\adler32.c" />
<ClCompile Include="$(zlibDir)\compress.c" />
<ClCompile Include="$(zlibDir)\crc32.c" />
@@ -556,7 +558,7 @@
<Target Name="_WarnAboutToolset" BeforeTargets="PrepareForBuild" Condition="$(PlatformToolset) != 'v140' and $(PlatformToolset) != 'v141' and $(PlatformToolset) != 'v142' and $(PlatformToolset) != 'v143'">
<Warning Text="Toolset $(PlatformToolset) is not used for official builds. Your build may have errors or incompatibilities." />
</Target>
- <Target Name="_WarnAboutZlib" BeforeTargets="PrepareForBuild" Condition="!$(IncludeExternals)">
+ <Target Name="_WarnAboutZlib" BeforeTargets="PrepareForBuild" Condition="false">
<Warning Text="Not including zlib is not a supported configuration." />
</Target>

--
2.28.0.windows.1

117 changes: 117 additions & 0 deletions Scripts/Ports/python3/0004-devendor-external-dependencies.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
From 6c5c3793cbc6ba2a1d0d623a2bdaa9c2125be516 Mon Sep 17 00:00:00 2001
From: Adam Johnson <AdamJohnso@gmail.com>
Date: Wed, 9 Sep 2020 15:24:38 -0400
Subject: [PATCH 3/6] devendor external dependencies

externally fetched libraries may cause linker errors resulting from
duplicate symbols in downstream projects.
---
PCbuild/_bz2.vcxproj | 4 +++-
PCbuild/_lzma.vcxproj | 5 ++---
PCbuild/_sqlite3.vcxproj | 2 +-
PCbuild/_ssl.vcxproj | 2 +-
PCbuild/pyexpat.vcxproj | 6 ++++--
5 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/PCbuild/_bz2.vcxproj b/PCbuild/_bz2.vcxproj
index 3fe95fbf83..6b12e8818e 100644
--- a/PCbuild/_bz2.vcxproj
+++ b/PCbuild/_bz2.vcxproj
@@ -101,6 +101,8 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\Modules\_bz2module.c" />
+ </ItemGroup>
+ <ItemGroup Condition="false">
<ClCompile Include="$(bz2Dir)\blocksort.c" />
<ClCompile Include="$(bz2Dir)\bzlib.c" />
<ClCompile Include="$(bz2Dir)\compress.c" />
@@ -109,7 +111,7 @@
<ClCompile Include="$(bz2Dir)\huffman.c" />
<ClCompile Include="$(bz2Dir)\randtable.c" />
</ItemGroup>
- <ItemGroup>
+ <ItemGroup Condition="false">
<ClInclude Include="$(bz2Dir)\bzlib.h" />
<ClInclude Include="$(bz2Dir)\bzlib_private.h" />
</ItemGroup>
diff --git a/PCbuild/_lzma.vcxproj b/PCbuild/_lzma.vcxproj
index fe076a6fc5..70cc61dd95 100644
--- a/PCbuild/_lzma.vcxproj
+++ b/PCbuild/_lzma.vcxproj
@@ -94,10 +94,9 @@
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(lzmaDir)src/liblzma/api;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_FILE_OFFSET_BITS=64;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;LZMA_API_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_FILE_OFFSET_BITS=64;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
- <AdditionalDependencies>$(OutDir)liblzma$(PyDebugExt).lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
@@ -111,7 +110,7 @@
<Project>{cf7ac3d1-e2df-41d2-bea6-1e2556cdea26}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
- <ProjectReference Include="liblzma.vcxproj">
+ <ProjectReference Condition="false" Include="liblzma.vcxproj">
<Project>{12728250-16eC-4dc6-94d7-e21dd88947f8}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
diff --git a/PCbuild/_sqlite3.vcxproj b/PCbuild/_sqlite3.vcxproj
index 7e0062692b..6fb3279a20 100644
--- a/PCbuild/_sqlite3.vcxproj
+++ b/PCbuild/_sqlite3.vcxproj
@@ -127,7 +127,7 @@
<Project>{cf7ac3d1-e2df-41d2-bea6-1e2556cdea26}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
- <ProjectReference Include="sqlite3.vcxproj">
+ <ProjectReference Condition="false" Include="sqlite3.vcxproj">
<Project>{a1a295e5-463c-437f-81ca-1f32367685da}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
diff --git a/PCbuild/_ssl.vcxproj b/PCbuild/_ssl.vcxproj
index 4907f49b66..4dffa202b7 100644
--- a/PCbuild/_ssl.vcxproj
+++ b/PCbuild/_ssl.vcxproj
@@ -99,7 +99,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\Modules\_ssl.c" />
- <ClCompile Include="$(opensslIncludeDir)\applink.c">
+ <ClCompile Condition="false" Include="$(opensslIncludeDir)\applink.c">
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;$(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemGroup>
diff --git a/PCbuild/pyexpat.vcxproj b/PCbuild/pyexpat.vcxproj
index b2d9f5d57d..4efb826a05 100644
--- a/PCbuild/pyexpat.vcxproj
+++ b/PCbuild/pyexpat.vcxproj
@@ -89,17 +89,19 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup>
- <ClCompile>
+ <ClCompile Condition="false">
<AdditionalIncludeDirectories>$(PySourcePath)Modules\expat;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;PYEXPAT_EXPORTS;HAVE_EXPAT_H;XML_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
- <ItemGroup>
+ <ItemGroup Condition="false">
<ClInclude Include="..\Modules\expat\xmlrole.h" />
<ClInclude Include="..\Modules\expat\xmltok.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\Modules\pyexpat.c" />
+ </ItemGroup>
+ <ItemGroup Condition="false">
<ClCompile Include="..\Modules\expat\xmlparse.c" />
<ClCompile Include="..\Modules\expat\xmlrole.c" />
<ClCompile Include="..\Modules\expat\xmltok.c" />
--
2.28.0.windows.1

26 changes: 26 additions & 0 deletions Scripts/Ports/python3/0005-dont-copy-vcruntime.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
From 8086c67fa7ada1888a7808cbdc6fe74b62abe5b1 Mon Sep 17 00:00:00 2001
From: Adam Johnson <AdamJohnso@gmail.com>
Date: Wed, 9 Sep 2020 16:12:49 -0400
Subject: [PATCH 4/6] dont copy vcruntime

VCRUNTIME140.dll should not be redistributed, ever.
---
PCbuild/pythoncore.vcxproj | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj
index 5f30a35eb3..3cf21ba39c 100644
--- a/PCbuild/pythoncore.vcxproj
+++ b/PCbuild/pythoncore.vcxproj
@@ -565,7 +565,7 @@
<Target Name="_CopyVCRuntime" AfterTargets="Build" Inputs="@(VCRuntimeDLL)" Outputs="$(OutDir)%(Filename)%(Extension)" DependsOnTargets="FindVCRuntime">
<!-- bpo-38597: When we switch to another VCRuntime DLL, include vcruntime140.dll as well -->
<Warning Text="A copy of vcruntime140.dll is also required" Condition="!$(VCToolsRedistVersion.StartsWith(`14.`))" />
- <Copy SourceFiles="%(VCRuntimeDLL.FullPath)" DestinationFolder="$(OutDir)" />
+ <Copy Condition="false" SourceFiles="%(VCRuntimeDLL.FullPath)" DestinationFolder="$(OutDir)" />
</Target>
<Target Name="_CleanVCRuntime" AfterTargets="Clean">
<Delete Files="@(VCRuntimeDLL->'$(OutDir)%(Filename)%(Extension)')" />
--
2.28.0.windows.1

Loading

0 comments on commit e9b5125

Please sign in to comment.