Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Drop a few more references to the version and fix build on Windows
  • Loading branch information
filmor committed Jun 18, 2020
commit 048219daec960326679050e3e4e8ac5d9085e699
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ def build_extension(self, ext):
if not enable_shared:
defines.append("PYTHON_WITHOUT_ENABLE_SHARED")

else:
defines.append("WINDOWS")

if hasattr(sys, "abiflags"):
if "d" in sys.abiflags:
defines.append("PYTHON_WITH_PYDEBUG")
Expand Down
26 changes: 0 additions & 26 deletions src/embed_tests/TestPythonEngineProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,6 @@ public void SetProgramName()
[Test]
public void SetPythonPath()
{
if (Runtime.Runtime.pyversion == "2.7")
{
// Assert.Skip outputs as a warning (ie. pending to fix)
Assert.Pass();
}

PythonEngine.Initialize();
string path = PythonEngine.PythonPath;
PythonEngine.Shutdown();
Expand All @@ -196,25 +190,5 @@ public void SetPythonPath()
Assert.AreEqual(path, PythonEngine.PythonPath);
PythonEngine.Shutdown();
}

[Test]
public void SetPythonPathExceptionOn27()
{
if (Runtime.Runtime.pyversion != "2.7")
{
Assert.Pass();
}

PythonEngine.Initialize();
string path = PythonEngine.PythonPath;
PythonEngine.Shutdown();

var ex = Assert.Throws<NotSupportedException>(() => PythonEngine.PythonPath = "foo");
Assert.AreEqual("Set PythonPath not supported on Python 2", ex.Message);

PythonEngine.Initialize();
Assert.AreEqual(path, PythonEngine.PythonPath);
PythonEngine.Shutdown();
}
}
}
30 changes: 8 additions & 22 deletions src/runtime/runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,36 +43,24 @@ public class Runtime
#error You must define either UCS2 or UCS4!
#endif

// C# compiler copies constants to the assemblies that references this library.
// We needs to replace all public constants to static readonly fields to allow
// binary substitution of different Python.Runtime.dll builds in a target application.

public static string pyversion => _pyversion;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@filmor I think a unit test depends on these public properties

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Which one? I was used in a few places, but only to check for Python 2 vs 3.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@filmor you already removed them actually from TestPythonEngineProperties.cs
Seems like this might require an entry in the changelog since its a breaking change technically

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, I could do that, but pyversion etc. where never really consumables in the first place. I'd like to move the whole Runtime to internal as a single Changelog entry, no need to do this for every single component.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@filmor moving Runtime to internal deserves its own tracking issue.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed: #1167

public static string pyver => _pyver;

#if PYTHON34
internal const string _pyversion = "3.4";
internal const string _pyver = "34";
const string _minor = "4";
#elif PYTHON35
internal const string _pyversion = "3.5";
internal const string _pyver = "35";
const string _minor = "5";
#elif PYTHON36
internal const string _pyversion = "3.6";
internal const string _pyver = "36";
const string _minor = "6";
#elif PYTHON37
internal const string _pyversion = "3.7";
internal const string _pyver = "37";
const string _minor = "7";
#elif PYTHON38
internal const string _pyversion = "3.8";
internal const string _pyver = "38";
const string _minor = "8";
#else
#error You must define one of PYTHON34 to PYTHON38
#endif

#if MONO_LINUX || MONO_OSX // Linux/macOS use dotted version string
internal const string dllBase = "python" + _pyversion;
#if !WINDOWS
internal const string dllBase = "python3" + _minor;
#else // Windows
internal const string dllBase = "python" + _pyver;
internal const string dllBase = "python3." + _minor;
#endif

#if PYTHON_WITH_PYDEBUG
Expand All @@ -98,8 +86,6 @@ public class Runtime
internal const string _PythonDll = dllBase + dllWithPyDebug + dllWithPyMalloc;
#endif

public static readonly int pyversionnumber = Convert.ToInt32(_pyver);

// set to true when python is finalizing
internal static object IsFinalizingLock = new object();
internal static bool IsFinalizing;
Expand Down