Skip to content

Commit 14e8f42

Browse files
committed
64-bit support on Windows. Note I didn't update anything to do with "mdp" files or makefile, as I don't know anything about those. These changes purely update the Visual Studio files to have an option to build 64bit (the x64 solution platform).
clrmodule.il: - Rewrote entirely to be more human readable/writable. Heavily commented with C# equivalents. Added #ifdef'd debug prints. - Supports loading out of PYTHONPATH (based on idea by Maksim Kozyarchuk). Default behavior is the same, and only falls back to PYTHONPATH if Python.Runtime can't be found. Note that the ".assembly extern Python.Runtime" block is removed now, as we're no longer binding to it at compile time. - If/when Python.Runtime.dll gets a solid version and/or strong name, clrmodule can be set to bind more closely with that build by using the USE_PYTHON_RUNTIME_VERSION and USE_PYTHON_RUNTIME_PUBLIC_KEY_TOKEN defines. See comments for details. - Updated mscorlib reference to 2.0 (required for 64-bit compat). - Removed ".corflags 0x00000002" (Not compatible with 64 bit version, and no longer needed for 32 bit version when using ilasm v2). Other files: - And added "runtime\x86\clrmodule-platform.il" and "runtime\x64\clrmodule-platform.il" subdirectories. 32/64 bit specific IL code is in there, and included into "runtime\clrmodule.il". Clunky, but since ilasm doesn't support command-line #defines, I think this is the best to be done to get the machine-specific stuff out of clrmodule.il. - Deleted oldmodule.il (seems to be left over drit that was basically the same as clrmodule.il anyway, casing notwithstanding). - Added an x64 platform target for the solution and Python.Runtime project. The platform is passed into the newly added buildclrmodule.bat, which builds the appropriate clr.pyd. - Removed Console.csproj.user, and put its Debug build StartArguments into Console.csproj, so it's no longer necessary to keep the .user file around in source control. - All projects are responsible for copying only their specific output (i.e. console no longer delets/builds/copies clr.pyd). Project dependencies should make sure things work still.
1 parent 86669a5 commit 14e8f42

File tree

11 files changed

+441
-172
lines changed

11 files changed

+441
-172
lines changed

