Skip to content

Added Python 3.5 Support #104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pythonnet.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.30110.0
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.Runtime", "src\runtime\Python.Runtime.csproj", "{097B4AC0-74E9-4C58-BCF8-C69746EC8271}"
EndProject
Expand Down Expand Up @@ -89,10 +89,14 @@ Global
{E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseWin|x64.Build.0 = Release|x64
{E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseWin|x86.ActiveCfg = Release|x86
{E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseWin|x86.Build.0 = Release|x86
{86E834DE-1139-4511-96CC-69636A56E7AC}.DebugMono|x64.ActiveCfg = DebugWin|x64
{86E834DE-1139-4511-96CC-69636A56E7AC}.DebugMono|x86.ActiveCfg = DebugWin|x86
{86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWin|x64.ActiveCfg = DebugWin|x64
{86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWin|x64.Build.0 = DebugWin|x64
{86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWin|x86.ActiveCfg = DebugWin|x86
{86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWin|x86.Build.0 = DebugWin|x86
{86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseMono|x64.ActiveCfg = ReleaseWin|x64
{86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseMono|x86.ActiveCfg = ReleaseWin|x86
{86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseWin|x64.ActiveCfg = ReleaseWin|x64
{86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseWin|x64.Build.0 = ReleaseWin|x64
{86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseWin|x86.ActiveCfg = ReleaseWin|x86
Expand Down
8 changes: 4 additions & 4 deletions src/clrmodule/ClrModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public class clrModule
// ReSharper restore InconsistentNaming
// ReSharper restore CheckNamespace
{
// ReSharper disable InconsistentNaming
#if (PYTHON32 || PYTHON33 || PYTHON34)
// ReSharper disable InconsistentNaming
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
[RGiesecke.DllExport.DllExport("PyInit_clr", System.Runtime.InteropServices.CallingConvention.StdCall)]
public static IntPtr PyInit_clr()
#else
Expand Down Expand Up @@ -107,7 +107,7 @@ public static void initclr()
#if DEBUG_PRINT
System.Console.WriteLine("Could not load Python.Runtime, so sad.");
#endif
#if (PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
return IntPtr.Zero;
#else
return;
Expand All @@ -119,7 +119,7 @@ public static void initclr()
// So now we get the PythonEngine and execute the InitExt method on it.
var pythonEngineType = pythonRuntime.GetType("Python.Runtime.PythonEngine");

#if (PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
return (IntPtr)pythonEngineType.InvokeMember("InitExt", System.Reflection.BindingFlags.InvokeMethod, null, null, null);
#else
pythonEngineType.InvokeMember("InitExt", System.Reflection.BindingFlags.InvokeMethod, null, null, null);
Expand Down
19 changes: 12 additions & 7 deletions src/clrmodule/clrmodule.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseMono|x86'">
<OutputPath>bin\x86\ReleaseMono\</OutputPath>
<DefineConstants Condition="'$(DefineConstants)' == ''"></DefineConstants>
<DefineConstants Condition="'$(DefineConstants)' == ''">
</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
Expand All @@ -51,7 +52,8 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseMono|x64'">
<OutputPath>bin\x64\ReleaseMono\</OutputPath>
<DefineConstants Condition="'$(DefineConstants)' == ''"></DefineConstants>
<DefineConstants Condition="'$(DefineConstants)' == ''">
</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
Expand Down Expand Up @@ -84,7 +86,8 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseWin|x86'">
<OutputPath>bin\x86\ReleaseWin\</OutputPath>
<DefineConstants Condition="'$(DefineConstants)' == ''"></DefineConstants>
<DefineConstants Condition="'$(DefineConstants)' == ''">
</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
Expand All @@ -95,14 +98,16 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseWin|x64'">
<OutputPath>bin\x64\ReleaseWin\</OutputPath>
<DefineConstants Condition="'$(DefineConstants)' == ''"></DefineConstants>
<DefineConstants Condition="'$(DefineConstants)' == ''">
</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
<DefineConstants>PYTHON35</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="RGiesecke.DllExport.Metadata">
Expand All @@ -124,8 +129,8 @@
<TargetAssemblyPdb>$(TargetDir)$(TargetName).pdb</TargetAssemblyPdb>
</PropertyGroup>
<Target Name="AfterBuild" DependsOnTargets="RGieseckeDllExport">
<Copy SourceFiles="$(TargetAssembly)" DestinationFiles="$(PythonBuildDir)\clr.pyd" />
<Copy SourceFiles="$(TargetAssemblyPdb)" Condition="Exists('$(TargetAssemblyPdb)')" DestinationFiles="$(PythonBuildDir)\clr.pdb" />
<Copy SourceFiles="$(TargetAssembly)" DestinationFiles="$(PythonBuildDir)\clr.pyd" />
<Copy SourceFiles="$(TargetAssemblyPdb)" Condition="Exists('$(TargetAssemblyPdb)')" DestinationFiles="$(PythonBuildDir)\clr.pdb" />
</Target>
<Import Project="../../packages/UnmanagedExports.1.2.6/tools/RGiesecke.DllExport.targets" Condition="Exists('../../packages/UnmanagedExports.1.2.6/tools/RGiesecke.DllExport.targets')" />
</Project>
</Project>
53 changes: 27 additions & 26 deletions src/runtime/Python.Runtime.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AssemblyName>Python.Runtime</AssemblyName>
<RootNamespace>Python.Runtime</RootNamespace>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<PythonBuildDir Condition=" '$(PythonBuildDir)' == '' ">$(SolutionDir)</PythonBuildDir>
<PythonBuildDir Condition=" '$(PythonBuildDir)' == '' ">$(SolutionDir)</PythonBuildDir>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseMono|x86'">
<OutputPath>bin\x86\ReleaseMono\</OutputPath>
Expand Down Expand Up @@ -51,6 +51,7 @@
<PlatformTarget>x64</PlatformTarget>
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
<DefineConstants>PYTHON35, UCS2</DefineConstants>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be guarded with a condition on DefineConstants not being already set. Otherwise the ReleaseWin|x64 target will always try and build the Python 3.5 build, regardless of the settings passed in via setup.py.

This line can probably just be removed (see line 47 just above here).

</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugMono|x86'">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -94,27 +95,27 @@
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<Choose>
<When Condition=" '$(Configuration)'=='DebugMono' ">
<ItemGroup>
<Reference Include="Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\MonoGAC\Mono.Posix\4.0.0.0__0738eb9f132ed756\Mono.Posix.dll</HintPath>
</Reference>
</ItemGroup>
</When>
<When Condition=" '$(Configuration)'=='ReleaseMono' ">
<ItemGroup>
<Reference Include="Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\MonoGAC\Mono.Posix\4.0.0.0__0738eb9f132ed756\Mono.Posix.dll</HintPath>
</Reference>
</ItemGroup>
</When>
</Choose>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<Choose>
<When Condition=" '$(Configuration)'=='DebugMono' ">
<ItemGroup>
<Reference Include="Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\MonoGAC\Mono.Posix\4.0.0.0__0738eb9f132ed756\Mono.Posix.dll</HintPath>
</Reference>
</ItemGroup>
</When>
<When Condition=" '$(Configuration)'=='ReleaseMono' ">
<ItemGroup>
<Reference Include="Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\MonoGAC\Mono.Posix\4.0.0.0__0738eb9f132ed756\Mono.Posix.dll</HintPath>
</Reference>
</ItemGroup>
</When>
</Choose>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to avoid just white space differences when making feature changes. It makes it harder to see what the real diffs are.

<ItemGroup>
<Compile Include="arrayobject.cs" />
<Compile Include="assemblyinfo.cs" />
Expand Down Expand Up @@ -184,7 +185,7 @@
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="resources\clr.py">
<LogicalName>clr.py</LogicalName>
<LogicalName>clr.py</LogicalName>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
Expand All @@ -196,7 +197,7 @@
<TargetAssemblyPdb>$(TargetDir)$(TargetName).pdb</TargetAssemblyPdb>
</PropertyGroup>
<Target Name="AfterBuild">
<Copy SourceFiles="$(TargetAssembly)" DestinationFolder="$(PythonBuildDir)" />
<Copy SourceFiles="$(TargetAssemblyPdb)" Condition="Exists('$(TargetAssemblyPdb)')" DestinationFolder="$(PythonBuildDir)" />
<Copy SourceFiles="$(TargetAssembly)" DestinationFolder="$(PythonBuildDir)" />
<Copy SourceFiles="$(TargetAssemblyPdb)" Condition="Exists('$(TargetAssemblyPdb)')" DestinationFolder="$(PythonBuildDir)" />
</Target>
</Project>
</Project>
2 changes: 1 addition & 1 deletion src/runtime/classbase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public virtual IntPtr type_subscript(IntPtr idx) {
//====================================================================
// Standard comparison implementation for instances of reflected types.
//====================================================================
#if (PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
public static IntPtr tp_richcompare(IntPtr ob, IntPtr other, int op) {
if (op != Runtime.Py_EQ && op != Runtime.Py_NE)
{
Expand Down
8 changes: 4 additions & 4 deletions src/runtime/converter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ static bool ToPrimitive(IntPtr value, Type obType, out Object result,
return true;

case TypeCode.Int32:
#if !(PYTHON32 || PYTHON33 || PYTHON34)
#if !(PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
// Trickery to support 64-bit platforms.
if (IntPtr.Size == 4) {
op = Runtime.PyNumber_Int(value);
Expand Down Expand Up @@ -456,7 +456,7 @@ static bool ToPrimitive(IntPtr value, Type obType, out Object result,
return true;

case TypeCode.Byte:
#if (PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
if (Runtime.PyObject_TypeCheck(value, Runtime.PyBytesType))
{
if (Runtime.PyBytes_Size(value) == 1)
Expand Down Expand Up @@ -496,7 +496,7 @@ static bool ToPrimitive(IntPtr value, Type obType, out Object result,
return true;

case TypeCode.SByte:
#if (PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
if (Runtime.PyObject_TypeCheck(value, Runtime.PyBytesType)) {
if (Runtime.PyBytes_Size(value) == 1) {
op = Runtime.PyBytes_AS_STRING(value);
Expand Down Expand Up @@ -534,7 +534,7 @@ static bool ToPrimitive(IntPtr value, Type obType, out Object result,
return true;

case TypeCode.Char:
#if (PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
if (Runtime.PyObject_TypeCheck(value, Runtime.PyBytesType)) {
if (Runtime.PyBytes_Size(value) == 1) {
op = Runtime.PyBytes_AS_STRING(value);
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/delegateobject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static IntPtr tp_call(IntPtr ob, IntPtr args, IntPtr kw) {
//====================================================================
// Implements __cmp__ for reflected delegate types.
//====================================================================
#if (PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
public static new IntPtr tp_richcompare(IntPtr ob, IntPtr other, int op) {
if (op != Runtime.Py_EQ && op != Runtime.Py_NE)
{
Expand Down
14 changes: 7 additions & 7 deletions src/runtime/exceptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal class ExceptionClassObject : ClassObject {
internal ExceptionClassObject(Type tp) : base(tp) {
}

#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
internal static Exception ToException(IntPtr ob) {
CLRObject co = GetManagedObject(ob) as CLRObject;
if (co == null) {
Expand Down Expand Up @@ -114,7 +114,7 @@ public static IntPtr tp_getattro(IntPtr ob, IntPtr key)

return Runtime.PyObject_GenericGetAttr(ob, key);
}
#endif // (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34)
#endif // (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
}

/// <summary>
Expand All @@ -136,7 +136,7 @@ private Exceptions() {}
//===================================================================

internal static void Initialize() {
#if (PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
exceptions_module = Runtime.PyImport_ImportModule("builtins");
#else
exceptions_module = Runtime.PyImport_ImportModule("exceptions");
Expand Down Expand Up @@ -572,15 +572,15 @@ internal static IntPtr RaiseTypeError(string message) {
puplic static variables on the Exceptions class filled in from
the python class using reflection in Initialize() looked up by
name, not posistion. */
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
public static IntPtr BaseException;
#endif
public static IntPtr Exception;
public static IntPtr StopIteration;
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
public static IntPtr GeneratorExit;
#endif
#if !(PYTHON32 || PYTHON33 || PYTHON34)
#if !(PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
public static IntPtr StandardError;
#endif
public static IntPtr ArithmeticError;
Expand Down Expand Up @@ -637,7 +637,7 @@ puplic static variables on the Exceptions class filled in from
public static IntPtr SyntaxWarning;
public static IntPtr RuntimeWarning;
public static IntPtr FutureWarning;
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
public static IntPtr ImportWarning;
public static IntPtr UnicodeWarning;
//PyAPI_DATA(PyObject *) PyExc_BytesWarning;
Expand Down
10 changes: 5 additions & 5 deletions src/runtime/importhook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal class ImportHook {
static CLRModule root;
static MethodWrapper hook;

#if (PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
static IntPtr py_clr_module;
static IntPtr module_def;
#endif
Expand All @@ -38,7 +38,7 @@ internal static void Initialize() {
// but it provides the most "Pythonic" way of dealing with CLR
// modules (Python doesn't provide a way to emulate packages).
IntPtr dict = Runtime.PyImport_GetModuleDict();
#if (PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
IntPtr mod = Runtime.PyImport_ImportModule("builtins");
py_import = Runtime.PyObject_GetAttrString(mod, "__import__");
#else
Expand All @@ -51,7 +51,7 @@ internal static void Initialize() {

root = new CLRModule();

#if (PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
// create a python module with the same methods as the clr module-like object
module_def = ModuleDefOffset.AllocModuleDef("clr");
py_clr_module = Runtime.PyModule_Create2(module_def, 3);
Expand All @@ -78,7 +78,7 @@ internal static void Initialize() {
//===================================================================

internal static void Shutdown() {
#if (PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
if (0 != Runtime.Py_IsInitialized()) {
Runtime.Decref(py_clr_module);
Runtime.Decref(root.pyHandle);
Expand All @@ -100,7 +100,7 @@ internal static void Shutdown() {
//===================================================================
public static IntPtr GetCLRModule(IntPtr? fromList=null) {
root.InitializePreload();
#if (PYTHON32 || PYTHON33 || PYTHON34)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
// update the module dictionary with the contents of the root dictionary
root.LoadNames();
IntPtr py_mod_dict = Runtime.PyModule_GetDict(py_clr_module);
Expand Down
Loading