Skip to content

Commit bbe316f

Browse files
committed
Enable debugging
1 parent 3685555 commit bbe316f

File tree

9 files changed

+35
-350
lines changed

9 files changed

+35
-350
lines changed

pythonnet.sln

Lines changed: 0 additions & 344 deletions
Large diffs are not rendered by default.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def initialize_options(self):
110110

111111
def finalize_options(self):
112112
if self.dotnet_config is None:
113-
self.dotnet_config = "release"
113+
self.dotnet_config = "debug"
114114

115115
build = self.distribution.get_command_obj("build")
116116
build.ensure_finalized()

src/clrmodule/ClrModule.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
using System.IO;
2727
using System.Reflection;
2828
using System.Runtime.InteropServices;
29+
2930
using NXPorts.Attributes;
3031

3132
public class clrModule
@@ -62,9 +63,9 @@ public static IntPtr PyInit_clr()
6263
pythonRuntime = Assembly.Load(pythonRuntimeName);
6364
DebugPrint("Success loading 'Python.Runtime' using standard binding rules.");
6465
}
65-
catch (IOException)
66+
catch (IOException ex)
6667
{
67-
DebugPrint("'Python.Runtime' not found using standard binding rules.");
68+
DebugPrint($"'Python.Runtime' not found using standard binding rules: {ex}");
6869
try
6970
{
7071
// If the above fails for any reason, we fallback to attempting to load "Python.Runtime.dll"
@@ -78,6 +79,10 @@ public static IntPtr PyInit_clr()
7879

7980
Assembly executingAssembly = Assembly.GetExecutingAssembly();
8081
string assemblyDirectory = Path.GetDirectoryName(executingAssembly.Location);
82+
#if DEBUG
83+
string newAssemblyDirectory = Path.Combine(assemblyDirectory, @"..\..\..\src\runtime\bin\Debug\netstandard2.0");
84+
if (Directory.Exists(newAssemblyDirectory)) assemblyDirectory = newAssemblyDirectory;
85+
#endif
8186
if (assemblyDirectory == null)
8287
{
8388
throw new InvalidOperationException(executingAssembly.Location);

src/embed_tests/Python.EmbeddingTest.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks>
4+
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
55
</PropertyGroup>
66

77
<ItemGroup>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"profiles": {
3+
"Python.Runtime": {
4+
"commandName": "Executable",
5+
"executablePath": "C:\\Users\\minka\\Depots\\pythonnet\\src\\tests\\Pythonnet\\Scripts\\python.exe",
6+
"commandLineArgs": "\\users\\minka\\Depots\\pythonnet\\src\\tests\\runtests.py \\users\\minka\\Depots\\pythonnet\\src\\tests"
7+
}
8+
}
9+
}

src/runtime/Python.Runtime.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>netstandard2.0</TargetFrameworks>
3+
<TargetFramework>netstandard2.0</TargetFramework>
44
<Platforms>AnyCPU</Platforms>
55
<RootNamespace>Python.Runtime</RootNamespace>
66
<AssemblyName>Python.Runtime</AssemblyName>
@@ -17,6 +17,8 @@
1717

1818
<PropertyGroup>
1919
<DefineConstants>TRACE;PYTHON37;WINDOWS</DefineConstants>
20+
<DebugType>full</DebugType>
21+
<DebugSymbols>true</DebugSymbols>
2022
</PropertyGroup>
2123

2224
<ItemGroup Condition=" '$(PythonInteropFile)' != '' ">

src/tests/conftest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@
1111

1212
import pytest
1313

14+
#if os.getenv('_PYTEST_RAISE', "0") != "0":
15+
16+
#@pytest.hookimpl(tryfirst=True)
17+
#def pytest_exception_interact(call):
18+
# raise call.excinfo.value
19+
20+
#@pytest.hookimpl(tryfirst=True)
21+
#def pytest_internalerror(excinfo):
22+
# raise excinfo.value
23+
1424
# Add path for `Python.Test`
1525
cwd = os.path.dirname(__file__)
1626
fixtures_path = os.path.join(cwd, "fixtures")

src/tests/runtests.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
print("Load clr import hook")
1515
import clr
1616

17-
clr.AddReference("Python.Test")
17+
#clr.AddReference("Python.Test")
1818
clr.AddReference("System.Collections")
1919
clr.AddReference("System.Data")
2020
clr.AddReference("System.Management")
@@ -29,6 +29,8 @@ def main(verbosity=1):
2929
# FIXME: test_engine has tests that are being skipped.
3030
# FIXME: test_subclass has tests that are being skipped.
3131
pytest.main()
32+
print("Done")
33+
input()
3234

3335

3436
if __name__ == '__main__':

src/tests/tests.pyproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<VisualStudioVersion Condition=" '$(VisualStudioVersion)' == '' ">10.0</VisualStudioVersion>
2929
</PropertyGroup>
3030
<ItemGroup>
31+
<Compile Include="conftest.py" />
3132
<Compile Include="__init__.py" />
3233
<Compile Include="_missing_import.py" />
3334
<Compile Include="leaktest.py" />

0 commit comments

Comments
 (0)