Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[WIP] PythonHome Path is correctly set#279

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
den-run-ai wants to merge2 commits intopythonnet:masterfromleomeuk:develop
Closed
Show file tree
Hide file tree
Changes fromall 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
32 changes: 32 additions & 0 deletionssrc/embed_tests/pysethome.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
using System;
using System.Reflection;
using System.Collections.Generic;
using NUnit.Framework;
using Python.Runtime;


namespace Python.EmbeddingTest
{
public class PySetHomeSet
{
[SetUp]
public void SetUp()
{
}

[TearDown]
public void TearDown()
{
PythonEngine.Shutdown();
}

[Test]
public void TestSetHome()
{
string homePath = @"C:\Python27\";
PythonEngine.PythonHome = homePath;
PythonEngine.Initialize();
Assert.AreEqual(PythonEngine.PythonHome, homePath);
}
}
}
6 changes: 4 additions & 2 deletionssrc/runtime/pythonengine.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,7 +11,8 @@
using System.IO;
using System.Threading;
using System.Reflection;

using System.Runtime.InteropServices;

namespace Python.Runtime {

/// <summary>
Expand DownExpand Up@@ -62,7 +63,8 @@ public static string PythonHome {
return result;
}
set {
Runtime.Py_SetPythonHome(value);
IntPtr pythonHome = Marshal.StringToHGlobalAnsi(value);
Runtime.Py_SetPythonHome(pythonHome);
}
}

Expand Down
10 changes: 5 additions & 5 deletionssrc/runtime/runtime.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -738,9 +738,9 @@ internal unsafe static extern IntPtr
[DllImport(Runtime.dll, CallingConvention=CallingConvention.Cdecl,
ExactSpelling=true, CharSet=CharSet.Ansi)]
internal unsafe static extern IntPtr
PyEval_GetLocals();


PyEval_GetLocals();
#if PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35
[DllImport(Runtime.dll, CallingConvention=CallingConvention.Cdecl,
ExactSpelling=true, CharSet=CharSet.Ansi)]
Expand All@@ -762,7 +762,7 @@ internal unsafe static extern string
[DllImport(Runtime.dll, CallingConvention=CallingConvention.Cdecl,
ExactSpelling=true, CharSet=CharSet.Ansi)]
internal unsafe static extern void
Py_SetPythonHome([MarshalAsAttribute(UnmanagedType.LPWStr)]string home);
Py_SetPythonHome(IntPtr home);

[DllImport(Runtime.dll, CallingConvention=CallingConvention.Cdecl,
ExactSpelling=true, CharSet=CharSet.Ansi)]
Expand DownExpand Up@@ -793,7 +793,7 @@ internal unsafe static extern string
[DllImport(Runtime.dll, CallingConvention = CallingConvention.Cdecl,
ExactSpelling = true, CharSet = CharSet.Ansi)]
internal unsafe static extern void
Py_SetPythonHome(string home);
Py_SetPythonHome(IntPtr home);

[DllImport(Runtime.dll, CallingConvention = CallingConvention.Cdecl,
ExactSpelling = true, CharSet = CharSet.Ansi)]
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp