This repository has been archived by the owner on Jan 25, 2023. It is now read-only.
forked from pythonnet/pythonnet
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented auto symlink creation for required python library.
- Loading branch information
ivanov
committed
Oct 14, 2016
1 parent
6310f7b
commit 74636e7
Showing
7 changed files
with
116 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,70 @@ | ||
namespace Python.Bootstrapper.Test | ||
{ | ||
using System; | ||
using System.IO; | ||
|
||
using Runtime; | ||
public class Program | ||
{ | ||
static void Main(string[] args) | ||
static Program() | ||
{ | ||
Console.WriteLine("Starting application..."); | ||
|
||
// Required to be placed in the static constructor for Mono. | ||
var loadedLib = PythonRuntimeBootstrapper.DetectPythonAndRegisterRuntime(); | ||
Console.WriteLine($"{loadedLib} runtime loaded."); | ||
} | ||
static int Main(string[] args) | ||
{ | ||
PythonRuntimeBootstrapper.DetectPythonAndRegisterRuntime(); | ||
// Mono workaround required to fix AssemblyResolve + EntryPoint class bug. | ||
// Classes that was referenced from EntryPoint class cannot use assemblies resolved through "AssemblyResolve" | ||
Action monoWorkaround = () => | ||
{ | ||
try | ||
{ | ||
// You should put this initialized only if some component starting to use it before first application configuration file read attempt. | ||
// So in rare cases. | ||
//// PythonConfig.EnsureInitialized(); | ||
|
||
|
||
PythonEngine.Initialize(); | ||
|
||
try | ||
{ | ||
using (Py.GIL()) | ||
{ | ||
dynamic sysModule = Py.Import("sys"); | ||
Console.WriteLine("Python engine version:"); | ||
Console.WriteLine(sysModule.version); | ||
} | ||
|
||
// This workaround reduces risk of Mono crash. | ||
// Problem will be fixed in mono 4.6 | ||
if (Path.DirectorySeparatorChar == '/' || Type.GetType("Mono.Runtime") != null) | ||
{ | ||
Runtime.Py_Main(3, new[] { "/pcfgtest.exe", "-c", "exit" }); | ||
} | ||
else | ||
{ | ||
// Program will crash if we will try to do this under Windows. | ||
//// Runtime.Py_Main(3, new[] { "/pcfgtest.exe", "-c", "exit" }); | ||
} | ||
} | ||
finally | ||
{ | ||
PythonEngine.Shutdown(); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.WriteLine(ex); | ||
} | ||
|
||
}; | ||
|
||
monoWorkaround(); | ||
|
||
return 0; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters