Skip to content

Commit 563a844

Browse files
author
dse
committed
DotNetCore + Ubuntu 14.04 x64 + Python 3.5 = all tests passed.
1 parent 36c2e85 commit 563a844

File tree

5 files changed

+83
-38
lines changed

5 files changed

+83
-38
lines changed

pythonnet.15.sln

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,28 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.EmbeddingTest.15", "
99
EndProject
1010
Global
1111
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12-
Debug|x64 = Debug|x64
1312
Debug-Linux-x64|x64 = Debug-Linux-x64|x64
1413
Debug-Win-x64|x64 = Debug-Win-x64|x64
15-
Release|x64 = Release|x64
1614
Release-Linux-x64|x64 = Release-Linux-x64|x64
1715
Release-Win-x64|x64 = Release-Win-x64|x64
1816
EndGlobalSection
1917
GlobalSection(ProjectConfigurationPlatforms) = postSolution
20-
{4D2089E1-5B6A-4799-984B-178AE467902D}.Debug|x64.ActiveCfg = Debug|x64
21-
{4D2089E1-5B6A-4799-984B-178AE467902D}.Debug|x64.Build.0 = Debug|x64
22-
{4D2089E1-5B6A-4799-984B-178AE467902D}.Debug-Linux-x64|x64.ActiveCfg = Release|x64
23-
{4D2089E1-5B6A-4799-984B-178AE467902D}.Debug-Linux-x64|x64.Build.0 = Debug|x64
18+
{4D2089E1-5B6A-4799-984B-178AE467902D}.Debug-Linux-x64|x64.ActiveCfg = Debug-Linux-x64|x64
19+
{4D2089E1-5B6A-4799-984B-178AE467902D}.Debug-Linux-x64|x64.Build.0 = Debug-Linux-x64|x64
2420
{4D2089E1-5B6A-4799-984B-178AE467902D}.Debug-Win-x64|x64.ActiveCfg = Debug-Win-x64|x64
2521
{4D2089E1-5B6A-4799-984B-178AE467902D}.Debug-Win-x64|x64.Build.0 = Debug-Win-x64|x64
26-
{4D2089E1-5B6A-4799-984B-178AE467902D}.Release|x64.ActiveCfg = Release|x64
27-
{4D2089E1-5B6A-4799-984B-178AE467902D}.Release|x64.Build.0 = Release|x64
28-
{4D2089E1-5B6A-4799-984B-178AE467902D}.Release-Linux-x64|x64.ActiveCfg = Release|x64
29-
{4D2089E1-5B6A-4799-984B-178AE467902D}.Release-Linux-x64|x64.Build.0 = Release|x64
30-
{4D2089E1-5B6A-4799-984B-178AE467902D}.Release-Win-x64|x64.ActiveCfg = Release|x64
31-
{4D2089E1-5B6A-4799-984B-178AE467902D}.Release-Win-x64|x64.Build.0 = Release|x64
32-
{4CACAA81-CC6A-4381-85B8-3A4B57EFE3BD}.Debug|x64.ActiveCfg = Debug|Any CPU
33-
{4CACAA81-CC6A-4381-85B8-3A4B57EFE3BD}.Debug|x64.Build.0 = Debug|Any CPU
34-
{4CACAA81-CC6A-4381-85B8-3A4B57EFE3BD}.Debug-Linux-x64|x64.ActiveCfg = Debug|Any CPU
35-
{4CACAA81-CC6A-4381-85B8-3A4B57EFE3BD}.Debug-Linux-x64|x64.Build.0 = Debug|Any CPU
22+
{4D2089E1-5B6A-4799-984B-178AE467902D}.Release-Linux-x64|x64.ActiveCfg = Release-Win-x64|x64
23+
{4D2089E1-5B6A-4799-984B-178AE467902D}.Release-Linux-x64|x64.Build.0 = Release-Win-x64|x64
24+
{4D2089E1-5B6A-4799-984B-178AE467902D}.Release-Win-x64|x64.ActiveCfg = Release-Win-x64|x64
25+
{4D2089E1-5B6A-4799-984B-178AE467902D}.Release-Win-x64|x64.Build.0 = Release-Win-x64|x64
26+
{4CACAA81-CC6A-4381-85B8-3A4B57EFE3BD}.Debug-Linux-x64|x64.ActiveCfg = Debug|x64
27+
{4CACAA81-CC6A-4381-85B8-3A4B57EFE3BD}.Debug-Linux-x64|x64.Build.0 = Debug|x64
3628
{4CACAA81-CC6A-4381-85B8-3A4B57EFE3BD}.Debug-Win-x64|x64.ActiveCfg = Debug|x64
3729
{4CACAA81-CC6A-4381-85B8-3A4B57EFE3BD}.Debug-Win-x64|x64.Build.0 = Debug|x64
38-
{4CACAA81-CC6A-4381-85B8-3A4B57EFE3BD}.Release|x64.ActiveCfg = Release|Any CPU
39-
{4CACAA81-CC6A-4381-85B8-3A4B57EFE3BD}.Release|x64.Build.0 = Release|Any CPU
40-
{4CACAA81-CC6A-4381-85B8-3A4B57EFE3BD}.Release-Linux-x64|x64.ActiveCfg = Release|Any CPU
41-
{4CACAA81-CC6A-4381-85B8-3A4B57EFE3BD}.Release-Linux-x64|x64.Build.0 = Release|Any CPU
42-
{4CACAA81-CC6A-4381-85B8-3A4B57EFE3BD}.Release-Win-x64|x64.ActiveCfg = Release|Any CPU
43-
{4CACAA81-CC6A-4381-85B8-3A4B57EFE3BD}.Release-Win-x64|x64.Build.0 = Release|Any CPU
30+
{4CACAA81-CC6A-4381-85B8-3A4B57EFE3BD}.Release-Linux-x64|x64.ActiveCfg = Release|x64
31+
{4CACAA81-CC6A-4381-85B8-3A4B57EFE3BD}.Release-Linux-x64|x64.Build.0 = Release|x64
32+
{4CACAA81-CC6A-4381-85B8-3A4B57EFE3BD}.Release-Win-x64|x64.ActiveCfg = Release|x64
33+
{4CACAA81-CC6A-4381-85B8-3A4B57EFE3BD}.Release-Win-x64|x64.Build.0 = Release|x64
4434
EndGlobalSection
4535
GlobalSection(SolutionProperties) = preSolution
4636
HideSolutionNode = FALSE
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
4+
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
5+
-->
6+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
7+
<PropertyGroup>
8+
<PublishProtocol>FileSystem</PublishProtocol>
9+
<Configuration>Debug-Linux-x64</Configuration>
10+
<TargetFramework>netcoreapp1.0</TargetFramework>
11+
<PublishDir>bin\publish\Debug-Linux-x64</PublishDir>
12+
<RuntimeIdentifier>ubuntu.14.04-x64</RuntimeIdentifier>
13+
</PropertyGroup>
14+
</Project>

src/embed_tests/Python.EmbeddingTest.15.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<OutputType>exe</OutputType>
44
<TargetFrameworks><!--net40;-->netcoreapp1.0</TargetFrameworks>
5-
<RuntimeIdentifiers>win7-x64;ubuntu.16.04-x64</RuntimeIdentifiers>
5+
<RuntimeIdentifiers>win7-x64;ubuntu.16.04-x64;ubuntu.14.04-x64</RuntimeIdentifiers>
66
<RootNamespace>Python.EmbeddingTest</RootNamespace>
77
<AssemblyName>Python.EmbeddingTest</AssemblyName>
88
<PackageId>Python.EmbeddingTest</PackageId>

src/runtime/Python.Runtime.15.csproj

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,49 @@
1212
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
1313
<!--<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>-->
1414
<NetStandardImplicitPackageVersion>1.6.0</NetStandardImplicitPackageVersion>
15+
</PropertyGroup>
16+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug-Linux-x64|net40|x64'">
17+
<PlatformTarget>x64</PlatformTarget>
18+
<DefineConstants>TRACE;DEBUG;X64;LINUX;UNIX;UCS4;PYTHON_WITH_PYMALLOC;MONO_LINUX</DefineConstants>
1519
</PropertyGroup>
16-
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug-Win-x64|net40|x64'">
20+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug-Linux-x64|netstandard1.5|x64'">
1721
<PlatformTarget>x64</PlatformTarget>
18-
<DefineConstants>TRACE;DEBUG;X64;LINUX;UNIX;NET40;UCS2;</DefineConstants>
22+
<DefineConstants>TRACE;DEBUG;X64;LINUX;UNIX;UCS4;PYTHON_WITH_PYMALLOC;MONO_LINUX</DefineConstants>
1923
</PropertyGroup>
20-
21-
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release-Win-x64|net40|x64'">
24+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release-Linux-x64|net40|x64'">
2225
<PlatformTarget>x64</PlatformTarget>
23-
<DefineConstants>TRACE;X64;LINUX;UNIX;NET40;UCS2;</DefineConstants>
26+
<DefineConstants>TRACE;DEBUG;X64;LINUX;UNIX;UCS4;PYTHON_WITH_PYMALLOC;MONO_LINUX</DefineConstants>
27+
</PropertyGroup>
28+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release-Linux-x64|netstandard1.5|x64'">
29+
<PlatformTarget>x64</PlatformTarget>
30+
<DefineConstants>TRACE;DEBUG;X64;LINUX;UNIX;UCS4;PYTHON_WITH_PYMALLOC;MONO_LINUX</DefineConstants>
2431
</PropertyGroup>
2532

33+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug-Win-x64|net40|x64'">
34+
<PlatformTarget>x64</PlatformTarget>
35+
<DefineConstants>TRACE;DEBUG;X64;UCS2</DefineConstants>
36+
</PropertyGroup>
2637
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug-Win-x64|netstandard1.5|x64'">
2738
<PlatformTarget>x64</PlatformTarget>
28-
<DefineConstants>TRACE;DEBUG;X64;LINUX;UNIX;NETSTANDARD1_5;UCS2;</DefineConstants>
39+
<DefineConstants>TRACE;DEBUG;X64;UCS2</DefineConstants>
40+
</PropertyGroup>
41+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release-Win-x64|net40|x64'">
42+
<PlatformTarget>x64</PlatformTarget>
43+
<DefineConstants>TRACE;X64;UCS2</DefineConstants>
2944
</PropertyGroup>
30-
3145
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release-Win-x64|netstandard1.5|x64'">
3246
<PlatformTarget>x64</PlatformTarget>
33-
<DefineConstants>TRACE;DEBUG;X64;LINUX;UNIX;NETSTANDARD1_5;UCS2;</DefineConstants>
47+
<DefineConstants>TRACE;DEBUG;X64;UCS2;</DefineConstants>
3448
</PropertyGroup>
3549

3650
<PropertyGroup>
3751
<DefineConstants>$(DefineConstants);XPLAT;REFLECTIONBRIDGE;PYTHON3;PYTHON35</DefineConstants>
3852
</PropertyGroup>
53+
54+
<PropertyGroup Condition="'$(Configuration.Substring(0,5))'=='Debug'">
55+
<!--MS bug, publish makes no sense to configuration name.-->
56+
<OutputPath>bin\Debug</OutputPath>
57+
</PropertyGroup>
3958

4059
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.5'">
4160
<PackageReference Include="System.AppDomain">

src/runtime/runtime.cs

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ internal static class NativeMethods
2424

2525
public static IntPtr LoadLibrary(string fileName)
2626
{
27+
#if NETSTANDARD1_5
28+
return dlopen(fileName, RTLD_NOW);
29+
#else
2730
return dlopen(fileName, RTLD_NOW | RTLD_SHARED);
31+
#endif
2832
}
2933

3034
public static void FreeLibrary(IntPtr handle)
@@ -281,9 +285,13 @@ internal static void Initialize()
281285
IntPtr dllLocal = IntPtr.Zero;
282286
if (PythonDll != "__Internal")
283287
{
288+
#if !NETSTANDARD1_5
284289
NativeMethods.LoadLibrary(PythonDll);
290+
#endif
285291
}
292+
#if !NETSTANDARD1_5
286293
_PyObject_NextNotImplemented = NativeMethods.GetProcAddress(dllLocal, "_PyObject_NextNotImplemented");
294+
#endif
287295
#if !(MONO_LINUX || MONO_OSX)
288296
if (dllLocal != IntPtr.Zero)
289297
{
@@ -648,8 +656,10 @@ string[] argv
648656
var unmanagedDataPtr = marshaler.MarshalManagedToNative(argv);
649657

650658
int result = Py_Main(argc, unmanagedDataPtr);
651-
652-
marshaler.CleanUpNativeData(unmanagedDataPtr);
659+
if (unmanagedDataPtr != IntPtr.Zero)
660+
{
661+
marshaler.CleanUpNativeData(unmanagedDataPtr);
662+
}
653663
return result;
654664
}
655665
#else
@@ -1207,7 +1217,10 @@ int size
12071217

12081218
IntPtr result = PyString_FromStringAndSize(unmanagedDataPtr, size);
12091219

1210-
marshaler.CleanUpNativeData(unmanagedDataPtr);
1220+
if (unmanagedDataPtr != IntPtr.Zero)
1221+
{
1222+
marshaler.CleanUpNativeData(unmanagedDataPtr);
1223+
}
12111224
return result;
12121225
}
12131226
#else
@@ -1262,7 +1275,11 @@ int size
12621275

12631276
IntPtr result = PyUnicode_FromKindAndData(kind, unmanagedDataPtr, size);
12641277

1265-
marshaler.CleanUpNativeData(unmanagedDataPtr);
1278+
if (unmanagedDataPtr != IntPtr.Zero)
1279+
{
1280+
marshaler.CleanUpNativeData(unmanagedDataPtr);
1281+
}
1282+
12661283
return result;
12671284
}
12681285
#else
@@ -1310,8 +1327,11 @@ int size
13101327
var unmanagedDataPtr = marshaler.MarshalManagedToNative(s);
13111328

13121329
IntPtr result = PyUnicode_FromUnicode(unmanagedDataPtr, size);
1330+
if (unmanagedDataPtr != IntPtr.Zero)
1331+
{
1332+
marshaler.CleanUpNativeData(unmanagedDataPtr);
1333+
}
13131334

1314-
marshaler.CleanUpNativeData(unmanagedDataPtr);
13151335
return result;
13161336
}
13171337
#else
@@ -1576,8 +1596,10 @@ int updatepath
15761596
var unmanagedDataPtr = marshaler.MarshalManagedToNative(argv);
15771597

15781598
PySys_SetArgvEx(argc, unmanagedDataPtr, updatepath);
1579-
1580-
marshaler.CleanUpNativeData(unmanagedDataPtr);
1599+
if (unmanagedDataPtr != IntPtr.Zero)
1600+
{
1601+
marshaler.CleanUpNativeData(unmanagedDataPtr);
1602+
}
15811603
}
15821604
#else
15831605
[DllImport(PythonDll)]

0 commit comments

Comments
 (0)