pythonnet/pythonnet.sln

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,40 +12,73 @@ EndProject
1212
Global
1313
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1414
Debug|Any CPU = Debug|Any CPU
15+
Debug|x64 = Debug|x64
1516
EmbeddingTest|Any CPU = EmbeddingTest|Any CPU
17+
EmbeddingTest|x64 = EmbeddingTest|x64
1618
Release|Any CPU = Release|Any CPU
19+
Release|x64 = Release|x64
1720
UnitTests|Any CPU = UnitTests|Any CPU
21+
UnitTests|x64 = UnitTests|x64
1822
EndGlobalSection
1923
GlobalSection(ProjectConfigurationPlatforms) = postSolution
2024
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2125
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Debug|Any CPU.Build.0 = Debug|Any CPU
26+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Debug|x64.ActiveCfg = Debug|x64
27+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Debug|x64.Build.0 = Debug|x64
2228
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.EmbeddingTest|Any CPU.ActiveCfg = Debug|Any CPU
2329
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.EmbeddingTest|Any CPU.Build.0 = Debug|Any CPU
30+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.EmbeddingTest|x64.ActiveCfg = Debug|x64
31+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.EmbeddingTest|x64.Build.0 = Debug|x64
2432
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Release|Any CPU.ActiveCfg = Release|Any CPU
2533
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Release|Any CPU.Build.0 = Release|Any CPU
34+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Release|x64.ActiveCfg = Release|x64
35+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Release|x64.Build.0 = Release|x64
2636
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.UnitTests|Any CPU.ActiveCfg = Debug|Any CPU
2737
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.UnitTests|Any CPU.Build.0 = Debug|Any CPU
38+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.UnitTests|x64.ActiveCfg = Debug|x64
39+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.UnitTests|x64.Build.0 = Debug|x64
2840
{6F401A34-273B-450F-9A4C-13550BE0767B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2941
{6F401A34-273B-450F-9A4C-13550BE0767B}.Debug|Any CPU.Build.0 = Debug|Any CPU
42+
{6F401A34-273B-450F-9A4C-13550BE0767B}.Debug|x64.ActiveCfg = Debug|Any CPU
43+
{6F401A34-273B-450F-9A4C-13550BE0767B}.Debug|x64.Build.0 = Debug|Any CPU
3044
{6F401A34-273B-450F-9A4C-13550BE0767B}.EmbeddingTest|Any CPU.ActiveCfg = Debug|Any CPU
3145
{6F401A34-273B-450F-9A4C-13550BE0767B}.EmbeddingTest|Any CPU.Build.0 = Debug|Any CPU
46+
{6F401A34-273B-450F-9A4C-13550BE0767B}.EmbeddingTest|x64.ActiveCfg = Debug|Any CPU
47+
{6F401A34-273B-450F-9A4C-13550BE0767B}.EmbeddingTest|x64.Build.0 = Debug|Any CPU
3248
{6F401A34-273B-450F-9A4C-13550BE0767B}.Release|Any CPU.ActiveCfg = Release|Any CPU
3349
{6F401A34-273B-450F-9A4C-13550BE0767B}.Release|Any CPU.Build.0 = Release|Any CPU
50+
{6F401A34-273B-450F-9A4C-13550BE0767B}.Release|x64.ActiveCfg = Release|Any CPU
51+
{6F401A34-273B-450F-9A4C-13550BE0767B}.Release|x64.Build.0 = Release|Any CPU
3452
{6F401A34-273B-450F-9A4C-13550BE0767B}.UnitTests|Any CPU.ActiveCfg = Debug|Any CPU
3553
{6F401A34-273B-450F-9A4C-13550BE0767B}.UnitTests|Any CPU.Build.0 = Debug|Any CPU
54+
{6F401A34-273B-450F-9A4C-13550BE0767B}.UnitTests|x64.ActiveCfg = Debug|Any CPU
55+
{6F401A34-273B-450F-9A4C-13550BE0767B}.UnitTests|x64.Build.0 = Debug|Any CPU
3656
{4165C59D-2822-499F-A6DB-EACA4C331EB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
57+
{4165C59D-2822-499F-A6DB-EACA4C331EB5}.Debug|x64.ActiveCfg = Debug|Any CPU
3758
{4165C59D-2822-499F-A6DB-EACA4C331EB5}.EmbeddingTest|Any CPU.ActiveCfg = Release|Any CPU
3859
{4165C59D-2822-499F-A6DB-EACA4C331EB5}.EmbeddingTest|Any CPU.Build.0 = Release|Any CPU
60+
{4165C59D-2822-499F-A6DB-EACA4C331EB5}.EmbeddingTest|x64.ActiveCfg = Release|Any CPU
61+
{4165C59D-2822-499F-A6DB-EACA4C331EB5}.EmbeddingTest|x64.Build.0 = Release|Any CPU
3962
{4165C59D-2822-499F-A6DB-EACA4C331EB5}.Release|Any CPU.ActiveCfg = Release|Any CPU
63+
{4165C59D-2822-499F-A6DB-EACA4C331EB5}.Release|x64.ActiveCfg = Release|Any CPU
4064
{4165C59D-2822-499F-A6DB-EACA4C331EB5}.UnitTests|Any CPU.ActiveCfg = Debug|Any CPU
65+
{4165C59D-2822-499F-A6DB-EACA4C331EB5}.UnitTests|x64.ActiveCfg = Debug|Any CPU
4166
{E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
4267
{E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Debug|Any CPU.Build.0 = Debug|Any CPU
68+
{E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Debug|x64.ActiveCfg = Debug|Any CPU
69+
{E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Debug|x64.Build.0 = Debug|Any CPU
4370
{E29DCF0A-5114-4A98-B1DD-71264B6EA349}.EmbeddingTest|Any CPU.ActiveCfg = EmbeddingTest|Any CPU
4471
{E29DCF0A-5114-4A98-B1DD-71264B6EA349}.EmbeddingTest|Any CPU.Build.0 = EmbeddingTest|Any CPU
72+
{E29DCF0A-5114-4A98-B1DD-71264B6EA349}.EmbeddingTest|x64.ActiveCfg = EmbeddingTest|Any CPU
73+
{E29DCF0A-5114-4A98-B1DD-71264B6EA349}.EmbeddingTest|x64.Build.0 = EmbeddingTest|Any CPU
4574
{E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Release|Any CPU.ActiveCfg = Release|Any CPU
4675
{E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Release|Any CPU.Build.0 = Release|Any CPU
76+
{E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Release|x64.ActiveCfg = Release|Any CPU
77+
{E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Release|x64.Build.0 = Release|Any CPU
4778
{E29DCF0A-5114-4A98-B1DD-71264B6EA349}.UnitTests|Any CPU.ActiveCfg = UnitTests|Any CPU
4879
{E29DCF0A-5114-4A98-B1DD-71264B6EA349}.UnitTests|Any CPU.Build.0 = UnitTests|Any CPU
80+
{E29DCF0A-5114-4A98-B1DD-71264B6EA349}.UnitTests|x64.ActiveCfg = UnitTests|Any CPU
81+
{E29DCF0A-5114-4A98-B1DD-71264B6EA349}.UnitTests|x64.Build.0 = UnitTests|Any CPU
4982
EndGlobalSection
5083
GlobalSection(SolutionProperties) = preSolution
5184
HideSolutionNode = FALSE

pythonnet/src/console/Console.csproj

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,7 @@
6060
<VisualStudio AllowExistingFolder="true" />
6161
</ProjectExtensions>
6262
<PropertyGroup>
63-
<PostBuildEvent>%25windir%25\Microsoft.NET\Framework\v2.0.50727\ilasm /nologo /dll /quiet /output="$(TargetDir)clr.pyd" "$(ProjectDir)..\runtime\clrmodule.il"
64-
copy "$(TargetDir)Python.Runtime.dll" ..\..\..\..\
65-
copy "$(TargetDir)python.exe" ..\..\..\..\
66-
copy "$(TargetDir)*.pdb" ..\..\..\..\
67-
copy "$(TargetDir)clr.pyd" ..\..\..\..\</PostBuildEvent>
68-
<PreBuildEvent>del "$(TargetDir)clr.pyd"</PreBuildEvent>
63+
<PostBuildEvent>copy "$(TargetPath)" "$(SolutionDir)"
64+
copy "$(TargetDir)*.pdb" "$(SolutionDir)"</PostBuildEvent>
6965
</PropertyGroup>
70-
</Project>
66+
</Project>

pythonnet/src/console/Console.csproj.user

Lines changed: 0 additions & 27 deletions
This file was deleted.

pythonnet/src/embed_tests/Python.EmbeddingTest.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@
5959
<VisualStudio AllowExistingFolder="true" />
6060
</ProjectExtensions>
6161
<PropertyGroup>
62-
<PostBuildEvent>copy "$(TargetDir)*.pdb" ..\..\..\..\
63-
copy "$(TargetDir)Python.EmbeddingTest.dll" ..\..\..\..\</PostBuildEvent>
62+
<PostBuildEvent>copy "$(TargetPath)" "$(SolutionDir)"
63+
copy "$(TargetDir)*.pdb" "$(SolutionDir)"
64+
</PostBuildEvent>
6465
</PropertyGroup>
65-
</Project>
66+
</Project>

pythonnet/src/runtime/Python.Runtime.csproj

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,45 @@
4242
<DebugType>full</DebugType>
4343
<PlatformTarget>AnyCPU</PlatformTarget>
4444
</PropertyGroup>
45+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
46+
<DebugSymbols>true</DebugSymbols>
47+
<OutputPath>bin\x64\Debug\</OutputPath>
48+
<DefineConstants>TRACE;DEBUG;PYTHON25,UCS2</DefineConstants>
49+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
50+
<Optimize>true</Optimize>
51+
<DebugType>full</DebugType>
52+
<PlatformTarget>x64</PlatformTarget>
53+
<NoWarn>1607</NoWarn>
54+
</PropertyGroup>
55+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
56+
<OutputPath>bin\x64\Release\</OutputPath>
57+
<DefineConstants>TRACE;PYTHON25,UCS2</DefineConstants>
58+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
59+
<Optimize>true</Optimize>
60+
<DebugType>pdbonly</DebugType>
61+
<PlatformTarget>x64</PlatformTarget>
62+
<NoWarn>1607</NoWarn>
63+
</PropertyGroup>
64+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'EmbeddingTest|x64' ">
65+
<DebugSymbols>true</DebugSymbols>
66+
<OutputPath>bin\x64\EmbeddingTest\</OutputPath>
67+
<DefineConstants>TRACE;DEBUG;PYTHON25,UCS2</DefineConstants>
68+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
69+
<Optimize>true</Optimize>
70+
<DebugType>full</DebugType>
71+
<PlatformTarget>x64</PlatformTarget>
72+
<NoWarn>1607</NoWarn>
73+
</PropertyGroup>
74+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'UnitTests|x64' ">
75+
<DebugSymbols>true</DebugSymbols>
76+
<OutputPath>bin\x64\UnitTests\</OutputPath>
77+
<DefineConstants>TRACE;DEBUG;PYTHON25,UCS2</DefineConstants>
78+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
79+
<Optimize>true</Optimize>
80+
<DebugType>full</DebugType>
81+
<PlatformTarget>x64</PlatformTarget>
82+
<NoWarn>1607</NoWarn>
83+
</PropertyGroup>
4584
<ItemGroup>
4685
<Reference Include="System" />
4786
</ItemGroup>
@@ -103,16 +142,21 @@
103142
<Compile Include="typemethod.cs" />
104143
</ItemGroup>
105144
<ItemGroup>
145+
<None Include="buildclrmodule.bat" />
106146
<None Include="clrmodule.il" />
107-
<None Include="oldmodule.il" />
147+
<None Include="x64\clrmodule-platform.il" />
148+
<None Include="x86\clrmodule-platform.il" />
108149
</ItemGroup>
109150
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
110151
<ProjectExtensions>
111152
<VisualStudio AllowExistingFolder="true" />
112153
</ProjectExtensions>
113154
<PropertyGroup>
114-
<PostBuildEvent>%25windir%25\Microsoft.NET\Framework\v2.0.50727\ilasm /nologo /dll /quiet /output="$(TargetDir)clr.pyd" "$(ProjectDir)clrmodule.il"
155+
<PostBuildEvent>call "$(ProjectDir)buildclrmodule.bat" $(Platform) "$(ProjectDir)" "$(TargetDir)clr.pyd"
156+
copy "$(TargetPath)" "$(SolutionDir)"
157+
copy "$(TargetDir)*.pdb" "$(SolutionDir)"
158+
copy "$(TargetDir)clr.pyd" "$(SolutionDir)"
115159
</PostBuildEvent>
116160
<PreBuildEvent>del "$(TargetDir)clr.pyd"</PreBuildEvent>
117161
</PropertyGroup>
118-
</Project>
162+
</Project>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
:: Call with buildclrmodule.bat <AnyCPU|x64> <INPUT_DIRECTORY> <OUTPUT_PATH>
2+
3+
@echo off
4+
5+
set TARGET_PLATFORM=%1
6+
set INPUT_DIRECTORY=%~2
7+
set INPUT_PATH="%INPUT_DIRECTORY%\clrmodule.il"
8+
set OUTPUT_PATH=%3
9+
10+
if %TARGET_PLATFORM%==AnyCPU goto SETUP32
11+
if %TARGET_PLATFORM%==x64 goto SETUP64
12+
goto ERROR_BAD_PLATFORM
13+
14+
:SETUP32
15+
set INCLUDE_PATH="%INPUT_DIRECTORY%\x86"
16+
goto BUILD_CLR_MODULE
17+
18+
:SETUP64
19+
set INCLUDE_PATH="%INPUT_DIRECTORY%\x64"
20+
set ILASM_EXTRA_ARGS=/pe64 /x64
21+
goto BUILD_CLR_MODULE
22+
23+
:ERROR_BAD_PLATFORM
24+
echo Unknown target platform: %TARGET_PLATFORM%
25+
exit /b 1
26+
27+
:ERROR_MISSING_INPUT
28+
echo Can't find input file: %INPUT_PATH%
29+
exit /b 1
30+
31+
:BUILD_CLR_MODULE
32+
if not exist %INPUT_PATH% goto ERROR_MISSING_INPUT
33+
%windir%\Microsoft.NET\Framework\v2.0.50727\ilasm /nologo /quiet /dll %ILASM_EXTRA_ARGS% /include=%INCLUDE_PATH% /output=%OUTPUT_PATH% %INPUT_PATH%
34+
:: Call with buildclrmodule.bat <AnyCPU|x64> <INPUT_DIRECTORY> <OUTPUT_PATH>
35+
36+
@echo off
37+
38+
set TARGET_PLATFORM=%1
39+
set INPUT_DIRECTORY=%~2
40+
set INPUT_PATH="%INPUT_DIRECTORY%\clrmodule.il"
41+
set OUTPUT_PATH=%3
42+
43+
if %TARGET_PLATFORM%==AnyCPU goto SETUP32
44+
if %TARGET_PLATFORM%==x64 goto SETUP64
45+
goto ERROR_BAD_PLATFORM
46+
47+
:SETUP32
48+
set INCLUDE_PATH="%INPUT_DIRECTORY%\x86"
49+
goto BUILD_CLR_MODULE
50+
51+
:SETUP64
52+
set INCLUDE_PATH="%INPUT_DIRECTORY%\x64"
53+
set ILASM_EXTRA_ARGS=/pe64 /x64
54+
goto BUILD_CLR_MODULE
55+
56+
:ERROR_BAD_PLATFORM
57+
echo Unknown target platform: %TARGET_PLATFORM%
58+
exit /b 1
59+
60+
:ERROR_MISSING_INPUT
61+
echo Can't find input file: %INPUT_PATH%
62+
exit /b 1
63+
64+
:BUILD_CLR_MODULE
65+
if not exist %INPUT_PATH% goto ERROR_MISSING_INPUT
66+
%windir%\Microsoft.NET\Framework\v2.0.50727\ilasm /nologo /quiet /dll %ILASM_EXTRA_ARGS% /include=%INCLUDE_PATH% /output=%OUTPUT_PATH% %INPUT_PATH%

0 commit comments

Comments
 (0)