You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
5.0 KiB

bpo-32030: Split Py_Main() into subfunctions (#4399) * Don't use "Python runtime" anymore to parse command line options or to get environment variables: pymain_init() is now a strict separation. * Use an error message rather than "crashing" directly with Py_FatalError(). Limit the number of calls to Py_FatalError(). It prepares the code to handle errors more nicely later. * Warnings options (-W, PYTHONWARNINGS) and "XOptions" (-X) are now only added to the sys module once Python core is properly initialized. * _PyMain is now the well identified owner of some important strings like: warnings options, XOptions, and the "program name". The program name string is now properly freed at exit. pymain_free() is now responsible to free the "command" string. * Rename most methods in Modules/main.c to use a "pymain_" prefix to avoid conflits and ease debug. * Replace _Py_CommandLineDetails_INIT with memset(0) * Reorder a lot of code to fix the initialization ordering. For example, initializing standard streams now comes before parsing PYTHONWARNINGS. * Py_Main() now handles errors when adding warnings options and XOptions. * Add _PyMem_GetDefaultRawAllocator() private function. * Cleanup _PyMem_Initialize(): remove useless global constants: move them into _PyMem_Initialize(). * Call _PyRuntime_Initialize() as soon as possible: _PyRuntime_Initialize() now returns an error message on failure. * Add _PyInitError structure and following macros: * _Py_INIT_OK() * _Py_INIT_ERR(msg) * _Py_INIT_USER_ERR(msg): "user" error, don't abort() in that case * _Py_INIT_FAILED(err)
8 years ago
bpo-32030: Split Py_Main() into subfunctions (#4399) * Don't use "Python runtime" anymore to parse command line options or to get environment variables: pymain_init() is now a strict separation. * Use an error message rather than "crashing" directly with Py_FatalError(). Limit the number of calls to Py_FatalError(). It prepares the code to handle errors more nicely later. * Warnings options (-W, PYTHONWARNINGS) and "XOptions" (-X) are now only added to the sys module once Python core is properly initialized. * _PyMain is now the well identified owner of some important strings like: warnings options, XOptions, and the "program name". The program name string is now properly freed at exit. pymain_free() is now responsible to free the "command" string. * Rename most methods in Modules/main.c to use a "pymain_" prefix to avoid conflits and ease debug. * Replace _Py_CommandLineDetails_INIT with memset(0) * Reorder a lot of code to fix the initialization ordering. For example, initializing standard streams now comes before parsing PYTHONWARNINGS. * Py_Main() now handles errors when adding warnings options and XOptions. * Add _PyMem_GetDefaultRawAllocator() private function. * Cleanup _PyMem_Initialize(): remove useless global constants: move them into _PyMem_Initialize(). * Call _PyRuntime_Initialize() as soon as possible: _PyRuntime_Initialize() now returns an error message on failure. * Add _PyInitError structure and following macros: * _Py_INIT_OK() * _Py_INIT_ERR(msg) * _Py_INIT_USER_ERR(msg): "user" error, don't abort() in that case * _Py_INIT_FAILED(err)
8 years ago
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  3. <ItemGroup Label="ProjectConfigurations">
  4. <ProjectConfiguration Include="Debug|Win32">
  5. <Configuration>Debug</Configuration>
  6. <Platform>Win32</Platform>
  7. </ProjectConfiguration>
  8. <ProjectConfiguration Include="Debug|x64">
  9. <Configuration>Debug</Configuration>
  10. <Platform>x64</Platform>
  11. </ProjectConfiguration>
  12. <ProjectConfiguration Include="PGInstrument|Win32">
  13. <Configuration>PGInstrument</Configuration>
  14. <Platform>Win32</Platform>
  15. </ProjectConfiguration>
  16. <ProjectConfiguration Include="PGInstrument|x64">
  17. <Configuration>PGInstrument</Configuration>
  18. <Platform>x64</Platform>
  19. </ProjectConfiguration>
  20. <ProjectConfiguration Include="PGUpdate|Win32">
  21. <Configuration>PGUpdate</Configuration>
  22. <Platform>Win32</Platform>
  23. </ProjectConfiguration>
  24. <ProjectConfiguration Include="PGUpdate|x64">
  25. <Configuration>PGUpdate</Configuration>
  26. <Platform>x64</Platform>
  27. </ProjectConfiguration>
  28. <ProjectConfiguration Include="Release|Win32">
  29. <Configuration>Release</Configuration>
  30. <Platform>Win32</Platform>
  31. </ProjectConfiguration>
  32. <ProjectConfiguration Include="Release|x64">
  33. <Configuration>Release</Configuration>
  34. <Platform>x64</Platform>
  35. </ProjectConfiguration>
  36. </ItemGroup>
  37. <PropertyGroup Label="Globals">
  38. <ProjectGuid>{B11D750F-CD1F-4A96-85CE-E69A5C5259F9}</ProjectGuid>
  39. </PropertyGroup>
  40. <Import Project="python.props" />
  41. <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
  42. <PropertyGroup Label="Configuration">
  43. <ConfigurationType>Application</ConfigurationType>
  44. <UseOfMfc>false</UseOfMfc>
  45. <CharacterSet>MultiByte</CharacterSet>
  46. </PropertyGroup>
  47. <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
  48. <ImportGroup Label="ExtensionSettings">
  49. </ImportGroup>
  50. <ImportGroup Label="PropertySheets">
  51. <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  52. <Import Project="pyproject.props" />
  53. </ImportGroup>
  54. <PropertyGroup Label="UserMacros" />
  55. <PropertyGroup>
  56. <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
  57. </PropertyGroup>
  58. <ItemDefinitionGroup>
  59. <ClCompile>
  60. <PreprocessorDefinitions>Py_BUILD_CORE;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  61. </ClCompile>
  62. <Link>
  63. <SubSystem>Console</SubSystem>
  64. <StackReserveSize>2000000</StackReserveSize>
  65. </Link>
  66. </ItemDefinitionGroup>
  67. <ItemGroup>
  68. <None Include="..\PC\pycon.ico" />
  69. </ItemGroup>
  70. <ItemGroup>
  71. <ResourceCompile Include="..\PC\python_exe.rc" />
  72. </ItemGroup>
  73. <ItemGroup>
  74. <ClCompile Include="..\Programs\python.c" />
  75. </ItemGroup>
  76. <ItemGroup>
  77. <ProjectReference Include="pythoncore.vcxproj">
  78. <Project>{cf7ac3d1-e2df-41d2-bea6-1e2556cdea26}</Project>
  79. <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
  80. </ProjectReference>
  81. </ItemGroup>
  82. <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  83. <ImportGroup Label="ExtensionTargets">
  84. </ImportGroup>
  85. <Target Name="ValidateUcrtbase" AfterTargets="AfterBuild" Condition="$(Configuration) != 'PGInstrument'">
  86. <PropertyGroup>
  87. <UcrtName>ucrtbase</UcrtName>
  88. <UcrtName Condition="'$(Configuration)' == 'Debug'">ucrtbased</UcrtName>
  89. </PropertyGroup>
  90. <Exec Command='setlocal
  91. set PYTHONPATH=$(PySourcePath)Lib
  92. "$(OutDir)python$(PyDebugExt).exe" "$(PySourcePath)PC\validate_ucrtbase.py" $(UcrtName)' ContinueOnError="true" />
  93. </Target>
  94. <Target Name="GeneratePythonBat" AfterTargets="AfterBuild">
  95. <PropertyGroup>
  96. <_PGOPath Condition="$(Configuration) == 'PGInstrument' and $(Platform) == 'Win32'">@set PATH=%PATH%%3B$(VCInstallDir)bin</_PGOPath>
  97. <_PGOPath Condition="$(Configuration) == 'PGInstrument' and $(Platform) == 'x64'">@set PATH=%PATH%%3B$(VCInstallDir)bin\amd64</_PGOPath>
  98. <_PGOPath Condition="$(Configuration) == 'PGInstrument' and $(VC_PGO_RunTime_Dir) != ''">@set PATH=%PATH%%3B$(VC_PGO_RunTime_Dir)</_PGOPath>
  99. <_Content>@rem This script invokes the most recently built Python with all arguments
  100. @rem passed through to the interpreter. This file is generated by the
  101. @rem build process and any changes *will* be thrown away by the next
  102. @rem rebuild.
  103. @rem This is only meant as a convenience for developing CPython
  104. @rem and using it outside of that context is ill-advised.
  105. @echo Running $(Configuration)^|$(Platform) interpreter...
  106. @setlocal
  107. @set PYTHONHOME=$(PySourcePath)
  108. $(_PGOPath)
  109. @"$(OutDir)python$(PyDebugExt).exe" %*
  110. </_Content>
  111. <_ExistingContent Condition="Exists('$(PySourcePath)python.bat')">$([System.IO.File]::ReadAllText('$(PySourcePath)python.bat'))</_ExistingContent>
  112. </PropertyGroup>
  113. <WriteLinesToFile File="$(PySourcePath)python.bat" Lines="$(_Content)" Overwrite="true" Condition="'$(_Content)' != '$(_ExistingContent)'" />
  114. </Target>
  115. </Project>