From 5a45156cacd2871cd5ec522fa910f3211c1ea8b9 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Sat, 9 Nov 2019 09:31:12 +0100 Subject: [PATCH 01/22] Drop monoclr and clrmodule --- pythonnet.15.sln | 2 - pythonnet.sln | 2 - setup.py | 44 +--- src/clrmodule/ClrModule.cs | 126 ------------ src/clrmodule/Properties/AssemblyInfo.cs | 11 - src/clrmodule/clrmodule.15.csproj | 95 --------- src/clrmodule/clrmodule.csproj | 95 --------- src/clrmodule/packages.config | 4 - src/monoclr/clrmod.c | 70 ------- src/monoclr/pynetclr.h | 33 --- src/monoclr/pynetinit.c | 252 ----------------------- 11 files changed, 1 insertion(+), 733 deletions(-) delete mode 100644 src/clrmodule/ClrModule.cs delete mode 100644 src/clrmodule/Properties/AssemblyInfo.cs delete mode 100644 src/clrmodule/clrmodule.15.csproj delete mode 100644 src/clrmodule/clrmodule.csproj delete mode 100644 src/clrmodule/packages.config delete mode 100644 src/monoclr/clrmod.c delete mode 100644 src/monoclr/pynetclr.h delete mode 100644 src/monoclr/pynetinit.c diff --git a/pythonnet.15.sln b/pythonnet.15.sln index 096dfbe9a..e57c74582 100644 --- a/pythonnet.15.sln +++ b/pythonnet.15.sln @@ -6,8 +6,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.Runtime.15", "src\ru EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.EmbeddingTest.15", "src\embed_tests\Python.EmbeddingTest.15.csproj", "{66B8D01A-9906-452A-B09E-BF75EA76468F}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "clrmodule.15", "src\clrmodule\clrmodule.15.csproj", "{E08678D4-9A52-4AD5-B63D-8EBC7399981B}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Console.15", "src\console\Console.15.csproj", "{CDAD305F-8E72-492C-A314-64CF58D472A0}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.Test.15", "src\testing\Python.Test.15.csproj", "{F94B547A-E97E-4500-8D53-B4D64D076E5F}" diff --git a/pythonnet.sln b/pythonnet.sln index c5afd66c3..d07bd654d 100644 --- a/pythonnet.sln +++ b/pythonnet.sln @@ -10,8 +10,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.EmbeddingTest", "src EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Console", "src\console\Console.csproj", "{E29DCF0A-5114-4A98-B1DD-71264B6EA349}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "clrmodule", "src\clrmodule\clrmodule.csproj", "{86E834DE-1139-4511-96CC-69636A56E7AC}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution DebugMono|x64 = DebugMono|x64 diff --git a/setup.py b/setup.py index c6e4007e6..50a3160f1 100644 --- a/setup.py +++ b/setup.py @@ -167,23 +167,6 @@ def _get_interop_filename(): return os.path.join("src", "runtime", interop_filename) -def _get_source_files(): - """Walk project and collect the files needed for ext_module""" - for ext in (".sln",): - for path in glob.glob("*" + ext): - yield path - - for root, dirnames, filenames in os.walk("src"): - for ext in (".cs", ".csproj", ".snk", ".config", ".py", ".c", ".h", ".ico"): - for filename in fnmatch.filter(filenames, "*" + ext): - yield os.path.join(root, filename) - - for root, dirnames, filenames in os.walk("tools"): - for ext in (".exe", ".py", ".c", ".h"): - for filename in fnmatch.filter(filenames, "*" + ext): - yield os.path.join(root, filename) - - def _get_long_description(): """Helper to populate long_description for pypi releases""" return open("README.rst").read() @@ -362,8 +345,6 @@ def build_extension(self, ext): ), shell=use_shell, ) - if DEVTOOLS == "Mono" or DEVTOOLS == "dotnet": - self._build_monoclr() def _get_manifest(self, build_dir): if DEVTOOLS != "MsDev" and DEVTOOLS != "MsDev15": @@ -379,30 +360,6 @@ def _get_manifest(self, build_dir): subprocess.check_call(" ".join(cmd), shell=False) return manifest - def _build_monoclr(self): - try: - mono_libs = _check_output("pkg-config --libs mono-2", shell=True) - except: - if DEVTOOLS == "dotnet": - print("Skipping building monoclr module...") - return - raise - mono_cflags = _check_output("pkg-config --cflags mono-2", shell=True) - glib_libs = _check_output("pkg-config --libs glib-2.0", shell=True) - glib_cflags = _check_output("pkg-config --cflags glib-2.0", shell=True) - cflags = mono_cflags.strip() + " " + glib_cflags.strip() - libs = mono_libs.strip() + " " + glib_libs.strip() - - # build the clr python module - clr_ext = Extension( - "clr", - sources=["src/monoclr/pynetinit.c", "src/monoclr/clrmod.c"], - extra_compile_args=cflags.split(" "), - extra_link_args=libs.split(" "), - ) - - build_ext.build_ext.build_extension(self, clr_ext) - def _install_packages(self): """install packages using nuget""" use_shell = DEVTOOLS == "Mono" or DEVTOOLS == "dotnet" @@ -643,6 +600,7 @@ def run(self): author="The Python for .Net developers", author_email="pythondotnet@python.org", setup_requires=setup_requires, + install_requires=["clr_loader"], long_description=_get_long_description(), ext_modules=[Extension("clr", sources=list(_get_source_files()))], data_files=[("{install_platlib}", ["{build_lib}/Python.Runtime.dll"])], diff --git a/src/clrmodule/ClrModule.cs b/src/clrmodule/ClrModule.cs deleted file mode 100644 index 7fc654fd6..000000000 --- a/src/clrmodule/ClrModule.cs +++ /dev/null @@ -1,126 +0,0 @@ -//============================================================================ -// This file replaces the hand-maintained stub that used to implement clr.dll. -// This is a line-by-line port from IL back to C#. -// We now use RGiesecke.DllExport on the required static init method so it can be -// loaded by a standard CPython interpreter as an extension module. When it -// is loaded, it bootstraps the managed runtime integration layer and defers -// to it to do initialization and put the clr module into sys.modules, etc. - -// The "USE_PYTHON_RUNTIME_*" defines control what extra evidence is used -// to help the CLR find the appropriate Python.Runtime assembly. - -// If defined, the "pythonRuntimeVersionString" variable must be set to -// Python.Runtime's current version. -#define USE_PYTHON_RUNTIME_VERSION - -// If defined, the "PythonRuntimePublicKeyTokenData" data array must be -// set to Python.Runtime's public key token. (sn -T Python.Runtin.dll) -#define USE_PYTHON_RUNTIME_PUBLIC_KEY_TOKEN - -// If DEBUG is defined in the Build Properties, a few Console.WriteLine -// calls are made to indicate what's going on during the load... -//============================================================================ -using System; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using System.Reflection; -using System.Runtime.InteropServices; -using RGiesecke.DllExport; - -public class clrModule -{ -#if PYTHON3 - [DllExport("PyInit_clr", CallingConvention.StdCall)] - public static IntPtr PyInit_clr() -#elif PYTHON2 - [DllExport("initclr", CallingConvention.StdCall)] - public static void initclr() -#endif - { - DebugPrint("Attempting to load 'Python.Runtime' using standard binding rules."); -#if USE_PYTHON_RUNTIME_PUBLIC_KEY_TOKEN - var pythonRuntimePublicKeyTokenData = new byte[] { 0x50, 0x00, 0xfe, 0xa6, 0xcb, 0xa7, 0x02, 0xdd }; -#endif - - // Attempt to find and load Python.Runtime using standard assembly binding rules. - // This roughly translates into looking in order: - // - GAC - // - ApplicationBase - // - A PrivateBinPath under ApplicationBase - // With an unsigned assembly, the GAC is skipped. - var pythonRuntimeName = new AssemblyName("Python.Runtime") - { -#if USE_PYTHON_RUNTIME_VERSION - // Has no effect until SNK works. Keep updated anyways. - Version = new Version("2.4.1"), -#endif - CultureInfo = CultureInfo.InvariantCulture - }; -#if USE_PYTHON_RUNTIME_PUBLIC_KEY_TOKEN - pythonRuntimeName.SetPublicKeyToken(pythonRuntimePublicKeyTokenData); -#endif - // We've got the AssemblyName with optional features; try to load it. - Assembly pythonRuntime; - try - { - pythonRuntime = Assembly.Load(pythonRuntimeName); - DebugPrint("Success loading 'Python.Runtime' using standard binding rules."); - } - catch (IOException) - { - DebugPrint("'Python.Runtime' not found using standard binding rules."); - try - { - // If the above fails for any reason, we fallback to attempting to load "Python.Runtime.dll" - // from the directory this assembly is running in. "This assembly" is probably "clr.pyd", - // sitting somewhere in PYTHONPATH. This is using Assembly.LoadFrom, and inherits all the - // caveats of that call. See MSDN docs for details. - // Suzanne Cook's blog is also an excellent source of info on this: - // http://blogs.msdn.com/suzcook/ - // http://blogs.msdn.com/suzcook/archive/2003/05/29/57143.aspx - // http://blogs.msdn.com/suzcook/archive/2003/06/13/57180.aspx - - Assembly executingAssembly = Assembly.GetExecutingAssembly(); - string assemblyDirectory = Path.GetDirectoryName(executingAssembly.Location); - if (assemblyDirectory == null) - { - throw new InvalidOperationException(executingAssembly.Location); - } - string pythonRuntimeDllPath = Path.Combine(assemblyDirectory, "Python.Runtime.dll"); - DebugPrint($"Attempting to load Python.Runtime from: '{pythonRuntimeDllPath}'."); - pythonRuntime = Assembly.LoadFrom(pythonRuntimeDllPath); - DebugPrint($"Success loading 'Python.Runtime' from: '{pythonRuntimeDllPath}'."); - } - catch (InvalidOperationException) - { - DebugPrint("Could not load 'Python.Runtime'."); -#if PYTHON3 - return IntPtr.Zero; -#elif PYTHON2 - return; -#endif - } - } - - // Once here, we've successfully loaded SOME version of Python.Runtime - // So now we get the PythonEngine and execute the InitExt method on it. - Type pythonEngineType = pythonRuntime.GetType("Python.Runtime.PythonEngine"); - -#if PYTHON3 - return (IntPtr)pythonEngineType.InvokeMember("InitExt", BindingFlags.InvokeMethod, null, null, null); -#elif PYTHON2 - pythonEngineType.InvokeMember("InitExt", BindingFlags.InvokeMethod, null, null, null); -#endif - } - - /// - /// Substitute for Debug.Writeline(...). Ideally we would use Debug.Writeline - /// but haven't been able to configure the TRACE from within Python. - /// - [Conditional("DEBUG")] - private static void DebugPrint(string str) - { - Console.WriteLine(str); - } -} diff --git a/src/clrmodule/Properties/AssemblyInfo.cs b/src/clrmodule/Properties/AssemblyInfo.cs deleted file mode 100644 index 939f4171f..000000000 --- a/src/clrmodule/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("clrmodule")] -[assembly: AssemblyDescription("")] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("ae10d6a4-55c2-482f-9716-9988e6c169e3")] diff --git a/src/clrmodule/clrmodule.15.csproj b/src/clrmodule/clrmodule.15.csproj deleted file mode 100644 index 326620c00..000000000 --- a/src/clrmodule/clrmodule.15.csproj +++ /dev/null @@ -1,95 +0,0 @@ - - - - - - net40 - x64;x86 - DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3 - clrmodule - clrmodule - clrmodule - 2.4.1 - false - false - false - false - false - false - bin\clrmodule.xml - bin\ - false - 1591 - ..\..\ - $(SolutionDir)\bin\ - $(PythonBuildDir)\$(TargetFramework)\ - 6 - prompt - $(PYTHONNET_DEFINE_CONSTANTS) - XPLAT - $(DefineConstants);$(CustomDefineConstants);$(BaseDefineConstants); - $(DefineConstants);TRACE;DEBUG - - - - x86 - - - x64 - - - - false - full - - - true - pdbonly - - - - $(DefineConstants);PYTHON2;TRACE;DEBUG - - - $(DefineConstants);PYTHON2 - - - $(DefineConstants);PYTHON2;TRACE;DEBUG - - - $(DefineConstants);PYTHON2 - - - $(DefineConstants);PYTHON3;TRACE;DEBUG - - - $(DefineConstants);PYTHON3 - - - $(DefineConstants);PYTHON3;TRACE;DEBUG - - - $(DefineConstants);PYTHON3 - - - - - - - - - - - - - - $(TargetPath) - $(TargetDir)$(TargetName).pdb - - - - - - - - diff --git a/src/clrmodule/clrmodule.csproj b/src/clrmodule/clrmodule.csproj deleted file mode 100644 index 6e5ff4966..000000000 --- a/src/clrmodule/clrmodule.csproj +++ /dev/null @@ -1,95 +0,0 @@ - - - - Debug - AnyCPU - {86E834DE-1139-4511-96CC-69636A56E7AC} - Library - clrmodule - clrmodule - bin\clrmodule.xml - bin\ - v4.0 - - 1591 - ..\..\ - $(SolutionDir)\bin\ - Properties - 6 - true - prompt - - - x86 - - - x64 - - - true - PYTHON2;TRACE;DEBUG - full - - - PYTHON2 - true - pdbonly - - - true - PYTHON2;TRACE;DEBUG - full - - - PYTHON2 - true - pdbonly - - - true - PYTHON3;TRACE;DEBUG - full - - - PYTHON3 - true - pdbonly - - - true - PYTHON3;TRACE;DEBUG - full - - - PYTHON3 - true - pdbonly - - - - ..\..\packages\UnmanagedExports.1.2.7\lib\net\RGiesecke.DllExport.Metadata.dll - False - - - - - - - Properties\SharedAssemblyInfo.cs - - - - - - - - - $(TargetPath) - $(TargetDir)$(TargetName).pdb - - - - - - - diff --git a/src/clrmodule/packages.config b/src/clrmodule/packages.config deleted file mode 100644 index 2a95dc54d..000000000 --- a/src/clrmodule/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/src/monoclr/clrmod.c b/src/monoclr/clrmod.c deleted file mode 100644 index 4e8027e3a..000000000 --- a/src/monoclr/clrmod.c +++ /dev/null @@ -1,70 +0,0 @@ -#include "pynetclr.h" - -/* List of functions defined in the module */ -static PyMethodDef clr_methods[] = { - {NULL, NULL, 0, NULL} /* Sentinel */ -}; - -PyDoc_STRVAR(clr_module_doc, - "clr facade module to initialize the CLR. It's later " - "replaced by the real clr module. This module has a facade " - "attribute to make it distinguishable from the real clr module." -); - -static PyNet_Args *pn_args; -char **environ = NULL; - -#if PY_MAJOR_VERSION >= 3 -static struct PyModuleDef clrdef = { - PyModuleDef_HEAD_INIT, - "clr", /* m_name */ - clr_module_doc, /* m_doc */ - -1, /* m_size */ - clr_methods, /* m_methods */ - NULL, /* m_reload */ - NULL, /* m_traverse */ - NULL, /* m_clear */ - NULL, /* m_free */ -}; -#endif - -static PyObject *_initclr() -{ - PyObject *m; - - /* Create the module and add the functions */ -#if PY_MAJOR_VERSION >= 3 - m = PyModule_Create(&clrdef); -#else - m = Py_InitModule3("clr", clr_methods, clr_module_doc); -#endif - if (m == NULL) - return NULL; - PyModule_AddObject(m, "facade", Py_True); - Py_INCREF(Py_True); - - pn_args = PyNet_Init(1); - if (pn_args->error) - { - return NULL; - } - - if (NULL != pn_args->module) - return pn_args->module; - - return m; -} - -#if PY_MAJOR_VERSION >= 3 -PyMODINIT_FUNC -PyInit_clr(void) -{ - return _initclr(); -} -#else -PyMODINIT_FUNC -initclr(void) -{ - _initclr(); -} -#endif diff --git a/src/monoclr/pynetclr.h b/src/monoclr/pynetclr.h deleted file mode 100644 index c5e181156..000000000 --- a/src/monoclr/pynetclr.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef PYNET_CLR_H -#define PYNET_CLR_H - -#include -#include -#include -#include -#include -#include -#include - -#define MONO_VERSION "v4.0.30319.1" -#define MONO_DOMAIN "Python.Runtime" -#define PR_ASSEMBLY "Python.Runtime.dll" - -typedef struct -{ - MonoDomain *domain; - MonoAssembly *pr_assm; - MonoMethod *shutdown; - char *pr_file; - char *error; - char *init_name; - char *shutdown_name; - PyObject *module; -} PyNet_Args; - -PyNet_Args *PyNet_Init(int); -void PyNet_Finalize(PyNet_Args *); -void main_thread_handler(gpointer user_data); -char *PyNet_ExceptionToString(MonoObject *); - -#endif // PYNET_CLR_H diff --git a/src/monoclr/pynetinit.c b/src/monoclr/pynetinit.c deleted file mode 100644 index 8b49ddae3..000000000 --- a/src/monoclr/pynetinit.c +++ /dev/null @@ -1,252 +0,0 @@ -#include "pynetclr.h" -#include "stdlib.h" - -#ifndef _WIN32 -#include "dirent.h" -#include "dlfcn.h" -#include "libgen.h" -#include "alloca.h" -#endif - - -// initialize Mono and PythonNet -PyNet_Args *PyNet_Init(int ext) -{ - PyNet_Args *pn_args; - pn_args = (PyNet_Args *)malloc(sizeof(PyNet_Args)); - pn_args->pr_file = PR_ASSEMBLY; - pn_args->error = NULL; - pn_args->shutdown = NULL; - pn_args->module = NULL; - - if (ext == 0) - { - pn_args->init_name = "Python.Runtime:Initialize()"; - } - else - { - pn_args->init_name = "Python.Runtime:InitExt()"; - } - pn_args->shutdown_name = "Python.Runtime:Shutdown()"; - - pn_args->domain = mono_jit_init_version(MONO_DOMAIN, MONO_VERSION); - mono_domain_set_config(pn_args->domain, ".", "Python.Runtime.dll.config"); - - /* - * Load the default Mono configuration file, this is needed - * if you are planning on using the dllmaps defined on the - * system configuration - */ - mono_config_parse(NULL); - - /* I can't use this call to run the main_thread_handler. The function - * runs it in another thread but *this* thread holds the Python - * import lock -> DEAD LOCK. - * - * mono_runtime_exec_managed_code(pn_args->domain, main_thread_handler, - * pn_args); - */ - - main_thread_handler(pn_args); - - if (pn_args->error != NULL) - { - PyErr_SetString(PyExc_ImportError, pn_args->error); - } - return pn_args; -} - -// Shuts down PythonNet and cleans up Mono -void PyNet_Finalize(PyNet_Args *pn_args) -{ - MonoObject *exception = NULL; - - if (pn_args->shutdown) - { - mono_runtime_invoke(pn_args->shutdown, NULL, NULL, &exception); - if (exception) - { - pn_args->error = PyNet_ExceptionToString(exception); - } - pn_args->shutdown = NULL; - } - - if (pn_args->domain) - { - mono_jit_cleanup(pn_args->domain); - pn_args->domain = NULL; - } - free(pn_args); -} - -MonoMethod *getMethodFromClass(MonoClass *cls, char *name) -{ - MonoMethodDesc *mdesc; - MonoMethod *method; - - mdesc = mono_method_desc_new(name, 1); - method = mono_method_desc_search_in_class(mdesc, cls); - mono_method_desc_free(mdesc); - - return method; -} - -void main_thread_handler(gpointer user_data) -{ - PyNet_Args *pn_args = (PyNet_Args *)user_data; - MonoMethod *init; - MonoImage *pr_image; - MonoClass *pythonengine; - MonoObject *exception = NULL; - MonoObject *init_result; - -#ifndef _WIN32 - // Get the filename of the python shared object and set - // LD_LIBRARY_PATH so Mono can find it. - Dl_info dlinfo = {0}; - if (0 != dladdr(&Py_Initialize, &dlinfo)) - { - char *fname = alloca(strlen(dlinfo.dli_fname) + 1); - strcpy(fname, dlinfo.dli_fname); - char *py_libdir = dirname(fname); - char *ld_library_path = getenv("LD_LIBRARY_PATH"); - if (NULL == ld_library_path) - { - setenv("LD_LIBRARY_PATH", py_libdir, 1); - } - else - { - char *new_ld_library_path = alloca(strlen(py_libdir) - + strlen(ld_library_path) - + 2); - strcpy(new_ld_library_path, py_libdir); - strcat(new_ld_library_path, ":"); - strcat(new_ld_library_path, ld_library_path); - setenv("LD_LIBRARY_PATH", py_libdir, 1); - } - } - - //get python path system variable - PyObject *syspath = PySys_GetObject("path"); - char *runtime_full_path = (char*) malloc(1024); - const char *slash = "/"; - int found = 0; - - int ii = 0; - for (ii = 0; ii < PyList_Size(syspath); ++ii) - { -#if PY_MAJOR_VERSION >= 3 - Py_ssize_t wlen; - wchar_t *wstr = PyUnicode_AsWideCharString(PyList_GetItem(syspath, ii), &wlen); - char *pydir = (char*)malloc(wlen + 1); - size_t mblen = wcstombs(pydir, wstr, wlen + 1); - if (mblen > wlen) - pydir[wlen] = '\0'; - PyMem_Free(wstr); -#else - const char *pydir = PyString_AsString(PyList_GetItem(syspath, ii)); -#endif - char *curdir = (char*) malloc(1024); - strncpy(curdir, strlen(pydir) > 0 ? pydir : ".", 1024); - strncat(curdir, slash, 1024); - -#if PY_MAJOR_VERSION >= 3 - free(pydir); -#endif - - //look in this directory for the pn_args->pr_file - DIR *dirp = opendir(curdir); - if (dirp != NULL) - { - struct dirent *dp; - while ((dp = readdir(dirp)) != NULL) - { - if (strcmp(dp->d_name, pn_args->pr_file) == 0) - { - strcpy(runtime_full_path, curdir); - strcat(runtime_full_path, pn_args->pr_file); - found = 1; - break; - } - } - closedir(dirp); - } - free(curdir); - - if (found) - { - pn_args->pr_file = runtime_full_path; - break; - } - } - - if (!found) - { - fprintf(stderr, "Could not find assembly %s. \n", pn_args->pr_file); - return; - } -#endif - - pn_args->pr_assm = mono_domain_assembly_open(pn_args->domain, pn_args->pr_file); - if (!pn_args->pr_assm) - { - pn_args->error = "Unable to load assembly"; - return; - } -#ifndef _WIN32 - free(runtime_full_path); -#endif - - pr_image = mono_assembly_get_image(pn_args->pr_assm); - if (!pr_image) - { - pn_args->error = "Unable to get image"; - return; - } - - pythonengine = mono_class_from_name(pr_image, "Python.Runtime", "PythonEngine"); - if (!pythonengine) - { - pn_args->error = "Unable to load class PythonEngine from Python.Runtime"; - return; - } - - init = getMethodFromClass(pythonengine, pn_args->init_name); - if (!init) - { - pn_args->error = "Unable to fetch Init method from PythonEngine"; - return; - } - - pn_args->shutdown = getMethodFromClass(pythonengine, pn_args->shutdown_name); - if (!pn_args->shutdown) - { - pn_args->error = "Unable to fetch shutdown method from PythonEngine"; - return; - } - - init_result = mono_runtime_invoke(init, NULL, NULL, &exception); - if (exception) - { - pn_args->error = PyNet_ExceptionToString(exception); - return; - } - -#if PY_MAJOR_VERSION >= 3 - if (NULL != init_result) - pn_args->module = *(PyObject**)mono_object_unbox(init_result); -#endif -} - -// Get string from a Mono exception -char *PyNet_ExceptionToString(MonoObject *e) -{ - MonoMethodDesc *mdesc = mono_method_desc_new(":ToString()", FALSE); - MonoMethod *mmethod = mono_method_desc_search_in_class(mdesc, mono_get_object_class()); - mono_method_desc_free(mdesc); - - mmethod = mono_object_get_virtual_method(e, mmethod); - MonoString *monoString = (MonoString*) mono_runtime_invoke(mmethod, e, NULL, NULL); - mono_runtime_invoke(mmethod, e, NULL, NULL); - return mono_string_to_utf8(monoString); -} From 2f077746bb3bd6079001d24e276585e44a74e3a2 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Tue, 26 Nov 2019 18:00:42 +0100 Subject: [PATCH 02/22] Add stub module --- pythonnet/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 pythonnet/__init__.py diff --git a/pythonnet/__init__.py b/pythonnet/__init__.py new file mode 100644 index 000000000..e69de29bb From a5e6aca311422e9eb9f0ef8d7a52db3a21e9fa56 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Tue, 26 Nov 2019 18:25:00 +0100 Subject: [PATCH 03/22] Move projects around and add clean project/solution files --- Python.Runtime/AssemblyInfo.cs | 3 + .../CustomMarshaler.cs | 0 Python.Runtime/Python.Runtime.csproj | 12 + {src/runtime => Python.Runtime}/Util.cs | 0 .../runtime => Python.Runtime}/arrayobject.cs | 0 .../assemblymanager.cs | 0 {src/runtime => Python.Runtime}/classbase.cs | 0 .../classderived.cs | 0 .../classmanager.cs | 0 .../runtime => Python.Runtime}/classobject.cs | 0 {src/runtime => Python.Runtime}/clrobject.cs | 0 .../codegenerator.cs | 0 .../constructorbinder.cs | 0 .../constructorbinding.cs | 0 {src/runtime => Python.Runtime}/converter.cs | 0 .../runtime => Python.Runtime}/debughelper.cs | 0 .../delegatemanager.cs | 0 .../delegateobject.cs | 0 .../eventbinding.cs | 0 .../runtime => Python.Runtime}/eventobject.cs | 0 {src/runtime => Python.Runtime}/exceptions.cs | 0 .../extensiontype.cs | 0 .../runtime => Python.Runtime}/fieldobject.cs | 0 {src/runtime => Python.Runtime}/finalizer.cs | 0 .../runtime => Python.Runtime}/generictype.cs | 0 .../runtime => Python.Runtime}/genericutil.cs | 0 {src/runtime => Python.Runtime}/importhook.cs | 0 {src/runtime => Python.Runtime}/indexer.cs | 0 .../interfaceobject.cs | 0 {src/runtime => Python.Runtime}/interfaces.cs | 0 {src/runtime => Python.Runtime}/interop.cs | 0 {src/runtime => Python.Runtime}/interop27.cs | 0 {src/runtime => Python.Runtime}/interop34.cs | 0 {src/runtime => Python.Runtime}/interop35.cs | 0 {src/runtime => Python.Runtime}/interop36.cs | 0 {src/runtime => Python.Runtime}/interop37.cs | 0 {src/runtime => Python.Runtime}/iterator.cs | 0 .../runtime => Python.Runtime}/managedtype.cs | 0 {src/runtime => Python.Runtime}/metatype.cs | 0 .../methodbinder.cs | 0 .../methodbinding.cs | 0 .../methodobject.cs | 0 .../methodwrapper.cs | 0 .../modulefunctionobject.cs | 0 .../moduleobject.cs | 0 .../modulepropertyobject.cs | 0 {src/runtime => Python.Runtime}/nativecall.cs | 0 {src/runtime => Python.Runtime}/overload.cs | 0 .../platform/LibraryLoader.cs | 0 .../platform/Types.cs | 0 .../polyfill/ReflectionPolifills.cs | 0 .../propertyobject.cs | 1 - .../pyansistring.cs | 0 {src/runtime => Python.Runtime}/pydict.cs | 0 {src/runtime => Python.Runtime}/pyfloat.cs | 0 {src/runtime => Python.Runtime}/pyint.cs | 0 {src/runtime => Python.Runtime}/pyiter.cs | 0 {src/runtime => Python.Runtime}/pylist.cs | 0 {src/runtime => Python.Runtime}/pylong.cs | 0 {src/runtime => Python.Runtime}/pynumber.cs | 0 {src/runtime => Python.Runtime}/pyobject.cs | 0 {src/runtime => Python.Runtime}/pyscope.cs | 0 {src/runtime => Python.Runtime}/pysequence.cs | 0 {src/runtime => Python.Runtime}/pystring.cs | 0 .../pythonengine.cs | 0 .../pythonexception.cs | 0 {src/runtime => Python.Runtime}/pytuple.cs | 0 .../resources/clr.py | 0 {src/runtime => Python.Runtime}/runtime.cs | 0 .../runtime => Python.Runtime}/typemanager.cs | 0 {src/runtime => Python.Runtime}/typemethod.cs | 0 .../GlobalTestsSetup.cs | 0 .../Program.cs | 0 .../Python.Test.Embed | 0 .../TestCallbacks.cs | 0 .../TestConverter.cs | 0 .../TestCustomMarshal.cs | 0 .../TestDomainReload.cs | 0 .../TestExample.cs | 0 .../TestFinalizer.cs | 0 .../TestNamedArguments.cs | 0 .../TestPyAnsiString.cs | 0 .../TestPyFloat.cs | 0 .../TestPyInt.cs | 0 .../TestPyList.cs | 0 .../TestPyLong.cs | 0 .../TestPyNumber.cs | 0 .../TestPyObject.cs | 0 .../TestPyScope.cs | 0 .../TestPySequence.cs | 0 .../TestPyString.cs | 0 .../TestPyTuple.cs | 0 .../TestPyWith.cs | 0 .../TestPythonEngineProperties.cs | 0 .../TestPythonException.cs | 0 .../TestRuntime.cs | 0 .../TestTypeManager.cs | 0 .../dynamic.cs | 0 .../fixtures/PyImportTest/__init__.py | 0 .../fixtures/PyImportTest/cast_global_var.py | 0 .../fixtures/PyImportTest/sysargv.py | 0 .../fixtures/PyImportTest/test/__init__.py | 0 .../fixtures/PyImportTest/test/one.py | 0 .../packages.config | 0 .../pyimport.cs | 0 .../pyinitialize.cs | 0 .../pyrunstring.cs | 0 .../InheritanceTest.cs | 0 .../ReprTest.cs | 0 .../arraytest.cs | 0 .../callbacktest.cs | 0 .../classtest.cs | 0 .../constructortests.cs | 0 .../conversiontest.cs | 0 .../delegatetest.cs | 0 .../testing => Python.Test.Helper}/doctest.cs | 0 .../enumtest.cs | 0 .../eventtest.cs | 0 .../exceptiontest.cs | 0 .../fieldtest.cs | 0 .../generictest.cs | 0 .../globaltest.cs | 0 .../indexertest.cs | 0 .../interfacetest.cs | 0 .../methodtest.cs | 0 .../moduletest.cs | 0 .../propertytest.cs | 0 .../subclasstest.cs | 0 .../threadtest.cs | 0 .../BaselineComparisonBenchmarkBase.cs | 0 .../BaselineComparisonConfig.cs | 0 .../BenchmarkTests.cs | 0 .../PythonCallingNetBenchmark.cs | 0 pythonnet.15.sln | 369 ------------------ pythonnet.sln | 234 ++--------- src/SharedAssemblyInfo.cs | 28 -- src/console/Console.15.csproj | 94 ----- src/console/Console.csproj | 101 ----- src/console/Properties/AssemblyInfo.cs | 8 - src/console/python-clear.ico | Bin 270398 -> 0 bytes src/console/pythonconsole.cs | 82 ---- .../Python.EmbeddingTest.15.csproj | 116 ------ src/perf_tests/Python.PerformanceTests.csproj | 34 -- src/pythonnet.snk | Bin 596 -> 0 bytes src/runtime/Properties/AssemblyInfo.cs | 11 - src/runtime/Python.Runtime.15.csproj | 147 ------- src/runtime/Python.Runtime.csproj | 174 --------- src/testing/Python.Test.15.csproj | 86 ---- src/testing/Python.Test.csproj | 115 ------ {src/tests => tests}/__init__.py | 0 {src/tests => tests}/_compat.py | 0 {src/tests => tests}/_missing_import.py | 0 {src/tests => tests}/conftest.py | 0 {src/tests => tests}/fixtures/.gitkeep | 0 {src/tests => tests}/fixtures/argv-fixture.py | 0 .../fixtures/netstandard2.0/.gitkeep | 0 {src/tests => tests}/importtest.py | 0 {src/tests => tests}/leaktest.py | 0 {src/tests => tests}/profile.py | 0 {src/tests => tests}/runtests.py | 0 {src/tests => tests}/stress.py | 0 {src/tests => tests}/stresstest.py | 0 {src/tests => tests}/test_array.py | 0 {src/tests => tests}/test_callback.py | 0 {src/tests => tests}/test_class.py | 0 {src/tests => tests}/test_clrmethod.py | 0 {src/tests => tests}/test_compat.py | 0 {src/tests => tests}/test_constructors.py | 0 {src/tests => tests}/test_conversion.py | 0 {src/tests => tests}/test_delegate.py | 0 {src/tests => tests}/test_docstring.py | 0 {src/tests => tests}/test_engine.py | 0 {src/tests => tests}/test_enum.py | 0 {src/tests => tests}/test_event.py | 0 {src/tests => tests}/test_exceptions.py | 0 {src/tests => tests}/test_field.py | 0 {src/tests => tests}/test_generic.py | 0 {src/tests => tests}/test_import.py | 0 {src/tests => tests}/test_indexer.py | 0 {src/tests => tests}/test_interface.py | 0 {src/tests => tests}/test_method.py | 0 {src/tests => tests}/test_module.py | 0 {src/tests => tests}/test_property.py | 0 {src/tests => tests}/test_recursive_types.py | 0 {src/tests => tests}/test_repr.py | 0 {src/tests => tests}/test_subclass.py | 0 {src/tests => tests}/test_sysargv.py | 0 {src/tests => tests}/test_thread.py | 0 {src/tests => tests}/tests.pyproj | 0 {src/tests => tests}/utils.py | 0 tox.ini | 27 -- 191 files changed, 49 insertions(+), 1593 deletions(-) create mode 100644 Python.Runtime/AssemblyInfo.cs rename {src/runtime => Python.Runtime}/CustomMarshaler.cs (100%) create mode 100644 Python.Runtime/Python.Runtime.csproj rename {src/runtime => Python.Runtime}/Util.cs (100%) rename {src/runtime => Python.Runtime}/arrayobject.cs (100%) rename {src/runtime => Python.Runtime}/assemblymanager.cs (100%) rename {src/runtime => Python.Runtime}/classbase.cs (100%) rename {src/runtime => Python.Runtime}/classderived.cs (100%) rename {src/runtime => Python.Runtime}/classmanager.cs (100%) rename {src/runtime => Python.Runtime}/classobject.cs (100%) rename {src/runtime => Python.Runtime}/clrobject.cs (100%) rename {src/runtime => Python.Runtime}/codegenerator.cs (100%) rename {src/runtime => Python.Runtime}/constructorbinder.cs (100%) rename {src/runtime => Python.Runtime}/constructorbinding.cs (100%) rename {src/runtime => Python.Runtime}/converter.cs (100%) rename {src/runtime => Python.Runtime}/debughelper.cs (100%) rename {src/runtime => Python.Runtime}/delegatemanager.cs (100%) rename {src/runtime => Python.Runtime}/delegateobject.cs (100%) rename {src/runtime => Python.Runtime}/eventbinding.cs (100%) rename {src/runtime => Python.Runtime}/eventobject.cs (100%) rename {src/runtime => Python.Runtime}/exceptions.cs (100%) rename {src/runtime => Python.Runtime}/extensiontype.cs (100%) rename {src/runtime => Python.Runtime}/fieldobject.cs (100%) rename {src/runtime => Python.Runtime}/finalizer.cs (100%) rename {src/runtime => Python.Runtime}/generictype.cs (100%) rename {src/runtime => Python.Runtime}/genericutil.cs (100%) rename {src/runtime => Python.Runtime}/importhook.cs (100%) rename {src/runtime => Python.Runtime}/indexer.cs (100%) rename {src/runtime => Python.Runtime}/interfaceobject.cs (100%) rename {src/runtime => Python.Runtime}/interfaces.cs (100%) rename {src/runtime => Python.Runtime}/interop.cs (100%) rename {src/runtime => Python.Runtime}/interop27.cs (100%) rename {src/runtime => Python.Runtime}/interop34.cs (100%) rename {src/runtime => Python.Runtime}/interop35.cs (100%) rename {src/runtime => Python.Runtime}/interop36.cs (100%) rename {src/runtime => Python.Runtime}/interop37.cs (100%) rename {src/runtime => Python.Runtime}/iterator.cs (100%) rename {src/runtime => Python.Runtime}/managedtype.cs (100%) rename {src/runtime => Python.Runtime}/metatype.cs (100%) rename {src/runtime => Python.Runtime}/methodbinder.cs (100%) rename {src/runtime => Python.Runtime}/methodbinding.cs (100%) rename {src/runtime => Python.Runtime}/methodobject.cs (100%) rename {src/runtime => Python.Runtime}/methodwrapper.cs (100%) rename {src/runtime => Python.Runtime}/modulefunctionobject.cs (100%) rename {src/runtime => Python.Runtime}/moduleobject.cs (100%) rename {src/runtime => Python.Runtime}/modulepropertyobject.cs (100%) rename {src/runtime => Python.Runtime}/nativecall.cs (100%) rename {src/runtime => Python.Runtime}/overload.cs (100%) rename {src/runtime => Python.Runtime}/platform/LibraryLoader.cs (100%) rename {src/runtime => Python.Runtime}/platform/Types.cs (100%) rename {src/runtime => Python.Runtime}/polyfill/ReflectionPolifills.cs (100%) rename {src/runtime => Python.Runtime}/propertyobject.cs (98%) rename {src/runtime => Python.Runtime}/pyansistring.cs (100%) rename {src/runtime => Python.Runtime}/pydict.cs (100%) rename {src/runtime => Python.Runtime}/pyfloat.cs (100%) rename {src/runtime => Python.Runtime}/pyint.cs (100%) rename {src/runtime => Python.Runtime}/pyiter.cs (100%) rename {src/runtime => Python.Runtime}/pylist.cs (100%) rename {src/runtime => Python.Runtime}/pylong.cs (100%) rename {src/runtime => Python.Runtime}/pynumber.cs (100%) rename {src/runtime => Python.Runtime}/pyobject.cs (100%) rename {src/runtime => Python.Runtime}/pyscope.cs (100%) rename {src/runtime => Python.Runtime}/pysequence.cs (100%) rename {src/runtime => Python.Runtime}/pystring.cs (100%) rename {src/runtime => Python.Runtime}/pythonengine.cs (100%) rename {src/runtime => Python.Runtime}/pythonexception.cs (100%) rename {src/runtime => Python.Runtime}/pytuple.cs (100%) rename {src/runtime => Python.Runtime}/resources/clr.py (100%) rename {src/runtime => Python.Runtime}/runtime.cs (100%) rename {src/runtime => Python.Runtime}/typemanager.cs (100%) rename {src/runtime => Python.Runtime}/typemethod.cs (100%) rename {src/embed_tests => Python.Test.Embed}/GlobalTestsSetup.cs (100%) rename {src/embed_tests => Python.Test.Embed}/Program.cs (100%) rename src/embed_tests/Python.EmbeddingTest.csproj => Python.Test.Embed/Python.Test.Embed (100%) rename {src/embed_tests => Python.Test.Embed}/TestCallbacks.cs (100%) rename {src/embed_tests => Python.Test.Embed}/TestConverter.cs (100%) rename {src/embed_tests => Python.Test.Embed}/TestCustomMarshal.cs (100%) rename {src/embed_tests => Python.Test.Embed}/TestDomainReload.cs (100%) rename {src/embed_tests => Python.Test.Embed}/TestExample.cs (100%) rename {src/embed_tests => Python.Test.Embed}/TestFinalizer.cs (100%) rename {src/embed_tests => Python.Test.Embed}/TestNamedArguments.cs (100%) rename {src/embed_tests => Python.Test.Embed}/TestPyAnsiString.cs (100%) rename {src/embed_tests => Python.Test.Embed}/TestPyFloat.cs (100%) rename {src/embed_tests => Python.Test.Embed}/TestPyInt.cs (100%) rename {src/embed_tests => Python.Test.Embed}/TestPyList.cs (100%) rename {src/embed_tests => Python.Test.Embed}/TestPyLong.cs (100%) rename {src/embed_tests => Python.Test.Embed}/TestPyNumber.cs (100%) rename {src/embed_tests => Python.Test.Embed}/TestPyObject.cs (100%) rename {src/embed_tests => Python.Test.Embed}/TestPyScope.cs (100%) rename {src/embed_tests => Python.Test.Embed}/TestPySequence.cs (100%) rename {src/embed_tests => Python.Test.Embed}/TestPyString.cs (100%) rename {src/embed_tests => Python.Test.Embed}/TestPyTuple.cs (100%) rename {src/embed_tests => Python.Test.Embed}/TestPyWith.cs (100%) rename {src/embed_tests => Python.Test.Embed}/TestPythonEngineProperties.cs (100%) rename {src/embed_tests => Python.Test.Embed}/TestPythonException.cs (100%) rename {src/embed_tests => Python.Test.Embed}/TestRuntime.cs (100%) rename {src/embed_tests => Python.Test.Embed}/TestTypeManager.cs (100%) rename {src/embed_tests => Python.Test.Embed}/dynamic.cs (100%) rename {src/embed_tests => Python.Test.Embed}/fixtures/PyImportTest/__init__.py (100%) rename {src/embed_tests => Python.Test.Embed}/fixtures/PyImportTest/cast_global_var.py (100%) rename {src/embed_tests => Python.Test.Embed}/fixtures/PyImportTest/sysargv.py (100%) rename {src/embed_tests => Python.Test.Embed}/fixtures/PyImportTest/test/__init__.py (100%) rename {src/embed_tests => Python.Test.Embed}/fixtures/PyImportTest/test/one.py (100%) rename {src/embed_tests => Python.Test.Embed}/packages.config (100%) rename {src/embed_tests => Python.Test.Embed}/pyimport.cs (100%) rename {src/embed_tests => Python.Test.Embed}/pyinitialize.cs (100%) rename {src/embed_tests => Python.Test.Embed}/pyrunstring.cs (100%) rename {src/testing => Python.Test.Helper}/InheritanceTest.cs (100%) rename {src/testing => Python.Test.Helper}/ReprTest.cs (100%) rename {src/testing => Python.Test.Helper}/arraytest.cs (100%) rename {src/testing => Python.Test.Helper}/callbacktest.cs (100%) rename {src/testing => Python.Test.Helper}/classtest.cs (100%) rename {src/testing => Python.Test.Helper}/constructortests.cs (100%) rename {src/testing => Python.Test.Helper}/conversiontest.cs (100%) rename {src/testing => Python.Test.Helper}/delegatetest.cs (100%) rename {src/testing => Python.Test.Helper}/doctest.cs (100%) rename {src/testing => Python.Test.Helper}/enumtest.cs (100%) rename {src/testing => Python.Test.Helper}/eventtest.cs (100%) rename {src/testing => Python.Test.Helper}/exceptiontest.cs (100%) rename {src/testing => Python.Test.Helper}/fieldtest.cs (100%) rename {src/testing => Python.Test.Helper}/generictest.cs (100%) rename {src/testing => Python.Test.Helper}/globaltest.cs (100%) rename {src/testing => Python.Test.Helper}/indexertest.cs (100%) rename {src/testing => Python.Test.Helper}/interfacetest.cs (100%) rename {src/testing => Python.Test.Helper}/methodtest.cs (100%) rename {src/testing => Python.Test.Helper}/moduletest.cs (100%) rename {src/testing => Python.Test.Helper}/propertytest.cs (100%) rename {src/testing => Python.Test.Helper}/subclasstest.cs (100%) rename {src/testing => Python.Test.Helper}/threadtest.cs (100%) rename {src/perf_tests => Python.Test.Performance}/BaselineComparisonBenchmarkBase.cs (100%) rename {src/perf_tests => Python.Test.Performance}/BaselineComparisonConfig.cs (100%) rename {src/perf_tests => Python.Test.Performance}/BenchmarkTests.cs (100%) rename {src/perf_tests => Python.Test.Performance}/PythonCallingNetBenchmark.cs (100%) delete mode 100644 pythonnet.15.sln delete mode 100644 src/SharedAssemblyInfo.cs delete mode 100644 src/console/Console.15.csproj delete mode 100644 src/console/Console.csproj delete mode 100644 src/console/Properties/AssemblyInfo.cs delete mode 100644 src/console/python-clear.ico delete mode 100644 src/console/pythonconsole.cs delete mode 100644 src/embed_tests/Python.EmbeddingTest.15.csproj delete mode 100644 src/perf_tests/Python.PerformanceTests.csproj delete mode 100644 src/pythonnet.snk delete mode 100644 src/runtime/Properties/AssemblyInfo.cs delete mode 100644 src/runtime/Python.Runtime.15.csproj delete mode 100644 src/runtime/Python.Runtime.csproj delete mode 100644 src/testing/Python.Test.15.csproj delete mode 100644 src/testing/Python.Test.csproj rename {src/tests => tests}/__init__.py (100%) rename {src/tests => tests}/_compat.py (100%) rename {src/tests => tests}/_missing_import.py (100%) rename {src/tests => tests}/conftest.py (100%) rename {src/tests => tests}/fixtures/.gitkeep (100%) rename {src/tests => tests}/fixtures/argv-fixture.py (100%) rename {src/tests => tests}/fixtures/netstandard2.0/.gitkeep (100%) rename {src/tests => tests}/importtest.py (100%) rename {src/tests => tests}/leaktest.py (100%) rename {src/tests => tests}/profile.py (100%) rename {src/tests => tests}/runtests.py (100%) rename {src/tests => tests}/stress.py (100%) rename {src/tests => tests}/stresstest.py (100%) rename {src/tests => tests}/test_array.py (100%) rename {src/tests => tests}/test_callback.py (100%) rename {src/tests => tests}/test_class.py (100%) rename {src/tests => tests}/test_clrmethod.py (100%) rename {src/tests => tests}/test_compat.py (100%) rename {src/tests => tests}/test_constructors.py (100%) rename {src/tests => tests}/test_conversion.py (100%) rename {src/tests => tests}/test_delegate.py (100%) rename {src/tests => tests}/test_docstring.py (100%) rename {src/tests => tests}/test_engine.py (100%) rename {src/tests => tests}/test_enum.py (100%) rename {src/tests => tests}/test_event.py (100%) rename {src/tests => tests}/test_exceptions.py (100%) rename {src/tests => tests}/test_field.py (100%) rename {src/tests => tests}/test_generic.py (100%) rename {src/tests => tests}/test_import.py (100%) rename {src/tests => tests}/test_indexer.py (100%) rename {src/tests => tests}/test_interface.py (100%) rename {src/tests => tests}/test_method.py (100%) rename {src/tests => tests}/test_module.py (100%) rename {src/tests => tests}/test_property.py (100%) rename {src/tests => tests}/test_recursive_types.py (100%) rename {src/tests => tests}/test_repr.py (100%) rename {src/tests => tests}/test_subclass.py (100%) rename {src/tests => tests}/test_sysargv.py (100%) rename {src/tests => tests}/test_thread.py (100%) rename {src/tests => tests}/tests.pyproj (100%) rename {src/tests => tests}/utils.py (100%) delete mode 100644 tox.ini diff --git a/Python.Runtime/AssemblyInfo.cs b/Python.Runtime/AssemblyInfo.cs new file mode 100644 index 000000000..0270020d3 --- /dev/null +++ b/Python.Runtime/AssemblyInfo.cs @@ -0,0 +1,3 @@ +using System; + +[assembly: CLSCompliant(true)] diff --git a/src/runtime/CustomMarshaler.cs b/Python.Runtime/CustomMarshaler.cs similarity index 100% rename from src/runtime/CustomMarshaler.cs rename to Python.Runtime/CustomMarshaler.cs diff --git a/Python.Runtime/Python.Runtime.csproj b/Python.Runtime/Python.Runtime.csproj new file mode 100644 index 000000000..b60ac1fa6 --- /dev/null +++ b/Python.Runtime/Python.Runtime.csproj @@ -0,0 +1,12 @@ + + + + netstandard2.0 + true + + + + + + + diff --git a/src/runtime/Util.cs b/Python.Runtime/Util.cs similarity index 100% rename from src/runtime/Util.cs rename to Python.Runtime/Util.cs diff --git a/src/runtime/arrayobject.cs b/Python.Runtime/arrayobject.cs similarity index 100% rename from src/runtime/arrayobject.cs rename to Python.Runtime/arrayobject.cs diff --git a/src/runtime/assemblymanager.cs b/Python.Runtime/assemblymanager.cs similarity index 100% rename from src/runtime/assemblymanager.cs rename to Python.Runtime/assemblymanager.cs diff --git a/src/runtime/classbase.cs b/Python.Runtime/classbase.cs similarity index 100% rename from src/runtime/classbase.cs rename to Python.Runtime/classbase.cs diff --git a/src/runtime/classderived.cs b/Python.Runtime/classderived.cs similarity index 100% rename from src/runtime/classderived.cs rename to Python.Runtime/classderived.cs diff --git a/src/runtime/classmanager.cs b/Python.Runtime/classmanager.cs similarity index 100% rename from src/runtime/classmanager.cs rename to Python.Runtime/classmanager.cs diff --git a/src/runtime/classobject.cs b/Python.Runtime/classobject.cs similarity index 100% rename from src/runtime/classobject.cs rename to Python.Runtime/classobject.cs diff --git a/src/runtime/clrobject.cs b/Python.Runtime/clrobject.cs similarity index 100% rename from src/runtime/clrobject.cs rename to Python.Runtime/clrobject.cs diff --git a/src/runtime/codegenerator.cs b/Python.Runtime/codegenerator.cs similarity index 100% rename from src/runtime/codegenerator.cs rename to Python.Runtime/codegenerator.cs diff --git a/src/runtime/constructorbinder.cs b/Python.Runtime/constructorbinder.cs similarity index 100% rename from src/runtime/constructorbinder.cs rename to Python.Runtime/constructorbinder.cs diff --git a/src/runtime/constructorbinding.cs b/Python.Runtime/constructorbinding.cs similarity index 100% rename from src/runtime/constructorbinding.cs rename to Python.Runtime/constructorbinding.cs diff --git a/src/runtime/converter.cs b/Python.Runtime/converter.cs similarity index 100% rename from src/runtime/converter.cs rename to Python.Runtime/converter.cs diff --git a/src/runtime/debughelper.cs b/Python.Runtime/debughelper.cs similarity index 100% rename from src/runtime/debughelper.cs rename to Python.Runtime/debughelper.cs diff --git a/src/runtime/delegatemanager.cs b/Python.Runtime/delegatemanager.cs similarity index 100% rename from src/runtime/delegatemanager.cs rename to Python.Runtime/delegatemanager.cs diff --git a/src/runtime/delegateobject.cs b/Python.Runtime/delegateobject.cs similarity index 100% rename from src/runtime/delegateobject.cs rename to Python.Runtime/delegateobject.cs diff --git a/src/runtime/eventbinding.cs b/Python.Runtime/eventbinding.cs similarity index 100% rename from src/runtime/eventbinding.cs rename to Python.Runtime/eventbinding.cs diff --git a/src/runtime/eventobject.cs b/Python.Runtime/eventobject.cs similarity index 100% rename from src/runtime/eventobject.cs rename to Python.Runtime/eventobject.cs diff --git a/src/runtime/exceptions.cs b/Python.Runtime/exceptions.cs similarity index 100% rename from src/runtime/exceptions.cs rename to Python.Runtime/exceptions.cs diff --git a/src/runtime/extensiontype.cs b/Python.Runtime/extensiontype.cs similarity index 100% rename from src/runtime/extensiontype.cs rename to Python.Runtime/extensiontype.cs diff --git a/src/runtime/fieldobject.cs b/Python.Runtime/fieldobject.cs similarity index 100% rename from src/runtime/fieldobject.cs rename to Python.Runtime/fieldobject.cs diff --git a/src/runtime/finalizer.cs b/Python.Runtime/finalizer.cs similarity index 100% rename from src/runtime/finalizer.cs rename to Python.Runtime/finalizer.cs diff --git a/src/runtime/generictype.cs b/Python.Runtime/generictype.cs similarity index 100% rename from src/runtime/generictype.cs rename to Python.Runtime/generictype.cs diff --git a/src/runtime/genericutil.cs b/Python.Runtime/genericutil.cs similarity index 100% rename from src/runtime/genericutil.cs rename to Python.Runtime/genericutil.cs diff --git a/src/runtime/importhook.cs b/Python.Runtime/importhook.cs similarity index 100% rename from src/runtime/importhook.cs rename to Python.Runtime/importhook.cs diff --git a/src/runtime/indexer.cs b/Python.Runtime/indexer.cs similarity index 100% rename from src/runtime/indexer.cs rename to Python.Runtime/indexer.cs diff --git a/src/runtime/interfaceobject.cs b/Python.Runtime/interfaceobject.cs similarity index 100% rename from src/runtime/interfaceobject.cs rename to Python.Runtime/interfaceobject.cs diff --git a/src/runtime/interfaces.cs b/Python.Runtime/interfaces.cs similarity index 100% rename from src/runtime/interfaces.cs rename to Python.Runtime/interfaces.cs diff --git a/src/runtime/interop.cs b/Python.Runtime/interop.cs similarity index 100% rename from src/runtime/interop.cs rename to Python.Runtime/interop.cs diff --git a/src/runtime/interop27.cs b/Python.Runtime/interop27.cs similarity index 100% rename from src/runtime/interop27.cs rename to Python.Runtime/interop27.cs diff --git a/src/runtime/interop34.cs b/Python.Runtime/interop34.cs similarity index 100% rename from src/runtime/interop34.cs rename to Python.Runtime/interop34.cs diff --git a/src/runtime/interop35.cs b/Python.Runtime/interop35.cs similarity index 100% rename from src/runtime/interop35.cs rename to Python.Runtime/interop35.cs diff --git a/src/runtime/interop36.cs b/Python.Runtime/interop36.cs similarity index 100% rename from src/runtime/interop36.cs rename to Python.Runtime/interop36.cs diff --git a/src/runtime/interop37.cs b/Python.Runtime/interop37.cs similarity index 100% rename from src/runtime/interop37.cs rename to Python.Runtime/interop37.cs diff --git a/src/runtime/iterator.cs b/Python.Runtime/iterator.cs similarity index 100% rename from src/runtime/iterator.cs rename to Python.Runtime/iterator.cs diff --git a/src/runtime/managedtype.cs b/Python.Runtime/managedtype.cs similarity index 100% rename from src/runtime/managedtype.cs rename to Python.Runtime/managedtype.cs diff --git a/src/runtime/metatype.cs b/Python.Runtime/metatype.cs similarity index 100% rename from src/runtime/metatype.cs rename to Python.Runtime/metatype.cs diff --git a/src/runtime/methodbinder.cs b/Python.Runtime/methodbinder.cs similarity index 100% rename from src/runtime/methodbinder.cs rename to Python.Runtime/methodbinder.cs diff --git a/src/runtime/methodbinding.cs b/Python.Runtime/methodbinding.cs similarity index 100% rename from src/runtime/methodbinding.cs rename to Python.Runtime/methodbinding.cs diff --git a/src/runtime/methodobject.cs b/Python.Runtime/methodobject.cs similarity index 100% rename from src/runtime/methodobject.cs rename to Python.Runtime/methodobject.cs diff --git a/src/runtime/methodwrapper.cs b/Python.Runtime/methodwrapper.cs similarity index 100% rename from src/runtime/methodwrapper.cs rename to Python.Runtime/methodwrapper.cs diff --git a/src/runtime/modulefunctionobject.cs b/Python.Runtime/modulefunctionobject.cs similarity index 100% rename from src/runtime/modulefunctionobject.cs rename to Python.Runtime/modulefunctionobject.cs diff --git a/src/runtime/moduleobject.cs b/Python.Runtime/moduleobject.cs similarity index 100% rename from src/runtime/moduleobject.cs rename to Python.Runtime/moduleobject.cs diff --git a/src/runtime/modulepropertyobject.cs b/Python.Runtime/modulepropertyobject.cs similarity index 100% rename from src/runtime/modulepropertyobject.cs rename to Python.Runtime/modulepropertyobject.cs diff --git a/src/runtime/nativecall.cs b/Python.Runtime/nativecall.cs similarity index 100% rename from src/runtime/nativecall.cs rename to Python.Runtime/nativecall.cs diff --git a/src/runtime/overload.cs b/Python.Runtime/overload.cs similarity index 100% rename from src/runtime/overload.cs rename to Python.Runtime/overload.cs diff --git a/src/runtime/platform/LibraryLoader.cs b/Python.Runtime/platform/LibraryLoader.cs similarity index 100% rename from src/runtime/platform/LibraryLoader.cs rename to Python.Runtime/platform/LibraryLoader.cs diff --git a/src/runtime/platform/Types.cs b/Python.Runtime/platform/Types.cs similarity index 100% rename from src/runtime/platform/Types.cs rename to Python.Runtime/platform/Types.cs diff --git a/src/runtime/polyfill/ReflectionPolifills.cs b/Python.Runtime/polyfill/ReflectionPolifills.cs similarity index 100% rename from src/runtime/polyfill/ReflectionPolifills.cs rename to Python.Runtime/polyfill/ReflectionPolifills.cs diff --git a/src/runtime/propertyobject.cs b/Python.Runtime/propertyobject.cs similarity index 98% rename from src/runtime/propertyobject.cs rename to Python.Runtime/propertyobject.cs index f2c97f163..893fbe54b 100644 --- a/src/runtime/propertyobject.cs +++ b/Python.Runtime/propertyobject.cs @@ -13,7 +13,6 @@ internal class PropertyObject : ExtensionType private MethodInfo getter; private MethodInfo setter; - [StrongNameIdentityPermission(SecurityAction.Assert)] public PropertyObject(PropertyInfo md) { getter = md.GetGetMethod(true); diff --git a/src/runtime/pyansistring.cs b/Python.Runtime/pyansistring.cs similarity index 100% rename from src/runtime/pyansistring.cs rename to Python.Runtime/pyansistring.cs diff --git a/src/runtime/pydict.cs b/Python.Runtime/pydict.cs similarity index 100% rename from src/runtime/pydict.cs rename to Python.Runtime/pydict.cs diff --git a/src/runtime/pyfloat.cs b/Python.Runtime/pyfloat.cs similarity index 100% rename from src/runtime/pyfloat.cs rename to Python.Runtime/pyfloat.cs diff --git a/src/runtime/pyint.cs b/Python.Runtime/pyint.cs similarity index 100% rename from src/runtime/pyint.cs rename to Python.Runtime/pyint.cs diff --git a/src/runtime/pyiter.cs b/Python.Runtime/pyiter.cs similarity index 100% rename from src/runtime/pyiter.cs rename to Python.Runtime/pyiter.cs diff --git a/src/runtime/pylist.cs b/Python.Runtime/pylist.cs similarity index 100% rename from src/runtime/pylist.cs rename to Python.Runtime/pylist.cs diff --git a/src/runtime/pylong.cs b/Python.Runtime/pylong.cs similarity index 100% rename from src/runtime/pylong.cs rename to Python.Runtime/pylong.cs diff --git a/src/runtime/pynumber.cs b/Python.Runtime/pynumber.cs similarity index 100% rename from src/runtime/pynumber.cs rename to Python.Runtime/pynumber.cs diff --git a/src/runtime/pyobject.cs b/Python.Runtime/pyobject.cs similarity index 100% rename from src/runtime/pyobject.cs rename to Python.Runtime/pyobject.cs diff --git a/src/runtime/pyscope.cs b/Python.Runtime/pyscope.cs similarity index 100% rename from src/runtime/pyscope.cs rename to Python.Runtime/pyscope.cs diff --git a/src/runtime/pysequence.cs b/Python.Runtime/pysequence.cs similarity index 100% rename from src/runtime/pysequence.cs rename to Python.Runtime/pysequence.cs diff --git a/src/runtime/pystring.cs b/Python.Runtime/pystring.cs similarity index 100% rename from src/runtime/pystring.cs rename to Python.Runtime/pystring.cs diff --git a/src/runtime/pythonengine.cs b/Python.Runtime/pythonengine.cs similarity index 100% rename from src/runtime/pythonengine.cs rename to Python.Runtime/pythonengine.cs diff --git a/src/runtime/pythonexception.cs b/Python.Runtime/pythonexception.cs similarity index 100% rename from src/runtime/pythonexception.cs rename to Python.Runtime/pythonexception.cs diff --git a/src/runtime/pytuple.cs b/Python.Runtime/pytuple.cs similarity index 100% rename from src/runtime/pytuple.cs rename to Python.Runtime/pytuple.cs diff --git a/src/runtime/resources/clr.py b/Python.Runtime/resources/clr.py similarity index 100% rename from src/runtime/resources/clr.py rename to Python.Runtime/resources/clr.py diff --git a/src/runtime/runtime.cs b/Python.Runtime/runtime.cs similarity index 100% rename from src/runtime/runtime.cs rename to Python.Runtime/runtime.cs diff --git a/src/runtime/typemanager.cs b/Python.Runtime/typemanager.cs similarity index 100% rename from src/runtime/typemanager.cs rename to Python.Runtime/typemanager.cs diff --git a/src/runtime/typemethod.cs b/Python.Runtime/typemethod.cs similarity index 100% rename from src/runtime/typemethod.cs rename to Python.Runtime/typemethod.cs diff --git a/src/embed_tests/GlobalTestsSetup.cs b/Python.Test.Embed/GlobalTestsSetup.cs similarity index 100% rename from src/embed_tests/GlobalTestsSetup.cs rename to Python.Test.Embed/GlobalTestsSetup.cs diff --git a/src/embed_tests/Program.cs b/Python.Test.Embed/Program.cs similarity index 100% rename from src/embed_tests/Program.cs rename to Python.Test.Embed/Program.cs diff --git a/src/embed_tests/Python.EmbeddingTest.csproj b/Python.Test.Embed/Python.Test.Embed similarity index 100% rename from src/embed_tests/Python.EmbeddingTest.csproj rename to Python.Test.Embed/Python.Test.Embed diff --git a/src/embed_tests/TestCallbacks.cs b/Python.Test.Embed/TestCallbacks.cs similarity index 100% rename from src/embed_tests/TestCallbacks.cs rename to Python.Test.Embed/TestCallbacks.cs diff --git a/src/embed_tests/TestConverter.cs b/Python.Test.Embed/TestConverter.cs similarity index 100% rename from src/embed_tests/TestConverter.cs rename to Python.Test.Embed/TestConverter.cs diff --git a/src/embed_tests/TestCustomMarshal.cs b/Python.Test.Embed/TestCustomMarshal.cs similarity index 100% rename from src/embed_tests/TestCustomMarshal.cs rename to Python.Test.Embed/TestCustomMarshal.cs diff --git a/src/embed_tests/TestDomainReload.cs b/Python.Test.Embed/TestDomainReload.cs similarity index 100% rename from src/embed_tests/TestDomainReload.cs rename to Python.Test.Embed/TestDomainReload.cs diff --git a/src/embed_tests/TestExample.cs b/Python.Test.Embed/TestExample.cs similarity index 100% rename from src/embed_tests/TestExample.cs rename to Python.Test.Embed/TestExample.cs diff --git a/src/embed_tests/TestFinalizer.cs b/Python.Test.Embed/TestFinalizer.cs similarity index 100% rename from src/embed_tests/TestFinalizer.cs rename to Python.Test.Embed/TestFinalizer.cs diff --git a/src/embed_tests/TestNamedArguments.cs b/Python.Test.Embed/TestNamedArguments.cs similarity index 100% rename from src/embed_tests/TestNamedArguments.cs rename to Python.Test.Embed/TestNamedArguments.cs diff --git a/src/embed_tests/TestPyAnsiString.cs b/Python.Test.Embed/TestPyAnsiString.cs similarity index 100% rename from src/embed_tests/TestPyAnsiString.cs rename to Python.Test.Embed/TestPyAnsiString.cs diff --git a/src/embed_tests/TestPyFloat.cs b/Python.Test.Embed/TestPyFloat.cs similarity index 100% rename from src/embed_tests/TestPyFloat.cs rename to Python.Test.Embed/TestPyFloat.cs diff --git a/src/embed_tests/TestPyInt.cs b/Python.Test.Embed/TestPyInt.cs similarity index 100% rename from src/embed_tests/TestPyInt.cs rename to Python.Test.Embed/TestPyInt.cs diff --git a/src/embed_tests/TestPyList.cs b/Python.Test.Embed/TestPyList.cs similarity index 100% rename from src/embed_tests/TestPyList.cs rename to Python.Test.Embed/TestPyList.cs diff --git a/src/embed_tests/TestPyLong.cs b/Python.Test.Embed/TestPyLong.cs similarity index 100% rename from src/embed_tests/TestPyLong.cs rename to Python.Test.Embed/TestPyLong.cs diff --git a/src/embed_tests/TestPyNumber.cs b/Python.Test.Embed/TestPyNumber.cs similarity index 100% rename from src/embed_tests/TestPyNumber.cs rename to Python.Test.Embed/TestPyNumber.cs diff --git a/src/embed_tests/TestPyObject.cs b/Python.Test.Embed/TestPyObject.cs similarity index 100% rename from src/embed_tests/TestPyObject.cs rename to Python.Test.Embed/TestPyObject.cs diff --git a/src/embed_tests/TestPyScope.cs b/Python.Test.Embed/TestPyScope.cs similarity index 100% rename from src/embed_tests/TestPyScope.cs rename to Python.Test.Embed/TestPyScope.cs diff --git a/src/embed_tests/TestPySequence.cs b/Python.Test.Embed/TestPySequence.cs similarity index 100% rename from src/embed_tests/TestPySequence.cs rename to Python.Test.Embed/TestPySequence.cs diff --git a/src/embed_tests/TestPyString.cs b/Python.Test.Embed/TestPyString.cs similarity index 100% rename from src/embed_tests/TestPyString.cs rename to Python.Test.Embed/TestPyString.cs diff --git a/src/embed_tests/TestPyTuple.cs b/Python.Test.Embed/TestPyTuple.cs similarity index 100% rename from src/embed_tests/TestPyTuple.cs rename to Python.Test.Embed/TestPyTuple.cs diff --git a/src/embed_tests/TestPyWith.cs b/Python.Test.Embed/TestPyWith.cs similarity index 100% rename from src/embed_tests/TestPyWith.cs rename to Python.Test.Embed/TestPyWith.cs diff --git a/src/embed_tests/TestPythonEngineProperties.cs b/Python.Test.Embed/TestPythonEngineProperties.cs similarity index 100% rename from src/embed_tests/TestPythonEngineProperties.cs rename to Python.Test.Embed/TestPythonEngineProperties.cs diff --git a/src/embed_tests/TestPythonException.cs b/Python.Test.Embed/TestPythonException.cs similarity index 100% rename from src/embed_tests/TestPythonException.cs rename to Python.Test.Embed/TestPythonException.cs diff --git a/src/embed_tests/TestRuntime.cs b/Python.Test.Embed/TestRuntime.cs similarity index 100% rename from src/embed_tests/TestRuntime.cs rename to Python.Test.Embed/TestRuntime.cs diff --git a/src/embed_tests/TestTypeManager.cs b/Python.Test.Embed/TestTypeManager.cs similarity index 100% rename from src/embed_tests/TestTypeManager.cs rename to Python.Test.Embed/TestTypeManager.cs diff --git a/src/embed_tests/dynamic.cs b/Python.Test.Embed/dynamic.cs similarity index 100% rename from src/embed_tests/dynamic.cs rename to Python.Test.Embed/dynamic.cs diff --git a/src/embed_tests/fixtures/PyImportTest/__init__.py b/Python.Test.Embed/fixtures/PyImportTest/__init__.py similarity index 100% rename from src/embed_tests/fixtures/PyImportTest/__init__.py rename to Python.Test.Embed/fixtures/PyImportTest/__init__.py diff --git a/src/embed_tests/fixtures/PyImportTest/cast_global_var.py b/Python.Test.Embed/fixtures/PyImportTest/cast_global_var.py similarity index 100% rename from src/embed_tests/fixtures/PyImportTest/cast_global_var.py rename to Python.Test.Embed/fixtures/PyImportTest/cast_global_var.py diff --git a/src/embed_tests/fixtures/PyImportTest/sysargv.py b/Python.Test.Embed/fixtures/PyImportTest/sysargv.py similarity index 100% rename from src/embed_tests/fixtures/PyImportTest/sysargv.py rename to Python.Test.Embed/fixtures/PyImportTest/sysargv.py diff --git a/src/embed_tests/fixtures/PyImportTest/test/__init__.py b/Python.Test.Embed/fixtures/PyImportTest/test/__init__.py similarity index 100% rename from src/embed_tests/fixtures/PyImportTest/test/__init__.py rename to Python.Test.Embed/fixtures/PyImportTest/test/__init__.py diff --git a/src/embed_tests/fixtures/PyImportTest/test/one.py b/Python.Test.Embed/fixtures/PyImportTest/test/one.py similarity index 100% rename from src/embed_tests/fixtures/PyImportTest/test/one.py rename to Python.Test.Embed/fixtures/PyImportTest/test/one.py diff --git a/src/embed_tests/packages.config b/Python.Test.Embed/packages.config similarity index 100% rename from src/embed_tests/packages.config rename to Python.Test.Embed/packages.config diff --git a/src/embed_tests/pyimport.cs b/Python.Test.Embed/pyimport.cs similarity index 100% rename from src/embed_tests/pyimport.cs rename to Python.Test.Embed/pyimport.cs diff --git a/src/embed_tests/pyinitialize.cs b/Python.Test.Embed/pyinitialize.cs similarity index 100% rename from src/embed_tests/pyinitialize.cs rename to Python.Test.Embed/pyinitialize.cs diff --git a/src/embed_tests/pyrunstring.cs b/Python.Test.Embed/pyrunstring.cs similarity index 100% rename from src/embed_tests/pyrunstring.cs rename to Python.Test.Embed/pyrunstring.cs diff --git a/src/testing/InheritanceTest.cs b/Python.Test.Helper/InheritanceTest.cs similarity index 100% rename from src/testing/InheritanceTest.cs rename to Python.Test.Helper/InheritanceTest.cs diff --git a/src/testing/ReprTest.cs b/Python.Test.Helper/ReprTest.cs similarity index 100% rename from src/testing/ReprTest.cs rename to Python.Test.Helper/ReprTest.cs diff --git a/src/testing/arraytest.cs b/Python.Test.Helper/arraytest.cs similarity index 100% rename from src/testing/arraytest.cs rename to Python.Test.Helper/arraytest.cs diff --git a/src/testing/callbacktest.cs b/Python.Test.Helper/callbacktest.cs similarity index 100% rename from src/testing/callbacktest.cs rename to Python.Test.Helper/callbacktest.cs diff --git a/src/testing/classtest.cs b/Python.Test.Helper/classtest.cs similarity index 100% rename from src/testing/classtest.cs rename to Python.Test.Helper/classtest.cs diff --git a/src/testing/constructortests.cs b/Python.Test.Helper/constructortests.cs similarity index 100% rename from src/testing/constructortests.cs rename to Python.Test.Helper/constructortests.cs diff --git a/src/testing/conversiontest.cs b/Python.Test.Helper/conversiontest.cs similarity index 100% rename from src/testing/conversiontest.cs rename to Python.Test.Helper/conversiontest.cs diff --git a/src/testing/delegatetest.cs b/Python.Test.Helper/delegatetest.cs similarity index 100% rename from src/testing/delegatetest.cs rename to Python.Test.Helper/delegatetest.cs diff --git a/src/testing/doctest.cs b/Python.Test.Helper/doctest.cs similarity index 100% rename from src/testing/doctest.cs rename to Python.Test.Helper/doctest.cs diff --git a/src/testing/enumtest.cs b/Python.Test.Helper/enumtest.cs similarity index 100% rename from src/testing/enumtest.cs rename to Python.Test.Helper/enumtest.cs diff --git a/src/testing/eventtest.cs b/Python.Test.Helper/eventtest.cs similarity index 100% rename from src/testing/eventtest.cs rename to Python.Test.Helper/eventtest.cs diff --git a/src/testing/exceptiontest.cs b/Python.Test.Helper/exceptiontest.cs similarity index 100% rename from src/testing/exceptiontest.cs rename to Python.Test.Helper/exceptiontest.cs diff --git a/src/testing/fieldtest.cs b/Python.Test.Helper/fieldtest.cs similarity index 100% rename from src/testing/fieldtest.cs rename to Python.Test.Helper/fieldtest.cs diff --git a/src/testing/generictest.cs b/Python.Test.Helper/generictest.cs similarity index 100% rename from src/testing/generictest.cs rename to Python.Test.Helper/generictest.cs diff --git a/src/testing/globaltest.cs b/Python.Test.Helper/globaltest.cs similarity index 100% rename from src/testing/globaltest.cs rename to Python.Test.Helper/globaltest.cs diff --git a/src/testing/indexertest.cs b/Python.Test.Helper/indexertest.cs similarity index 100% rename from src/testing/indexertest.cs rename to Python.Test.Helper/indexertest.cs diff --git a/src/testing/interfacetest.cs b/Python.Test.Helper/interfacetest.cs similarity index 100% rename from src/testing/interfacetest.cs rename to Python.Test.Helper/interfacetest.cs diff --git a/src/testing/methodtest.cs b/Python.Test.Helper/methodtest.cs similarity index 100% rename from src/testing/methodtest.cs rename to Python.Test.Helper/methodtest.cs diff --git a/src/testing/moduletest.cs b/Python.Test.Helper/moduletest.cs similarity index 100% rename from src/testing/moduletest.cs rename to Python.Test.Helper/moduletest.cs diff --git a/src/testing/propertytest.cs b/Python.Test.Helper/propertytest.cs similarity index 100% rename from src/testing/propertytest.cs rename to Python.Test.Helper/propertytest.cs diff --git a/src/testing/subclasstest.cs b/Python.Test.Helper/subclasstest.cs similarity index 100% rename from src/testing/subclasstest.cs rename to Python.Test.Helper/subclasstest.cs diff --git a/src/testing/threadtest.cs b/Python.Test.Helper/threadtest.cs similarity index 100% rename from src/testing/threadtest.cs rename to Python.Test.Helper/threadtest.cs diff --git a/src/perf_tests/BaselineComparisonBenchmarkBase.cs b/Python.Test.Performance/BaselineComparisonBenchmarkBase.cs similarity index 100% rename from src/perf_tests/BaselineComparisonBenchmarkBase.cs rename to Python.Test.Performance/BaselineComparisonBenchmarkBase.cs diff --git a/src/perf_tests/BaselineComparisonConfig.cs b/Python.Test.Performance/BaselineComparisonConfig.cs similarity index 100% rename from src/perf_tests/BaselineComparisonConfig.cs rename to Python.Test.Performance/BaselineComparisonConfig.cs diff --git a/src/perf_tests/BenchmarkTests.cs b/Python.Test.Performance/BenchmarkTests.cs similarity index 100% rename from src/perf_tests/BenchmarkTests.cs rename to Python.Test.Performance/BenchmarkTests.cs diff --git a/src/perf_tests/PythonCallingNetBenchmark.cs b/Python.Test.Performance/PythonCallingNetBenchmark.cs similarity index 100% rename from src/perf_tests/PythonCallingNetBenchmark.cs rename to Python.Test.Performance/PythonCallingNetBenchmark.cs diff --git a/pythonnet.15.sln b/pythonnet.15.sln deleted file mode 100644 index e57c74582..000000000 --- a/pythonnet.15.sln +++ /dev/null @@ -1,369 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29102.190 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.Runtime.15", "src\runtime\Python.Runtime.15.csproj", "{2759F4FF-716B-4828-916F-50FA86613DFC}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.EmbeddingTest.15", "src\embed_tests\Python.EmbeddingTest.15.csproj", "{66B8D01A-9906-452A-B09E-BF75EA76468F}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Console.15", "src\console\Console.15.csproj", "{CDAD305F-8E72-492C-A314-64CF58D472A0}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.Test.15", "src\testing\Python.Test.15.csproj", "{F94B547A-E97E-4500-8D53-B4D64D076E5F}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.PerformanceTests", "src\perf_tests\Python.PerformanceTests.csproj", "{6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Repo", "Repo", "{441A0123-F4C6-4EE4-9AEE-315FD79BE2D5}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - DebugMono|Any CPU = DebugMono|Any CPU - DebugMono|x64 = DebugMono|x64 - DebugMono|x86 = DebugMono|x86 - DebugMonoPY3|Any CPU = DebugMonoPY3|Any CPU - DebugMonoPY3|x64 = DebugMonoPY3|x64 - DebugMonoPY3|x86 = DebugMonoPY3|x86 - DebugWin|Any CPU = DebugWin|Any CPU - DebugWin|x64 = DebugWin|x64 - DebugWin|x86 = DebugWin|x86 - DebugWinPY3|Any CPU = DebugWinPY3|Any CPU - DebugWinPY3|x64 = DebugWinPY3|x64 - DebugWinPY3|x86 = DebugWinPY3|x86 - Release|Any CPU = Release|Any CPU - Release|x64 = Release|x64 - Release|x86 = Release|x86 - ReleaseMono|Any CPU = ReleaseMono|Any CPU - ReleaseMono|x64 = ReleaseMono|x64 - ReleaseMono|x86 = ReleaseMono|x86 - ReleaseMonoPY3|Any CPU = ReleaseMonoPY3|Any CPU - ReleaseMonoPY3|x64 = ReleaseMonoPY3|x64 - ReleaseMonoPY3|x86 = ReleaseMonoPY3|x86 - ReleaseWin|Any CPU = ReleaseWin|Any CPU - ReleaseWin|x64 = ReleaseWin|x64 - ReleaseWin|x86 = ReleaseWin|x86 - ReleaseWinPY3|Any CPU = ReleaseWinPY3|Any CPU - ReleaseWinPY3|x64 = ReleaseWinPY3|x64 - ReleaseWinPY3|x86 = ReleaseWinPY3|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {2759F4FF-716B-4828-916F-50FA86613DFC}.Debug|Any CPU.ActiveCfg = DebugWinPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.Debug|Any CPU.Build.0 = DebugWinPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.Debug|x64.ActiveCfg = DebugWinPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.Debug|x64.Build.0 = DebugWinPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.Debug|x86.ActiveCfg = DebugWinPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.Debug|x86.Build.0 = DebugWinPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugMono|Any CPU.ActiveCfg = DebugMono|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugMono|Any CPU.Build.0 = DebugMono|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugMono|x64.ActiveCfg = DebugMono|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugMono|x64.Build.0 = DebugMono|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugMono|x86.ActiveCfg = DebugMono|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugMono|x86.Build.0 = DebugMono|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugMonoPY3|Any CPU.ActiveCfg = DebugMonoPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugMonoPY3|Any CPU.Build.0 = DebugMonoPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugMonoPY3|x64.ActiveCfg = DebugMonoPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugMonoPY3|x64.Build.0 = DebugMonoPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugMonoPY3|x86.ActiveCfg = DebugMonoPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugMonoPY3|x86.Build.0 = DebugMonoPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugWin|Any CPU.ActiveCfg = DebugWin|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugWin|Any CPU.Build.0 = DebugWin|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugWin|x64.ActiveCfg = DebugWin|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugWin|x64.Build.0 = DebugWin|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugWin|x86.ActiveCfg = DebugWin|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugWin|x86.Build.0 = DebugWin|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugWinPY3|Any CPU.ActiveCfg = DebugWinPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugWinPY3|Any CPU.Build.0 = DebugWinPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugWinPY3|x64.ActiveCfg = DebugWinPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugWinPY3|x64.Build.0 = DebugWinPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugWinPY3|x86.ActiveCfg = DebugWinPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugWinPY3|x86.Build.0 = DebugWinPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.Release|Any CPU.ActiveCfg = ReleaseWinPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.Release|Any CPU.Build.0 = ReleaseWinPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.Release|x64.ActiveCfg = ReleaseWinPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.Release|x64.Build.0 = ReleaseWinPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.Release|x86.ActiveCfg = ReleaseWinPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.Release|x86.Build.0 = ReleaseWinPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseMono|Any CPU.ActiveCfg = ReleaseMono|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseMono|Any CPU.Build.0 = ReleaseMono|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseMono|x64.ActiveCfg = ReleaseMono|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseMono|x64.Build.0 = ReleaseMono|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseMono|x86.ActiveCfg = ReleaseMono|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseMono|x86.Build.0 = ReleaseMono|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseMonoPY3|Any CPU.ActiveCfg = ReleaseMonoPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseMonoPY3|Any CPU.Build.0 = ReleaseMonoPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseMonoPY3|x64.ActiveCfg = ReleaseMonoPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseMonoPY3|x64.Build.0 = ReleaseMonoPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseMonoPY3|x86.ActiveCfg = ReleaseMonoPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseMonoPY3|x86.Build.0 = ReleaseMonoPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseWin|Any CPU.ActiveCfg = ReleaseWin|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseWin|Any CPU.Build.0 = ReleaseWin|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseWin|x64.ActiveCfg = ReleaseWin|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseWin|x64.Build.0 = ReleaseWin|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseWin|x86.ActiveCfg = ReleaseWin|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseWin|x86.Build.0 = ReleaseWin|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseWinPY3|Any CPU.ActiveCfg = ReleaseWinPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseWinPY3|Any CPU.Build.0 = ReleaseWinPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseWinPY3|x64.ActiveCfg = ReleaseWinPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseWinPY3|x64.Build.0 = ReleaseWinPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseWinPY3|x86.ActiveCfg = ReleaseWinPY3|Any CPU - {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseWinPY3|x86.Build.0 = ReleaseWinPY3|Any CPU - {66B8D01A-9906-452A-B09E-BF75EA76468F}.Debug|Any CPU.ActiveCfg = ReleaseWinPY3|x86 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.Debug|Any CPU.Build.0 = ReleaseWinPY3|x86 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.Debug|x64.ActiveCfg = DebugWinPY3|x64 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.Debug|x64.Build.0 = DebugWinPY3|x64 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.Debug|x86.ActiveCfg = DebugWinPY3|x86 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.Debug|x86.Build.0 = DebugWinPY3|x86 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugMono|Any CPU.ActiveCfg = DebugMono|x86 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugMono|x64.ActiveCfg = DebugMono|x64 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugMono|x64.Build.0 = DebugMono|x64 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugMono|x86.ActiveCfg = DebugMono|x86 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugMono|x86.Build.0 = DebugMono|x86 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugMonoPY3|Any CPU.ActiveCfg = DebugMonoPY3|x86 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugMonoPY3|x64.ActiveCfg = DebugMonoPY3|x64 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugMonoPY3|x64.Build.0 = DebugMonoPY3|x64 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugMonoPY3|x86.ActiveCfg = DebugMonoPY3|x86 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugMonoPY3|x86.Build.0 = DebugMonoPY3|x86 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugWin|Any CPU.ActiveCfg = DebugWin|x86 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugWin|x64.ActiveCfg = DebugWin|x64 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugWin|x64.Build.0 = DebugWin|x64 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugWin|x86.ActiveCfg = DebugWin|x86 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugWin|x86.Build.0 = DebugWin|x86 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugWinPY3|Any CPU.ActiveCfg = DebugWinPY3|x86 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugWinPY3|x64.ActiveCfg = DebugWinPY3|x64 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugWinPY3|x64.Build.0 = DebugWinPY3|x64 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugWinPY3|x86.ActiveCfg = DebugWinPY3|x86 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugWinPY3|x86.Build.0 = DebugWinPY3|x86 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.Release|Any CPU.ActiveCfg = ReleaseWinPY3|x86 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.Release|Any CPU.Build.0 = ReleaseWinPY3|x86 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.Release|x64.ActiveCfg = ReleaseWinPY3|x64 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.Release|x64.Build.0 = ReleaseWinPY3|x64 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.Release|x86.ActiveCfg = ReleaseWinPY3|x86 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.Release|x86.Build.0 = ReleaseWinPY3|x86 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseMono|Any CPU.ActiveCfg = ReleaseMono|x86 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseMono|x64.ActiveCfg = ReleaseMono|x64 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseMono|x64.Build.0 = ReleaseMono|x64 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseMono|x86.ActiveCfg = ReleaseMono|x86 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseMono|x86.Build.0 = ReleaseMono|x86 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseMonoPY3|Any CPU.ActiveCfg = ReleaseMonoPY3|x86 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseMonoPY3|x64.ActiveCfg = ReleaseMonoPY3|x64 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseMonoPY3|x64.Build.0 = ReleaseMonoPY3|x64 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseMonoPY3|x86.ActiveCfg = ReleaseMonoPY3|x86 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseMonoPY3|x86.Build.0 = ReleaseMonoPY3|x86 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseWin|Any CPU.ActiveCfg = ReleaseWin|x86 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseWin|x64.ActiveCfg = ReleaseWin|x64 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseWin|x64.Build.0 = ReleaseWin|x64 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseWin|x86.ActiveCfg = ReleaseWin|x86 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseWin|x86.Build.0 = ReleaseWin|x86 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseWinPY3|Any CPU.ActiveCfg = ReleaseWinPY3|x86 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseWinPY3|x64.ActiveCfg = ReleaseWinPY3|x64 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseWinPY3|x64.Build.0 = ReleaseWinPY3|x64 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseWinPY3|x86.ActiveCfg = ReleaseWinPY3|x86 - {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseWinPY3|x86.Build.0 = ReleaseWinPY3|x86 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.Debug|Any CPU.ActiveCfg = ReleaseWinPY3|x86 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.Debug|Any CPU.Build.0 = ReleaseWinPY3|x86 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.Debug|x64.ActiveCfg = DebugWinPY3|x64 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.Debug|x64.Build.0 = DebugWinPY3|x64 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.Debug|x86.ActiveCfg = DebugWinPY3|x86 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.Debug|x86.Build.0 = DebugWinPY3|x86 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.DebugMono|Any CPU.ActiveCfg = DebugMono|x86 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.DebugMono|x64.ActiveCfg = DebugMono|x64 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.DebugMono|x86.ActiveCfg = DebugMono|x86 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.DebugMonoPY3|Any CPU.ActiveCfg = DebugMonoPY3|x86 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.DebugMonoPY3|x64.ActiveCfg = DebugMonoPY3|x64 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.DebugMonoPY3|x86.ActiveCfg = DebugMonoPY3|x86 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.DebugWin|Any CPU.ActiveCfg = DebugWin|x86 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.DebugWin|x64.ActiveCfg = DebugWin|x64 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.DebugWin|x64.Build.0 = DebugWin|x64 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.DebugWin|x86.ActiveCfg = DebugWin|x86 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.DebugWin|x86.Build.0 = DebugWin|x86 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.DebugWinPY3|Any CPU.ActiveCfg = DebugWinPY3|x86 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.DebugWinPY3|x64.ActiveCfg = DebugWinPY3|x64 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.DebugWinPY3|x64.Build.0 = DebugWinPY3|x64 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.DebugWinPY3|x86.ActiveCfg = DebugWinPY3|x86 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.DebugWinPY3|x86.Build.0 = DebugWinPY3|x86 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.Release|Any CPU.ActiveCfg = ReleaseWinPY3|x86 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.Release|Any CPU.Build.0 = ReleaseWinPY3|x86 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.Release|x64.ActiveCfg = ReleaseWinPY3|x64 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.Release|x64.Build.0 = ReleaseWinPY3|x64 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.Release|x86.ActiveCfg = ReleaseWinPY3|x86 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.Release|x86.Build.0 = ReleaseWinPY3|x86 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.ReleaseMono|Any CPU.ActiveCfg = ReleaseMono|x86 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.ReleaseMono|x64.ActiveCfg = ReleaseMono|x64 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.ReleaseMono|x86.ActiveCfg = ReleaseMono|x86 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.ReleaseMonoPY3|Any CPU.ActiveCfg = ReleaseMonoPY3|x86 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.ReleaseMonoPY3|x64.ActiveCfg = ReleaseMonoPY3|x64 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.ReleaseMonoPY3|x86.ActiveCfg = ReleaseMonoPY3|x86 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.ReleaseWin|Any CPU.ActiveCfg = ReleaseWin|x86 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.ReleaseWin|x64.ActiveCfg = ReleaseWin|x64 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.ReleaseWin|x64.Build.0 = ReleaseWin|x64 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.ReleaseWin|x86.ActiveCfg = ReleaseWin|x86 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.ReleaseWin|x86.Build.0 = ReleaseWin|x86 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.ReleaseWinPY3|Any CPU.ActiveCfg = ReleaseWinPY3|x86 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.ReleaseWinPY3|x64.ActiveCfg = ReleaseWinPY3|x64 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.ReleaseWinPY3|x64.Build.0 = ReleaseWinPY3|x64 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.ReleaseWinPY3|x86.ActiveCfg = ReleaseWinPY3|x86 - {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.ReleaseWinPY3|x86.Build.0 = ReleaseWinPY3|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.Debug|Any CPU.ActiveCfg = ReleaseWinPY3|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.Debug|Any CPU.Build.0 = ReleaseWinPY3|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.Debug|x64.ActiveCfg = DebugWinPY3|x64 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.Debug|x64.Build.0 = DebugWinPY3|x64 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.Debug|x86.ActiveCfg = DebugWinPY3|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.Debug|x86.Build.0 = DebugWinPY3|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugMono|Any CPU.ActiveCfg = DebugMono|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugMono|x64.ActiveCfg = DebugMono|x64 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugMono|x64.Build.0 = DebugMono|x64 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugMono|x86.ActiveCfg = DebugMono|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugMono|x86.Build.0 = DebugMono|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugMonoPY3|Any CPU.ActiveCfg = DebugMonoPY3|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugMonoPY3|x64.ActiveCfg = DebugMonoPY3|x64 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugMonoPY3|x64.Build.0 = DebugMonoPY3|x64 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugMonoPY3|x86.ActiveCfg = DebugMonoPY3|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugMonoPY3|x86.Build.0 = DebugMonoPY3|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugWin|Any CPU.ActiveCfg = DebugWin|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugWin|x64.ActiveCfg = DebugWin|x64 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugWin|x64.Build.0 = DebugWin|x64 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugWin|x86.ActiveCfg = DebugWin|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugWin|x86.Build.0 = DebugWin|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugWinPY3|Any CPU.ActiveCfg = DebugWinPY3|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugWinPY3|x64.ActiveCfg = DebugWinPY3|x64 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugWinPY3|x64.Build.0 = DebugWinPY3|x64 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugWinPY3|x86.ActiveCfg = DebugWinPY3|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugWinPY3|x86.Build.0 = DebugWinPY3|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.Release|Any CPU.ActiveCfg = ReleaseWinPY3|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.Release|Any CPU.Build.0 = ReleaseWinPY3|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.Release|x64.ActiveCfg = ReleaseWinPY3|x64 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.Release|x64.Build.0 = ReleaseWinPY3|x64 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.Release|x86.ActiveCfg = ReleaseWinPY3|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.Release|x86.Build.0 = ReleaseWinPY3|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseMono|Any CPU.ActiveCfg = ReleaseMono|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseMono|x64.ActiveCfg = ReleaseMono|x64 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseMono|x64.Build.0 = ReleaseMono|x64 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseMono|x86.ActiveCfg = ReleaseMono|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseMono|x86.Build.0 = ReleaseMono|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseMonoPY3|Any CPU.ActiveCfg = ReleaseMonoPY3|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseMonoPY3|x64.ActiveCfg = ReleaseMonoPY3|x64 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseMonoPY3|x64.Build.0 = ReleaseMonoPY3|x64 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseMonoPY3|x86.ActiveCfg = ReleaseMonoPY3|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseMonoPY3|x86.Build.0 = ReleaseMonoPY3|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseWin|Any CPU.ActiveCfg = ReleaseWin|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseWin|x64.ActiveCfg = ReleaseWin|x64 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseWin|x64.Build.0 = ReleaseWin|x64 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseWin|x86.ActiveCfg = ReleaseWin|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseWin|x86.Build.0 = ReleaseWin|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseWinPY3|Any CPU.ActiveCfg = ReleaseWinPY3|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseWinPY3|x64.ActiveCfg = ReleaseWinPY3|x64 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseWinPY3|x64.Build.0 = ReleaseWinPY3|x64 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseWinPY3|x86.ActiveCfg = ReleaseWinPY3|x86 - {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseWinPY3|x86.Build.0 = ReleaseWinPY3|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.Debug|Any CPU.ActiveCfg = ReleaseWinPY3|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.Debug|Any CPU.Build.0 = ReleaseWinPY3|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.Debug|x64.ActiveCfg = DebugWinPY3|x64 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.Debug|x64.Build.0 = DebugWinPY3|x64 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.Debug|x86.ActiveCfg = DebugWinPY3|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.Debug|x86.Build.0 = DebugWinPY3|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugMono|Any CPU.ActiveCfg = DebugMono|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugMono|x64.ActiveCfg = DebugMono|x64 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugMono|x64.Build.0 = DebugMono|x64 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugMono|x86.ActiveCfg = DebugMono|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugMono|x86.Build.0 = DebugMono|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugMonoPY3|Any CPU.ActiveCfg = DebugMonoPY3|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugMonoPY3|x64.ActiveCfg = DebugMonoPY3|x64 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugMonoPY3|x64.Build.0 = DebugMonoPY3|x64 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugMonoPY3|x86.ActiveCfg = DebugMonoPY3|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugMonoPY3|x86.Build.0 = DebugMonoPY3|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugWin|Any CPU.ActiveCfg = DebugWin|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugWin|x64.ActiveCfg = DebugWin|x64 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugWin|x64.Build.0 = DebugWin|x64 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugWin|x86.ActiveCfg = DebugWin|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugWin|x86.Build.0 = DebugWin|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugWinPY3|Any CPU.ActiveCfg = DebugWinPY3|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugWinPY3|x64.ActiveCfg = DebugWinPY3|x64 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugWinPY3|x64.Build.0 = DebugWinPY3|x64 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugWinPY3|x86.ActiveCfg = DebugWinPY3|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugWinPY3|x86.Build.0 = DebugWinPY3|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.Release|Any CPU.ActiveCfg = ReleaseWinPY3|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.Release|Any CPU.Build.0 = ReleaseWinPY3|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.Release|x64.ActiveCfg = ReleaseWinPY3|x64 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.Release|x64.Build.0 = ReleaseWinPY3|x64 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.Release|x86.ActiveCfg = ReleaseWinPY3|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.Release|x86.Build.0 = ReleaseWinPY3|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseMono|Any CPU.ActiveCfg = ReleaseMono|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseMono|x64.ActiveCfg = ReleaseMono|x64 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseMono|x64.Build.0 = ReleaseMono|x64 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseMono|x86.ActiveCfg = ReleaseMono|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseMono|x86.Build.0 = ReleaseMono|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseMonoPY3|Any CPU.ActiveCfg = ReleaseMonoPY3|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseMonoPY3|x64.ActiveCfg = ReleaseMonoPY3|x64 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseMonoPY3|x64.Build.0 = ReleaseMonoPY3|x64 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseMonoPY3|x86.ActiveCfg = ReleaseMonoPY3|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseMonoPY3|x86.Build.0 = ReleaseMonoPY3|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseWin|Any CPU.ActiveCfg = ReleaseWin|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseWin|x64.ActiveCfg = ReleaseWin|x64 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseWin|x64.Build.0 = ReleaseWin|x64 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseWin|x86.ActiveCfg = ReleaseWin|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseWin|x86.Build.0 = ReleaseWin|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseWinPY3|Any CPU.ActiveCfg = ReleaseWinPY3|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseWinPY3|x64.ActiveCfg = ReleaseWinPY3|x64 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseWinPY3|x64.Build.0 = ReleaseWinPY3|x64 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseWinPY3|x86.ActiveCfg = ReleaseWinPY3|x86 - {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseWinPY3|x86.Build.0 = ReleaseWinPY3|x86 - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.Debug|Any CPU.ActiveCfg = DebugMono|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.Debug|Any CPU.Build.0 = DebugMono|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.Debug|x64.ActiveCfg = DebugMono|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.Debug|x64.Build.0 = DebugMono|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.Debug|x86.ActiveCfg = DebugMono|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.Debug|x86.Build.0 = DebugMono|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.DebugMono|Any CPU.ActiveCfg = DebugMono|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.DebugMono|x64.ActiveCfg = DebugMono|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.DebugMono|x86.ActiveCfg = DebugMono|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.DebugMonoPY3|Any CPU.ActiveCfg = DebugMonoPY3|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.DebugMonoPY3|x64.ActiveCfg = DebugMonoPY3|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.DebugMonoPY3|x86.ActiveCfg = DebugMonoPY3|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.DebugWin|Any CPU.ActiveCfg = DebugWin|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.DebugWin|Any CPU.Build.0 = DebugWin|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.DebugWin|x64.ActiveCfg = DebugWin|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.DebugWin|x64.Build.0 = DebugWin|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.DebugWin|x86.ActiveCfg = DebugWin|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.DebugWin|x86.Build.0 = DebugWin|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.DebugWinPY3|Any CPU.ActiveCfg = DebugWinPY3|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.DebugWinPY3|Any CPU.Build.0 = DebugWinPY3|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.DebugWinPY3|x64.ActiveCfg = DebugWinPY3|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.DebugWinPY3|x64.Build.0 = DebugWinPY3|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.DebugWinPY3|x86.ActiveCfg = DebugWinPY3|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.DebugWinPY3|x86.Build.0 = DebugWinPY3|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.Release|Any CPU.ActiveCfg = ReleaseMono|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.Release|Any CPU.Build.0 = ReleaseMono|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.Release|x64.ActiveCfg = ReleaseMono|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.Release|x64.Build.0 = ReleaseMono|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.Release|x86.ActiveCfg = ReleaseMono|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.Release|x86.Build.0 = ReleaseMono|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.ReleaseMono|Any CPU.ActiveCfg = ReleaseMono|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.ReleaseMono|x64.ActiveCfg = ReleaseMono|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.ReleaseMono|x86.ActiveCfg = ReleaseMono|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.ReleaseMonoPY3|Any CPU.ActiveCfg = ReleaseMonoPY3|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.ReleaseMonoPY3|x64.ActiveCfg = ReleaseMonoPY3|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.ReleaseMonoPY3|x86.ActiveCfg = ReleaseMonoPY3|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.ReleaseWin|Any CPU.ActiveCfg = ReleaseWin|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.ReleaseWin|Any CPU.Build.0 = ReleaseWin|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.ReleaseWin|x64.ActiveCfg = ReleaseWin|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.ReleaseWin|x64.Build.0 = ReleaseWin|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.ReleaseWin|x86.ActiveCfg = ReleaseWin|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.ReleaseWin|x86.Build.0 = ReleaseWin|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.ReleaseWinPY3|Any CPU.ActiveCfg = ReleaseWinPY3|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.ReleaseWinPY3|Any CPU.Build.0 = ReleaseWinPY3|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.ReleaseWinPY3|x64.ActiveCfg = ReleaseWinPY3|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.ReleaseWinPY3|x64.Build.0 = ReleaseWinPY3|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.ReleaseWinPY3|x86.ActiveCfg = ReleaseWinPY3|Any CPU - {6FB0D091-9CEC-4DCC-8701-C40F9BFC9EDE}.ReleaseWinPY3|x86.Build.0 = ReleaseWinPY3|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {A6347B90-BBE6-4E45-90BF-1BD8B76069E3} - EndGlobalSection -EndGlobal diff --git a/pythonnet.sln b/pythonnet.sln index d07bd654d..48153b648 100644 --- a/pythonnet.sln +++ b/pythonnet.sln @@ -1,200 +1,34 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.Runtime", "src\runtime\Python.Runtime.csproj", "{097B4AC0-74E9-4C58-BCF8-C69746EC8271}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.Test", "src\testing\Python.Test.csproj", "{6F401A34-273B-450F-9A4C-13550BE0767B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.EmbeddingTest", "src\embed_tests\Python.EmbeddingTest.csproj", "{4165C59D-2822-499F-A6DB-EACA4C331EB5}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Console", "src\console\Console.csproj", "{E29DCF0A-5114-4A98-B1DD-71264B6EA349}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - DebugMono|x64 = DebugMono|x64 - DebugMono|x86 = DebugMono|x86 - DebugMonoPY3|x64 = DebugMonoPY3|x64 - DebugMonoPY3|x86 = DebugMonoPY3|x86 - DebugWin|x64 = DebugWin|x64 - DebugWin|x86 = DebugWin|x86 - DebugWinPY3|x64 = DebugWinPY3|x64 - DebugWinPY3|x86 = DebugWinPY3|x86 - ReleaseMono|x64 = ReleaseMono|x64 - ReleaseMono|x86 = ReleaseMono|x86 - ReleaseMonoPY3|x64 = ReleaseMonoPY3|x64 - ReleaseMonoPY3|x86 = ReleaseMonoPY3|x86 - ReleaseWin|x64 = ReleaseWin|x64 - ReleaseWin|x86 = ReleaseWin|x86 - ReleaseWinPY3|x64 = ReleaseWinPY3|x64 - ReleaseWinPY3|x86 = ReleaseWinPY3|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMono|x64.ActiveCfg = DebugMono|x64 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMono|x64.Build.0 = DebugMono|x64 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMono|x86.ActiveCfg = DebugMono|x86 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMono|x86.Build.0 = DebugMono|x86 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMonoPY3|x64.ActiveCfg = DebugMonoPY3|x64 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMonoPY3|x64.Build.0 = DebugMonoPY3|x64 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMonoPY3|x86.ActiveCfg = DebugMonoPY3|x86 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMonoPY3|x86.Build.0 = DebugMonoPY3|x86 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWin|x64.ActiveCfg = DebugWin|x64 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWin|x64.Build.0 = DebugWin|x64 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWin|x86.ActiveCfg = DebugWin|x86 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWin|x86.Build.0 = DebugWin|x86 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWinPY3|x64.ActiveCfg = DebugWinPY3|x64 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWinPY3|x64.Build.0 = DebugWinPY3|x64 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWinPY3|x86.ActiveCfg = DebugWinPY3|x86 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWinPY3|x86.Build.0 = DebugWinPY3|x86 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMono|x64.ActiveCfg = ReleaseMono|x64 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMono|x64.Build.0 = ReleaseMono|x64 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMono|x86.ActiveCfg = ReleaseMono|x86 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMono|x86.Build.0 = ReleaseMono|x86 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMonoPY3|x64.ActiveCfg = ReleaseMonoPY3|x64 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMonoPY3|x64.Build.0 = ReleaseMonoPY3|x64 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMonoPY3|x86.ActiveCfg = ReleaseMonoPY3|x86 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMonoPY3|x86.Build.0 = ReleaseMonoPY3|x86 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWin|x64.ActiveCfg = ReleaseWin|x64 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWin|x64.Build.0 = ReleaseWin|x64 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWin|x86.ActiveCfg = ReleaseWin|x86 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWin|x86.Build.0 = ReleaseWin|x86 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWinPY3|x64.ActiveCfg = ReleaseWinPY3|x64 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWinPY3|x64.Build.0 = ReleaseWinPY3|x64 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWinPY3|x86.ActiveCfg = ReleaseWinPY3|x86 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWinPY3|x86.Build.0 = ReleaseWinPY3|x86 - {6F401A34-273B-450F-9A4C-13550BE0767B}.DebugMono|x64.ActiveCfg = DebugMono|x64 - {6F401A34-273B-450F-9A4C-13550BE0767B}.DebugMono|x64.Build.0 = DebugMono|x64 - {6F401A34-273B-450F-9A4C-13550BE0767B}.DebugMono|x86.ActiveCfg = DebugMono|x86 - {6F401A34-273B-450F-9A4C-13550BE0767B}.DebugMono|x86.Build.0 = DebugMono|x86 - {6F401A34-273B-450F-9A4C-13550BE0767B}.DebugMonoPY3|x64.ActiveCfg = DebugMonoPY3|x64 - {6F401A34-273B-450F-9A4C-13550BE0767B}.DebugMonoPY3|x64.Build.0 = DebugMonoPY3|x64 - {6F401A34-273B-450F-9A4C-13550BE0767B}.DebugMonoPY3|x86.ActiveCfg = DebugMonoPY3|x86 - {6F401A34-273B-450F-9A4C-13550BE0767B}.DebugMonoPY3|x86.Build.0 = DebugMonoPY3|x86 - {6F401A34-273B-450F-9A4C-13550BE0767B}.DebugWin|x64.ActiveCfg = DebugWin|x64 - {6F401A34-273B-450F-9A4C-13550BE0767B}.DebugWin|x64.Build.0 = DebugWin|x64 - {6F401A34-273B-450F-9A4C-13550BE0767B}.DebugWin|x86.ActiveCfg = DebugWin|x86 - {6F401A34-273B-450F-9A4C-13550BE0767B}.DebugWin|x86.Build.0 = DebugWin|x86 - {6F401A34-273B-450F-9A4C-13550BE0767B}.DebugWinPY3|x64.ActiveCfg = DebugWinPY3|x64 - {6F401A34-273B-450F-9A4C-13550BE0767B}.DebugWinPY3|x64.Build.0 = DebugWinPY3|x64 - {6F401A34-273B-450F-9A4C-13550BE0767B}.DebugWinPY3|x86.ActiveCfg = DebugWinPY3|x86 - {6F401A34-273B-450F-9A4C-13550BE0767B}.DebugWinPY3|x86.Build.0 = DebugWinPY3|x86 - {6F401A34-273B-450F-9A4C-13550BE0767B}.ReleaseMono|x64.ActiveCfg = ReleaseMono|x64 - {6F401A34-273B-450F-9A4C-13550BE0767B}.ReleaseMono|x64.Build.0 = ReleaseMono|x64 - {6F401A34-273B-450F-9A4C-13550BE0767B}.ReleaseMono|x86.ActiveCfg = ReleaseMono|x86 - {6F401A34-273B-450F-9A4C-13550BE0767B}.ReleaseMono|x86.Build.0 = ReleaseMono|x86 - {6F401A34-273B-450F-9A4C-13550BE0767B}.ReleaseMonoPY3|x64.ActiveCfg = ReleaseMonoPY3|x64 - {6F401A34-273B-450F-9A4C-13550BE0767B}.ReleaseMonoPY3|x64.Build.0 = ReleaseMonoPY3|x64 - {6F401A34-273B-450F-9A4C-13550BE0767B}.ReleaseMonoPY3|x86.ActiveCfg = ReleaseMonoPY3|x86 - {6F401A34-273B-450F-9A4C-13550BE0767B}.ReleaseMonoPY3|x86.Build.0 = ReleaseMonoPY3|x86 - {6F401A34-273B-450F-9A4C-13550BE0767B}.ReleaseWin|x64.ActiveCfg = ReleaseWin|x64 - {6F401A34-273B-450F-9A4C-13550BE0767B}.ReleaseWin|x64.Build.0 = ReleaseWin|x64 - {6F401A34-273B-450F-9A4C-13550BE0767B}.ReleaseWin|x86.ActiveCfg = ReleaseWin|x86 - {6F401A34-273B-450F-9A4C-13550BE0767B}.ReleaseWin|x86.Build.0 = ReleaseWin|x86 - {6F401A34-273B-450F-9A4C-13550BE0767B}.ReleaseWinPY3|x64.ActiveCfg = ReleaseWinPY3|x64 - {6F401A34-273B-450F-9A4C-13550BE0767B}.ReleaseWinPY3|x64.Build.0 = ReleaseWinPY3|x64 - {6F401A34-273B-450F-9A4C-13550BE0767B}.ReleaseWinPY3|x86.ActiveCfg = ReleaseWinPY3|x86 - {6F401A34-273B-450F-9A4C-13550BE0767B}.ReleaseWinPY3|x86.Build.0 = ReleaseWinPY3|x86 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.DebugMono|x64.ActiveCfg = DebugMono|x64 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.DebugMono|x64.Build.0 = DebugMono|x64 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.DebugMono|x86.ActiveCfg = DebugMono|x86 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.DebugMono|x86.Build.0 = DebugMono|x86 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.DebugMonoPY3|x64.ActiveCfg = DebugMonoPY3|x64 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.DebugMonoPY3|x64.Build.0 = DebugMonoPY3|x64 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.DebugMonoPY3|x86.ActiveCfg = DebugMonoPY3|x86 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.DebugMonoPY3|x86.Build.0 = DebugMonoPY3|x86 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.DebugWin|x64.ActiveCfg = DebugWin|x64 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.DebugWin|x64.Build.0 = DebugWin|x64 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.DebugWin|x86.ActiveCfg = DebugWin|x86 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.DebugWin|x86.Build.0 = DebugWin|x86 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.DebugWinPY3|x64.ActiveCfg = DebugWinPY3|x64 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.DebugWinPY3|x64.Build.0 = DebugWinPY3|x64 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.DebugWinPY3|x86.ActiveCfg = DebugWinPY3|x86 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.DebugWinPY3|x86.Build.0 = DebugWinPY3|x86 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.ReleaseMono|x64.ActiveCfg = ReleaseMono|x64 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.ReleaseMono|x64.Build.0 = ReleaseMono|x64 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.ReleaseMono|x86.ActiveCfg = ReleaseMono|x86 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.ReleaseMono|x86.Build.0 = ReleaseMono|x86 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.ReleaseMonoPY3|x64.ActiveCfg = ReleaseMonoPY3|x64 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.ReleaseMonoPY3|x64.Build.0 = ReleaseMonoPY3|x64 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.ReleaseMonoPY3|x86.ActiveCfg = ReleaseMonoPY3|x86 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.ReleaseMonoPY3|x86.Build.0 = ReleaseMonoPY3|x86 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.ReleaseWin|x64.ActiveCfg = ReleaseWin|x64 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.ReleaseWin|x64.Build.0 = ReleaseWin|x64 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.ReleaseWin|x86.ActiveCfg = ReleaseWin|x86 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.ReleaseWin|x86.Build.0 = ReleaseWin|x86 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.ReleaseWinPY3|x64.ActiveCfg = ReleaseWinPY3|x64 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.ReleaseWinPY3|x64.Build.0 = ReleaseWinPY3|x64 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.ReleaseWinPY3|x86.ActiveCfg = ReleaseWinPY3|x86 - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.ReleaseWinPY3|x86.Build.0 = ReleaseWinPY3|x86 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.DebugMono|x64.ActiveCfg = DebugMono|x64 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.DebugMono|x64.Build.0 = DebugMono|x64 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.DebugMono|x86.ActiveCfg = DebugMono|x86 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.DebugMono|x86.Build.0 = DebugMono|x86 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.DebugMonoPY3|x64.ActiveCfg = DebugMonoPY3|x64 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.DebugMonoPY3|x64.Build.0 = DebugMonoPY3|x64 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.DebugMonoPY3|x86.ActiveCfg = DebugMonoPY3|x86 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.DebugMonoPY3|x86.Build.0 = DebugMonoPY3|x86 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.DebugWin|x64.ActiveCfg = DebugWin|x64 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.DebugWin|x64.Build.0 = DebugWin|x64 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.DebugWin|x86.ActiveCfg = DebugWin|x86 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.DebugWin|x86.Build.0 = DebugWin|x86 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.DebugWinPY3|x64.ActiveCfg = DebugWinPY3|x64 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.DebugWinPY3|x64.Build.0 = DebugWinPY3|x64 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.DebugWinPY3|x86.ActiveCfg = DebugWinPY3|x86 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.DebugWinPY3|x86.Build.0 = DebugWinPY3|x86 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseMono|x64.ActiveCfg = ReleaseMono|x64 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseMono|x64.Build.0 = ReleaseMono|x64 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseMono|x86.ActiveCfg = ReleaseMono|x86 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseMono|x86.Build.0 = ReleaseMono|x86 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseMonoPY3|x64.ActiveCfg = ReleaseMonoPY3|x64 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseMonoPY3|x64.Build.0 = ReleaseMonoPY3|x64 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseMonoPY3|x86.ActiveCfg = ReleaseMonoPY3|x86 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseMonoPY3|x86.Build.0 = ReleaseMonoPY3|x86 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseWin|x64.ActiveCfg = ReleaseWin|x64 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseWin|x64.Build.0 = ReleaseWin|x64 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseWin|x86.ActiveCfg = ReleaseWin|x86 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseWin|x86.Build.0 = ReleaseWin|x86 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseWinPY3|x64.ActiveCfg = ReleaseWinPY3|x64 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseWinPY3|x64.Build.0 = ReleaseWinPY3|x64 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseWinPY3|x86.ActiveCfg = ReleaseWinPY3|x86 - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseWinPY3|x86.Build.0 = ReleaseWinPY3|x86 - {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugMono|x64.ActiveCfg = DebugMono|x64 - {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugMono|x86.ActiveCfg = DebugMono|x86 - {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugMonoPY3|x64.ActiveCfg = DebugMonoPY3|x64 - {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugMonoPY3|x86.ActiveCfg = DebugMonoPY3|x86 - {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWin|x64.ActiveCfg = DebugWin|x64 - {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWin|x64.Build.0 = DebugWin|x64 - {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWin|x86.ActiveCfg = DebugWin|x86 - {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWin|x86.Build.0 = DebugWin|x86 - {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWinPY3|x64.ActiveCfg = DebugWinPY3|x64 - {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWinPY3|x64.Build.0 = DebugWinPY3|x64 - {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWinPY3|x86.ActiveCfg = DebugWinPY3|x86 - {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWinPY3|x86.Build.0 = DebugWinPY3|x86 - {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseMono|x64.ActiveCfg = ReleaseMono|x64 - {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseMono|x86.ActiveCfg = ReleaseMono|x86 - {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseMonoPY3|x64.ActiveCfg = ReleaseMonoPY3|x64 - {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseMonoPY3|x86.ActiveCfg = ReleaseMonoPY3|x86 - {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseWin|x64.ActiveCfg = ReleaseWin|x64 - {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseWin|x64.Build.0 = ReleaseWin|x64 - {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseWin|x86.ActiveCfg = ReleaseWin|x86 - {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseWin|x86.Build.0 = ReleaseWin|x86 - {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseWinPY3|x64.ActiveCfg = ReleaseWinPY3|x64 - {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseWinPY3|x64.Build.0 = ReleaseWinPY3|x64 - {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseWinPY3|x86.ActiveCfg = ReleaseWinPY3|x86 - {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseWinPY3|x86.Build.0 = ReleaseWinPY3|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(MonoDevelopProperties) = preSolution - StartupItem = src\console\Console.csproj - Policies = $0 - $0.VersionControlPolicy = $1 - $1.inheritsSet = Mono - $0.ChangeLogPolicy = $2 - $2.UpdateMode = None - $2.MessageStyle = $3 - $3.LineAlign = 0 - $2.inheritsSet = Mono - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26124.0 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.Runtime", "Python.Runtime\Python.Runtime.csproj", "{C9E02762-3DD2-4669-81DA-6A64C80D07E0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C9E02762-3DD2-4669-81DA-6A64C80D07E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C9E02762-3DD2-4669-81DA-6A64C80D07E0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C9E02762-3DD2-4669-81DA-6A64C80D07E0}.Debug|x64.ActiveCfg = Debug|Any CPU + {C9E02762-3DD2-4669-81DA-6A64C80D07E0}.Debug|x64.Build.0 = Debug|Any CPU + {C9E02762-3DD2-4669-81DA-6A64C80D07E0}.Debug|x86.ActiveCfg = Debug|Any CPU + {C9E02762-3DD2-4669-81DA-6A64C80D07E0}.Debug|x86.Build.0 = Debug|Any CPU + {C9E02762-3DD2-4669-81DA-6A64C80D07E0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C9E02762-3DD2-4669-81DA-6A64C80D07E0}.Release|Any CPU.Build.0 = Release|Any CPU + {C9E02762-3DD2-4669-81DA-6A64C80D07E0}.Release|x64.ActiveCfg = Release|Any CPU + {C9E02762-3DD2-4669-81DA-6A64C80D07E0}.Release|x64.Build.0 = Release|Any CPU + {C9E02762-3DD2-4669-81DA-6A64C80D07E0}.Release|x86.ActiveCfg = Release|Any CPU + {C9E02762-3DD2-4669-81DA-6A64C80D07E0}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/src/SharedAssemblyInfo.cs b/src/SharedAssemblyInfo.cs deleted file mode 100644 index dc72b0bdf..000000000 --- a/src/SharedAssemblyInfo.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Reflection; -using System.Resources; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("pythonnet")] -[assembly: AssemblyProduct("Python for .NET")] -[assembly: AssemblyCopyright("Copyright (c) 2006-2019 the contributors of the 'Python for .NET' project")] -[assembly: AssemblyTrademark("")] - -[assembly: AssemblyCulture("")] -[assembly: NeutralResourcesLanguage("")] - -[assembly: CLSCompliant(true)] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// Version Information. Keeping it simple. May need to revisit for Nuget -// See: https://codingforsmarties.wordpress.com/2016/01/21/how-to-version-assemblies-destined-for-nuget/ -// AssemblyVersion can only be numeric -[assembly: AssemblyVersion("2.4.1")] diff --git a/src/console/Console.15.csproj b/src/console/Console.15.csproj deleted file mode 100644 index 4e765fea4..000000000 --- a/src/console/Console.15.csproj +++ /dev/null @@ -1,94 +0,0 @@ - - - - net40;netcoreapp2.0 - x64;x86 - DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3 - Exe - nPython - Python.Runtime - nPython - 2.4.1 - false - false - false - false - false - false - bin\ - false - $(OutputPath)\$(AssemblyName).xml - $(OutputPath)\$(TargetFramework)\$(AssemblyName).xml - 1591 - ..\..\ - $(SolutionDir)\bin\ - $(PythonBuildDir)\$(TargetFramework)\ - 6 - python-clear.ico - prompt - $(PYTHONNET_DEFINE_CONSTANTS) - XPLAT - $(DefineConstants);$(CustomDefineConstants);$(BaseDefineConstants); - $(DefineConstants);TRACE;DEBUG - $(NuGetPackageRoot)\microsoft.targetingpack.netframework.v4.5\1.0.1\lib\net45\ - - - x86 - - - x64 - - - - false - full - - - true - pdbonly - - - true - false - full - - - true - true - portable - - - - $(DefineConstants);DEBUG;TRACE - - - $(DefineConstants) - - - - $(PythonManifest) - - - - - - - Properties\SharedAssemblyInfo.cs - - - - - - Python.Runtime.dll - - - - - - - - - - - - diff --git a/src/console/Console.csproj b/src/console/Console.csproj deleted file mode 100644 index ea88b6356..000000000 --- a/src/console/Console.csproj +++ /dev/null @@ -1,101 +0,0 @@ - - - - Debug - AnyCPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349} - Exe - nPython - Python.Runtime - bin\nPython.xml - bin\ - v4.0 - - 1591 - ..\..\ - $(SolutionDir)\bin\ - Properties - 6 - python-clear.ico - prompt - - - x86 - - - x64 - - - true - DEBUG;TRACE - full - - - - - true - pdbonly - - - true - DEBUG;TRACE - full - - - - - true - pdbonly - - - true - DEBUG;TRACE - full - - - - - true - pdbonly - - - true - DEBUG;TRACE - full - - - - - true - pdbonly - - - $(PythonManifest) - - - - - - - - Properties\SharedAssemblyInfo.cs - - - - - - - Python.Runtime.dll - - - - - {097b4ac0-74e9-4c58-bcf8-c69746ec8271} - Python.Runtime - - - - - - - diff --git a/src/console/Properties/AssemblyInfo.cs b/src/console/Properties/AssemblyInfo.cs deleted file mode 100644 index 081ae0c94..000000000 --- a/src/console/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System.Reflection; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Python Console")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyDefaultAlias("python.exe")] diff --git a/src/console/python-clear.ico b/src/console/python-clear.ico deleted file mode 100644 index b37050cce6b7bf79e540b30ed0c27beef0365794..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 270398 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 - /// Example of Embedding Python inside of a .NET program. - /// - /// - /// It has similar functionality to doing `import clr` from within Python, but this does it - /// the other way around; That is, it loads Python inside of .NET program. - /// See https://github.com/pythonnet/pythonnet/issues/358 for more info. - /// - public sealed class PythonConsole - { -#if NET40 - private static AssemblyLoader assemblyLoader = new AssemblyLoader(); -#endif - private PythonConsole() - { - } - - [STAThread] - public static int Main(string[] args) - { - // Only net40 is capable to safely inject python.runtime.dll into resources. -#if NET40 - // reference the static assemblyLoader to stop it being optimized away - AssemblyLoader a = assemblyLoader; -#endif - string[] cmd = Environment.GetCommandLineArgs(); - PythonEngine.Initialize(); - - int i = Runtime.Py_Main(cmd.Length, cmd); - PythonEngine.Shutdown(); - - return i; - } - -#if NET40 - // Register a callback function to load embedded assemblies. - // (Python.Runtime.dll is included as a resource) - private sealed class AssemblyLoader - { - private Dictionary loadedAssemblies; - - public AssemblyLoader() - { - loadedAssemblies = new Dictionary(); - - AppDomain.CurrentDomain.AssemblyResolve += (sender, args) => - { - string shortName = args.Name.Split(',')[0]; - string resourceName = $"{shortName}.dll"; - - if (loadedAssemblies.ContainsKey(resourceName)) - { - return loadedAssemblies[resourceName]; - } - - // looks for the assembly from the resources and load it - using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName)) - { - if (stream != null) - { - var assemblyData = new byte[stream.Length]; - stream.Read(assemblyData, 0, assemblyData.Length); - Assembly assembly = Assembly.Load(assemblyData); - loadedAssemblies[resourceName] = assembly; - return assembly; - } - } - return null; - }; - } - } -#endif - } -} diff --git a/src/embed_tests/Python.EmbeddingTest.15.csproj b/src/embed_tests/Python.EmbeddingTest.15.csproj deleted file mode 100644 index 4f6b2de46..000000000 --- a/src/embed_tests/Python.EmbeddingTest.15.csproj +++ /dev/null @@ -1,116 +0,0 @@ - - - - - net40;netcoreapp2.0 - x64;x86 - DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3 - Exe - false - Python.EmbeddingTest - Python.EmbeddingTest - Python.EmbeddingTest - 2.4.1 - false - false - false - false - bin\ - false - $(OutputPath)\$(AssemblyName).xml - $(OutputPath)\$(TargetFramework)\$(AssemblyName).xml - 1591 - ..\..\ - $(SolutionDir)\bin\ - $(OutputPath)\$(TargetFramework)_publish - 6 - prompt - $(PYTHONNET_DEFINE_CONSTANTS) - XPLAT - $(DefineConstants);$(CustomDefineConstants);$(BaseDefineConstants); - $(DefineConstants);NETCOREAPP - $(DefineConstants);NETSTANDARD - $(DefineConstants);TRACE;DEBUG - $(NuGetPackageRoot)\microsoft.targetingpack.netframework.v4.5\1.0.1\lib\net45\ - - - x86 - - - x64 - - - - false - full - - - true - pdbonly - - - true - false - full - - - true - true - portable - - - - $(DefineConstants);DEBUG;TRACE - - - $(DefineConstants) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(TargetPath) - $(TargetDir)$(TargetName).pdb - - - - - - - - diff --git a/src/perf_tests/Python.PerformanceTests.csproj b/src/perf_tests/Python.PerformanceTests.csproj deleted file mode 100644 index 33949fdc1..000000000 --- a/src/perf_tests/Python.PerformanceTests.csproj +++ /dev/null @@ -1,34 +0,0 @@ - - - - net461 - DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3 - - false - - - - - - - - - compile - - - - - - - - - - - - - - - - - - diff --git a/src/pythonnet.snk b/src/pythonnet.snk deleted file mode 100644 index 90e3d6f4128f5f69be0c88f40395172d345cc85d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONaL0001A{f|leM5_itv;B=#=SlY#=G~AGGAUiQ zLF<_AMg}~-4N4sn9`L*>`Cp23IM=8OH8C-6Yjwif=`XNaneaRJ;J`V6;lt0jOQw*l zqVqGJ^C>Yq%w5dR(Iuq++(j|m?~z6V%~*KcU%O3AbKU#FGx$Iw6GPw=b|{3_6fuc! zB_+h+sW9cl#{;wxjuJeP<S z?|?mM^P--|a?8bB_cTA2lNt`8r{@UtO1RumWm^RS%1|{dJ@f6!t(XZ`_hC7hI``$c zfvVb7g9G&}>|+oX9Y#mo_xtW^Z<84z=6i!f#T&kXqN*F!mHLX;aBF5F-pEAT5{wTi zknh;l*b6r?#qmt=vv?R@;Qw)XZ@%7IKZJp?GbwqfoGBMDJZ7r<*r+k$FhqIsuAjY& zI{55%;!EIh6j^EioDNN6OhnH!s&NtG<~PXztb - - - net40;netstandard2.0 - AnyCPU - DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3 - net45 - Python.Runtime - Python.Runtime - pythonnet - 2.4.1 - true - false - Python for .NET - Copyright (c) 2006-2019 the contributors of the 'Python for .NET' project - Python and CLR (.NET and Mono) cross-platform language interop - pythonnet - https://github.com/pythonnet/pythonnet/blob/master/LICENSE - https://github.com/pythonnet/pythonnet - git - - python interop dynamic dlr Mono pinvoke - https://raw.githubusercontent.com/pythonnet/pythonnet/master/src/console/python-clear.ico - https://pythonnet.github.io/ - bin\ - false - $(OutputPath)\$(AssemblyName).xml - $(OutputPath)\$(TargetFramework)\$(AssemblyName).xml - 1591;NU1701 - ..\..\ - $(SolutionDir)\bin\ - $(PythonBuildDir)\$(TargetFramework)\ - 7.3 - True - ..\pythonnet.snk - $(PYTHONNET_DEFINE_CONSTANTS) - XPLAT - $(DefineConstants);$(CustomDefineConstants);$(BaseDefineConstants); - $(DefineConstants);NETSTANDARD - $(DefineConstants);TRACE;DEBUG - $(NuGetPackageRoot)\microsoft.targetingpack.netframework.v4.5\1.0.1\lib\net45\ - $(PYTHONNET_PY2_VERSION) - PYTHON27 - $(PYTHONNET_PY3_VERSION) - PYTHON38 - $(PYTHONNET_WIN_DEFINE_CONSTANTS) - UCS2 - $(PYTHONNET_MONO_DEFINE_CONSTANTS) - UCS4;MONO_LINUX;PYTHON_WITH_PYMALLOC - $(PYTHONNET_INTEROP_FILE) - - - false - full - - - true - pdbonly - - - true - false - full - - - true - true - portable - - - - $(DefineConstants);PYTHON2;$(Python2Version);$(PythonMonoDefineConstants) - - - $(DefineConstants);PYTHON3;$(Python3Version);$(PythonMonoDefineConstants) - - - $(DefineConstants);PYTHON2;$(Python2Version);$(PythonMonoDefineConstants);FINALIZER_CHECK;TRACE;DEBUG - - - $(DefineConstants);PYTHON3;$(Python3Version);$(PythonMonoDefineConstants);FINALIZER_CHECK;TRACE;DEBUG - - - $(DefineConstants);PYTHON2;$(Python2Version);$(PythonWinDefineConstants) - - - $(DefineConstants);PYTHON3;$(Python3Version);$(PythonWinDefineConstants) - - - $(DefineConstants);PYTHON2;$(Python2Version);$(PythonWinDefineConstants);FINALIZER_CHECK;TRACE;DEBUG - - - $(DefineConstants);PYTHON3;$(Python3Version);$(PythonWinDefineConstants);FINALIZER_CHECK;TRACE;DEBUG - - - - - - - - - - - - - - - - - - - - - - clr.py - - - - - - - - - - - - - - - - - - - - $(TargetPath) - $(TargetDir)$(TargetName).pdb - - - - - - - - - - - diff --git a/src/runtime/Python.Runtime.csproj b/src/runtime/Python.Runtime.csproj deleted file mode 100644 index 02656e51e..000000000 --- a/src/runtime/Python.Runtime.csproj +++ /dev/null @@ -1,174 +0,0 @@ - - - - Debug - AnyCPU - {097B4AC0-74E9-4C58-BCF8-C69746EC8271} - Library - Python.Runtime - Python.Runtime - bin\Python.Runtime.xml - bin\ - v4.0 - - 1591 - ..\..\ - $(SolutionDir)\bin\ - Properties - 7.3 - true - false - ..\pythonnet.snk - - - - - - PYTHON2;PYTHON27;UCS4 - true - pdbonly - - - PYTHON3;PYTHON38;UCS4 - true - pdbonly - - - true - PYTHON2;PYTHON27;UCS4;TRACE;DEBUG - false - full - - - true - PYTHON3;PYTHON38;UCS4;TRACE;DEBUG - false - full - - - PYTHON2;PYTHON27;UCS2 - true - pdbonly - - - PYTHON3;PYTHON38;UCS2 - true - pdbonly - - - true - PYTHON2;PYTHON27;UCS2;TRACE;DEBUG - false - full - - - true - PYTHON3;PYTHON38;UCS2;TRACE;DEBUG - false - full - - - - - - - - - Properties\SharedAssemblyInfo.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - clr.py - - - - - $(TargetPath) - $(TargetDir)$(TargetName).pdb - - - - - - diff --git a/src/testing/Python.Test.15.csproj b/src/testing/Python.Test.15.csproj deleted file mode 100644 index 8c23fe4b5..000000000 --- a/src/testing/Python.Test.15.csproj +++ /dev/null @@ -1,86 +0,0 @@ - - - - net40;netstandard2.0 - x64;x86 - DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3 - Python.Test - Python.Test - Python.Test - 2.4.1 - bin\ - false - $(OutputPath)\$(AssemblyName).xml - $(OutputPath)\$(TargetFramework)\$(AssemblyName).xml - 1591,0067 - ..\..\ - $(SolutionDir)\bin\ - $(PythonBuildDir)\$(TargetFramework)\ - 6 - false - ..\pythonnet.snk - prompt - $(PYTHONNET_DEFINE_CONSTANTS) - XPLAT - $(DefineConstants);$(CustomDefineConstants);$(BaseDefineConstants); - $(DefineConstants);TRACE;DEBUG - $(NuGetPackageRoot)\microsoft.targetingpack.netframework.v4.5\1.0.1\lib\net45\ - - - x86 - - - x64 - - - - false - full - - - true - pdbonly - - - true - false - full - - - true - true - portable - - - - $(DefineConstants);DEBUG;TRACE - - - $(DefineConstants) - - - - - - - - - - - - - - - - - - - $(TargetPath) - $(TargetDir)$(TargetName).pdb - - - - - - - diff --git a/src/testing/Python.Test.csproj b/src/testing/Python.Test.csproj deleted file mode 100644 index 6bf5c2d22..000000000 --- a/src/testing/Python.Test.csproj +++ /dev/null @@ -1,115 +0,0 @@ - - - - Debug - AnyCPU - {6F401A34-273B-450F-9A4C-13550BE0767B} - Library - Python.Test - Python.Test - bin\Python.Test.xml - bin\ - v4.0 - - 1591,0067 - ..\..\ - $(SolutionDir)\bin\ - 6 - false - ..\pythonnet.snk - prompt - - - x86 - - - x64 - - - true - DEBUG;TRACE - full - - - - - true - pdbonly - - - true - DEBUG;TRACE - full - - - - - true - pdbonly - - - true - DEBUG;TRACE - full - - - - - true - pdbonly - - - true - DEBUG;TRACE - full - - - - - true - pdbonly - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {097B4AC0-74E9-4C58-BCF8-C69746EC8271} - Python.Runtime - - - - - $(TargetPath) - $(TargetDir)$(TargetName).pdb - - - - - - diff --git a/src/tests/__init__.py b/tests/__init__.py similarity index 100% rename from src/tests/__init__.py rename to tests/__init__.py diff --git a/src/tests/_compat.py b/tests/_compat.py similarity index 100% rename from src/tests/_compat.py rename to tests/_compat.py diff --git a/src/tests/_missing_import.py b/tests/_missing_import.py similarity index 100% rename from src/tests/_missing_import.py rename to tests/_missing_import.py diff --git a/src/tests/conftest.py b/tests/conftest.py similarity index 100% rename from src/tests/conftest.py rename to tests/conftest.py diff --git a/src/tests/fixtures/.gitkeep b/tests/fixtures/.gitkeep similarity index 100% rename from src/tests/fixtures/.gitkeep rename to tests/fixtures/.gitkeep diff --git a/src/tests/fixtures/argv-fixture.py b/tests/fixtures/argv-fixture.py similarity index 100% rename from src/tests/fixtures/argv-fixture.py rename to tests/fixtures/argv-fixture.py diff --git a/src/tests/fixtures/netstandard2.0/.gitkeep b/tests/fixtures/netstandard2.0/.gitkeep similarity index 100% rename from src/tests/fixtures/netstandard2.0/.gitkeep rename to tests/fixtures/netstandard2.0/.gitkeep diff --git a/src/tests/importtest.py b/tests/importtest.py similarity index 100% rename from src/tests/importtest.py rename to tests/importtest.py diff --git a/src/tests/leaktest.py b/tests/leaktest.py similarity index 100% rename from src/tests/leaktest.py rename to tests/leaktest.py diff --git a/src/tests/profile.py b/tests/profile.py similarity index 100% rename from src/tests/profile.py rename to tests/profile.py diff --git a/src/tests/runtests.py b/tests/runtests.py similarity index 100% rename from src/tests/runtests.py rename to tests/runtests.py diff --git a/src/tests/stress.py b/tests/stress.py similarity index 100% rename from src/tests/stress.py rename to tests/stress.py diff --git a/src/tests/stresstest.py b/tests/stresstest.py similarity index 100% rename from src/tests/stresstest.py rename to tests/stresstest.py diff --git a/src/tests/test_array.py b/tests/test_array.py similarity index 100% rename from src/tests/test_array.py rename to tests/test_array.py diff --git a/src/tests/test_callback.py b/tests/test_callback.py similarity index 100% rename from src/tests/test_callback.py rename to tests/test_callback.py diff --git a/src/tests/test_class.py b/tests/test_class.py similarity index 100% rename from src/tests/test_class.py rename to tests/test_class.py diff --git a/src/tests/test_clrmethod.py b/tests/test_clrmethod.py similarity index 100% rename from src/tests/test_clrmethod.py rename to tests/test_clrmethod.py diff --git a/src/tests/test_compat.py b/tests/test_compat.py similarity index 100% rename from src/tests/test_compat.py rename to tests/test_compat.py diff --git a/src/tests/test_constructors.py b/tests/test_constructors.py similarity index 100% rename from src/tests/test_constructors.py rename to tests/test_constructors.py diff --git a/src/tests/test_conversion.py b/tests/test_conversion.py similarity index 100% rename from src/tests/test_conversion.py rename to tests/test_conversion.py diff --git a/src/tests/test_delegate.py b/tests/test_delegate.py similarity index 100% rename from src/tests/test_delegate.py rename to tests/test_delegate.py diff --git a/src/tests/test_docstring.py b/tests/test_docstring.py similarity index 100% rename from src/tests/test_docstring.py rename to tests/test_docstring.py diff --git a/src/tests/test_engine.py b/tests/test_engine.py similarity index 100% rename from src/tests/test_engine.py rename to tests/test_engine.py diff --git a/src/tests/test_enum.py b/tests/test_enum.py similarity index 100% rename from src/tests/test_enum.py rename to tests/test_enum.py diff --git a/src/tests/test_event.py b/tests/test_event.py similarity index 100% rename from src/tests/test_event.py rename to tests/test_event.py diff --git a/src/tests/test_exceptions.py b/tests/test_exceptions.py similarity index 100% rename from src/tests/test_exceptions.py rename to tests/test_exceptions.py diff --git a/src/tests/test_field.py b/tests/test_field.py similarity index 100% rename from src/tests/test_field.py rename to tests/test_field.py diff --git a/src/tests/test_generic.py b/tests/test_generic.py similarity index 100% rename from src/tests/test_generic.py rename to tests/test_generic.py diff --git a/src/tests/test_import.py b/tests/test_import.py similarity index 100% rename from src/tests/test_import.py rename to tests/test_import.py diff --git a/src/tests/test_indexer.py b/tests/test_indexer.py similarity index 100% rename from src/tests/test_indexer.py rename to tests/test_indexer.py diff --git a/src/tests/test_interface.py b/tests/test_interface.py similarity index 100% rename from src/tests/test_interface.py rename to tests/test_interface.py diff --git a/src/tests/test_method.py b/tests/test_method.py similarity index 100% rename from src/tests/test_method.py rename to tests/test_method.py diff --git a/src/tests/test_module.py b/tests/test_module.py similarity index 100% rename from src/tests/test_module.py rename to tests/test_module.py diff --git a/src/tests/test_property.py b/tests/test_property.py similarity index 100% rename from src/tests/test_property.py rename to tests/test_property.py diff --git a/src/tests/test_recursive_types.py b/tests/test_recursive_types.py similarity index 100% rename from src/tests/test_recursive_types.py rename to tests/test_recursive_types.py diff --git a/src/tests/test_repr.py b/tests/test_repr.py similarity index 100% rename from src/tests/test_repr.py rename to tests/test_repr.py diff --git a/src/tests/test_subclass.py b/tests/test_subclass.py similarity index 100% rename from src/tests/test_subclass.py rename to tests/test_subclass.py diff --git a/src/tests/test_sysargv.py b/tests/test_sysargv.py similarity index 100% rename from src/tests/test_sysargv.py rename to tests/test_sysargv.py diff --git a/src/tests/test_thread.py b/tests/test_thread.py similarity index 100% rename from src/tests/test_thread.py rename to tests/test_thread.py diff --git a/src/tests/tests.pyproj b/tests/tests.pyproj similarity index 100% rename from src/tests/tests.pyproj rename to tests/tests.pyproj diff --git a/src/tests/utils.py b/tests/utils.py similarity index 100% rename from src/tests/utils.py rename to tests/utils.py diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 3c9be5c63..000000000 --- a/tox.ini +++ /dev/null @@ -1,27 +0,0 @@ -[tox] -skip_missing_interpreters=True -envlist = - py27 - py33 - py34 - py35 - py36 - py37 - check - -[testenv] -deps = - pytest -commands = - {posargs:py.test} - -[testenv:check] -ignore_errors=True -skip_install=True -basepython=python3.5 -deps = - check-manifest - flake8 -commands = - flake8 src setup.py - python setup.py check --strict --metadata From 95f07f0a900ea757b02d4e227c0673c5f360a22a Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Tue, 26 Nov 2019 18:38:30 +0100 Subject: [PATCH 04/22] Drop nuget config --- NuGet.config | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 NuGet.config diff --git a/NuGet.config b/NuGet.config deleted file mode 100644 index 5210cd6c9..000000000 --- a/NuGet.config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file From 04ab475a38ce42a413ac76ba8f150a1a5e1f0de7 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Tue, 26 Nov 2019 18:48:47 +0100 Subject: [PATCH 05/22] Adjust embed test project --- Python.Runtime/AssemblyInfo.cs | 2 ++ Python.Test.Embed/Program.cs | 19 ---------------- Python.Test.Embed/Python.Test.Embed.csproj | 25 ++++++++++++++++++++++ pythonnet.sln | 14 ++++++++++++ 4 files changed, 41 insertions(+), 19 deletions(-) delete mode 100644 Python.Test.Embed/Program.cs create mode 100644 Python.Test.Embed/Python.Test.Embed.csproj diff --git a/Python.Runtime/AssemblyInfo.cs b/Python.Runtime/AssemblyInfo.cs index 0270020d3..a369d6c8e 100644 --- a/Python.Runtime/AssemblyInfo.cs +++ b/Python.Runtime/AssemblyInfo.cs @@ -1,3 +1,5 @@ using System; +using System.Runtime.CompilerServices; [assembly: CLSCompliant(true)] +[assembly: InternalsVisibleTo("Python.Test.Embed")] diff --git a/Python.Test.Embed/Program.cs b/Python.Test.Embed/Program.cs deleted file mode 100644 index b4439e3e4..000000000 --- a/Python.Test.Embed/Program.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; - -using NUnit.Common; - -using NUnitLite; - -namespace Python.EmbeddingTest -{ - public class Program - { - public static int Main(string[] args) - { - return new AutoRun(typeof(Program).Assembly).Execute( - args, - new ExtendedTextWrapper(Console.Out), - Console.In); - } - } -} diff --git a/Python.Test.Embed/Python.Test.Embed.csproj b/Python.Test.Embed/Python.Test.Embed.csproj new file mode 100644 index 000000000..a23567744 --- /dev/null +++ b/Python.Test.Embed/Python.Test.Embed.csproj @@ -0,0 +1,25 @@ + + + + netcoreapp3.0;net472 + true + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers + + + + + + + + diff --git a/pythonnet.sln b/pythonnet.sln index 48153b648..9e01c9d83 100644 --- a/pythonnet.sln +++ b/pythonnet.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 15.0.26124.0 MinimumVisualStudioVersion = 15.0.26124.0 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.Runtime", "Python.Runtime\Python.Runtime.csproj", "{C9E02762-3DD2-4669-81DA-6A64C80D07E0}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.Test.Embed", "Python.Test.Embed\Python.Test.Embed.csproj", "{298D6A0A-C41B-4B6D-ABF6-1E24A1BF223C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -30,5 +32,17 @@ Global {C9E02762-3DD2-4669-81DA-6A64C80D07E0}.Release|x64.Build.0 = Release|Any CPU {C9E02762-3DD2-4669-81DA-6A64C80D07E0}.Release|x86.ActiveCfg = Release|Any CPU {C9E02762-3DD2-4669-81DA-6A64C80D07E0}.Release|x86.Build.0 = Release|Any CPU + {298D6A0A-C41B-4B6D-ABF6-1E24A1BF223C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {298D6A0A-C41B-4B6D-ABF6-1E24A1BF223C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {298D6A0A-C41B-4B6D-ABF6-1E24A1BF223C}.Debug|x64.ActiveCfg = Debug|Any CPU + {298D6A0A-C41B-4B6D-ABF6-1E24A1BF223C}.Debug|x64.Build.0 = Debug|Any CPU + {298D6A0A-C41B-4B6D-ABF6-1E24A1BF223C}.Debug|x86.ActiveCfg = Debug|Any CPU + {298D6A0A-C41B-4B6D-ABF6-1E24A1BF223C}.Debug|x86.Build.0 = Debug|Any CPU + {298D6A0A-C41B-4B6D-ABF6-1E24A1BF223C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {298D6A0A-C41B-4B6D-ABF6-1E24A1BF223C}.Release|Any CPU.Build.0 = Release|Any CPU + {298D6A0A-C41B-4B6D-ABF6-1E24A1BF223C}.Release|x64.ActiveCfg = Release|Any CPU + {298D6A0A-C41B-4B6D-ABF6-1E24A1BF223C}.Release|x64.Build.0 = Release|Any CPU + {298D6A0A-C41B-4B6D-ABF6-1E24A1BF223C}.Release|x86.ActiveCfg = Release|Any CPU + {298D6A0A-C41B-4B6D-ABF6-1E24A1BF223C}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection EndGlobal From 627c4c4c7901baf80533926130e4013699480270 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Tue, 26 Nov 2019 19:10:09 +0100 Subject: [PATCH 06/22] Add test helper project --- Python.Test.Helper/Python.Test.Helper.csproj | 15 +++++++++++++++ pythonnet.sln | 14 ++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 Python.Test.Helper/Python.Test.Helper.csproj diff --git a/Python.Test.Helper/Python.Test.Helper.csproj b/Python.Test.Helper/Python.Test.Helper.csproj new file mode 100644 index 000000000..32a5e7129 --- /dev/null +++ b/Python.Test.Helper/Python.Test.Helper.csproj @@ -0,0 +1,15 @@ + + + + + + + + + + + + netstandard2.0 + + + diff --git a/pythonnet.sln b/pythonnet.sln index 9e01c9d83..2678b2ae1 100644 --- a/pythonnet.sln +++ b/pythonnet.sln @@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.Runtime", "Python.Ru EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.Test.Embed", "Python.Test.Embed\Python.Test.Embed.csproj", "{298D6A0A-C41B-4B6D-ABF6-1E24A1BF223C}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.Test.Helper", "Python.Test.Helper\Python.Test.Helper.csproj", "{23C09493-58CD-4B50-A24E-64B56A967DCC}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -44,5 +46,17 @@ Global {298D6A0A-C41B-4B6D-ABF6-1E24A1BF223C}.Release|x64.Build.0 = Release|Any CPU {298D6A0A-C41B-4B6D-ABF6-1E24A1BF223C}.Release|x86.ActiveCfg = Release|Any CPU {298D6A0A-C41B-4B6D-ABF6-1E24A1BF223C}.Release|x86.Build.0 = Release|Any CPU + {23C09493-58CD-4B50-A24E-64B56A967DCC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {23C09493-58CD-4B50-A24E-64B56A967DCC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {23C09493-58CD-4B50-A24E-64B56A967DCC}.Debug|x64.ActiveCfg = Debug|Any CPU + {23C09493-58CD-4B50-A24E-64B56A967DCC}.Debug|x64.Build.0 = Debug|Any CPU + {23C09493-58CD-4B50-A24E-64B56A967DCC}.Debug|x86.ActiveCfg = Debug|Any CPU + {23C09493-58CD-4B50-A24E-64B56A967DCC}.Debug|x86.Build.0 = Debug|Any CPU + {23C09493-58CD-4B50-A24E-64B56A967DCC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {23C09493-58CD-4B50-A24E-64B56A967DCC}.Release|Any CPU.Build.0 = Release|Any CPU + {23C09493-58CD-4B50-A24E-64B56A967DCC}.Release|x64.ActiveCfg = Release|Any CPU + {23C09493-58CD-4B50-A24E-64B56A967DCC}.Release|x64.Build.0 = Release|Any CPU + {23C09493-58CD-4B50-A24E-64B56A967DCC}.Release|x86.ActiveCfg = Release|Any CPU + {23C09493-58CD-4B50-A24E-64B56A967DCC}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection EndGlobal From c0415be4d4e6d5c7650229b9bc0cb17fafb433cd Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Tue, 26 Nov 2019 20:48:41 +0100 Subject: [PATCH 07/22] Readd benchmark project --- Python.Test.Embed/Python.Test.Embed.csproj | 2 +- .../Python.Test.Performance.csproj | 31 ++++ pythonnet.sln | 14 ++ src/runtime/interop38.cs | 152 ------------------ 4 files changed, 46 insertions(+), 153 deletions(-) create mode 100644 Python.Test.Performance/Python.Test.Performance.csproj delete mode 100644 src/runtime/interop38.cs diff --git a/Python.Test.Embed/Python.Test.Embed.csproj b/Python.Test.Embed/Python.Test.Embed.csproj index a23567744..6ed446c5b 100644 --- a/Python.Test.Embed/Python.Test.Embed.csproj +++ b/Python.Test.Embed/Python.Test.Embed.csproj @@ -1,4 +1,4 @@ - + netcoreapp3.0;net472 diff --git a/Python.Test.Performance/Python.Test.Performance.csproj b/Python.Test.Performance/Python.Test.Performance.csproj new file mode 100644 index 000000000..2c857c938 --- /dev/null +++ b/Python.Test.Performance/Python.Test.Performance.csproj @@ -0,0 +1,31 @@ + + + + net472 + false + + + + + + + + compile + + + + + + + + + + + + + + + + + + diff --git a/pythonnet.sln b/pythonnet.sln index 2678b2ae1..602bb4dd7 100644 --- a/pythonnet.sln +++ b/pythonnet.sln @@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.Test.Embed", "Python EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.Test.Helper", "Python.Test.Helper\Python.Test.Helper.csproj", "{23C09493-58CD-4B50-A24E-64B56A967DCC}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.Test.Performance", "Python.Test.Performance\Python.Test.Performance.csproj", "{A232F9F5-3A03-431F-8863-0BA177D650BA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -58,5 +60,17 @@ Global {23C09493-58CD-4B50-A24E-64B56A967DCC}.Release|x64.Build.0 = Release|Any CPU {23C09493-58CD-4B50-A24E-64B56A967DCC}.Release|x86.ActiveCfg = Release|Any CPU {23C09493-58CD-4B50-A24E-64B56A967DCC}.Release|x86.Build.0 = Release|Any CPU + {A232F9F5-3A03-431F-8863-0BA177D650BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A232F9F5-3A03-431F-8863-0BA177D650BA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A232F9F5-3A03-431F-8863-0BA177D650BA}.Debug|x64.ActiveCfg = Debug|Any CPU + {A232F9F5-3A03-431F-8863-0BA177D650BA}.Debug|x64.Build.0 = Debug|Any CPU + {A232F9F5-3A03-431F-8863-0BA177D650BA}.Debug|x86.ActiveCfg = Debug|Any CPU + {A232F9F5-3A03-431F-8863-0BA177D650BA}.Debug|x86.Build.0 = Debug|Any CPU + {A232F9F5-3A03-431F-8863-0BA177D650BA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A232F9F5-3A03-431F-8863-0BA177D650BA}.Release|Any CPU.Build.0 = Release|Any CPU + {A232F9F5-3A03-431F-8863-0BA177D650BA}.Release|x64.ActiveCfg = Release|Any CPU + {A232F9F5-3A03-431F-8863-0BA177D650BA}.Release|x64.Build.0 = Release|Any CPU + {A232F9F5-3A03-431F-8863-0BA177D650BA}.Release|x86.ActiveCfg = Release|Any CPU + {A232F9F5-3A03-431F-8863-0BA177D650BA}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/src/runtime/interop38.cs b/src/runtime/interop38.cs deleted file mode 100644 index 8f2e32afe..000000000 --- a/src/runtime/interop38.cs +++ /dev/null @@ -1,152 +0,0 @@ - -// Auto-generated by geninterop.py. -// DO NOT MODIFIY BY HAND. - - -#if PYTHON38 -using System; -using System.Collections; -using System.Collections.Specialized; -using System.Runtime.InteropServices; -using System.Reflection; -using System.Text; - -namespace Python.Runtime -{ - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - internal class TypeOffset - { - static TypeOffset() - { - Type type = typeof(TypeOffset); - FieldInfo[] fi = type.GetFields(); - int size = IntPtr.Size; - for (int i = 0; i < fi.Length; i++) - { - fi[i].SetValue(null, i * size); - } - } - - public static int magic() - { - return ob_size; - } - - // Auto-generated from PyHeapTypeObject in Python.h - public static int ob_refcnt = 0; - public static int ob_type = 0; - public static int ob_size = 0; - public static int tp_name = 0; - public static int tp_basicsize = 0; - public static int tp_itemsize = 0; - public static int tp_dealloc = 0; - public static int tp_vectorcall_offset = 0; - public static int tp_getattr = 0; - public static int tp_setattr = 0; - public static int tp_as_async = 0; - public static int tp_repr = 0; - public static int tp_as_number = 0; - public static int tp_as_sequence = 0; - public static int tp_as_mapping = 0; - public static int tp_hash = 0; - public static int tp_call = 0; - public static int tp_str = 0; - public static int tp_getattro = 0; - public static int tp_setattro = 0; - public static int tp_as_buffer = 0; - public static int tp_flags = 0; - public static int tp_doc = 0; - public static int tp_traverse = 0; - public static int tp_clear = 0; - public static int tp_richcompare = 0; - public static int tp_weaklistoffset = 0; - public static int tp_iter = 0; - public static int tp_iternext = 0; - public static int tp_methods = 0; - public static int tp_members = 0; - public static int tp_getset = 0; - public static int tp_base = 0; - public static int tp_dict = 0; - public static int tp_descr_get = 0; - public static int tp_descr_set = 0; - public static int tp_dictoffset = 0; - public static int tp_init = 0; - public static int tp_alloc = 0; - public static int tp_new = 0; - public static int tp_free = 0; - public static int tp_is_gc = 0; - public static int tp_bases = 0; - public static int tp_mro = 0; - public static int tp_cache = 0; - public static int tp_subclasses = 0; - public static int tp_weaklist = 0; - public static int tp_del = 0; - public static int tp_version_tag = 0; - public static int tp_finalize = 0; - public static int tp_vectorcall = 0; - public static int am_await = 0; - public static int am_aiter = 0; - public static int am_anext = 0; - public static int nb_add = 0; - public static int nb_subtract = 0; - public static int nb_multiply = 0; - public static int nb_remainder = 0; - public static int nb_divmod = 0; - public static int nb_power = 0; - public static int nb_negative = 0; - public static int nb_positive = 0; - public static int nb_absolute = 0; - public static int nb_bool = 0; - public static int nb_invert = 0; - public static int nb_lshift = 0; - public static int nb_rshift = 0; - public static int nb_and = 0; - public static int nb_xor = 0; - public static int nb_or = 0; - public static int nb_int = 0; - public static int nb_reserved = 0; - public static int nb_float = 0; - public static int nb_inplace_add = 0; - public static int nb_inplace_subtract = 0; - public static int nb_inplace_multiply = 0; - public static int nb_inplace_remainder = 0; - public static int nb_inplace_power = 0; - public static int nb_inplace_lshift = 0; - public static int nb_inplace_rshift = 0; - public static int nb_inplace_and = 0; - public static int nb_inplace_xor = 0; - public static int nb_inplace_or = 0; - public static int nb_floor_divide = 0; - public static int nb_true_divide = 0; - public static int nb_inplace_floor_divide = 0; - public static int nb_inplace_true_divide = 0; - public static int nb_index = 0; - public static int nb_matrix_multiply = 0; - public static int nb_inplace_matrix_multiply = 0; - public static int mp_length = 0; - public static int mp_subscript = 0; - public static int mp_ass_subscript = 0; - public static int sq_length = 0; - public static int sq_concat = 0; - public static int sq_repeat = 0; - public static int sq_item = 0; - public static int was_sq_slice = 0; - public static int sq_ass_item = 0; - public static int was_sq_ass_slice = 0; - public static int sq_contains = 0; - public static int sq_inplace_concat = 0; - public static int sq_inplace_repeat = 0; - public static int bf_getbuffer = 0; - public static int bf_releasebuffer = 0; - public static int name = 0; - public static int ht_slots = 0; - public static int qualname = 0; - public static int ht_cached_keys = 0; - - /* here are optional user slots, followed by the members. */ - public static int members = 0; - } -} - -#endif - From 3031e9663b3c00f9e706862f029bd0289e63800e Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Tue, 26 Nov 2019 20:56:32 +0100 Subject: [PATCH 08/22] Update setup.py --- setup.cfg | 12 +- setup.py | 632 +++++------------------------------------------------- 2 files changed, 52 insertions(+), 592 deletions(-) diff --git a/setup.cfg b/setup.cfg index 38aa3eb3d..0c9e0fc14 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,10 +1,2 @@ -# [bumpversion] comments. bumpversion deleted all comments on its file. -# Don't combine `.bumpversion.cfg` with `setup.cfg`. Messes up formatting. -# Don't use `first_value = 1`. It will break `release` bump -# Keep `optional = dummy` needed to bump to release. -# See: https://github.com/peritus/bumpversion/issues/59 - -[tool:pytest] -xfail_strict = True -# -r fsxX: show extra summary info for: (f)ailed, (s)kip, (x)failed, (X)passed -addopts = -r fsxX --color=yes --durations=5 +[metadata] +license_file = LICENSE diff --git a/setup.py b/setup.py index 50a3160f1..b76606026 100644 --- a/setup.py +++ b/setup.py @@ -1,610 +1,68 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- -""" -Setup script for building clr.pyd and dependencies using mono and into -an egg or wheel. -""" +from setuptools import setup, find_packages, Command, Extension +from wheel.bdist_wheel import bdist_wheel -import collections -import fnmatch -import glob -import os -import subprocess -import sys -import sysconfig -from distutils import spawn -from distutils.command import install, build, build_ext, install_data, install_lib -from setuptools import Extension, setup +class DotnetLib(Extension): + def __init__(self, name, path, **kwargs): + self.path = path + self.args = kwargs + super().__init__(name, sources=[]) -try: - from wheel import bdist_wheel -except ImportError: - bdist_wheel = None -# Allow config/verbosity to be set from cli -# http://stackoverflow.com/a/4792601/5208670 -CONFIG = "Release" # Release or Debug -VERBOSITY = "normal" # quiet, minimal, normal, detailed, diagnostic +class BuildDotnet(Command): + """Build command for dotnet-cli based builds""" -is_64bits = sys.maxsize > 2 ** 32 -DEVTOOLS = "MsDev" if sys.platform == "win32" else "Mono" -ARCH = "x64" if is_64bits else "x86" -PY_MAJOR = sys.version_info[0] -PY_MINOR = sys.version_info[1] - -############################################################################### -# Windows Keys Constants for MSBUILD tools -RegKey = collections.namedtuple("RegKey", "sdk_name key value_name suffix") -vs_python = "Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\WinSDK" -vs_root = "SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\{0}" -sdks_root = "SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v{0}Win32Tools" -kits_root = "SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots" -kits_suffix = os.path.join("bin", ARCH) - -WIN_SDK_KEYS = [ - RegKey( - sdk_name="Windows Kit 10.0", - key=kits_root, - value_name="KitsRoot10", - suffix=os.path.join("bin", "10.0.16299.0", ARCH), - ), - RegKey( - sdk_name="Windows Kit 10.0", - key=kits_root, - value_name="KitsRoot10", - suffix=os.path.join("bin", "10.0.15063.0", ARCH), - ), - RegKey( - sdk_name="Windows Kit 10.0", - key=kits_root, - value_name="KitsRoot10", - suffix=kits_suffix, - ), - RegKey( - sdk_name="Windows Kit 8.1", - key=kits_root, - value_name="KitsRoot81", - suffix=kits_suffix, - ), - RegKey( - sdk_name="Windows Kit 8.0", - key=kits_root, - value_name="KitsRoot", - suffix=kits_suffix, - ), - RegKey( - sdk_name="Windows SDK 7.1A", - key=sdks_root.format("7.1A\\WinSDK-"), - value_name="InstallationFolder", - suffix="", - ), - RegKey( - sdk_name="Windows SDK 7.1", - key=sdks_root.format("7.1\\WinSDK"), - value_name="InstallationFolder", - suffix="", - ), - RegKey( - sdk_name="Windows SDK 7.0A", - key=sdks_root.format("7.0A\\WinSDK-"), - value_name="InstallationFolder", - suffix="", - ), - RegKey( - sdk_name="Windows SDK 7.0", - key=sdks_root.format("7.0\\WinSDK"), - value_name="InstallationFolder", - suffix="", - ), - RegKey( - sdk_name="Windows SDK 6.0A", - key=sdks_root.format("6.0A\\WinSDK"), - value_name="InstallationFolder", - suffix="", - ), -] - -VS_KEYS = ( - RegKey( - sdk_name="MSBuild 15", - key=vs_root.format("15.0"), - value_name="MSBuildToolsPath", - suffix="", - ), - RegKey( - sdk_name="MSBuild 14", - key=vs_root.format("14.0"), - value_name="MSBuildToolsPath", - suffix="", - ), - RegKey( - sdk_name="MSBuild 12", - key=vs_root.format("12.0"), - value_name="MSBuildToolsPath", - suffix="", - ), - RegKey( - sdk_name="MSBuild 4", - key=vs_root.format("4.0"), - value_name="MSBuildToolsPath", - suffix="", - ), - RegKey( - sdk_name="MSBuild 3.5", - key=vs_root.format("3.5"), - value_name="MSBuildToolsPath", - suffix="", - ), - RegKey( - sdk_name="MSBuild 2.0", - key=vs_root.format("2.0"), - value_name="MSBuildToolsPath", - suffix="", - ), -) - - -############################################################################### -def _check_output(*args, **kwargs): - """Check output wrapper for py2/py3 compatibility""" - output = subprocess.check_output(*args, **kwargs) - if PY_MAJOR == 2: - return output - return output.decode("ascii") - - -def _get_interop_filename(): - """interopXX.cs is auto-generated as part of the build. - For common windows platforms pre-generated files are included - as most windows users won't have Clang installed, which is - required to generate the file. - """ - interop_filename = "interop{0}{1}{2}.cs".format( - PY_MAJOR, PY_MINOR, getattr(sys, "abiflags", "") - ) - return os.path.join("src", "runtime", interop_filename) - - -def _get_long_description(): - """Helper to populate long_description for pypi releases""" - return open("README.rst").read() - - -def _update_xlat_devtools(): - global DEVTOOLS - if DEVTOOLS == "MsDev": - DEVTOOLS = "MsDev15" - elif DEVTOOLS == "Mono": - DEVTOOLS = "dotnet" - - -def _collect_installed_windows_kits_v10(winreg): - """Adds the installed Windows 10 kits to WIN_SDK_KEYS """ - global WIN_SDK_KEYS - installed_kits = [] - - with winreg.OpenKey( - winreg.HKEY_LOCAL_MACHINE, kits_root, 0, winreg.KEY_READ - ) as key: - i = 0 - while True: - try: - installed_kits.append(winreg.EnumKey(key, i)) - i += 1 - except WindowsError: - break - - def make_reg_key(version): - return RegKey( - sdk_name="Windows Kit 10.0", - key=kits_root, - value_name="KitsRoot10", - suffix=os.path.join("bin", version, ARCH), - ) - - WIN_SDK_KEYS += [make_reg_key(e) for e in installed_kits if e.startswith("10.")] - - # Make sure this function won't be called again - _collect_installed_windows_kits_v10 = lambda: None - - -class BuildExtPythonnet(build_ext.build_ext): - user_options = build_ext.build_ext.user_options + [("xplat", None, None)] + description = "Build DLLs with dotnet-cli" + user_options = [("dotnet-config", None, "dotnet build configuration")] def initialize_options(self): - build_ext.build_ext.initialize_options(self) - self.xplat = None + self.dotnet_config = "release" def finalize_options(self): - build_ext.build_ext.finalize_options(self) - - def build_extension(self, ext): - if self.xplat: - _update_xlat_devtools() - - """Builds the .pyd file using msbuild or xbuild""" - if ext.name != "clr": - return build_ext.build_ext.build_extension(self, ext) - - # install packages using nuget - self._install_packages() - - dest_file = self.get_ext_fullpath(ext.name) - dest_dir = os.path.dirname(dest_file) - if not os.path.exists(dest_dir): - os.makedirs(dest_dir) - - # Up to Python 3.2 sys.maxunicode is used to determine the size of - # Py_UNICODE, but from 3.3 onwards Py_UNICODE is a typedef of wchar_t. - # TODO: Is this doing the right check for Py27? - if sys.version_info[:2] <= (3, 2): - unicode_width = 2 if sys.maxunicode < 0x10FFFF else 4 - else: - import ctypes - - unicode_width = ctypes.sizeof(ctypes.c_wchar) - - defines = [ - "PYTHON{0}{1}".format(PY_MAJOR, PY_MINOR), - "PYTHON{0}".format(PY_MAJOR), # Python Major Version - "UCS{0}".format(unicode_width), - ] - - if CONFIG == "Debug": - defines.extend(["DEBUG", "TRACE"]) - - if sys.platform != "win32" and (DEVTOOLS == "Mono" or DEVTOOLS == "dotnet"): - on_darwin = sys.platform == "darwin" - defines.append("MONO_OSX" if on_darwin else "MONO_LINUX") - - # Check if --enable-shared was set when Python was built - enable_shared = sysconfig.get_config_var("Py_ENABLE_SHARED") - if enable_shared: - # Double-check if libpython is linked dynamically with python - ldd_cmd = ["otool", "-L"] if on_darwin else ["ldd"] - lddout = _check_output(ldd_cmd + [sys.executable]) - if "libpython" not in lddout: - enable_shared = False - - if not enable_shared: - defines.append("PYTHON_WITHOUT_ENABLE_SHARED") - - if hasattr(sys, "abiflags"): - if "d" in sys.abiflags: - defines.append("PYTHON_WITH_PYDEBUG") - if "m" in sys.abiflags: - defines.append("PYTHON_WITH_PYMALLOC") - - # check the interop file exists, and create it if it doesn't - interop_file = _get_interop_filename() - if not os.path.exists(interop_file): - self.debug_print("Creating {0}".format(interop_file)) - geninterop = os.path.join("tools", "geninterop", "geninterop.py") - subprocess.check_call([sys.executable, geninterop, interop_file]) - - if DEVTOOLS == "MsDev": - _xbuild = '"{0}"'.format(self._find_msbuild_tool("msbuild.exe")) - _config = "{0}Win".format(CONFIG) - _solution_file = "pythonnet.sln" - _custom_define_constants = False - elif DEVTOOLS == "MsDev15": - _xbuild = '"{0}"'.format(self._find_msbuild_tool_15()) - _config = "{0}Win".format(CONFIG) - _solution_file = "pythonnet.15.sln" - _custom_define_constants = True - elif DEVTOOLS == "Mono": - _xbuild = "xbuild" - _config = "{0}Mono".format(CONFIG) - _solution_file = "pythonnet.sln" - _custom_define_constants = False - elif DEVTOOLS == "dotnet": - _xbuild = "dotnet msbuild" - _config = "{0}Mono".format(CONFIG) - _solution_file = "pythonnet.15.sln" - _custom_define_constants = True - else: - raise NotImplementedError( - "DevTool {0} not supported (use MsDev/MsDev15/Mono/dotnet)".format( - DEVTOOLS - ) - ) - - cmd = [ - _xbuild, - _solution_file, - "/p:Configuration={}".format(_config), - "/p:Platform={}".format(ARCH), - '/p:{}DefineConstants="{}"'.format( - "Custom" if _custom_define_constants else "", "%3B".join(defines) - ), - '/p:PythonBuildDir="{}"'.format(os.path.abspath(dest_dir)), - '/p:PythonInteropFile="{}"'.format(os.path.basename(interop_file)), - "/p:PackageId=pythonnet_py{0}{1}_{2}".format(PY_MAJOR, PY_MINOR, ARCH), - "/verbosity:{}".format(VERBOSITY), - ] - - manifest = self._get_manifest(dest_dir) - if manifest: - cmd.append('/p:PythonManifest="{0}"'.format(manifest)) - - self.debug_print("Building: {0}".format(" ".join(cmd))) - use_shell = True if DEVTOOLS == "Mono" or DEVTOOLS == "dotnet" else False - - subprocess.check_call(" ".join(cmd + ["/t:Clean"]), shell=use_shell) - subprocess.check_call(" ".join(cmd + ["/t:Build"]), shell=use_shell) - if DEVTOOLS == "MsDev15" or DEVTOOLS == "dotnet": - subprocess.check_call( - " ".join( - cmd - + [ - '"/t:Console_15:publish;Python_EmbeddingTest_15:publish"', - "/p:TargetFramework=netcoreapp2.0", - ] - ), - shell=use_shell, - ) + pass - def _get_manifest(self, build_dir): - if DEVTOOLS != "MsDev" and DEVTOOLS != "MsDev15": - return - mt = self._find_msbuild_tool("mt.exe", use_windows_sdk=True) - manifest = os.path.abspath(os.path.join(build_dir, "app.manifest")) - cmd = [ - mt, - '-inputresource:"{0}"'.format(sys.executable), - '-out:"{0}"'.format(manifest), - ] - self.debug_print("Extracting manifest from {}".format(sys.executable)) - subprocess.check_call(" ".join(cmd), shell=False) - return manifest + def get_source_files(self): + return [] - def _install_packages(self): - """install packages using nuget""" - use_shell = DEVTOOLS == "Mono" or DEVTOOLS == "dotnet" - - if DEVTOOLS == "MsDev15" or DEVTOOLS == "dotnet": - if DEVTOOLS == "MsDev15": - _config = "{0}Win".format(CONFIG) - elif DEVTOOLS == "dotnet": - _config = "{0}Mono".format(CONFIG) - - cmd = "dotnet msbuild /t:Restore pythonnet.15.sln /p:Configuration={0} /p:Platform={1}".format( - _config, ARCH - ) - self.debug_print("Updating packages with xplat: {0}".format(cmd)) - subprocess.check_call(cmd, shell=use_shell) - else: - nuget = os.path.join("tools", "nuget", "nuget.exe") - - if DEVTOOLS == "Mono": - nuget = "mono {0}".format(nuget) - - cmd = "{0} update -self".format(nuget) - self.debug_print("Updating NuGet: {0}".format(cmd)) - subprocess.check_call(cmd, shell=use_shell) - - try: - # msbuild=14 is mainly for Mono issues - cmd = "{0} restore pythonnet.sln -MSBuildVersion 14 -o packages".format( - nuget - ) - self.debug_print("Installing packages: {0}".format(cmd)) - subprocess.check_call(cmd, shell=use_shell) - except: - # when only VS 2017 is installed do not specify msbuild version - cmd = "{0} restore pythonnet.sln -o packages".format(nuget) - self.debug_print("Installing packages: {0}".format(cmd)) - subprocess.check_call(cmd, shell=use_shell) - - def _find_msbuild_tool(self, tool="msbuild.exe", use_windows_sdk=False): - """Return full path to one of the Microsoft build tools""" - - # trying to search path with help of vswhere when MSBuild 15.0 and higher installed. - if tool == "msbuild.exe" and use_windows_sdk == False: - try: - basePathes = subprocess.check_output( - [ - "tools\\vswhere\\vswhere.exe", - "-latest", - "-version", - "[15.0, 16.0)", - "-requires", - "Microsoft.Component.MSBuild", - "-property", - "InstallationPath", - ] - ).splitlines() - if len(basePathes): - return os.path.join( - basePathes[0].decode(sys.stdout.encoding or "utf-8"), - "MSBuild", - "15.0", - "Bin", - "MSBuild.exe", - ) - except: - pass # keep trying to search by old method. - - # Search in PATH first - path = spawn.find_executable(tool) - if path: - return path - - # Search within registry to find build tools - try: # PY2 - import _winreg as winreg - except ImportError: # PY3 - import winreg - - _collect_installed_windows_kits_v10(winreg) - - keys_to_check = WIN_SDK_KEYS if use_windows_sdk else VS_KEYS - hklm = winreg.HKEY_LOCAL_MACHINE - for rkey in keys_to_check: - try: - with winreg.OpenKey(hklm, rkey.key) as hkey: - val, type_ = winreg.QueryValueEx(hkey, rkey.value_name) - if type_ != winreg.REG_SZ: - continue - path = os.path.join(val, rkey.suffix, tool) - if os.path.exists(path): - self.debug_print( - "Using {0} from {1}".format(tool, rkey.sdk_name) - ) - return path - except WindowsError: - # Key doesn't exist - pass - - # Add Visual C++ for Python as a fall-back in case one - # of the other Windows SDKs isn't installed. - # TODO: Extend checking by using setuptools/msvc.py? - if use_windows_sdk: - sdk_name = "Visual C++ for Python" - localappdata = os.environ["LOCALAPPDATA"] - suffix = "Bin\\x64" if ARCH == "x64" else "Bin" - path = os.path.join(localappdata, vs_python, suffix, tool) - if os.path.exists(path): - self.debug_print("Using {0} from {1}".format(tool, sdk_name)) - return path - - raise RuntimeError("{0} could not be found".format(tool)) - - def _find_msbuild_tool_15(self): - """Return full path to one of the Microsoft build tools""" - try: - basePathes = subprocess.check_output( + def run(self): + for lib in self.distribution.ext_modules: + opts = sum( [ - "tools\\vswhere\\vswhere.exe", - "-latest", - "-version", - "[15.0, 16.0)", - "-requires", - "Microsoft.Component.MSBuild", - "-property", - "InstallationPath", - ] - ).splitlines() - if len(basePathes): - return os.path.join( - basePathes[0].decode(sys.stdout.encoding or "utf-8"), - "MSBuild", - "15.0", - "Bin", - "MSBuild.exe", - ) - else: - raise RuntimeError("MSBuild >=15.0 could not be found.") - except subprocess.CalledProcessError as e: - raise RuntimeError( - "MSBuild >=15.0 could not be found. {0}".format(e.output) + ["--" + name.replace("_", "-"), value] + for name, value in lib.args.items() + ], + [], ) + opts.append("--configuration") + opts.append(self.dotnet_config) -class InstallLibPythonnet(install_lib.install_lib): - def install(self): - if not os.path.isdir(self.build_dir): - self.warn( - "'{0}' does not exist -- no Python modules" - " to install".format(self.build_dir) - ) - return - - if not os.path.exists(self.install_dir): - self.mkpath(self.install_dir) - - # only copy clr.pyd/.so - for srcfile in glob.glob(os.path.join(self.build_dir, "clr.*")): - destfile = os.path.join(self.install_dir, os.path.basename(srcfile)) - self.copy_file(srcfile, destfile) - + self.spawn(["dotnet", "build", lib.path] + opts) -class InstallDataPythonnet(install_data.install_data): - def run(self): - build_cmd = self.get_finalized_command("build_ext") - install_cmd = self.get_finalized_command("install") - build_lib = os.path.abspath(build_cmd.build_lib) - install_platlib = os.path.relpath(install_cmd.install_platlib, self.install_dir) - - for i, data_files in enumerate(self.data_files): - if isinstance(data_files, str): - self.data_files[i] = data_files[i].format(build_lib=build_lib) - else: - for j, filename in enumerate(data_files[1]): - data_files[1][j] = filename.format(build_lib=build_lib) - dest = data_files[0].format(install_platlib=install_platlib) - self.data_files[i] = dest, data_files[1] - - return install_data.install_data.run(self) - - -class InstallPythonnet(install.install): - user_options = install.install.user_options + [("xplat", None, None)] - - def initialize_options(self): - install.install.initialize_options(self) - self.xplat = None +class bdist_wheel_patched(bdist_wheel): def finalize_options(self): - install.install.finalize_options(self) - - def run(self): - if self.xplat: - _update_xlat_devtools() - return install.install.run(self) - -if bdist_wheel: - class BDistWheelPythonnet(bdist_wheel.bdist_wheel): - user_options = bdist_wheel.bdist_wheel.user_options + [("xplat", None, None)] + # Monkey patch bdist_wheel to think the package is pure even though we + # include DLLs + super().finalize_options() + self.root_is_pure = True - def initialize_options(self): - bdist_wheel.bdist_wheel.initialize_options(self) - self.xplat = None - def finalize_options(self): - bdist_wheel.bdist_wheel.finalize_options(self) - - def run(self): - if self.xplat: - _update_xlat_devtools() - return bdist_wheel.bdist_wheel.run(self) - - ############################################################################### - - -setupdir = os.path.dirname(__file__) -if setupdir: - os.chdir(setupdir) - -setup_requires = [] -if not os.path.exists(_get_interop_filename()): - setup_requires.append("pycparser") - -cmdclass={ - "install": InstallPythonnet, - "build_ext": BuildExtPythonnet, - "install_lib": InstallLibPythonnet, - "install_data": InstallDataPythonnet, -} -if bdist_wheel: - cmdclass["bdist_wheel"] = BDistWheelPythonnet +with open("README.rst", "r") as f: + long_description = f.read() setup( name="pythonnet", - version="2.4.1-dev", - description=".Net and Mono integration for Python", - url="https://pythonnet.github.io/", - license="MIT", - author="The Python for .Net developers", + version="2.5.0", + description=".NET and Mono integration for Python", + author="The Python for .NET developers", author_email="pythondotnet@python.org", - setup_requires=setup_requires, - install_requires=["clr_loader"], - long_description=_get_long_description(), - ext_modules=[Extension("clr", sources=list(_get_source_files()))], - data_files=[("{install_platlib}", ["{build_lib}/Python.Runtime.dll"])], - cmdclass=cmdclass, + long_description=long_description, + license="MIT", + install_requires=["clr-loader"], + zip_safe=False, classifiers=[ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", @@ -616,9 +74,19 @@ def run(self): "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX :: Linux", "Operating System :: MacOS :: MacOS X", ], - zip_safe=False, + package_data={"pythonnet": ["dlls/*.dll"]}, + packages=find_packages(), + cmdclass={"build_ext": BuildDotnet, "bdist_wheel": bdist_wheel_patched}, + ext_modules={ + DotnetLib( + "python-runtime", + "Python.Runtime/", + output="pythonnet/dlls", + ), + }, ) From 8aba5fc0412105a4d559019e4e0f92e189f866d0 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Sat, 14 Dec 2019 14:51:26 +0100 Subject: [PATCH 09/22] Drop PYTHON3 flag (default now) --- Python.Runtime/converter.cs | 24 +++--- Python.Runtime/delegateobject.cs | 9 -- Python.Runtime/exceptions.cs | 2 +- Python.Runtime/importhook.cs | 6 +- Python.Runtime/interop.cs | 26 +++--- Python.Runtime/pythonengine.cs | 23 ++--- Python.Runtime/runtime.cs | 142 +++++++------------------------ Python.Runtime/typemanager.cs | 13 ++- 8 files changed, 70 insertions(+), 175 deletions(-) diff --git a/Python.Runtime/converter.cs b/Python.Runtime/converter.cs index e7e047419..14c481b21 100644 --- a/Python.Runtime/converter.cs +++ b/Python.Runtime/converter.cs @@ -519,7 +519,7 @@ private static bool ToPrimitive(IntPtr value, Type obType, out object result, bo return true; case TypeCode.Byte: -#if PYTHON3 +#if !PYTHON2 if (Runtime.PyObject_TypeCheck(value, Runtime.PyBytesType)) { if (Runtime.PyBytes_Size(value) == 1) @@ -530,7 +530,7 @@ private static bool ToPrimitive(IntPtr value, Type obType, out object result, bo } goto type_error; } -#elif PYTHON2 +#else if (Runtime.PyObject_TypeCheck(value, Runtime.PyStringType)) { if (Runtime.PyString_Size(value) == 1) @@ -564,7 +564,7 @@ private static bool ToPrimitive(IntPtr value, Type obType, out object result, bo return true; case TypeCode.SByte: -#if PYTHON3 +#if !PYTHON2 if (Runtime.PyObject_TypeCheck(value, Runtime.PyBytesType)) { if (Runtime.PyBytes_Size(value) == 1) @@ -575,7 +575,7 @@ private static bool ToPrimitive(IntPtr value, Type obType, out object result, bo } goto type_error; } -#elif PYTHON2 +#else if (Runtime.PyObject_TypeCheck(value, Runtime.PyStringType)) { if (Runtime.PyString_Size(value) == 1) @@ -609,7 +609,7 @@ private static bool ToPrimitive(IntPtr value, Type obType, out object result, bo return true; case TypeCode.Char: -#if PYTHON3 +#if !PYTHON2 if (Runtime.PyObject_TypeCheck(value, Runtime.PyBytesType)) { if (Runtime.PyBytes_Size(value) == 1) @@ -620,7 +620,7 @@ private static bool ToPrimitive(IntPtr value, Type obType, out object result, bo } goto type_error; } -#elif PYTHON2 +#else if (Runtime.PyObject_TypeCheck(value, Runtime.PyStringType)) { if (Runtime.PyString_Size(value) == 1) @@ -728,20 +728,20 @@ private static bool ToPrimitive(IntPtr value, Type obType, out object result, bo } goto type_error; } - + uint ui; - try + try { ui = Convert.ToUInt32(Runtime.PyLong_AsUnsignedLong(op)); } catch (OverflowException) { // Probably wasn't an overflow in python but was in C# (e.g. if cpython - // longs are 64 bit then 0xFFFFFFFF + 1 will not overflow in + // longs are 64 bit then 0xFFFFFFFF + 1 will not overflow in // PyLong_AsUnsignedLong) Runtime.XDecref(op); goto overflow; } - + if (Exceptions.ErrorOccurred()) { @@ -875,7 +875,7 @@ private static bool ToArray(IntPtr value, Type obType, out object result, bool s var listType = typeof(List<>); var constructedListType = listType.MakeGenericType(elementType); - IList list = IsSeqObj ? (IList) Activator.CreateInstance(constructedListType, new Object[] {(int) len}) : + IList list = IsSeqObj ? (IList) Activator.CreateInstance(constructedListType, new Object[] {(int) len}) : (IList) Activator.CreateInstance(constructedListType); IntPtr item; @@ -896,7 +896,7 @@ private static bool ToArray(IntPtr value, Type obType, out object result, bool s items = Array.CreateInstance(elementType, list.Count); list.CopyTo(items, 0); - + result = items; return true; } diff --git a/Python.Runtime/delegateobject.cs b/Python.Runtime/delegateobject.cs index e1103cbc7..c9aad9898 100644 --- a/Python.Runtime/delegateobject.cs +++ b/Python.Runtime/delegateobject.cs @@ -96,7 +96,6 @@ public static IntPtr tp_call(IntPtr ob, IntPtr args, IntPtr kw) /// /// Implements __cmp__ for reflected delegate types. /// -#if PYTHON3 // TODO: Doesn't PY2 implement tp_richcompare too? public new static IntPtr tp_richcompare(IntPtr ob, IntPtr other, int op) { if (op != Runtime.Py_EQ && op != Runtime.Py_NE) @@ -126,13 +125,5 @@ public static IntPtr tp_call(IntPtr ob, IntPtr args, IntPtr kw) Runtime.XIncref(pyfalse); return pyfalse; } -#elif PYTHON2 - public static int tp_compare(IntPtr ob, IntPtr other) - { - Delegate d1 = GetTrueDelegate(ob); - Delegate d2 = GetTrueDelegate(other); - return d1 == d2 ? 0 : -1; - } -#endif } } diff --git a/Python.Runtime/exceptions.cs b/Python.Runtime/exceptions.cs index 31c367eb2..a2d3bbd19 100644 --- a/Python.Runtime/exceptions.cs +++ b/Python.Runtime/exceptions.cs @@ -180,7 +180,7 @@ internal static void SetArgsAndCause(IntPtr ob) Marshal.WriteIntPtr(ob, ExceptionOffset.args, args); -#if PYTHON3 +#if !PYTHON2 if (e.InnerException != null) { IntPtr cause = CLRObject.GetInstHandle(e.InnerException); diff --git a/Python.Runtime/importhook.cs b/Python.Runtime/importhook.cs index 06ba7a56d..ee8ad648e 100644 --- a/Python.Runtime/importhook.cs +++ b/Python.Runtime/importhook.cs @@ -13,7 +13,6 @@ internal class ImportHook private static MethodWrapper hook; private static IntPtr py_clr_module; -#if PYTHON3 private static IntPtr module_def = IntPtr.Zero; internal static void InitializeModuleDef() @@ -23,7 +22,6 @@ internal static void InitializeModuleDef() module_def = ModuleDefOffset.AllocModuleDef("clr"); } } -#endif /// /// Get a New reference to the builtins module. @@ -86,7 +84,7 @@ internal static void Initialize() // Initialize the clr module and tell Python about it. root = new CLRModule(); -#if PYTHON3 +#if !PYTHON2 // create a python module with the same methods as the clr module-like object InitializeModuleDef(); py_clr_module = Runtime.PyModule_Create2(module_def, 3); @@ -97,7 +95,7 @@ internal static void Initialize() clr_dict = (IntPtr)Marshal.PtrToStructure(clr_dict, typeof(IntPtr)); Runtime.PyDict_Update(mod_dict, clr_dict); -#elif PYTHON2 +#else Runtime.XIncref(root.pyHandle); // we are using the module two times py_clr_module = root.pyHandle; // Alias handle for PY2/PY3 #endif diff --git a/Python.Runtime/interop.cs b/Python.Runtime/interop.cs index 4ae4b61e0..69d7637b4 100644 --- a/Python.Runtime/interop.cs +++ b/Python.Runtime/interop.cs @@ -155,7 +155,7 @@ public static int Size() public static int args = 0; #if PYTHON2 public static int message = 0; -#elif PYTHON3 +#else public static int traceback = 0; public static int context = 0; public static int cause = 0; @@ -168,7 +168,6 @@ public static int Size() } -#if PYTHON3 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] internal class BytesOffset { @@ -259,7 +258,6 @@ public static void FreeModuleDef(IntPtr ptr) public static int name = 0; } -#endif // PYTHON3 /// /// TypeFlags(): The actual bit values for the Type Flags stored @@ -269,17 +267,6 @@ public static void FreeModuleDef(IntPtr ptr) /// internal class TypeFlags { -#if PYTHON2 // these flags were removed in Python 3 - public static int HaveGetCharBuffer = (1 << 0); - public static int HaveSequenceIn = (1 << 1); - public static int GC = 0; - public static int HaveInPlaceOps = (1 << 3); - public static int CheckTypes = (1 << 4); - public static int HaveRichCompare = (1 << 5); - public static int HaveWeakRefs = (1 << 6); - public static int HaveIter = (1 << 7); - public static int HaveClass = (1 << 8); -#endif public static int HeapType = (1 << 9); public static int BaseType = (1 << 10); public static int Ready = (1 << 12); @@ -308,6 +295,15 @@ internal class TypeFlags public static int TypeSubclass = (1 << 31); #if PYTHON2 // Default flags for Python 2 + public static int HaveGetCharBuffer = (1 << 0); + public static int HaveSequenceIn = (1 << 1); + public static int GC = 0; + public static int HaveInPlaceOps = (1 << 3); + public static int CheckTypes = (1 << 4); + public static int HaveRichCompare = (1 << 5); + public static int HaveWeakRefs = (1 << 6); + public static int HaveIter = (1 << 7); + public static int HaveClass = (1 << 8); public static int Default = ( HaveGetCharBuffer | HaveSequenceIn | @@ -319,7 +315,7 @@ internal class TypeFlags HaveStacklessExtension | HaveIndex | 0); -#elif PYTHON3 // Default flags for Python 3 +#else // Default flags for Python 3 public static int Default = ( HaveStacklessExtension | HaveVersionTag); diff --git a/Python.Runtime/pythonengine.cs b/Python.Runtime/pythonengine.cs index 700543839..f11e1b60a 100644 --- a/Python.Runtime/pythonengine.cs +++ b/Python.Runtime/pythonengine.cs @@ -254,11 +254,7 @@ static void OnDomainUnload(object _, EventArgs __) /// CPython interpreter process - this bootstraps the managed runtime /// when it is imported by the CLR extension module. /// -#if PYTHON3 - public static IntPtr InitExt() -#elif PYTHON2 - public static void InitExt() -#endif + public static int InternalInitialize(int size, IntPtr data) { try { @@ -294,18 +290,13 @@ public static void InitExt() " break\n"; PythonEngine.Exec(code); + return 0; } catch (PythonException e) { e.Restore(); -#if PYTHON3 - return IntPtr.Zero; -#endif + return -1; } - -#if PYTHON3 - return Python.Runtime.ImportHook.GetCLRModule(); -#endif } /// @@ -321,7 +312,7 @@ public static void Shutdown() if (initialized) { PyScopeManager.Global.Clear(); - + // If the shutdown handlers trigger a domain unload, // don't call shutdown again. AppDomain.CurrentDomain.DomainUnload -= OnDomainUnload; @@ -584,7 +575,7 @@ internal static PyObject RunString(string code, IntPtr? globals, IntPtr? locals, borrowedGlobals = false; } } - + if (locals == null) { locals = globals; @@ -640,7 +631,7 @@ public static PyScope CreateScope(string name) var scope = PyScopeManager.Global.Create(name); return scope; } - + public class GILState : IDisposable { private IntPtr state; @@ -737,7 +728,7 @@ public static void SetArgv(IEnumerable argv) public static void With(PyObject obj, Action Body) { - // Behavior described here: + // Behavior described here: // https://docs.python.org/2/reference/datamodel.html#with-statement-context-managers IntPtr type = Runtime.PyNone; diff --git a/Python.Runtime/runtime.cs b/Python.Runtime/runtime.cs index 7a78cd6e1..909ac4bc8 100644 --- a/Python.Runtime/runtime.cs +++ b/Python.Runtime/runtime.cs @@ -22,7 +22,7 @@ public class Runtime public static int UCS => _UCS; -#if UCS4 +#if UCS2 internal const int _UCS = 4; /// @@ -30,7 +30,7 @@ public class Runtime /// methods prior to PEP393. Only used for PY27. /// private const string PyUnicodeEntryPoint = "PyUnicodeUCS4_"; -#elif UCS2 +#else internal const int _UCS = 2; /// @@ -38,69 +38,9 @@ public class Runtime /// methods prior to PEP393. Only used for PY27. /// private const string PyUnicodeEntryPoint = "PyUnicodeUCS2_"; -#else -#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; - public static string pyver => _pyver; - -#if PYTHON27 - internal const string _pyversion = "2.7"; - internal const string _pyver = "27"; -#elif PYTHON34 - internal const string _pyversion = "3.4"; - internal const string _pyver = "34"; -#elif PYTHON35 - internal const string _pyversion = "3.5"; - internal const string _pyver = "35"; -#elif PYTHON36 - internal const string _pyversion = "3.6"; - internal const string _pyver = "36"; -#elif PYTHON37 - internal const string _pyversion = "3.7"; - internal const string _pyver = "37"; -#elif PYTHON38 - internal const string _pyversion = "3.8"; - internal const string _pyver = "38"; -#else -#error You must define one of PYTHON34 to PYTHON38 or PYTHON27 -#endif - -#if MONO_LINUX || MONO_OSX // Linux/macOS use dotted version string - internal const string dllBase = "python" + _pyversion; -#else // Windows - internal const string dllBase = "python" + _pyver; #endif -#if PYTHON_WITH_PYDEBUG - internal const string dllWithPyDebug = "d"; -#else - internal const string dllWithPyDebug = ""; -#endif -#if PYTHON_WITH_PYMALLOC - internal const string dllWithPyMalloc = "m"; -#else - internal const string dllWithPyMalloc = ""; -#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 readonly string PythonDLL = _PythonDll; - -#if PYTHON_WITHOUT_ENABLE_SHARED && !NETSTANDARD internal const string _PythonDll = "__Internal"; -#else - 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(); @@ -159,8 +99,13 @@ public class Runtime /// public static string MachineName { get; private set; } - internal static bool IsPython2 = pyversionnumber < 30; - internal static bool IsPython3 = pyversionnumber >= 30; +#if PYTHON2 + internal static bool IsPython2 = true; +#else + internal static bool IsPython2 = false; +#endif + + internal static bool IsPython3 = !IsPython2; public static int MainManagedThreadId { get; private set; } @@ -229,7 +174,7 @@ internal static void Initialize(bool initSigs = false) PyWrapperDescriptorType = PyObject_Type(op); XDecref(op); -#if PYTHON3 +#if !PYTHON2 XDecref(dict); #endif @@ -241,7 +186,7 @@ internal static void Initialize(bool initSigs = false) PyUnicodeType = PyObject_Type(op); XDecref(op); -#if PYTHON3 +#if !PYTHON2 op = PyBytes_FromString("bytes"); PyBytesType = PyObject_Type(op); XDecref(op); @@ -271,10 +216,10 @@ internal static void Initialize(bool initSigs = false) PyFloatType = PyObject_Type(op); XDecref(op); -#if PYTHON3 PyClassType = IntPtr.Zero; PyInstanceType = IntPtr.Zero; -#elif PYTHON2 + +#if PYTHON2 IntPtr s = PyString_FromString("_temp"); IntPtr d = PyDict_New(); @@ -420,9 +365,7 @@ internal static int AtExit() internal static IntPtr Py_NoSiteFlag; -#if PYTHON3 internal static IntPtr PyBytesType; -#endif internal static IntPtr _PyObject_NextNotImplemented; internal static IntPtr PyNotImplemented; @@ -677,13 +620,13 @@ internal static unsafe long Refcount(IntPtr op) [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern IntPtr PyGILState_GetThisThreadState(); -#if PYTHON3 +#if !PYTHON2 [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] public static extern int Py_Main( int argc, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StrArrayMarshaler))] string[] argv ); -#elif PYTHON2 +#else [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] public static extern int Py_Main(int argc, string[] argv); #endif @@ -886,7 +829,6 @@ internal static bool PyObject_IsIterable(IntPtr pointer) [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern IntPtr PyObject_CallObject(IntPtr pointer, IntPtr args); -#if PYTHON3 [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern int PyObject_RichCompareBool(IntPtr value1, IntPtr value2, int opid); @@ -914,10 +856,6 @@ internal static int PyObject_Compare(IntPtr value1, IntPtr value2) Exceptions.SetError(Exceptions.SystemError, "Error comparing objects"); return -1; } -#elif PYTHON2 - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyObject_Compare(IntPtr value1, IntPtr value2); -#endif [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern int PyObject_IsInstance(IntPtr ob, IntPtr type); @@ -951,11 +889,11 @@ internal static long PyObject_Size(IntPtr pointer) [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern IntPtr PyObject_Str(IntPtr pointer); -#if PYTHON3 +#if !PYTHON2 [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PyObject_Str")] internal static extern IntPtr PyObject_Unicode(IntPtr pointer); -#elif PYTHON2 +#else [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern IntPtr PyObject_Unicode(IntPtr pointer); #endif @@ -968,11 +906,11 @@ internal static long PyObject_Size(IntPtr pointer) // Python number API //==================================================================== -#if PYTHON3 +#if !PYTHON2 [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PyNumber_Long")] internal static extern IntPtr PyNumber_Int(IntPtr ob); -#elif PYTHON2 +#else [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern IntPtr PyNumber_Int(IntPtr ob); #endif @@ -1008,7 +946,7 @@ internal static IntPtr PyInt_FromInt64(long value) return PyInt_FromLong(v); } -#if PYTHON3 +#if !PYTHON2 [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PyLong_FromLong")] private static extern IntPtr PyInt_FromLong(IntPtr value); @@ -1020,7 +958,7 @@ internal static IntPtr PyInt_FromInt64(long value) [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PyLong_FromString")] internal static extern IntPtr PyInt_FromString(string value, IntPtr end, int radix); -#elif PYTHON2 +#else [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] private static extern IntPtr PyInt_FromLong(IntPtr value); @@ -1297,14 +1235,14 @@ internal static bool PyString_Check(IntPtr ob) internal static IntPtr PyString_FromString(string value) { -#if PYTHON3 +#if !PYTHON2 return PyUnicode_FromKindAndData(_UCS, value, value.Length); -#elif PYTHON2 +#else return PyString_FromStringAndSize(value, value.Length); #endif } -#if PYTHON3 +#if !PYTHON2 [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern IntPtr PyBytes_FromString(string op); @@ -1340,7 +1278,7 @@ internal static IntPtr PyUnicode_FromStringAndSize(IntPtr value, long size) [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] private static extern IntPtr PyUnicode_FromStringAndSize(IntPtr value, IntPtr size); -#elif PYTHON2 +#else internal static IntPtr PyString_FromStringAndSize(string value, long size) { return PyString_FromStringAndSize(value, new IntPtr(size)); @@ -1361,7 +1299,7 @@ internal static bool PyUnicode_Check(IntPtr ob) return PyObject_TYPE(ob) == PyUnicodeType; } -#if PYTHON3 +#if !PYTHON2 [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern IntPtr PyUnicode_FromObject(IntPtr ob); @@ -1398,7 +1336,7 @@ internal static long PyUnicode_GetSize(IntPtr ob) [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern IntPtr PyUnicode_FromOrdinal(int c); -#elif PYTHON2 +#else [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = PyUnicodeEntryPoint + "FromObject")] internal static extern IntPtr PyUnicode_FromObject(IntPtr ob); @@ -1707,7 +1645,7 @@ internal static bool PyIter_Check(IntPtr pointer) [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern string PyModule_GetFilename(IntPtr module); -#if PYTHON3 +#if !PYTHON2 [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern IntPtr PyModule_Create2(IntPtr module, int apiver); #endif @@ -1727,14 +1665,14 @@ internal static bool PyIter_Check(IntPtr pointer) [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern IntPtr PyImport_GetModuleDict(); -#if PYTHON3 +#if !PYTHON2 [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern void PySys_SetArgvEx( int argc, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StrArrayMarshaler))] string[] argv, int updatepath ); -#elif PYTHON2 +#else [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern void PySys_SetArgvEx( int argc, @@ -1895,24 +1833,8 @@ internal static void SetNoSiteFlag() { var loader = LibraryLoader.Get(OperatingSystem); - IntPtr dllLocal; - if (_PythonDll != "__Internal") - { - dllLocal = loader.Load(_PythonDll); - } - - try - { - Py_NoSiteFlag = loader.GetFunction(dllLocal, "Py_NoSiteFlag"); - Marshal.WriteInt32(Py_NoSiteFlag, 1); - } - finally - { - if (dllLocal != IntPtr.Zero) - { - loader.Free(dllLocal); - } - } + Py_NoSiteFlag = loader.GetFunction(IntPtr.Zero, "Py_NoSiteFlag"); + Marshal.WriteInt32(Py_NoSiteFlag, 1); } } } diff --git a/Python.Runtime/typemanager.cs b/Python.Runtime/typemanager.cs index 9a98e9ebb..0f1b1fcda 100644 --- a/Python.Runtime/typemanager.cs +++ b/Python.Runtime/typemanager.cs @@ -414,24 +414,21 @@ internal static IntPtr AllocateTypeObject(string name) // Cheat a little: we'll set tp_name to the internal char * of // the Python version of the type name - otherwise we'd have to // allocate the tp_name and would have no way to free it. -#if PYTHON3 +#if !PYTHON2 // For python3 we leak two objects. One for the ASCII representation // required for tp_name, and another for the Unicode representation // for ht_name. IntPtr temp = Runtime.PyBytes_FromString(name); IntPtr raw = Runtime.PyBytes_AS_STRING(temp); temp = Runtime.PyUnicode_FromString(name); -#elif PYTHON2 + Marshal.WriteIntPtr(type, TypeOffset.qualname, temp); +#else IntPtr temp = Runtime.PyString_FromString(name); IntPtr raw = Runtime.PyString_AsString(temp); #endif Marshal.WriteIntPtr(type, TypeOffset.tp_name, raw); Marshal.WriteIntPtr(type, TypeOffset.name, temp); -#if PYTHON3 - Marshal.WriteIntPtr(type, TypeOffset.qualname, temp); -#endif - long ptr = type.ToInt64(); // 64-bit safe temp = new IntPtr(ptr + TypeOffset.nb_add); @@ -443,9 +440,9 @@ internal static IntPtr AllocateTypeObject(string name) temp = new IntPtr(ptr + TypeOffset.mp_length); Marshal.WriteIntPtr(type, TypeOffset.tp_as_mapping, temp); -#if PYTHON3 +#if !PYTHON2 temp = new IntPtr(ptr + TypeOffset.bf_getbuffer); -#elif PYTHON2 +#else temp = new IntPtr(ptr + TypeOffset.bf_getreadbuffer); #endif Marshal.WriteIntPtr(type, TypeOffset.tp_as_buffer, temp); From e933e7968c8e8033c2d84f18e2edff4acaef0c6c Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Sat, 14 Dec 2019 23:28:19 +0100 Subject: [PATCH 10/22] Remove unneeded additional interop files --- .../{interop27.cs => interop/interop2.cs} | 0 .../{interop35.cs => interop/interop3.cs} | 9 +- Python.Runtime/interop34.cs | 144 ----------------- Python.Runtime/interop36.cs | 149 ------------------ Python.Runtime/interop37.cs | 149 ------------------ 5 files changed, 6 insertions(+), 445 deletions(-) rename Python.Runtime/{interop27.cs => interop/interop2.cs} (100%) rename Python.Runtime/{interop35.cs => interop/interop3.cs} (97%) delete mode 100644 Python.Runtime/interop34.cs delete mode 100644 Python.Runtime/interop36.cs delete mode 100644 Python.Runtime/interop37.cs diff --git a/Python.Runtime/interop27.cs b/Python.Runtime/interop/interop2.cs similarity index 100% rename from Python.Runtime/interop27.cs rename to Python.Runtime/interop/interop2.cs diff --git a/Python.Runtime/interop35.cs b/Python.Runtime/interop/interop3.cs similarity index 97% rename from Python.Runtime/interop35.cs rename to Python.Runtime/interop/interop3.cs index a30bfa4fd..008064c34 100644 --- a/Python.Runtime/interop35.cs +++ b/Python.Runtime/interop/interop3.cs @@ -1,8 +1,9 @@ + // Auto-generated by geninterop.py. -// DO NOT MODIFIY BY HAND. +// DO NOT MODIFY BY HAND. -#if PYTHON35 +#if !PYTHON2 using System; using System.Collections; using System.Collections.Specialized; @@ -39,7 +40,7 @@ public static int magic() public static int tp_basicsize = 0; public static int tp_itemsize = 0; public static int tp_dealloc = 0; - public static int tp_print = 0; + public static int tp_vectorcall_offset = 0; public static int tp_getattr = 0; public static int tp_setattr = 0; public static int tp_as_async = 0; @@ -82,6 +83,8 @@ public static int magic() public static int tp_del = 0; public static int tp_version_tag = 0; public static int tp_finalize = 0; + public static int tp_vectorcall = 0; + public static int tp_print = 0; public static int am_await = 0; public static int am_aiter = 0; public static int am_anext = 0; diff --git a/Python.Runtime/interop34.cs b/Python.Runtime/interop34.cs deleted file mode 100644 index 6857ff2d0..000000000 --- a/Python.Runtime/interop34.cs +++ /dev/null @@ -1,144 +0,0 @@ -// Auto-generated by geninterop.py. -// DO NOT MODIFIY BY HAND. - - -#if PYTHON34 -using System; -using System.Collections; -using System.Collections.Specialized; -using System.Runtime.InteropServices; -using System.Reflection; -using System.Text; - -namespace Python.Runtime -{ - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - internal class TypeOffset - { - static TypeOffset() - { - Type type = typeof(TypeOffset); - FieldInfo[] fi = type.GetFields(); - int size = IntPtr.Size; - for (int i = 0; i < fi.Length; i++) - { - fi[i].SetValue(null, i * size); - } - } - - public static int magic() - { - return ob_size; - } - - // Auto-generated from PyHeapTypeObject in Python.h - public static int ob_refcnt = 0; - public static int ob_type = 0; - public static int ob_size = 0; - public static int tp_name = 0; - public static int tp_basicsize = 0; - public static int tp_itemsize = 0; - public static int tp_dealloc = 0; - public static int tp_print = 0; - public static int tp_getattr = 0; - public static int tp_setattr = 0; - public static int tp_reserved = 0; - public static int tp_repr = 0; - public static int tp_as_number = 0; - public static int tp_as_sequence = 0; - public static int tp_as_mapping = 0; - public static int tp_hash = 0; - public static int tp_call = 0; - public static int tp_str = 0; - public static int tp_getattro = 0; - public static int tp_setattro = 0; - public static int tp_as_buffer = 0; - public static int tp_flags = 0; - public static int tp_doc = 0; - public static int tp_traverse = 0; - public static int tp_clear = 0; - public static int tp_richcompare = 0; - public static int tp_weaklistoffset = 0; - public static int tp_iter = 0; - public static int tp_iternext = 0; - public static int tp_methods = 0; - public static int tp_members = 0; - public static int tp_getset = 0; - public static int tp_base = 0; - public static int tp_dict = 0; - public static int tp_descr_get = 0; - public static int tp_descr_set = 0; - public static int tp_dictoffset = 0; - public static int tp_init = 0; - public static int tp_alloc = 0; - public static int tp_new = 0; - public static int tp_free = 0; - public static int tp_is_gc = 0; - public static int tp_bases = 0; - public static int tp_mro = 0; - public static int tp_cache = 0; - public static int tp_subclasses = 0; - public static int tp_weaklist = 0; - public static int tp_del = 0; - public static int tp_version_tag = 0; - public static int tp_finalize = 0; - public static int nb_add = 0; - public static int nb_subtract = 0; - public static int nb_multiply = 0; - public static int nb_remainder = 0; - public static int nb_divmod = 0; - public static int nb_power = 0; - public static int nb_negative = 0; - public static int nb_positive = 0; - public static int nb_absolute = 0; - public static int nb_bool = 0; - public static int nb_invert = 0; - public static int nb_lshift = 0; - public static int nb_rshift = 0; - public static int nb_and = 0; - public static int nb_xor = 0; - public static int nb_or = 0; - public static int nb_int = 0; - public static int nb_reserved = 0; - public static int nb_float = 0; - public static int nb_inplace_add = 0; - public static int nb_inplace_subtract = 0; - public static int nb_inplace_multiply = 0; - public static int nb_inplace_remainder = 0; - public static int nb_inplace_power = 0; - public static int nb_inplace_lshift = 0; - public static int nb_inplace_rshift = 0; - public static int nb_inplace_and = 0; - public static int nb_inplace_xor = 0; - public static int nb_inplace_or = 0; - public static int nb_floor_divide = 0; - public static int nb_true_divide = 0; - public static int nb_inplace_floor_divide = 0; - public static int nb_inplace_true_divide = 0; - public static int nb_index = 0; - public static int mp_length = 0; - public static int mp_subscript = 0; - public static int mp_ass_subscript = 0; - public static int sq_length = 0; - public static int sq_concat = 0; - public static int sq_repeat = 0; - public static int sq_item = 0; - public static int was_sq_slice = 0; - public static int sq_ass_item = 0; - public static int was_sq_ass_slice = 0; - public static int sq_contains = 0; - public static int sq_inplace_concat = 0; - public static int sq_inplace_repeat = 0; - public static int bf_getbuffer = 0; - public static int bf_releasebuffer = 0; - public static int name = 0; - public static int ht_slots = 0; - public static int qualname = 0; - public static int ht_cached_keys = 0; - - /* here are optional user slots, followed by the members. */ - public static int members = 0; - } -} - -#endif diff --git a/Python.Runtime/interop36.cs b/Python.Runtime/interop36.cs deleted file mode 100644 index c46bcc2f5..000000000 --- a/Python.Runtime/interop36.cs +++ /dev/null @@ -1,149 +0,0 @@ -// Auto-generated by geninterop.py. -// DO NOT MODIFIY BY HAND. - - -#if PYTHON36 -using System; -using System.Collections; -using System.Collections.Specialized; -using System.Runtime.InteropServices; -using System.Reflection; -using System.Text; - -namespace Python.Runtime -{ - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - internal class TypeOffset - { - static TypeOffset() - { - Type type = typeof(TypeOffset); - FieldInfo[] fi = type.GetFields(); - int size = IntPtr.Size; - for (int i = 0; i < fi.Length; i++) - { - fi[i].SetValue(null, i * size); - } - } - - public static int magic() - { - return ob_size; - } - - // Auto-generated from PyHeapTypeObject in Python.h - public static int ob_refcnt = 0; - public static int ob_type = 0; - public static int ob_size = 0; - public static int tp_name = 0; - public static int tp_basicsize = 0; - public static int tp_itemsize = 0; - public static int tp_dealloc = 0; - public static int tp_print = 0; - public static int tp_getattr = 0; - public static int tp_setattr = 0; - public static int tp_as_async = 0; - public static int tp_repr = 0; - public static int tp_as_number = 0; - public static int tp_as_sequence = 0; - public static int tp_as_mapping = 0; - public static int tp_hash = 0; - public static int tp_call = 0; - public static int tp_str = 0; - public static int tp_getattro = 0; - public static int tp_setattro = 0; - public static int tp_as_buffer = 0; - public static int tp_flags = 0; - public static int tp_doc = 0; - public static int tp_traverse = 0; - public static int tp_clear = 0; - public static int tp_richcompare = 0; - public static int tp_weaklistoffset = 0; - public static int tp_iter = 0; - public static int tp_iternext = 0; - public static int tp_methods = 0; - public static int tp_members = 0; - public static int tp_getset = 0; - public static int tp_base = 0; - public static int tp_dict = 0; - public static int tp_descr_get = 0; - public static int tp_descr_set = 0; - public static int tp_dictoffset = 0; - public static int tp_init = 0; - public static int tp_alloc = 0; - public static int tp_new = 0; - public static int tp_free = 0; - public static int tp_is_gc = 0; - public static int tp_bases = 0; - public static int tp_mro = 0; - public static int tp_cache = 0; - public static int tp_subclasses = 0; - public static int tp_weaklist = 0; - public static int tp_del = 0; - public static int tp_version_tag = 0; - public static int tp_finalize = 0; - public static int am_await = 0; - public static int am_aiter = 0; - public static int am_anext = 0; - public static int nb_add = 0; - public static int nb_subtract = 0; - public static int nb_multiply = 0; - public static int nb_remainder = 0; - public static int nb_divmod = 0; - public static int nb_power = 0; - public static int nb_negative = 0; - public static int nb_positive = 0; - public static int nb_absolute = 0; - public static int nb_bool = 0; - public static int nb_invert = 0; - public static int nb_lshift = 0; - public static int nb_rshift = 0; - public static int nb_and = 0; - public static int nb_xor = 0; - public static int nb_or = 0; - public static int nb_int = 0; - public static int nb_reserved = 0; - public static int nb_float = 0; - public static int nb_inplace_add = 0; - public static int nb_inplace_subtract = 0; - public static int nb_inplace_multiply = 0; - public static int nb_inplace_remainder = 0; - public static int nb_inplace_power = 0; - public static int nb_inplace_lshift = 0; - public static int nb_inplace_rshift = 0; - public static int nb_inplace_and = 0; - public static int nb_inplace_xor = 0; - public static int nb_inplace_or = 0; - public static int nb_floor_divide = 0; - public static int nb_true_divide = 0; - public static int nb_inplace_floor_divide = 0; - public static int nb_inplace_true_divide = 0; - public static int nb_index = 0; - public static int nb_matrix_multiply = 0; - public static int nb_inplace_matrix_multiply = 0; - public static int mp_length = 0; - public static int mp_subscript = 0; - public static int mp_ass_subscript = 0; - public static int sq_length = 0; - public static int sq_concat = 0; - public static int sq_repeat = 0; - public static int sq_item = 0; - public static int was_sq_slice = 0; - public static int sq_ass_item = 0; - public static int was_sq_ass_slice = 0; - public static int sq_contains = 0; - public static int sq_inplace_concat = 0; - public static int sq_inplace_repeat = 0; - public static int bf_getbuffer = 0; - public static int bf_releasebuffer = 0; - public static int name = 0; - public static int ht_slots = 0; - public static int qualname = 0; - public static int ht_cached_keys = 0; - - /* here are optional user slots, followed by the members. */ - public static int members = 0; - } -} - -#endif diff --git a/Python.Runtime/interop37.cs b/Python.Runtime/interop37.cs deleted file mode 100644 index d5fc76ad3..000000000 --- a/Python.Runtime/interop37.cs +++ /dev/null @@ -1,149 +0,0 @@ -// Auto-generated by geninterop.py. -// DO NOT MODIFIY BY HAND. - - -#if PYTHON37 -using System; -using System.Collections; -using System.Collections.Specialized; -using System.Runtime.InteropServices; -using System.Reflection; -using System.Text; - -namespace Python.Runtime -{ - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - internal class TypeOffset - { - static TypeOffset() - { - Type type = typeof(TypeOffset); - FieldInfo[] fi = type.GetFields(); - int size = IntPtr.Size; - for (int i = 0; i < fi.Length; i++) - { - fi[i].SetValue(null, i * size); - } - } - - public static int magic() - { - return ob_size; - } - - // Auto-generated from PyHeapTypeObject in Python.h - public static int ob_refcnt = 0; - public static int ob_type = 0; - public static int ob_size = 0; - public static int tp_name = 0; - public static int tp_basicsize = 0; - public static int tp_itemsize = 0; - public static int tp_dealloc = 0; - public static int tp_print = 0; - public static int tp_getattr = 0; - public static int tp_setattr = 0; - public static int tp_as_async = 0; - public static int tp_repr = 0; - public static int tp_as_number = 0; - public static int tp_as_sequence = 0; - public static int tp_as_mapping = 0; - public static int tp_hash = 0; - public static int tp_call = 0; - public static int tp_str = 0; - public static int tp_getattro = 0; - public static int tp_setattro = 0; - public static int tp_as_buffer = 0; - public static int tp_flags = 0; - public static int tp_doc = 0; - public static int tp_traverse = 0; - public static int tp_clear = 0; - public static int tp_richcompare = 0; - public static int tp_weaklistoffset = 0; - public static int tp_iter = 0; - public static int tp_iternext = 0; - public static int tp_methods = 0; - public static int tp_members = 0; - public static int tp_getset = 0; - public static int tp_base = 0; - public static int tp_dict = 0; - public static int tp_descr_get = 0; - public static int tp_descr_set = 0; - public static int tp_dictoffset = 0; - public static int tp_init = 0; - public static int tp_alloc = 0; - public static int tp_new = 0; - public static int tp_free = 0; - public static int tp_is_gc = 0; - public static int tp_bases = 0; - public static int tp_mro = 0; - public static int tp_cache = 0; - public static int tp_subclasses = 0; - public static int tp_weaklist = 0; - public static int tp_del = 0; - public static int tp_version_tag = 0; - public static int tp_finalize = 0; - public static int am_await = 0; - public static int am_aiter = 0; - public static int am_anext = 0; - public static int nb_add = 0; - public static int nb_subtract = 0; - public static int nb_multiply = 0; - public static int nb_remainder = 0; - public static int nb_divmod = 0; - public static int nb_power = 0; - public static int nb_negative = 0; - public static int nb_positive = 0; - public static int nb_absolute = 0; - public static int nb_bool = 0; - public static int nb_invert = 0; - public static int nb_lshift = 0; - public static int nb_rshift = 0; - public static int nb_and = 0; - public static int nb_xor = 0; - public static int nb_or = 0; - public static int nb_int = 0; - public static int nb_reserved = 0; - public static int nb_float = 0; - public static int nb_inplace_add = 0; - public static int nb_inplace_subtract = 0; - public static int nb_inplace_multiply = 0; - public static int nb_inplace_remainder = 0; - public static int nb_inplace_power = 0; - public static int nb_inplace_lshift = 0; - public static int nb_inplace_rshift = 0; - public static int nb_inplace_and = 0; - public static int nb_inplace_xor = 0; - public static int nb_inplace_or = 0; - public static int nb_floor_divide = 0; - public static int nb_true_divide = 0; - public static int nb_inplace_floor_divide = 0; - public static int nb_inplace_true_divide = 0; - public static int nb_index = 0; - public static int nb_matrix_multiply = 0; - public static int nb_inplace_matrix_multiply = 0; - public static int mp_length = 0; - public static int mp_subscript = 0; - public static int mp_ass_subscript = 0; - public static int sq_length = 0; - public static int sq_concat = 0; - public static int sq_repeat = 0; - public static int sq_item = 0; - public static int was_sq_slice = 0; - public static int sq_ass_item = 0; - public static int was_sq_ass_slice = 0; - public static int sq_contains = 0; - public static int sq_inplace_concat = 0; - public static int sq_inplace_repeat = 0; - public static int bf_getbuffer = 0; - public static int bf_releasebuffer = 0; - public static int name = 0; - public static int ht_slots = 0; - public static int qualname = 0; - public static int ht_cached_keys = 0; - - /* here are optional user slots, followed by the members. */ - public static int members = 0; - } -} - -#endif From f27d7be072d1aebdb6658d91fef03dcc55985b41 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Sun, 15 Dec 2019 15:57:49 +0100 Subject: [PATCH 11/22] Make NETSTANDARD the default Drops also - Custom XDecref/XIncref (should be readded) - Remote object handling for .NET Framework --- Python.Runtime/codegenerator.cs | 38 +++++- Python.Runtime/converter.cs | 8 -- Python.Runtime/nativecall.cs | 128 ------------------ ...ionPolifills.cs => ReflectionPolyfills.cs} | 4 +- Python.Runtime/runtime.cs | 46 ------- Python.Test.Embed/TestDomainReload.cs | 2 +- 6 files changed, 33 insertions(+), 193 deletions(-) rename Python.Runtime/polyfill/{ReflectionPolifills.cs => ReflectionPolyfills.cs} (88%) diff --git a/Python.Runtime/codegenerator.cs b/Python.Runtime/codegenerator.cs index dc466bafb..d5c03aa18 100644 --- a/Python.Runtime/codegenerator.cs +++ b/Python.Runtime/codegenerator.cs @@ -13,16 +13,40 @@ namespace Python.Runtime /// internal class CodeGenerator { - private AssemblyBuilder aBuilder; - private ModuleBuilder mBuilder; + private AssemblyBuilder _aBuilder = null; - internal CodeGenerator() + private AssemblyBuilder aBuilder + { + get + { + if (_aBuilder == null) + { + var aname = new AssemblyName { Name = "__CodeGenerator_Assembly" }; + var aa = AssemblyBuilderAccess.Run; + + _aBuilder = Thread.GetDomain().DefineDynamicAssembly(aname, aa); + } + + return _aBuilder; + } + } + + private ModuleBuilder _mBuilder = null; + private ModuleBuilder mBuilder { - var aname = new AssemblyName { Name = "__CodeGenerator_Assembly" }; - var aa = AssemblyBuilderAccess.Run; + get + { + if (_mBuilder == null) + { + _mBuilder = aBuilder.DefineDynamicModule("__CodeGenerator_Module"); + } + + return _mBuilder; + } + } - aBuilder = Thread.GetDomain().DefineDynamicAssembly(aname, aa); - mBuilder = aBuilder.DefineDynamicModule("__CodeGenerator_Module"); + internal CodeGenerator() + { } /// diff --git a/Python.Runtime/converter.cs b/Python.Runtime/converter.cs index 14c481b21..6bbdb4c39 100644 --- a/Python.Runtime/converter.cs +++ b/Python.Runtime/converter.cs @@ -156,15 +156,7 @@ internal static IntPtr ToPython(object value, Type type) var pyderived = value as IPythonDerivedType; if (null != pyderived) { - #if NETSTANDARD return ClassDerivedObject.ToPython(pyderived); - #else - // if object is remote don't do this - if (!System.Runtime.Remoting.RemotingServices.IsTransparentProxy(pyderived)) - { - return ClassDerivedObject.ToPython(pyderived); - } - #endif } // hmm - from Python, we almost never care what the declared diff --git a/Python.Runtime/nativecall.cs b/Python.Runtime/nativecall.cs index 4a7bf05c8..eea4b6fae 100644 --- a/Python.Runtime/nativecall.cs +++ b/Python.Runtime/nativecall.cs @@ -23,7 +23,6 @@ namespace Python.Runtime /// internal class NativeCall { -#if NETSTANDARD [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Void_1_Delegate(IntPtr a1); @@ -48,132 +47,5 @@ public static int Int_Call_3(IntPtr fp, IntPtr a1, IntPtr a2, IntPtr a3) var d = Marshal.GetDelegateForFunctionPointer(fp); return d(a1, a2, a3); } -#else - private static AssemblyBuilder aBuilder; - private static ModuleBuilder mBuilder; - - public static INativeCall Impl; - - static NativeCall() - { - // The static constructor is responsible for generating the - // assembly and the methods that implement the IJW thunks. - // - // To do this, we actually use reflection on the INativeCall - // interface (defined below) and generate the required thunk - // code based on the method signatures. - - var aname = new AssemblyName { Name = "e__NativeCall_Assembly" }; - var aa = AssemblyBuilderAccess.Run; - - aBuilder = Thread.GetDomain().DefineDynamicAssembly(aname, aa); - mBuilder = aBuilder.DefineDynamicModule("e__NativeCall_Module"); - - var ta = TypeAttributes.Public; - TypeBuilder tBuilder = mBuilder.DefineType("e__NativeCall", ta); - - Type iType = typeof(INativeCall); - tBuilder.AddInterfaceImplementation(iType); - - // Use reflection to loop over the INativeCall interface methods, - // calling GenerateThunk to create a managed thunk for each one. - - foreach (MethodInfo method in iType.GetMethods()) - { - GenerateThunk(tBuilder, method); - } - - Type theType = tBuilder.CreateType(); - - Impl = (INativeCall)Activator.CreateInstance(theType); - } - - private static void GenerateThunk(TypeBuilder tb, MethodInfo method) - { - ParameterInfo[] pi = method.GetParameters(); - int count = pi.Length; - int argc = count - 1; - - var args = new Type[count]; - for (var i = 0; i < count; i++) - { - args[i] = pi[i].ParameterType; - } - - MethodBuilder mb = tb.DefineMethod( - method.Name, - MethodAttributes.Public | - MethodAttributes.Virtual, - method.ReturnType, - args - ); - - // Build the method signature for the actual native function. - // This is essentially the signature of the wrapper method - // minus the first argument (the passed in function pointer). - - var nargs = new Type[argc]; - for (var i = 1; i < count; i++) - { - nargs[i - 1] = args[i]; - } - - // IL generation: the (implicit) first argument of the method - // is the 'this' pointer and the second is the function pointer. - // This code pushes the real args onto the stack, followed by - // the function pointer, then the calli opcode to make the call. - - ILGenerator il = mb.GetILGenerator(); - - for (var i = 0; i < argc; i++) - { - il.Emit(OpCodes.Ldarg_S, i + 2); - } - - il.Emit(OpCodes.Ldarg_1); - - il.EmitCalli(OpCodes.Calli, - CallingConvention.Cdecl, - method.ReturnType, - nargs - ); - - il.Emit(OpCodes.Ret); - - tb.DefineMethodOverride(mb, method); - } - - - public static void Void_Call_1(IntPtr fp, IntPtr a1) - { - Impl.Void_Call_1(fp, a1); - } - - public static IntPtr Call_3(IntPtr fp, IntPtr a1, IntPtr a2, IntPtr a3) - { - return Impl.Call_3(fp, a1, a2, a3); - } - - public static int Int_Call_3(IntPtr fp, IntPtr a1, IntPtr a2, IntPtr a3) - { - return Impl.Int_Call_3(fp, a1, a2, a3); - } -#endif - } - -#if !NETSTANDARD - /// - /// Defines native call signatures to be generated by NativeCall. - /// - public interface INativeCall - { - void Void_Call_0(IntPtr funcPtr); - - void Void_Call_1(IntPtr funcPtr, IntPtr arg1); - - int Int_Call_3(IntPtr funcPtr, IntPtr t, IntPtr n, IntPtr v); - - IntPtr Call_3(IntPtr funcPtr, IntPtr a1, IntPtr a2, IntPtr a3); } -#endif } diff --git a/Python.Runtime/polyfill/ReflectionPolifills.cs b/Python.Runtime/polyfill/ReflectionPolyfills.cs similarity index 88% rename from Python.Runtime/polyfill/ReflectionPolifills.cs rename to Python.Runtime/polyfill/ReflectionPolyfills.cs index a7e9c879a..a44a15f72 100644 --- a/Python.Runtime/polyfill/ReflectionPolifills.cs +++ b/Python.Runtime/polyfill/ReflectionPolyfills.cs @@ -4,8 +4,7 @@ namespace Python.Runtime { -#if NETSTANDARD - public static class ReflectionPolifills + public static class ReflectionPolyfills { public static AssemblyBuilder DefineDynamicAssembly(this AppDomain appDomain, AssemblyName assemblyName, AssemblyBuilderAccess assemblyBuilderAccess) { @@ -17,5 +16,4 @@ public static Type CreateType(this TypeBuilder typeBuilder) return typeBuilder.GetTypeInfo().GetType(); } } -#endif } diff --git a/Python.Runtime/runtime.cs b/Python.Runtime/runtime.cs index 909ac4bc8..2eb66b3a8 100644 --- a/Python.Runtime/runtime.cs +++ b/Python.Runtime/runtime.cs @@ -492,60 +492,14 @@ internal static Type[] PythonArgsToTypeArray(IntPtr arg, bool mangleObjects) /// internal static unsafe void XIncref(IntPtr op) { -#if PYTHON_WITH_PYDEBUG || NETSTANDARD Py_IncRef(op); return; -#else - var p = (void*)op; - if ((void*)0 != p) - { - if (Is32Bit) - { - (*(int*)p)++; - } - else - { - (*(long*)p)++; - } - } -#endif } internal static unsafe void XDecref(IntPtr op) { -#if PYTHON_WITH_PYDEBUG || NETSTANDARD Py_DecRef(op); return; -#else - var p = (void*)op; - if ((void*)0 != p) - { - if (Is32Bit) - { - --(*(int*)p); - } - else - { - --(*(long*)p); - } - if ((*(int*)p) == 0) - { - // PyObject_HEAD: struct _typeobject *ob_type - void* t = Is32Bit - ? (void*)(*((uint*)p + 1)) - : (void*)(*((ulong*)p + 1)); - // PyTypeObject: destructor tp_dealloc - void* f = Is32Bit - ? (void*)(*((uint*)t + 6)) - : (void*)(*((ulong*)t + 6)); - if ((void*)0 == f) - { - return; - } - NativeCall.Impl.Void_Call_1(new IntPtr(f), op); - } - } -#endif } internal static unsafe long Refcount(IntPtr op) diff --git a/Python.Test.Embed/TestDomainReload.cs b/Python.Test.Embed/TestDomainReload.cs index b162d4eb0..e925d761b 100644 --- a/Python.Test.Embed/TestDomainReload.cs +++ b/Python.Test.Embed/TestDomainReload.cs @@ -11,7 +11,7 @@ // // Unfortunately this means no continuous integration testing for this case. // -#if !NETSTANDARD && !NETCOREAPP +#if NETFX namespace Python.EmbeddingTest { class TestDomainReload From 52caf17aaa65e1b7afdaf23267fe9e7e5f835bd2 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Sun, 15 Dec 2019 15:58:49 +0100 Subject: [PATCH 12/22] Add very simple initial load in pythonnet --- pythonnet/__init__.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pythonnet/__init__.py b/pythonnet/__init__.py index e69de29bb..97e60239d 100644 --- a/pythonnet/__init__.py +++ b/pythonnet/__init__.py @@ -0,0 +1,18 @@ +import os + +_RUNTIME = None + + +def set_runtime(runtime): + global _RUNTIME + _RUNTIME = runtime + + +def load(): + dll_path = os.path.join(os.path.dirname(__file__), "dlls", "Python.Runtime.dll") + + assembly = _RUNTIME.get_assembly(dll_path) + func = assembly["Python.Runtime.PythonEngine.InternalInitialize"] + + if func(b"") != 0: + raise RuntimeError("Failed to initialize Python.Runtime.dll") From ca99b178cf5f3a2835a1bc31b339969099ceb906 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Sun, 15 Dec 2019 16:13:13 +0100 Subject: [PATCH 13/22] Remove Runtime._UCS dependency from CustomMarshaler --- Python.Runtime/CustomMarshaler.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Python.Runtime/CustomMarshaler.cs b/Python.Runtime/CustomMarshaler.cs index b51911816..4bae59c33 100644 --- a/Python.Runtime/CustomMarshaler.cs +++ b/Python.Runtime/CustomMarshaler.cs @@ -91,9 +91,11 @@ public static int GetUnicodeByteLength(IntPtr p) var len = 0; while (true) { - int c = Runtime._UCS == 2 - ? Marshal.ReadInt16(p, len * 2) - : Marshal.ReadInt32(p, len * 4); +#if UCS2 + int c = Marshal.ReadInt16(p, len * 2); +#else + int c = Marshal.ReadInt32(p, len * 4); +#endif if (c == 0) { From 146e6ace5d7872c93014165ae6b40dc6a40f95e2 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Sun, 15 Dec 2019 16:25:06 +0100 Subject: [PATCH 14/22] Stop using Runtime.IsPython2/3 Contrary to what I said before, I don't think trying to provide a single DLL for Python 2 and 3. We will in the future default to Python 3, and if someone really wants Python 2, for a while we will support a separate compile configuration for that. --- Python.Runtime/CustomMarshaler.cs | 16 +++++++++------ Python.Runtime/converter.cs | 11 +++++++--- Python.Runtime/exceptions.cs | 7 ++++++- Python.Runtime/importhook.cs | 32 +++++++++++++----------------- Python.Runtime/pythonengine.cs | 8 ++++---- Python.Test.Embed/TestCallbacks.cs | 9 ++++++--- 6 files changed, 48 insertions(+), 35 deletions(-) diff --git a/Python.Runtime/CustomMarshaler.cs b/Python.Runtime/CustomMarshaler.cs index 4bae59c33..ec6898c53 100644 --- a/Python.Runtime/CustomMarshaler.cs +++ b/Python.Runtime/CustomMarshaler.cs @@ -122,9 +122,11 @@ public static int GetUnicodeByteLength(IntPtr p) /// public static IntPtr Py3UnicodePy2StringtoPtr(string s) { - return Runtime.IsPython3 - ? Instance.MarshalManagedToNative(s) - : Marshal.StringToHGlobalAnsi(s); +#if PYTHON2 + return Marshal.StringToHGlobalAnsi(s); +#else + return Instance.MarshalManagedToNative(s); +#endif } /// @@ -139,9 +141,11 @@ public static IntPtr Py3UnicodePy2StringtoPtr(string s) /// public static string PtrToPy3UnicodePy2String(IntPtr p) { - return Runtime.IsPython3 - ? PtrToStringUni(p) - : Marshal.PtrToStringAnsi(p); +#if PYTHON2 + return Marshal.PtrToStringAnsi(p); +#else + return PtrToStringUni(p); +#endif } } diff --git a/Python.Runtime/converter.cs b/Python.Runtime/converter.cs index 6bbdb4c39..2e88065ed 100644 --- a/Python.Runtime/converter.cs +++ b/Python.Runtime/converter.cs @@ -86,8 +86,10 @@ internal static IntPtr GetPythonTypeByAlias(Type op) if (op == int32Type) return Runtime.PyIntType; - if (op == int64Type && Runtime.IsPython2) +#if PYTHON2 + if (op == int64Type) return Runtime.PyLongType; +#endif if (op == int64Type) return Runtime.PyIntType; @@ -455,8 +457,9 @@ private static bool ToPrimitive(IntPtr value, Type obType, out object result, bo return true; case TypeCode.Int32: +#if PYTHON2 // Trickery to support 64-bit platforms. - if (Runtime.IsPython2 && Runtime.Is32Bit) + if (Runtime.Is32Bit) { op = Runtime.PyNumber_Int(value); @@ -480,7 +483,8 @@ private static bool ToPrimitive(IntPtr value, Type obType, out object result, bo result = ival; return true; } - else // Python3 always use PyLong API +#else + // Python3 always use PyLong API { op = Runtime.PyNumber_Long(value); if (op == IntPtr.Zero) @@ -505,6 +509,7 @@ private static bool ToPrimitive(IntPtr value, Type obType, out object result, bo result = (int)ll; return true; } +#endif case TypeCode.Boolean: result = Runtime.PyObject_IsTrue(value) != 0; diff --git a/Python.Runtime/exceptions.cs b/Python.Runtime/exceptions.cs index a2d3bbd19..e4e823a9a 100644 --- a/Python.Runtime/exceptions.cs +++ b/Python.Runtime/exceptions.cs @@ -103,7 +103,12 @@ private Exceptions() /// internal static void Initialize() { - string exceptionsModuleName = Runtime.IsPython3 ? "builtins" : "exceptions"; + string exceptionsModuleName = +#if PYTHON2 + "exceptions"; +#else + "builtins"; +#endif exceptions_module = Runtime.PyImport_ImportModule(exceptionsModuleName); Exceptions.ErrorCheck(exceptions_module); diff --git a/Python.Runtime/importhook.cs b/Python.Runtime/importhook.cs index ee8ad648e..5458a932a 100644 --- a/Python.Runtime/importhook.cs +++ b/Python.Runtime/importhook.cs @@ -28,20 +28,17 @@ internal static void InitializeModuleDef() /// static IntPtr GetNewRefToBuiltins() { - if (Runtime.IsPython3) - { - return Runtime.PyImport_ImportModule("builtins"); - } - else - { - // dict is a borrowed ref, no need to decref - IntPtr dict = Runtime.PyImport_GetModuleDict(); +#if !PYTHON2 + return Runtime.PyImport_ImportModule("builtins"); +#else + // dict is a borrowed ref, no need to decref + IntPtr dict = Runtime.PyImport_GetModuleDict(); - // GetItemString is a borrowed ref; incref to get a new ref - IntPtr builtins = Runtime.PyDict_GetItemString(dict, "__builtin__"); - Runtime.XIncref(builtins); - return builtins; - } + // GetItemString is a borrowed ref; incref to get a new ref + IntPtr builtins = Runtime.PyDict_GetItemString(dict, "__builtin__"); + Runtime.XIncref(builtins); + return builtins; +#endif } /// @@ -126,11 +123,10 @@ public static IntPtr GetCLRModule(IntPtr? fromList = null) { root.InitializePreload(); - if (Runtime.IsPython2) - { - Runtime.XIncref(py_clr_module); - return py_clr_module; - } +#if PYTHON2 + Runtime.XIncref(py_clr_module); + return py_clr_module; +#endif // Python 3 // update the module dictionary with the contents of the root dictionary diff --git a/Python.Runtime/pythonengine.cs b/Python.Runtime/pythonengine.cs index f11e1b60a..c451a60fc 100644 --- a/Python.Runtime/pythonengine.cs +++ b/Python.Runtime/pythonengine.cs @@ -95,13 +95,13 @@ public static string PythonPath } set { - if (Runtime.IsPython2) - { - throw new NotSupportedException("Set PythonPath not supported on Python 2"); - } +#if PYTHON2 + throw new NotSupportedException("Set PythonPath not supported on Python 2"); +#else Marshal.FreeHGlobal(_pythonPath); _pythonPath = UcsMarshaler.Py3UnicodePy2StringtoPtr(value); Runtime.Py_SetPath(_pythonPath); +#endif } } diff --git a/Python.Test.Embed/TestCallbacks.cs b/Python.Test.Embed/TestCallbacks.cs index 220b0a86a..3d1946c78 100644 --- a/Python.Test.Embed/TestCallbacks.cs +++ b/Python.Test.Embed/TestCallbacks.cs @@ -25,9 +25,12 @@ public void TestNoOverloadException() { dynamic callWith42 = PythonEngine.Eval("lambda f: f([42])"); var error = Assert.Throws(() => callWith42(aFunctionThatCallsIntoPython.ToPython())); Assert.AreEqual("TypeError", error.PythonTypeName); - string expectedArgTypes = Runtime.IsPython2 - ? "()" - : "()"; + string expectedArgTypes = +#if PYTHON2 + "()"; +#else + "()"; +#endif StringAssert.EndsWith(expectedArgTypes, error.Message); } } From e61dd723ae505da263fe7c275c55684f0639fbfd Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Mon, 16 Dec 2019 10:12:54 +0100 Subject: [PATCH 15/22] Start implementing interface ILibPython --- .gitignore | 2 + .../CustomMarshaler.cs | 18 +- Python.Runtime.Native/ILibPython.cs | 352 ++++ .../LibPythonPInvoke.cs.dontcompile | 1692 +++++++++++++++++ .../Python.Runtime.Native.csproj | 12 + Python.Runtime/Python.Runtime.csproj | 5 + Python.Runtime/runtime_.cs | 219 +++ Python.Runtime/runtime_.tt | 40 + 8 files changed, 2334 insertions(+), 6 deletions(-) rename {Python.Runtime => Python.Runtime.Native}/CustomMarshaler.cs (94%) create mode 100644 Python.Runtime.Native/ILibPython.cs create mode 100644 Python.Runtime.Native/LibPythonPInvoke.cs.dontcompile create mode 100644 Python.Runtime.Native/Python.Runtime.Native.csproj create mode 100644 Python.Runtime/runtime_.cs create mode 100644 Python.Runtime/runtime_.tt diff --git a/.gitignore b/.gitignore index 1e494b12d..3de297c78 100644 --- a/.gitignore +++ b/.gitignore @@ -64,3 +64,5 @@ cov-int/ !.vscode/tasks.json !.vscode/launch.json !.vscode/extensions.json + +pythonnet/dlls diff --git a/Python.Runtime/CustomMarshaler.cs b/Python.Runtime.Native/CustomMarshaler.cs similarity index 94% rename from Python.Runtime/CustomMarshaler.cs rename to Python.Runtime.Native/CustomMarshaler.cs index ec6898c53..775548b0f 100644 --- a/Python.Runtime/CustomMarshaler.cs +++ b/Python.Runtime.Native/CustomMarshaler.cs @@ -3,7 +3,7 @@ using System.Runtime.InteropServices; using System.Text; -namespace Python.Runtime +namespace Python.Runtime.Native { /// /// Abstract class defining boiler plate methods that @@ -11,6 +11,14 @@ namespace Python.Runtime /// internal abstract class MarshalerBase : ICustomMarshaler { + #if UCS2 && PYTHON2 + internal static Encoding PyEncoding = Encoding.Unicode; + internal static int UCS = 2; + #else + internal static Encoding PyEncoding = Encoding.UTF32; + internal static int UCS = 4; + #endif + public object MarshalNativeToManaged(IntPtr pNativeData) { throw new NotImplementedException(); @@ -42,7 +50,6 @@ public int GetNativeDataSize() internal class UcsMarshaler : MarshalerBase { private static readonly MarshalerBase Instance = new UcsMarshaler(); - private static readonly Encoding PyEncoding = Runtime.PyEncoding; public override IntPtr MarshalManagedToNative(object managedObj) { @@ -91,7 +98,7 @@ public static int GetUnicodeByteLength(IntPtr p) var len = 0; while (true) { -#if UCS2 +#if UCS2 && PYTHON2 int c = Marshal.ReadInt16(p, len * 2); #else int c = Marshal.ReadInt32(p, len * 4); @@ -99,7 +106,7 @@ public static int GetUnicodeByteLength(IntPtr p) if (c == 0) { - return len * Runtime._UCS; + return len * UCS; } checked { @@ -157,7 +164,6 @@ public static string PtrToPy3UnicodePy2String(IntPtr p) internal class StrArrayMarshaler : MarshalerBase { private static readonly MarshalerBase Instance = new StrArrayMarshaler(); - private static readonly Encoding PyEncoding = Runtime.PyEncoding; public override IntPtr MarshalManagedToNative(object managedObj) { @@ -169,7 +175,7 @@ public override IntPtr MarshalManagedToNative(object managedObj) } int totalStrLength = argv.Sum(arg => arg.Length + 1); - int memSize = argv.Length * IntPtr.Size + totalStrLength * Runtime._UCS; + int memSize = argv.Length * IntPtr.Size + totalStrLength * UCS; IntPtr mem = Marshal.AllocHGlobal(memSize); try diff --git a/Python.Runtime.Native/ILibPython.cs b/Python.Runtime.Native/ILibPython.cs new file mode 100644 index 000000000..c30febed9 --- /dev/null +++ b/Python.Runtime.Native/ILibPython.cs @@ -0,0 +1,352 @@ +using System; +using System.Runtime.InteropServices; +using System.Security; +using System.Text; +using System.Threading; +using System.Collections.Generic; + +namespace Python.Runtime.Native +{ + public interface ILibPython + { + /// + /// Export of Macro Py_XIncRef. Use XIncref instead. + /// Limit this function usage for Testing and Py_Debug builds + /// + /// PyObject Ptr + void Py_IncRef(IntPtr ob); + + /// + /// Export of Macro Py_XDecRef. Use XDecref instead. + /// Limit this function usage for Testing and Py_Debug builds + /// + /// PyObject Ptr + void Py_DecRef(IntPtr ob); + + void Py_InitializeEx(int initsigs); + int Py_IsInitialized(); + void Py_Finalize(); + + IntPtr PyGILState_Ensure(); + void PyGILState_Release(IntPtr gs); + + + void PyEval_InitThreads(); + int PyEval_ThreadsInitialized(); + + void PyEval_AcquireLock(); + void PyEval_ReleaseLock(); + + IntPtr PyEval_SaveThread(); + void PyEval_RestoreThread(IntPtr tstate); + + IntPtr PyEval_GetBuiltins(); + IntPtr PyEval_GetGlobals(); + IntPtr PyEval_GetLocals(); + + IntPtr Py_GetProgramName(); + void Py_SetProgramName(IntPtr name); + + IntPtr Py_GetPythonHome(); + void Py_SetPythonHome(IntPtr home); + + IntPtr Py_GetPath(); + void Py_SetPath(IntPtr home); + + IntPtr Py_GetVersion(); + IntPtr Py_GetPlatform(); + IntPtr Py_GetCopyright(); + IntPtr Py_GetCompiler(); + IntPtr Py_GetBuildInfo(); + + int PyRun_SimpleString(string code); + IntPtr PyRun_String(string code, IntPtr st, IntPtr globals, IntPtr locals); + IntPtr PyEval_EvalCode(IntPtr co, IntPtr globals, IntPtr locals); + IntPtr Py_CompileString(string code, string file, IntPtr tok); + + IntPtr PyImport_ExecCodeModule(string name, IntPtr code); + + IntPtr PyCFunction_NewEx(IntPtr ml, IntPtr self, IntPtr mod); + IntPtr PyCFunction_Call(IntPtr func, IntPtr args, IntPtr kw); + +#if PYTHON2 + IntPtr PyClass_New(IntPtr bases, IntPtr dict, IntPtr name); +#endif + + IntPtr PyInstance_New(IntPtr cls, IntPtr args, IntPtr kw); + IntPtr PyInstance_NewRaw(IntPtr cls, IntPtr dict); + IntPtr PyMethod_New(IntPtr func, IntPtr self, IntPtr cls); + + //==================================================================== + // Python abstract object API + //==================================================================== + + int PyObject_HasAttrString(IntPtr pointer, string name); + IntPtr PyObject_GetAttrString(IntPtr pointer, string name); + int PyObject_SetAttrString(IntPtr pointer, string name, IntPtr value); + int PyObject_HasAttr(IntPtr pointer, IntPtr name); + IntPtr PyObject_GetAttr(IntPtr pointer, IntPtr name); + int PyObject_SetAttr(IntPtr pointer, IntPtr name, IntPtr value); + IntPtr PyObject_GetItem(IntPtr pointer, IntPtr key); + int PyObject_SetItem(IntPtr pointer, IntPtr key, IntPtr value); + int PyObject_DelItem(IntPtr pointer, IntPtr key); + IntPtr PyObject_GetIter(IntPtr op); + IntPtr PyObject_Call(IntPtr pointer, IntPtr args, IntPtr kw); + IntPtr PyObject_CallObject(IntPtr pointer, IntPtr args); + int PyObject_RichCompareBool(IntPtr value1, IntPtr value2, int opid); + int PyObject_IsInstance(IntPtr ob, IntPtr type); + int PyObject_IsSubclass(IntPtr ob, IntPtr type); + int PyCallable_Check(IntPtr pointer); + int PyObject_IsTrue(IntPtr pointer); + int PyObject_Not(IntPtr pointer); + + IntPtr _PyObject_Size(IntPtr pointer); + IntPtr PyObject_Hash(IntPtr op); + IntPtr PyObject_Repr(IntPtr pointer); + IntPtr PyObject_Str(IntPtr pointer); + IntPtr PyObject_Unicode(IntPtr pointer); + IntPtr PyObject_Dir(IntPtr pointer); + + + //==================================================================== + // Python number API + //==================================================================== + + IntPtr PyNumber_Int(IntPtr ob); + IntPtr PyNumber_Long(IntPtr ob); + IntPtr PyNumber_Float(IntPtr ob); + bool PyNumber_Check(IntPtr ob); + + IntPtr PyInt_FromLong(IntPtr value); + int PyInt_AsLong(IntPtr value); + IntPtr PyInt_FromString(string value, IntPtr end, int radix); + + IntPtr PyLong_FromLong(long value); + IntPtr PyLong_FromUnsignedLong32(uint value); + IntPtr PyLong_FromUnsignedLong64(ulong value); + IntPtr PyLong_FromDouble(double value); + IntPtr PyLong_FromLongLong(long value); + IntPtr PyLong_FromUnsignedLongLong(ulong value); + IntPtr PyLong_FromString(string value, IntPtr end, int radix); + int PyLong_AsLong(IntPtr value); + uint PyLong_AsUnsignedLong32(IntPtr value); + ulong PyLong_AsUnsignedLong64(IntPtr value); + long PyLong_AsLongLong(IntPtr value); + ulong PyLong_AsUnsignedLongLong(IntPtr value); + + IntPtr PyFloat_FromDouble(double value); + IntPtr PyFloat_FromString(IntPtr value, IntPtr junk); + double PyFloat_AsDouble(IntPtr ob); + + IntPtr PyNumber_Add(IntPtr o1, IntPtr o2); + IntPtr PyNumber_Subtract(IntPtr o1, IntPtr o2); + IntPtr PyNumber_Multiply(IntPtr o1, IntPtr o2); + IntPtr PyNumber_TrueDivide(IntPtr o1, IntPtr o2); + IntPtr PyNumber_And(IntPtr o1, IntPtr o2); + IntPtr PyNumber_Xor(IntPtr o1, IntPtr o2); + IntPtr PyNumber_Or(IntPtr o1, IntPtr o2); + IntPtr PyNumber_Lshift(IntPtr o1, IntPtr o2); + IntPtr PyNumber_Rshift(IntPtr o1, IntPtr o2); + IntPtr PyNumber_Power(IntPtr o1, IntPtr o2); + IntPtr PyNumber_Remainder(IntPtr o1, IntPtr o2); + IntPtr PyNumber_InPlaceAdd(IntPtr o1, IntPtr o2); + IntPtr PyNumber_InPlaceSubtract(IntPtr o1, IntPtr o2); + IntPtr PyNumber_InPlaceMultiply(IntPtr o1, IntPtr o2); + IntPtr PyNumber_InPlaceTrueDivide(IntPtr o1, IntPtr o2); + IntPtr PyNumber_InPlaceAnd(IntPtr o1, IntPtr o2); + IntPtr PyNumber_InPlaceXor(IntPtr o1, IntPtr o2); + IntPtr PyNumber_InPlaceOr(IntPtr o1, IntPtr o2); + IntPtr PyNumber_InPlaceLshift(IntPtr o1, IntPtr o2); + IntPtr PyNumber_InPlaceRshift(IntPtr o1, IntPtr o2); + IntPtr PyNumber_InPlacePower(IntPtr o1, IntPtr o2); + IntPtr PyNumber_InPlaceRemainder(IntPtr o1, IntPtr o2); + IntPtr PyNumber_Negative(IntPtr o1); + IntPtr PyNumber_Positive(IntPtr o1); + IntPtr PyNumber_Invert(IntPtr o1); + + + //==================================================================== + // Python sequence API + //==================================================================== + + bool PySequence_Check(IntPtr pointer); + IntPtr PySequence_GetItem(IntPtr pointer, IntPtr index); + int PySequence_SetItem(IntPtr pointer, IntPtr index, IntPtr value); + int PySequence_DelItem(IntPtr pointer, IntPtr index); + IntPtr PySequence_GetSlice(IntPtr pointer, IntPtr i1, IntPtr i2); + int PySequence_SetSlice(IntPtr pointer, IntPtr i1, IntPtr i2, IntPtr v); + int PySequence_DelSlice(IntPtr pointer, IntPtr i1, IntPtr i2); + IntPtr _PySequence_Size(IntPtr pointer); + int PySequence_Contains(IntPtr pointer, IntPtr item); + IntPtr PySequence_Concat(IntPtr pointer, IntPtr other); + IntPtr PySequence_Repeat(IntPtr pointer, IntPtr count); + int PySequence_Index(IntPtr pointer, IntPtr item); + IntPtr _PySequence_Count(IntPtr pointer, IntPtr value); + IntPtr PySequence_Tuple(IntPtr pointer); + IntPtr PySequence_List(IntPtr pointer); + + + //==================================================================== + // Python string API + //==================================================================== + +#if !PYTHON2 + IntPtr PyBytes_FromString(string op); + IntPtr _PyBytes_Size(IntPtr op); + IntPtr _PyString_FromStringAndSize(string value, IntPtr size); + IntPtr PyUnicode_FromStringAndSize(IntPtr value, IntPtr size); +#else + IntPtr PyString_FromStringAndSize(string value, IntPtr size); + IntPtr PyString_AsString(IntPtr op); + int PyString_Size(IntPtr pointer); +#endif + + IntPtr PyUnicode_FromOrdinal(int c); + IntPtr PyUnicode_AsUnicode(IntPtr ob); + IntPtr PyUnicode_FromObject(IntPtr ob); + IntPtr PyUnicode_FromEncodedObject(IntPtr ob, IntPtr enc, IntPtr err); + IntPtr _PyUnicode_GetSize(IntPtr ob); +#if !PYTHON2 + IntPtr PyUnicode_FromKindAndData(int kind, string s, IntPtr size); +#else + IntPtr PyUnicode_FromUnicode(string s, IntPtr size); +#endif + + + //==================================================================== + // Python dictionary API + //==================================================================== + + IntPtr PyDict_New(); + IntPtr PyDictProxy_New(IntPtr dict); + IntPtr PyDict_GetItem(IntPtr pointer, IntPtr key); + IntPtr PyDict_GetItemString(IntPtr pointer, string key); + int PyDict_SetItem(IntPtr pointer, IntPtr key, IntPtr value); + int PyDict_SetItemString(IntPtr pointer, string key, IntPtr value); + int PyDict_DelItem(IntPtr pointer, IntPtr key); + int PyDict_DelItemString(IntPtr pointer, string key); + int PyMapping_HasKey(IntPtr pointer, IntPtr key); + IntPtr PyDict_Keys(IntPtr pointer); + IntPtr PyDict_Values(IntPtr pointer); + IntPtr PyDict_Items(IntPtr pointer); + IntPtr PyDict_Copy(IntPtr pointer); + int PyDict_Update(IntPtr pointer, IntPtr other); + void PyDict_Clear(IntPtr pointer); + IntPtr _PyDict_Size(IntPtr pointer); + + + //==================================================================== + // Python list API + //==================================================================== + + IntPtr PyList_New(IntPtr size); + IntPtr PyList_AsTuple(IntPtr pointer); + IntPtr PyList_GetItem(IntPtr pointer, IntPtr index); + int PyList_SetItem(IntPtr pointer, IntPtr index, IntPtr value); + int PyList_Insert(IntPtr pointer, IntPtr index, IntPtr value); + int PyList_Append(IntPtr pointer, IntPtr value); + int PyList_Reverse(IntPtr pointer); + int PyList_Sort(IntPtr pointer); + IntPtr PyList_GetSlice(IntPtr pointer, IntPtr start, IntPtr end); + int PyList_SetSlice(IntPtr pointer, IntPtr start, IntPtr end, IntPtr value); + IntPtr _PyList_Size(IntPtr pointer); + + //==================================================================== + // Python tuple API + //==================================================================== + + IntPtr PyTuple_New(IntPtr size); + IntPtr PyTuple_GetItem(IntPtr pointer, IntPtr index); + int PyTuple_SetItem(IntPtr pointer, IntPtr index, IntPtr value); + IntPtr PyTuple_GetSlice(IntPtr pointer, IntPtr start, IntPtr end); + IntPtr _PyTuple_Size(IntPtr pointer); + + + //==================================================================== + // Python iterator API + //==================================================================== + + IntPtr PyIter_Next(IntPtr pointer); + + //==================================================================== + // Python module API + //==================================================================== + + IntPtr PyModule_New(string name); + string PyModule_GetName(IntPtr module); + IntPtr PyModule_GetDict(IntPtr module); + string PyModule_GetFilename(IntPtr module); +#if !PYTHON2 + IntPtr PyModule_Create2(IntPtr module, int apiver); +#endif + + IntPtr PyImport_Import(IntPtr name); + IntPtr PyImport_ImportModule(string name); + IntPtr PyImport_ReloadModule(IntPtr module); + IntPtr PyImport_AddModule(string name); + IntPtr PyImport_GetModuleDict(); + + void PySys_SetArgvEx(int argc, string[] argv, int updatepath); + IntPtr PySys_GetObject(string name); + int PySys_SetObject(string name, IntPtr ob); + + + //==================================================================== + // Python type object API + //==================================================================== + + void PyType_Modified(IntPtr type); + bool PyType_IsSubtype(IntPtr t1, IntPtr t2); + IntPtr PyType_GenericNew(IntPtr type, IntPtr args, IntPtr kw); + IntPtr PyType_GenericAlloc(IntPtr type, IntPtr n); + int PyType_Ready(IntPtr type); + IntPtr _PyType_Lookup(IntPtr type, IntPtr name); + + IntPtr PyObject_GenericGetAttr(IntPtr obj, IntPtr name); + int PyObject_GenericSetAttr(IntPtr obj, IntPtr name, IntPtr value); + IntPtr _PyObject_GetDictPtr(IntPtr obj); + IntPtr PyObject_GC_New(IntPtr tp); + void PyObject_GC_Del(IntPtr tp); + void PyObject_GC_Track(IntPtr tp); + void PyObject_GC_UnTrack(IntPtr tp); + + + //==================================================================== + // Python memory API + //==================================================================== + + IntPtr PyMem_Malloc(IntPtr size); + IntPtr PyMem_Realloc(IntPtr ptr, IntPtr size); + void PyMem_Free(IntPtr ptr); + + + //==================================================================== + // Python exception API + //==================================================================== + + void PyErr_SetString(IntPtr ob, string message); + void PyErr_SetObject(IntPtr ob, IntPtr message); + IntPtr PyErr_SetFromErrno(IntPtr ob); + void PyErr_SetNone(IntPtr ob); + int PyErr_ExceptionMatches(IntPtr exception); + int PyErr_GivenExceptionMatches(IntPtr ob, IntPtr val); + void PyErr_NormalizeException(IntPtr ob, IntPtr val, IntPtr tb); + IntPtr PyErr_Occurred(); + void PyErr_Fetch(ref IntPtr ob, ref IntPtr val, ref IntPtr tb); + void PyErr_Restore(IntPtr ob, IntPtr val, IntPtr tb); + void PyErr_Clear(); + void PyErr_Print(); + + + //==================================================================== + // Miscellaneous + //==================================================================== + + IntPtr PyMethod_Self(IntPtr ob); + IntPtr PyMethod_Function(IntPtr ob); + int Py_AddPendingCall(IntPtr func, IntPtr arg); + int Py_MakePendingCalls(); + + int Py_NoSiteFlag { get; set; } + } +} diff --git a/Python.Runtime.Native/LibPythonPInvoke.cs.dontcompile b/Python.Runtime.Native/LibPythonPInvoke.cs.dontcompile new file mode 100644 index 000000000..27c2a225e --- /dev/null +++ b/Python.Runtime.Native/LibPythonPInvoke.cs.dontcompile @@ -0,0 +1,1692 @@ +using System; +using System.Runtime.InteropServices; +using System.Security; +using System.Text; +using System.Threading; +using System.Collections.Generic; + +namespace Python.Runtime.Native +{ + public class LibPythonPInvoke : ILibPython + { + // 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 int UCS => _UCS; + +#if UCS2 + internal const int _UCS = 4; + + /// + /// EntryPoint to be used in DllImport to map to correct Unicode + /// methods prior to PEP393. Only used for PY27. + /// + private const string PyUnicodeEntryPoint = "PyUnicodeUCS4_"; +#else + internal const int _UCS = 2; + + /// + /// EntryPoint to be used in DllImport to map to correct Unicode + /// methods prior to PEP393. Only used for PY27. + /// + private const string PyUnicodeEntryPoint = "PyUnicodeUCS2_"; +#endif + + internal const string _PythonDll = "__Internal"; + + // set to true when python is finalizing + internal static object IsFinalizingLock = new object(); + internal static bool IsFinalizing; + + internal static bool Is32Bit = IntPtr.Size == 4; + + // .NET core: System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Windows) + internal static bool IsWindows = Environment.OSVersion.Platform == PlatformID.Win32NT; + + public static int MainManagedThreadId { get; private set; } + + /// + /// Encoding to use to convert Unicode to/from Managed to Native + /// + internal static readonly Encoding PyEncoding = _UCS == 2 ? Encoding.Unicode : Encoding.UTF32; + + /// + /// Initialize the runtime... + /// + internal static void Initialize(bool initSigs = false) + { + if (Py_IsInitialized() == 0) + { + Py_InitializeEx(initSigs ? 1 : 0); + MainManagedThreadId = Thread.CurrentThread.ManagedThreadId; + } + + if (PyEval_ThreadsInitialized() == 0) + { + PyEval_InitThreads(); + } + + IsFinalizing = false; + + CLRModule.Reset(); + GenericUtil.Reset(); + PyScopeManager.Reset(); + ClassManager.Reset(); + ClassDerivedObject.Reset(); + TypeManager.Reset(); + + IntPtr op; + IntPtr dict; + if (IsPython3) + { + op = PyImport_ImportModule("builtins"); + dict = PyObject_GetAttrString(op, "__dict__"); + } + else // Python2 + { + dict = PyImport_GetModuleDict(); + op = PyDict_GetItemString(dict, "__builtin__"); + } + PyNotImplemented = PyObject_GetAttrString(op, "NotImplemented"); + PyBaseObjectType = PyObject_GetAttrString(op, "object"); + + PyNone = PyObject_GetAttrString(op, "None"); + PyTrue = PyObject_GetAttrString(op, "True"); + PyFalse = PyObject_GetAttrString(op, "False"); + + PyBoolType = PyObject_Type(PyTrue); + PyNoneType = PyObject_Type(PyNone); + PyTypeType = PyObject_Type(PyNoneType); + + op = PyObject_GetAttrString(dict, "keys"); + PyMethodType = PyObject_Type(op); + XDecref(op); + + // For some arcane reason, builtins.__dict__.__setitem__ is *not* + // a wrapper_descriptor, even though dict.__setitem__ is. + // + // object.__init__ seems safe, though. + op = PyObject_GetAttrString(PyBaseObjectType, "__init__"); + PyWrapperDescriptorType = PyObject_Type(op); + XDecref(op); + +#if !PYTHON2 + XDecref(dict); +#endif + + op = PyString_FromString("string"); + PyStringType = PyObject_Type(op); + XDecref(op); + + op = PyUnicode_FromString("unicode"); + PyUnicodeType = PyObject_Type(op); + XDecref(op); + +#if !PYTHON2 + op = PyBytes_FromString("bytes"); + PyBytesType = PyObject_Type(op); + XDecref(op); +#endif + + op = PyTuple_New(0); + PyTupleType = PyObject_Type(op); + XDecref(op); + + op = PyList_New(0); + PyListType = PyObject_Type(op); + XDecref(op); + + op = PyDict_New(); + PyDictType = PyObject_Type(op); + XDecref(op); + + op = PyInt_FromInt32(0); + PyIntType = PyObject_Type(op); + XDecref(op); + + op = PyLong_FromLong(0); + PyLongType = PyObject_Type(op); + XDecref(op); + + op = PyFloat_FromDouble(0); + PyFloatType = PyObject_Type(op); + XDecref(op); + + PyClassType = IntPtr.Zero; + PyInstanceType = IntPtr.Zero; + +#if PYTHON2 + IntPtr s = PyString_FromString("_temp"); + IntPtr d = PyDict_New(); + + IntPtr c = PyClass_New(IntPtr.Zero, d, s); + PyClassType = PyObject_Type(c); + + IntPtr i = PyInstance_New(c, IntPtr.Zero, IntPtr.Zero); + PyInstanceType = PyObject_Type(i); + + XDecref(s); + XDecref(i); + XDecref(c); + XDecref(d); +#endif + + Error = new IntPtr(-1); + + // Initialize data about the platform we're running on. We need + // this for the type manager and potentially other details. Must + // happen after caching the python types, above. + InitializePlatformData(); + + IntPtr dllLocal = IntPtr.Zero; + var loader = LibraryLoader.Get(OperatingSystem); + + if (_PythonDll != "__Internal") + { + dllLocal = loader.Load(_PythonDll); + } + _PyObject_NextNotImplemented = loader.GetFunction(dllLocal, "_PyObject_NextNotImplemented"); + PyModuleType = loader.GetFunction(dllLocal, "PyModule_Type"); + + if (dllLocal != IntPtr.Zero) + { + loader.Free(dllLocal); + } + + // Initialize modules that depend on the runtime class. + AssemblyManager.Initialize(); + PyCLRMetaType = MetaType.Initialize(); + Exceptions.Initialize(); + ImportHook.Initialize(); + + // Need to add the runtime directory to sys.path so that we + // can find built-in assemblies like System.Data, et. al. + string rtdir = RuntimeEnvironment.GetRuntimeDirectory(); + IntPtr path = PySys_GetObject("path"); + IntPtr item = PyString_FromString(rtdir); + PyList_Append(path, item); + XDecref(item); + AssemblyManager.UpdatePath(); + } + + /// + /// Initializes the data about platforms. + /// + /// This must be the last step when initializing the runtime: + /// GetManagedString needs to have the cached values for types. + /// But it must run before initializing anything outside the runtime + /// because those rely on the platform data. + /// + private static void InitializePlatformData() + { + IntPtr op; + IntPtr fn; + IntPtr platformModule = PyImport_ImportModule("platform"); + IntPtr emptyTuple = PyTuple_New(0); + + fn = PyObject_GetAttrString(platformModule, "system"); + op = PyObject_Call(fn, emptyTuple, IntPtr.Zero); + OperatingSystemName = GetManagedString(op); + XDecref(op); + XDecref(fn); + + fn = PyObject_GetAttrString(platformModule, "machine"); + op = PyObject_Call(fn, emptyTuple, IntPtr.Zero); + MachineName = GetManagedString(op); + XDecref(op); + XDecref(fn); + + XDecref(emptyTuple); + XDecref(platformModule); + + // Now convert the strings into enum values so we can do switch + // statements rather than constant parsing. + OperatingSystemType OSType; + if (!OperatingSystemTypeMapping.TryGetValue(OperatingSystemName, out OSType)) + { + OSType = OperatingSystemType.Other; + } + OperatingSystem = OSType; + + MachineType MType; + if (!MachineTypeMapping.TryGetValue(MachineName.ToLower(), out MType)) + { + MType = MachineType.Other; + } + Machine = MType; + } + + internal static void Shutdown() + { + AssemblyManager.Shutdown(); + Exceptions.Shutdown(); + ImportHook.Shutdown(); + Finalizer.Shutdown(); + Py_Finalize(); + } + + // called *without* the GIL acquired by clr._AtExit + internal static int AtExit() + { + lock (IsFinalizingLock) + { + IsFinalizing = true; + } + return 0; + } + + internal static IntPtr Py_single_input = (IntPtr)256; + internal static IntPtr Py_file_input = (IntPtr)257; + internal static IntPtr Py_eval_input = (IntPtr)258; + + internal static IntPtr PyBaseObjectType; + internal static IntPtr PyModuleType; + internal static IntPtr PyClassType; + internal static IntPtr PyInstanceType; + internal static IntPtr PyCLRMetaType; + internal static IntPtr PyMethodType; + internal static IntPtr PyWrapperDescriptorType; + + internal static IntPtr PyUnicodeType; + internal static IntPtr PyStringType; + internal static IntPtr PyTupleType; + internal static IntPtr PyListType; + internal static IntPtr PyDictType; + internal static IntPtr PyIntType; + internal static IntPtr PyLongType; + internal static IntPtr PyFloatType; + internal static IntPtr PyBoolType; + internal static IntPtr PyNoneType; + internal static IntPtr PyTypeType; + + internal static IntPtr Py_NoSiteFlag; + + internal static IntPtr PyBytesType; + internal static IntPtr _PyObject_NextNotImplemented; + + internal static IntPtr PyNotImplemented; + internal const int Py_LT = 0; + internal const int Py_LE = 1; + internal const int Py_EQ = 2; + internal const int Py_NE = 3; + internal const int Py_GT = 4; + internal const int Py_GE = 5; + + internal static IntPtr PyTrue; + internal static IntPtr PyFalse; + internal static IntPtr PyNone; + internal static IntPtr Error; + + /// + /// Check if any Python Exceptions occurred. + /// If any exist throw new PythonException. + /// + /// + /// Can be used instead of `obj == IntPtr.Zero` for example. + /// + internal static void CheckExceptionOccurred() + { + if (PyErr_Occurred() != IntPtr.Zero) + { + throw new PythonException(); + } + } + + internal static IntPtr ExtendTuple(IntPtr t, params IntPtr[] args) + { + var size = PyTuple_Size(t); + int add = args.Length; + IntPtr item; + + IntPtr items = PyTuple_New(size + add); + for (var i = 0; i < size; i++) + { + item = PyTuple_GetItem(t, i); + XIncref(item); + PyTuple_SetItem(items, i, item); + } + + for (var n = 0; n < add; n++) + { + item = args[n]; + XIncref(item); + PyTuple_SetItem(items, size + n, item); + } + + return items; + } + + internal static Type[] PythonArgsToTypeArray(IntPtr arg) + { + return PythonArgsToTypeArray(arg, false); + } + + internal static Type[] PythonArgsToTypeArray(IntPtr arg, bool mangleObjects) + { + // Given a PyObject * that is either a single type object or a + // tuple of (managed or unmanaged) type objects, return a Type[] + // containing the CLR Type objects that map to those types. + IntPtr args = arg; + var free = false; + + if (!PyTuple_Check(arg)) + { + args = PyTuple_New(1); + XIncref(arg); + PyTuple_SetItem(args, 0, arg); + free = true; + } + + var n = PyTuple_Size(args); + var types = new Type[n]; + Type t = null; + + for (var i = 0; i < n; i++) + { + IntPtr op = PyTuple_GetItem(args, i); + if (mangleObjects && (!PyType_Check(op))) + { + op = PyObject_TYPE(op); + } + ManagedType mt = ManagedType.GetManagedObject(op); + + if (mt is ClassBase) + { + t = ((ClassBase)mt).type; + } + else if (mt is CLRObject) + { + object inst = ((CLRObject)mt).inst; + if (inst is Type) + { + t = inst as Type; + } + } + else + { + t = Converter.GetTypeByAlias(op); + } + + if (t == null) + { + types = null; + break; + } + types[i] = t; + } + if (free) + { + XDecref(args); + } + return types; + } + + /// + /// Managed exports of the Python C API. Where appropriate, we do + /// some optimization to avoid managed <--> unmanaged transitions + /// (mostly for heavily used methods). + /// + internal static unsafe void XIncref(IntPtr op) + { + Py_IncRef(op); + return; + } + + internal static unsafe void XDecref(IntPtr op) + { + Py_DecRef(op); + return; + } + + internal static unsafe long Refcount(IntPtr op) + { + var p = (void*)op; + if ((void*)0 == p) + { + return 0; + } + return Is32Bit ? (*(int*)p) : (*(long*)p); + } + + /// + /// Export of Macro Py_XIncRef. Use XIncref instead. + /// Limit this function usage for Testing and Py_Debug builds + /// + /// PyObject Ptr + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void Py_IncRef(IntPtr ob); + + /// + /// Export of Macro Py_XDecRef. Use XDecref instead. + /// Limit this function usage for Testing and Py_Debug builds + /// + /// PyObject Ptr + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void Py_DecRef(IntPtr ob); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void Py_Initialize(); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void Py_InitializeEx(int initsigs); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int Py_IsInitialized(); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void Py_Finalize(); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr Py_NewInterpreter(); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void Py_EndInterpreter(IntPtr threadState); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyThreadState_New(IntPtr istate); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyThreadState_Get(); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyThread_get_key_value(IntPtr key); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyThread_get_thread_ident(); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyThread_set_key_value(IntPtr key, IntPtr value); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyThreadState_Swap(IntPtr key); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyGILState_Ensure(); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void PyGILState_Release(IntPtr gs); + + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyGILState_GetThisThreadState(); + +#if !PYTHON2 + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + public static extern int Py_Main( + int argc, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StrArrayMarshaler))] string[] argv + ); +#else + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + public static extern int Py_Main(int argc, string[] argv); +#endif + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void PyEval_InitThreads(); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyEval_ThreadsInitialized(); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void PyEval_AcquireLock(); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void PyEval_ReleaseLock(); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void PyEval_AcquireThread(IntPtr tstate); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void PyEval_ReleaseThread(IntPtr tstate); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyEval_SaveThread(); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void PyEval_RestoreThread(IntPtr tstate); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyEval_GetBuiltins(); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyEval_GetGlobals(); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyEval_GetLocals(); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr Py_GetProgramName(); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void Py_SetProgramName(IntPtr name); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr Py_GetPythonHome(); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void Py_SetPythonHome(IntPtr home); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr Py_GetPath(); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void Py_SetPath(IntPtr home); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr Py_GetVersion(); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr Py_GetPlatform(); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr Py_GetCopyright(); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr Py_GetCompiler(); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr Py_GetBuildInfo(); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyRun_SimpleString(string code); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyRun_String(string code, IntPtr st, IntPtr globals, IntPtr locals); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyEval_EvalCode(IntPtr co, IntPtr globals, IntPtr locals); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr Py_CompileString(string code, string file, IntPtr tok); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyImport_ExecCodeModule(string name, IntPtr code); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyCFunction_NewEx(IntPtr ml, IntPtr self, IntPtr mod); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyCFunction_Call(IntPtr func, IntPtr args, IntPtr kw); + +#if PYTHON2 + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyClass_New(IntPtr bases, IntPtr dict, IntPtr name); +#endif + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyInstance_New(IntPtr cls, IntPtr args, IntPtr kw); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyInstance_NewRaw(IntPtr cls, IntPtr dict); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyMethod_New(IntPtr func, IntPtr self, IntPtr cls); + + + //==================================================================== + // Python abstract object API + //==================================================================== + + /// + /// A macro-like method to get the type of a Python object. This is + /// designed to be lean and mean in IL & avoid managed <-> unmanaged + /// transitions. Note that this does not incref the type object. + /// + internal static unsafe IntPtr PyObject_TYPE(IntPtr op) + { + var p = (void*)op; + if ((void*)0 == p) + { + return IntPtr.Zero; + } +#if PYTHON_WITH_PYDEBUG + var n = 3; +#else + var n = 1; +#endif + return Is32Bit + ? new IntPtr((void*)(*((uint*)p + n))) + : new IntPtr((void*)(*((ulong*)p + n))); + } + + /// + /// Managed version of the standard Python C API PyObject_Type call. + /// This version avoids a managed <-> unmanaged transition. + /// This one does incref the returned type object. + /// + internal static IntPtr PyObject_Type(IntPtr op) + { + IntPtr tp = PyObject_TYPE(op); + XIncref(tp); + return tp; + } + + internal static string PyObject_GetTypeName(IntPtr op) + { + IntPtr pyType = Marshal.ReadIntPtr(op, ObjectOffset.ob_type); + IntPtr ppName = Marshal.ReadIntPtr(pyType, TypeOffset.tp_name); + return Marshal.PtrToStringAnsi(ppName); + } + + /// + /// Test whether the Python object is an iterable. + /// + internal static bool PyObject_IsIterable(IntPtr pointer) + { + var ob_type = Marshal.ReadIntPtr(pointer, ObjectOffset.ob_type); +#if PYTHON2 + long tp_flags = Util.ReadCLong(ob_type, TypeOffset.tp_flags); + if ((tp_flags & TypeFlags.HaveIter) == 0) + return false; +#endif + IntPtr tp_iter = Marshal.ReadIntPtr(ob_type, TypeOffset.tp_iter); + return tp_iter != IntPtr.Zero; + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyObject_HasAttrString(IntPtr pointer, string name); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyObject_GetAttrString(IntPtr pointer, string name); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyObject_SetAttrString(IntPtr pointer, string name, IntPtr value); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyObject_HasAttr(IntPtr pointer, IntPtr name); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyObject_GetAttr(IntPtr pointer, IntPtr name); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyObject_SetAttr(IntPtr pointer, IntPtr name, IntPtr value); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyObject_GetItem(IntPtr pointer, IntPtr key); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyObject_SetItem(IntPtr pointer, IntPtr key, IntPtr value); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyObject_DelItem(IntPtr pointer, IntPtr key); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyObject_GetIter(IntPtr op); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyObject_Call(IntPtr pointer, IntPtr args, IntPtr kw); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyObject_CallObject(IntPtr pointer, IntPtr args); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyObject_RichCompareBool(IntPtr value1, IntPtr value2, int opid); + + internal static int PyObject_Compare(IntPtr value1, IntPtr value2) + { + int res; + res = PyObject_RichCompareBool(value1, value2, Py_LT); + if (-1 == res) + return -1; + else if (1 == res) + return -1; + + res = PyObject_RichCompareBool(value1, value2, Py_EQ); + if (-1 == res) + return -1; + else if (1 == res) + return 0; + + res = PyObject_RichCompareBool(value1, value2, Py_GT); + if (-1 == res) + return -1; + else if (1 == res) + return 1; + + Exceptions.SetError(Exceptions.SystemError, "Error comparing objects"); + return -1; + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyObject_IsInstance(IntPtr ob, IntPtr type); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyObject_IsSubclass(IntPtr ob, IntPtr type); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyCallable_Check(IntPtr pointer); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyObject_IsTrue(IntPtr pointer); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyObject_Not(IntPtr pointer); + + internal static long PyObject_Size(IntPtr pointer) + { + return (long) _PyObject_Size(pointer); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PyObject_Size")] + private static extern IntPtr _PyObject_Size(IntPtr pointer); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyObject_Hash(IntPtr op); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyObject_Repr(IntPtr pointer); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyObject_Str(IntPtr pointer); + +#if !PYTHON2 + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, + EntryPoint = "PyObject_Str")] + internal static extern IntPtr PyObject_Unicode(IntPtr pointer); +#else + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyObject_Unicode(IntPtr pointer); +#endif + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyObject_Dir(IntPtr pointer); + + + //==================================================================== + // Python number API + //==================================================================== + +#if !PYTHON2 + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, + EntryPoint = "PyNumber_Long")] + internal static extern IntPtr PyNumber_Int(IntPtr ob); +#else + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyNumber_Int(IntPtr ob); +#endif + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyNumber_Long(IntPtr ob); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyNumber_Float(IntPtr ob); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern bool PyNumber_Check(IntPtr ob); + + internal static bool PyInt_Check(IntPtr ob) + { + return PyObject_TypeCheck(ob, PyIntType); + } + + internal static bool PyBool_Check(IntPtr ob) + { + return PyObject_TypeCheck(ob, PyBoolType); + } + + internal static IntPtr PyInt_FromInt32(int value) + { + var v = new IntPtr(value); + return PyInt_FromLong(v); + } + + internal static IntPtr PyInt_FromInt64(long value) + { + var v = new IntPtr(value); + return PyInt_FromLong(v); + } + +#if !PYTHON2 + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, + EntryPoint = "PyLong_FromLong")] + private static extern IntPtr PyInt_FromLong(IntPtr value); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, + EntryPoint = "PyLong_AsLong")] + internal static extern int PyInt_AsLong(IntPtr value); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, + EntryPoint = "PyLong_FromString")] + internal static extern IntPtr PyInt_FromString(string value, IntPtr end, int radix); +#else + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr PyInt_FromLong(IntPtr value); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyInt_AsLong(IntPtr value); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyInt_FromString(string value, IntPtr end, int radix); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyInt_GetMax(); +#endif + + internal static bool PyLong_Check(IntPtr ob) + { + return PyObject_TYPE(ob) == PyLongType; + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyLong_FromLong(long value); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, + EntryPoint = "PyLong_FromUnsignedLong")] + internal static extern IntPtr PyLong_FromUnsignedLong32(uint value); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, + EntryPoint = "PyLong_FromUnsignedLong")] + internal static extern IntPtr PyLong_FromUnsignedLong64(ulong value); + + internal static IntPtr PyLong_FromUnsignedLong(object value) + { + if(Is32Bit || IsWindows) + return PyLong_FromUnsignedLong32(Convert.ToUInt32(value)); + else + return PyLong_FromUnsignedLong64(Convert.ToUInt64(value)); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyLong_FromDouble(double value); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyLong_FromLongLong(long value); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyLong_FromUnsignedLongLong(ulong value); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyLong_FromString(string value, IntPtr end, int radix); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyLong_AsLong(IntPtr value); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, + EntryPoint = "PyLong_AsUnsignedLong")] + internal static extern uint PyLong_AsUnsignedLong32(IntPtr value); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, + EntryPoint = "PyLong_AsUnsignedLong")] + internal static extern ulong PyLong_AsUnsignedLong64(IntPtr value); + + internal static object PyLong_AsUnsignedLong(IntPtr value) + { + if (Is32Bit || IsWindows) + return PyLong_AsUnsignedLong32(value); + else + return PyLong_AsUnsignedLong64(value); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern long PyLong_AsLongLong(IntPtr value); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern ulong PyLong_AsUnsignedLongLong(IntPtr value); + + internal static bool PyFloat_Check(IntPtr ob) + { + return PyObject_TYPE(ob) == PyFloatType; + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyFloat_FromDouble(double value); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyFloat_FromString(IntPtr value, IntPtr junk); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern double PyFloat_AsDouble(IntPtr ob); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyNumber_Add(IntPtr o1, IntPtr o2); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyNumber_Subtract(IntPtr o1, IntPtr o2); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyNumber_Multiply(IntPtr o1, IntPtr o2); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyNumber_TrueDivide(IntPtr o1, IntPtr o2); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyNumber_And(IntPtr o1, IntPtr o2); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyNumber_Xor(IntPtr o1, IntPtr o2); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyNumber_Or(IntPtr o1, IntPtr o2); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyNumber_Lshift(IntPtr o1, IntPtr o2); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyNumber_Rshift(IntPtr o1, IntPtr o2); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyNumber_Power(IntPtr o1, IntPtr o2); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyNumber_Remainder(IntPtr o1, IntPtr o2); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyNumber_InPlaceAdd(IntPtr o1, IntPtr o2); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyNumber_InPlaceSubtract(IntPtr o1, IntPtr o2); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyNumber_InPlaceMultiply(IntPtr o1, IntPtr o2); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyNumber_InPlaceTrueDivide(IntPtr o1, IntPtr o2); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyNumber_InPlaceAnd(IntPtr o1, IntPtr o2); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyNumber_InPlaceXor(IntPtr o1, IntPtr o2); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyNumber_InPlaceOr(IntPtr o1, IntPtr o2); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyNumber_InPlaceLshift(IntPtr o1, IntPtr o2); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyNumber_InPlaceRshift(IntPtr o1, IntPtr o2); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyNumber_InPlacePower(IntPtr o1, IntPtr o2); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyNumber_InPlaceRemainder(IntPtr o1, IntPtr o2); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyNumber_Negative(IntPtr o1); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyNumber_Positive(IntPtr o1); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyNumber_Invert(IntPtr o1); + + + //==================================================================== + // Python sequence API + //==================================================================== + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern bool PySequence_Check(IntPtr pointer); + + internal static IntPtr PySequence_GetItem(IntPtr pointer, long index) + { + return PySequence_GetItem(pointer, new IntPtr(index)); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr PySequence_GetItem(IntPtr pointer, IntPtr index); + + internal static int PySequence_SetItem(IntPtr pointer, long index, IntPtr value) + { + return PySequence_SetItem(pointer, new IntPtr(index), value); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + private static extern int PySequence_SetItem(IntPtr pointer, IntPtr index, IntPtr value); + + internal static int PySequence_DelItem(IntPtr pointer, long index) + { + return PySequence_DelItem(pointer, new IntPtr(index)); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + private static extern int PySequence_DelItem(IntPtr pointer, IntPtr index); + + internal static IntPtr PySequence_GetSlice(IntPtr pointer, long i1, long i2) + { + return PySequence_GetSlice(pointer, new IntPtr(i1), new IntPtr(i2)); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr PySequence_GetSlice(IntPtr pointer, IntPtr i1, IntPtr i2); + + internal static int PySequence_SetSlice(IntPtr pointer, long i1, long i2, IntPtr v) + { + return PySequence_SetSlice(pointer, new IntPtr(i1), new IntPtr(i2), v); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + private static extern int PySequence_SetSlice(IntPtr pointer, IntPtr i1, IntPtr i2, IntPtr v); + + internal static int PySequence_DelSlice(IntPtr pointer, long i1, long i2) + { + return PySequence_DelSlice(pointer, new IntPtr(i1), new IntPtr(i2)); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + private static extern int PySequence_DelSlice(IntPtr pointer, IntPtr i1, IntPtr i2); + + internal static long PySequence_Size(IntPtr pointer) + { + return (long) _PySequence_Size(pointer); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PySequence_Size")] + private static extern IntPtr _PySequence_Size(IntPtr pointer); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PySequence_Contains(IntPtr pointer, IntPtr item); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PySequence_Concat(IntPtr pointer, IntPtr other); + + internal static IntPtr PySequence_Repeat(IntPtr pointer, long count) + { + return PySequence_Repeat(pointer, new IntPtr(count)); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr PySequence_Repeat(IntPtr pointer, IntPtr count); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PySequence_Index(IntPtr pointer, IntPtr item); + + internal static long PySequence_Count(IntPtr pointer, IntPtr value) + { + return (long) _PySequence_Count(pointer, value); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PySequence_Count")] + private static extern IntPtr _PySequence_Count(IntPtr pointer, IntPtr value); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PySequence_Tuple(IntPtr pointer); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PySequence_List(IntPtr pointer); + + + //==================================================================== + // Python string API + //==================================================================== + + internal static bool IsStringType(IntPtr op) + { + IntPtr t = PyObject_TYPE(op); + return (t == PyStringType) || (t == PyUnicodeType); + } + + internal static bool PyString_Check(IntPtr ob) + { + return PyObject_TYPE(ob) == PyStringType; + } + + internal static IntPtr PyString_FromString(string value) + { +#if !PYTHON2 + return PyUnicode_FromKindAndData(_UCS, value, value.Length); +#else + return PyString_FromStringAndSize(value, value.Length); +#endif + } + +#if !PYTHON2 + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyBytes_FromString(string op); + + internal static long PyBytes_Size(IntPtr op) + { + return (long) _PyBytes_Size(op); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PyBytes_Size")] + private static extern IntPtr _PyBytes_Size(IntPtr op); + + internal static IntPtr PyBytes_AS_STRING(IntPtr ob) + { + return ob + BytesOffset.ob_sval; + } + + internal static IntPtr PyString_FromStringAndSize(string value, long size) + { + return _PyString_FromStringAndSize(value, new IntPtr(size)); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, + EntryPoint = "PyUnicode_FromStringAndSize")] + internal static extern IntPtr _PyString_FromStringAndSize( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string value, + IntPtr size + ); + + internal static IntPtr PyUnicode_FromStringAndSize(IntPtr value, long size) + { + return PyUnicode_FromStringAndSize(value, new IntPtr(size)); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr PyUnicode_FromStringAndSize(IntPtr value, IntPtr size); +#else + internal static IntPtr PyString_FromStringAndSize(string value, long size) + { + return PyString_FromStringAndSize(value, new IntPtr(size)); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr PyString_FromStringAndSize(string value, IntPtr size); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyString_AsString(IntPtr op); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyString_Size(IntPtr pointer); +#endif + +#if !PYTHON2 + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyUnicode_FromObject(IntPtr ob); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyUnicode_FromEncodedObject(IntPtr ob, IntPtr enc, IntPtr err); + + internal static IntPtr PyUnicode_FromKindAndData(int kind, string s, long size) + { + return PyUnicode_FromKindAndData(kind, s, new IntPtr(size)); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr PyUnicode_FromKindAndData( + int kind, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UcsMarshaler))] string s, + IntPtr size + ); + + internal static IntPtr PyUnicode_FromUnicode(string s, long size) + { + return PyUnicode_FromKindAndData(_UCS, s, size); + } + + internal static long PyUnicode_GetSize(IntPtr ob) + { + return (long)_PyUnicode_GetSize(ob); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PyUnicode_GetSize")] + private static extern IntPtr _PyUnicode_GetSize(IntPtr ob); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyUnicode_AsUnicode(IntPtr ob); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyUnicode_FromOrdinal(int c); +#else + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, + EntryPoint = PyUnicodeEntryPoint + "FromObject")] + internal static extern IntPtr PyUnicode_FromObject(IntPtr ob); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, + EntryPoint = PyUnicodeEntryPoint + "FromEncodedObject")] + internal static extern IntPtr PyUnicode_FromEncodedObject(IntPtr ob, IntPtr enc, IntPtr err); + + internal static IntPtr PyUnicode_FromUnicode(string s, long size) + { + return PyUnicode_FromUnicode(s, new IntPtr(size)); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, + EntryPoint = PyUnicodeEntryPoint + "FromUnicode")] + private static extern IntPtr PyUnicode_FromUnicode( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UcsMarshaler))] string s, + IntPtr size + ); + + internal static long PyUnicode_GetSize(IntPtr ob) + { + return (long) _PyUnicode_GetSize(ob); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, + EntryPoint = PyUnicodeEntryPoint + "GetSize")] + internal static extern IntPtr _PyUnicode_GetSize(IntPtr ob); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, + EntryPoint = PyUnicodeEntryPoint + "AsUnicode")] + internal static extern IntPtr PyUnicode_AsUnicode(IntPtr ob); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, + EntryPoint = PyUnicodeEntryPoint + "FromOrdinal")] + internal static extern IntPtr PyUnicode_FromOrdinal(int c); +#endif + + internal static IntPtr PyUnicode_FromString(string s) + { + return PyUnicode_FromUnicode(s, s.Length); + } + + //==================================================================== + // Python dictionary API + //==================================================================== + + internal static bool PyDict_Check(IntPtr ob) + { + return PyObject_TYPE(ob) == PyDictType; + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyDict_New(); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyDictProxy_New(IntPtr dict); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyDict_GetItem(IntPtr pointer, IntPtr key); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyDict_GetItemString(IntPtr pointer, string key); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyDict_SetItem(IntPtr pointer, IntPtr key, IntPtr value); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyDict_SetItemString(IntPtr pointer, string key, IntPtr value); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyDict_DelItem(IntPtr pointer, IntPtr key); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyDict_DelItemString(IntPtr pointer, string key); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyMapping_HasKey(IntPtr pointer, IntPtr key); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyDict_Keys(IntPtr pointer); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyDict_Values(IntPtr pointer); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyDict_Items(IntPtr pointer); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyDict_Copy(IntPtr pointer); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyDict_Update(IntPtr pointer, IntPtr other); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void PyDict_Clear(IntPtr pointer); + + internal static long PyDict_Size(IntPtr pointer) + { + return (long) _PyDict_Size(pointer); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PyDict_Size")] + internal static extern IntPtr _PyDict_Size(IntPtr pointer); + + + //==================================================================== + // Python list API + //==================================================================== + + internal static bool PyList_Check(IntPtr ob) + { + return PyObject_TYPE(ob) == PyListType; + } + + internal static IntPtr PyList_New(long size) + { + return PyList_New(new IntPtr(size)); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr PyList_New(IntPtr size); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyList_AsTuple(IntPtr pointer); + + internal static IntPtr PyList_GetItem(IntPtr pointer, long index) + { + return PyList_GetItem(pointer, new IntPtr(index)); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr PyList_GetItem(IntPtr pointer, IntPtr index); + + internal static int PyList_SetItem(IntPtr pointer, long index, IntPtr value) + { + return PyList_SetItem(pointer, new IntPtr(index), value); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + private static extern int PyList_SetItem(IntPtr pointer, IntPtr index, IntPtr value); + + internal static int PyList_Insert(IntPtr pointer, long index, IntPtr value) + { + return PyList_Insert(pointer, new IntPtr(index), value); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + private static extern int PyList_Insert(IntPtr pointer, IntPtr index, IntPtr value); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyList_Append(IntPtr pointer, IntPtr value); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyList_Reverse(IntPtr pointer); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyList_Sort(IntPtr pointer); + + internal static IntPtr PyList_GetSlice(IntPtr pointer, long start, long end) + { + return PyList_GetSlice(pointer, new IntPtr(start), new IntPtr(end)); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr PyList_GetSlice(IntPtr pointer, IntPtr start, IntPtr end); + + internal static int PyList_SetSlice(IntPtr pointer, long start, long end, IntPtr value) + { + return PyList_SetSlice(pointer, new IntPtr(start), new IntPtr(end), value); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + private static extern int PyList_SetSlice(IntPtr pointer, IntPtr start, IntPtr end, IntPtr value); + + internal static long PyList_Size(IntPtr pointer) + { + return (long) _PyList_Size(pointer); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PyList_Size")] + private static extern IntPtr _PyList_Size(IntPtr pointer); + + //==================================================================== + // Python tuple API + //==================================================================== + + internal static bool PyTuple_Check(IntPtr ob) + { + return PyObject_TYPE(ob) == PyTupleType; + } + + internal static IntPtr PyTuple_New(long size) + { + return PyTuple_New(new IntPtr(size)); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr PyTuple_New(IntPtr size); + + internal static IntPtr PyTuple_GetItem(IntPtr pointer, long index) + { + return PyTuple_GetItem(pointer, new IntPtr(index)); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr PyTuple_GetItem(IntPtr pointer, IntPtr index); + + internal static int PyTuple_SetItem(IntPtr pointer, long index, IntPtr value) + { + return PyTuple_SetItem(pointer, new IntPtr(index), value); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + private static extern int PyTuple_SetItem(IntPtr pointer, IntPtr index, IntPtr value); + + internal static IntPtr PyTuple_GetSlice(IntPtr pointer, long start, long end) + { + return PyTuple_GetSlice(pointer, new IntPtr(start), new IntPtr(end)); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr PyTuple_GetSlice(IntPtr pointer, IntPtr start, IntPtr end); + + internal static long PyTuple_Size(IntPtr pointer) + { + return (long) _PyTuple_Size(pointer); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PyTuple_Size")] + private static extern IntPtr _PyTuple_Size(IntPtr pointer); + + + //==================================================================== + // Python iterator API + //==================================================================== + + internal static bool PyIter_Check(IntPtr pointer) + { + var ob_type = Marshal.ReadIntPtr(pointer, ObjectOffset.ob_type); +#if PYTHON2 + long tp_flags = Util.ReadCLong(ob_type, TypeOffset.tp_flags); + if ((tp_flags & TypeFlags.HaveIter) == 0) + return false; +#endif + IntPtr tp_iternext = Marshal.ReadIntPtr(ob_type, TypeOffset.tp_iternext); + return tp_iternext != IntPtr.Zero && tp_iternext != _PyObject_NextNotImplemented; + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyIter_Next(IntPtr pointer); + + + //==================================================================== + // Python module API + //==================================================================== + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyModule_New(string name); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern string PyModule_GetName(IntPtr module); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyModule_GetDict(IntPtr module); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern string PyModule_GetFilename(IntPtr module); + +#if !PYTHON2 + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyModule_Create2(IntPtr module, int apiver); +#endif + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyImport_Import(IntPtr name); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyImport_ImportModule(string name); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyImport_ReloadModule(IntPtr module); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyImport_AddModule(string name); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyImport_GetModuleDict(); + +#if !PYTHON2 + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void PySys_SetArgvEx( + int argc, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StrArrayMarshaler))] string[] argv, + int updatepath + ); +#else + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void PySys_SetArgvEx( + int argc, + string[] argv, + int updatepath + ); +#endif + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PySys_GetObject(string name); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PySys_SetObject(string name, IntPtr ob); + + + //==================================================================== + // Python type object API + //==================================================================== + + internal static bool PyType_Check(IntPtr ob) + { + return PyObject_TypeCheck(ob, PyTypeType); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void PyType_Modified(IntPtr type); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern bool PyType_IsSubtype(IntPtr t1, IntPtr t2); + + internal static bool PyObject_TypeCheck(IntPtr ob, IntPtr tp) + { + IntPtr t = PyObject_TYPE(ob); + return (t == tp) || PyType_IsSubtype(t, tp); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyType_GenericNew(IntPtr type, IntPtr args, IntPtr kw); + + internal static IntPtr PyType_GenericAlloc(IntPtr type, long n) + { + return PyType_GenericAlloc(type, new IntPtr(n)); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr PyType_GenericAlloc(IntPtr type, IntPtr n); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyType_Ready(IntPtr type); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr _PyType_Lookup(IntPtr type, IntPtr name); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyObject_GenericGetAttr(IntPtr obj, IntPtr name); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyObject_GenericSetAttr(IntPtr obj, IntPtr name, IntPtr value); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr _PyObject_GetDictPtr(IntPtr obj); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyObject_GC_New(IntPtr tp); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void PyObject_GC_Del(IntPtr tp); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void PyObject_GC_Track(IntPtr tp); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void PyObject_GC_UnTrack(IntPtr tp); + + + //==================================================================== + // Python memory API + //==================================================================== + + internal static IntPtr PyMem_Malloc(long size) + { + return PyMem_Malloc(new IntPtr(size)); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr PyMem_Malloc(IntPtr size); + + internal static IntPtr PyMem_Realloc(IntPtr ptr, long size) + { + return PyMem_Realloc(ptr, new IntPtr(size)); + } + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr PyMem_Realloc(IntPtr ptr, IntPtr size); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void PyMem_Free(IntPtr ptr); + + + //==================================================================== + // Python exception API + //==================================================================== + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void PyErr_SetString(IntPtr ob, string message); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void PyErr_SetObject(IntPtr ob, IntPtr message); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyErr_SetFromErrno(IntPtr ob); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void PyErr_SetNone(IntPtr ob); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyErr_ExceptionMatches(IntPtr exception); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int PyErr_GivenExceptionMatches(IntPtr ob, IntPtr val); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void PyErr_NormalizeException(IntPtr ob, IntPtr val, IntPtr tb); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyErr_Occurred(); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void PyErr_Fetch(ref IntPtr ob, ref IntPtr val, ref IntPtr tb); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void PyErr_Restore(IntPtr ob, IntPtr val, IntPtr tb); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void PyErr_Clear(); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern void PyErr_Print(); + + + //==================================================================== + // Miscellaneous + //==================================================================== + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyMethod_Self(IntPtr ob); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr PyMethod_Function(IntPtr ob); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int Py_AddPendingCall(IntPtr func, IntPtr arg); + + [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] + internal static extern int Py_MakePendingCalls(); + + public int ILibPython.Py_MakePendingCalls() => Py_MakePendingCalls(); + + public int Py_NoSiteFlag { + get; set; + } + /* + { + var loader = LibraryLoader.Get(OperatingSystem); + + Py_NoSiteFlag = loader.GetFunction(IntPtr.Zero, "Py_NoSiteFlag"); + Marshal.WriteInt32(Py_NoSiteFlag, 1); + } */ + } +} diff --git a/Python.Runtime.Native/Python.Runtime.Native.csproj b/Python.Runtime.Native/Python.Runtime.Native.csproj new file mode 100644 index 000000000..8cd2f745b --- /dev/null +++ b/Python.Runtime.Native/Python.Runtime.Native.csproj @@ -0,0 +1,12 @@ + + + + netstandard2.0 + true + + + + + + + diff --git a/Python.Runtime/Python.Runtime.csproj b/Python.Runtime/Python.Runtime.csproj index b60ac1fa6..1b159e903 100644 --- a/Python.Runtime/Python.Runtime.csproj +++ b/Python.Runtime/Python.Runtime.csproj @@ -7,6 +7,11 @@ + + + + + diff --git a/Python.Runtime/runtime_.cs b/Python.Runtime/runtime_.cs new file mode 100644 index 000000000..3ab6a3b76 --- /dev/null +++ b/Python.Runtime/runtime_.cs @@ -0,0 +1,219 @@ + +namespace Python.Runtime { + + partial class Runtime { + internal static void Py_IncRef(System.IntPtr ob) => LibPython.Py_IncRef(ob); + internal static void Py_DecRef(System.IntPtr ob) => LibPython.Py_DecRef(ob); + internal static void Py_InitializeEx(System.Int32 initsigs) => LibPython.Py_InitializeEx(initsigs); + internal static System.Int32 Py_IsInitialized() => LibPython.Py_IsInitialized(); + internal static void Py_Finalize() => LibPython.Py_Finalize(); + internal static System.IntPtr PyGILState_Ensure() => LibPython.PyGILState_Ensure(); + internal static void PyGILState_Release(System.IntPtr gs) => LibPython.PyGILState_Release(gs); + internal static void PyEval_InitThreads() => LibPython.PyEval_InitThreads(); + internal static System.Int32 PyEval_ThreadsInitialized() => LibPython.PyEval_ThreadsInitialized(); + internal static void PyEval_AcquireLock() => LibPython.PyEval_AcquireLock(); + internal static void PyEval_ReleaseLock() => LibPython.PyEval_ReleaseLock(); + internal static System.IntPtr PyEval_SaveThread() => LibPython.PyEval_SaveThread(); + internal static void PyEval_RestoreThread(System.IntPtr tstate) => LibPython.PyEval_RestoreThread(tstate); + internal static System.IntPtr PyEval_GetBuiltins() => LibPython.PyEval_GetBuiltins(); + internal static System.IntPtr PyEval_GetGlobals() => LibPython.PyEval_GetGlobals(); + internal static System.IntPtr PyEval_GetLocals() => LibPython.PyEval_GetLocals(); + internal static System.IntPtr Py_GetProgramName() => LibPython.Py_GetProgramName(); + internal static void Py_SetProgramName(System.IntPtr name) => LibPython.Py_SetProgramName(name); + internal static System.IntPtr Py_GetPythonHome() => LibPython.Py_GetPythonHome(); + internal static void Py_SetPythonHome(System.IntPtr home) => LibPython.Py_SetPythonHome(home); + internal static System.IntPtr Py_GetPath() => LibPython.Py_GetPath(); + internal static void Py_SetPath(System.IntPtr home) => LibPython.Py_SetPath(home); + internal static System.IntPtr Py_GetVersion() => LibPython.Py_GetVersion(); + internal static System.IntPtr Py_GetPlatform() => LibPython.Py_GetPlatform(); + internal static System.IntPtr Py_GetCopyright() => LibPython.Py_GetCopyright(); + internal static System.IntPtr Py_GetCompiler() => LibPython.Py_GetCompiler(); + internal static System.IntPtr Py_GetBuildInfo() => LibPython.Py_GetBuildInfo(); + internal static System.Int32 PyRun_SimpleString(System.String code) => LibPython.PyRun_SimpleString(code); + internal static System.IntPtr PyRun_String(System.String code, System.IntPtr st, System.IntPtr globals, System.IntPtr locals) => LibPython.PyRun_String(code, st, globals, locals); + internal static System.IntPtr PyEval_EvalCode(System.IntPtr co, System.IntPtr globals, System.IntPtr locals) => LibPython.PyEval_EvalCode(co, globals, locals); + internal static System.IntPtr Py_CompileString(System.String code, System.String file, System.IntPtr tok) => LibPython.Py_CompileString(code, file, tok); + internal static System.IntPtr PyImport_ExecCodeModule(System.String name, System.IntPtr code) => LibPython.PyImport_ExecCodeModule(name, code); + internal static System.IntPtr PyCFunction_NewEx(System.IntPtr ml, System.IntPtr self, System.IntPtr mod) => LibPython.PyCFunction_NewEx(ml, self, mod); + internal static System.IntPtr PyCFunction_Call(System.IntPtr func, System.IntPtr args, System.IntPtr kw) => LibPython.PyCFunction_Call(func, args, kw); + internal static System.IntPtr PyInstance_New(System.IntPtr cls, System.IntPtr args, System.IntPtr kw) => LibPython.PyInstance_New(cls, args, kw); + internal static System.IntPtr PyInstance_NewRaw(System.IntPtr cls, System.IntPtr dict) => LibPython.PyInstance_NewRaw(cls, dict); + internal static System.IntPtr PyMethod_New(System.IntPtr func, System.IntPtr self, System.IntPtr cls) => LibPython.PyMethod_New(func, self, cls); + internal static System.Int32 PyObject_HasAttrString(System.IntPtr pointer, System.String name) => LibPython.PyObject_HasAttrString(pointer, name); + internal static System.IntPtr PyObject_GetAttrString(System.IntPtr pointer, System.String name) => LibPython.PyObject_GetAttrString(pointer, name); + internal static System.Int32 PyObject_SetAttrString(System.IntPtr pointer, System.String name, System.IntPtr value) => LibPython.PyObject_SetAttrString(pointer, name, value); + internal static System.Int32 PyObject_HasAttr(System.IntPtr pointer, System.IntPtr name) => LibPython.PyObject_HasAttr(pointer, name); + internal static System.IntPtr PyObject_GetAttr(System.IntPtr pointer, System.IntPtr name) => LibPython.PyObject_GetAttr(pointer, name); + internal static System.Int32 PyObject_SetAttr(System.IntPtr pointer, System.IntPtr name, System.IntPtr value) => LibPython.PyObject_SetAttr(pointer, name, value); + internal static System.IntPtr PyObject_GetItem(System.IntPtr pointer, System.IntPtr key) => LibPython.PyObject_GetItem(pointer, key); + internal static System.Int32 PyObject_SetItem(System.IntPtr pointer, System.IntPtr key, System.IntPtr value) => LibPython.PyObject_SetItem(pointer, key, value); + internal static System.Int32 PyObject_DelItem(System.IntPtr pointer, System.IntPtr key) => LibPython.PyObject_DelItem(pointer, key); + internal static System.IntPtr PyObject_GetIter(System.IntPtr op) => LibPython.PyObject_GetIter(op); + internal static System.IntPtr PyObject_Call(System.IntPtr pointer, System.IntPtr args, System.IntPtr kw) => LibPython.PyObject_Call(pointer, args, kw); + internal static System.IntPtr PyObject_CallObject(System.IntPtr pointer, System.IntPtr args) => LibPython.PyObject_CallObject(pointer, args); + internal static System.Int32 PyObject_RichCompareBool(System.IntPtr value1, System.IntPtr value2, System.Int32 opid) => LibPython.PyObject_RichCompareBool(value1, value2, opid); + internal static System.Int32 PyObject_IsInstance(System.IntPtr ob, System.IntPtr type) => LibPython.PyObject_IsInstance(ob, type); + internal static System.Int32 PyObject_IsSubclass(System.IntPtr ob, System.IntPtr type) => LibPython.PyObject_IsSubclass(ob, type); + internal static System.Int32 PyCallable_Check(System.IntPtr pointer) => LibPython.PyCallable_Check(pointer); + internal static System.Int32 PyObject_IsTrue(System.IntPtr pointer) => LibPython.PyObject_IsTrue(pointer); + internal static System.Int32 PyObject_Not(System.IntPtr pointer) => LibPython.PyObject_Not(pointer); + internal static System.IntPtr _PyObject_Size(System.IntPtr pointer) => LibPython._PyObject_Size(pointer); + internal static System.IntPtr PyObject_Hash(System.IntPtr op) => LibPython.PyObject_Hash(op); + internal static System.IntPtr PyObject_Repr(System.IntPtr pointer) => LibPython.PyObject_Repr(pointer); + internal static System.IntPtr PyObject_Str(System.IntPtr pointer) => LibPython.PyObject_Str(pointer); + internal static System.IntPtr PyObject_Unicode(System.IntPtr pointer) => LibPython.PyObject_Unicode(pointer); + internal static System.IntPtr PyObject_Dir(System.IntPtr pointer) => LibPython.PyObject_Dir(pointer); + internal static System.IntPtr PyNumber_Int(System.IntPtr ob) => LibPython.PyNumber_Int(ob); + internal static System.IntPtr PyNumber_Long(System.IntPtr ob) => LibPython.PyNumber_Long(ob); + internal static System.IntPtr PyNumber_Float(System.IntPtr ob) => LibPython.PyNumber_Float(ob); + internal static System.Boolean PyNumber_Check(System.IntPtr ob) => LibPython.PyNumber_Check(ob); + internal static System.IntPtr PyInt_FromLong(System.IntPtr value) => LibPython.PyInt_FromLong(value); + internal static System.Int32 PyInt_AsLong(System.IntPtr value) => LibPython.PyInt_AsLong(value); + internal static System.IntPtr PyInt_FromString(System.String value, System.IntPtr end, System.Int32 radix) => LibPython.PyInt_FromString(value, end, radix); + internal static System.IntPtr PyLong_FromLong(System.Int64 value) => LibPython.PyLong_FromLong(value); + internal static System.IntPtr PyLong_FromUnsignedLong32(System.UInt32 value) => LibPython.PyLong_FromUnsignedLong32(value); + internal static System.IntPtr PyLong_FromUnsignedLong64(System.UInt64 value) => LibPython.PyLong_FromUnsignedLong64(value); + internal static System.IntPtr PyLong_FromDouble(System.Double value) => LibPython.PyLong_FromDouble(value); + internal static System.IntPtr PyLong_FromLongLong(System.Int64 value) => LibPython.PyLong_FromLongLong(value); + internal static System.IntPtr PyLong_FromUnsignedLongLong(System.UInt64 value) => LibPython.PyLong_FromUnsignedLongLong(value); + internal static System.IntPtr PyLong_FromString(System.String value, System.IntPtr end, System.Int32 radix) => LibPython.PyLong_FromString(value, end, radix); + internal static System.Int32 PyLong_AsLong(System.IntPtr value) => LibPython.PyLong_AsLong(value); + internal static System.UInt32 PyLong_AsUnsignedLong32(System.IntPtr value) => LibPython.PyLong_AsUnsignedLong32(value); + internal static System.UInt64 PyLong_AsUnsignedLong64(System.IntPtr value) => LibPython.PyLong_AsUnsignedLong64(value); + internal static System.Int64 PyLong_AsLongLong(System.IntPtr value) => LibPython.PyLong_AsLongLong(value); + internal static System.UInt64 PyLong_AsUnsignedLongLong(System.IntPtr value) => LibPython.PyLong_AsUnsignedLongLong(value); + internal static System.IntPtr PyFloat_FromDouble(System.Double value) => LibPython.PyFloat_FromDouble(value); + internal static System.IntPtr PyFloat_FromString(System.IntPtr value, System.IntPtr junk) => LibPython.PyFloat_FromString(value, junk); + internal static System.Double PyFloat_AsDouble(System.IntPtr ob) => LibPython.PyFloat_AsDouble(ob); + internal static System.IntPtr PyNumber_Add(System.IntPtr o1, System.IntPtr o2) => LibPython.PyNumber_Add(o1, o2); + internal static System.IntPtr PyNumber_Subtract(System.IntPtr o1, System.IntPtr o2) => LibPython.PyNumber_Subtract(o1, o2); + internal static System.IntPtr PyNumber_Multiply(System.IntPtr o1, System.IntPtr o2) => LibPython.PyNumber_Multiply(o1, o2); + internal static System.IntPtr PyNumber_TrueDivide(System.IntPtr o1, System.IntPtr o2) => LibPython.PyNumber_TrueDivide(o1, o2); + internal static System.IntPtr PyNumber_And(System.IntPtr o1, System.IntPtr o2) => LibPython.PyNumber_And(o1, o2); + internal static System.IntPtr PyNumber_Xor(System.IntPtr o1, System.IntPtr o2) => LibPython.PyNumber_Xor(o1, o2); + internal static System.IntPtr PyNumber_Or(System.IntPtr o1, System.IntPtr o2) => LibPython.PyNumber_Or(o1, o2); + internal static System.IntPtr PyNumber_Lshift(System.IntPtr o1, System.IntPtr o2) => LibPython.PyNumber_Lshift(o1, o2); + internal static System.IntPtr PyNumber_Rshift(System.IntPtr o1, System.IntPtr o2) => LibPython.PyNumber_Rshift(o1, o2); + internal static System.IntPtr PyNumber_Power(System.IntPtr o1, System.IntPtr o2) => LibPython.PyNumber_Power(o1, o2); + internal static System.IntPtr PyNumber_Remainder(System.IntPtr o1, System.IntPtr o2) => LibPython.PyNumber_Remainder(o1, o2); + internal static System.IntPtr PyNumber_InPlaceAdd(System.IntPtr o1, System.IntPtr o2) => LibPython.PyNumber_InPlaceAdd(o1, o2); + internal static System.IntPtr PyNumber_InPlaceSubtract(System.IntPtr o1, System.IntPtr o2) => LibPython.PyNumber_InPlaceSubtract(o1, o2); + internal static System.IntPtr PyNumber_InPlaceMultiply(System.IntPtr o1, System.IntPtr o2) => LibPython.PyNumber_InPlaceMultiply(o1, o2); + internal static System.IntPtr PyNumber_InPlaceTrueDivide(System.IntPtr o1, System.IntPtr o2) => LibPython.PyNumber_InPlaceTrueDivide(o1, o2); + internal static System.IntPtr PyNumber_InPlaceAnd(System.IntPtr o1, System.IntPtr o2) => LibPython.PyNumber_InPlaceAnd(o1, o2); + internal static System.IntPtr PyNumber_InPlaceXor(System.IntPtr o1, System.IntPtr o2) => LibPython.PyNumber_InPlaceXor(o1, o2); + internal static System.IntPtr PyNumber_InPlaceOr(System.IntPtr o1, System.IntPtr o2) => LibPython.PyNumber_InPlaceOr(o1, o2); + internal static System.IntPtr PyNumber_InPlaceLshift(System.IntPtr o1, System.IntPtr o2) => LibPython.PyNumber_InPlaceLshift(o1, o2); + internal static System.IntPtr PyNumber_InPlaceRshift(System.IntPtr o1, System.IntPtr o2) => LibPython.PyNumber_InPlaceRshift(o1, o2); + internal static System.IntPtr PyNumber_InPlacePower(System.IntPtr o1, System.IntPtr o2) => LibPython.PyNumber_InPlacePower(o1, o2); + internal static System.IntPtr PyNumber_InPlaceRemainder(System.IntPtr o1, System.IntPtr o2) => LibPython.PyNumber_InPlaceRemainder(o1, o2); + internal static System.IntPtr PyNumber_Negative(System.IntPtr o1) => LibPython.PyNumber_Negative(o1); + internal static System.IntPtr PyNumber_Positive(System.IntPtr o1) => LibPython.PyNumber_Positive(o1); + internal static System.IntPtr PyNumber_Invert(System.IntPtr o1) => LibPython.PyNumber_Invert(o1); + internal static System.Boolean PySequence_Check(System.IntPtr pointer) => LibPython.PySequence_Check(pointer); + internal static System.IntPtr PySequence_GetItem(System.IntPtr pointer, System.IntPtr index) => LibPython.PySequence_GetItem(pointer, index); + internal static System.Int32 PySequence_SetItem(System.IntPtr pointer, System.IntPtr index, System.IntPtr value) => LibPython.PySequence_SetItem(pointer, index, value); + internal static System.Int32 PySequence_DelItem(System.IntPtr pointer, System.IntPtr index) => LibPython.PySequence_DelItem(pointer, index); + internal static System.IntPtr PySequence_GetSlice(System.IntPtr pointer, System.IntPtr i1, System.IntPtr i2) => LibPython.PySequence_GetSlice(pointer, i1, i2); + internal static System.Int32 PySequence_SetSlice(System.IntPtr pointer, System.IntPtr i1, System.IntPtr i2, System.IntPtr v) => LibPython.PySequence_SetSlice(pointer, i1, i2, v); + internal static System.Int32 PySequence_DelSlice(System.IntPtr pointer, System.IntPtr i1, System.IntPtr i2) => LibPython.PySequence_DelSlice(pointer, i1, i2); + internal static System.IntPtr _PySequence_Size(System.IntPtr pointer) => LibPython._PySequence_Size(pointer); + internal static System.Int32 PySequence_Contains(System.IntPtr pointer, System.IntPtr item) => LibPython.PySequence_Contains(pointer, item); + internal static System.IntPtr PySequence_Concat(System.IntPtr pointer, System.IntPtr other) => LibPython.PySequence_Concat(pointer, other); + internal static System.IntPtr PySequence_Repeat(System.IntPtr pointer, System.IntPtr count) => LibPython.PySequence_Repeat(pointer, count); + internal static System.Int32 PySequence_Index(System.IntPtr pointer, System.IntPtr item) => LibPython.PySequence_Index(pointer, item); + internal static System.IntPtr _PySequence_Count(System.IntPtr pointer, System.IntPtr value) => LibPython._PySequence_Count(pointer, value); + internal static System.IntPtr PySequence_Tuple(System.IntPtr pointer) => LibPython.PySequence_Tuple(pointer); + internal static System.IntPtr PySequence_List(System.IntPtr pointer) => LibPython.PySequence_List(pointer); + internal static System.IntPtr PyBytes_FromString(System.String op) => LibPython.PyBytes_FromString(op); + internal static System.IntPtr _PyBytes_Size(System.IntPtr op) => LibPython._PyBytes_Size(op); + internal static System.IntPtr _PyString_FromStringAndSize(System.String value, System.IntPtr size) => LibPython._PyString_FromStringAndSize(value, size); + internal static System.IntPtr PyUnicode_FromStringAndSize(System.IntPtr value, System.IntPtr size) => LibPython.PyUnicode_FromStringAndSize(value, size); + internal static System.IntPtr PyUnicode_FromOrdinal(System.Int32 c) => LibPython.PyUnicode_FromOrdinal(c); + internal static System.IntPtr PyUnicode_AsUnicode(System.IntPtr ob) => LibPython.PyUnicode_AsUnicode(ob); + internal static System.IntPtr PyUnicode_FromObject(System.IntPtr ob) => LibPython.PyUnicode_FromObject(ob); + internal static System.IntPtr PyUnicode_FromEncodedObject(System.IntPtr ob, System.IntPtr enc, System.IntPtr err) => LibPython.PyUnicode_FromEncodedObject(ob, enc, err); + internal static System.IntPtr _PyUnicode_GetSize(System.IntPtr ob) => LibPython._PyUnicode_GetSize(ob); + internal static System.IntPtr PyUnicode_FromKindAndData(System.Int32 kind, System.String s, System.IntPtr size) => LibPython.PyUnicode_FromKindAndData(kind, s, size); + internal static System.IntPtr PyDict_New() => LibPython.PyDict_New(); + internal static System.IntPtr PyDictProxy_New(System.IntPtr dict) => LibPython.PyDictProxy_New(dict); + internal static System.IntPtr PyDict_GetItem(System.IntPtr pointer, System.IntPtr key) => LibPython.PyDict_GetItem(pointer, key); + internal static System.IntPtr PyDict_GetItemString(System.IntPtr pointer, System.String key) => LibPython.PyDict_GetItemString(pointer, key); + internal static System.Int32 PyDict_SetItem(System.IntPtr pointer, System.IntPtr key, System.IntPtr value) => LibPython.PyDict_SetItem(pointer, key, value); + internal static System.Int32 PyDict_SetItemString(System.IntPtr pointer, System.String key, System.IntPtr value) => LibPython.PyDict_SetItemString(pointer, key, value); + internal static System.Int32 PyDict_DelItem(System.IntPtr pointer, System.IntPtr key) => LibPython.PyDict_DelItem(pointer, key); + internal static System.Int32 PyDict_DelItemString(System.IntPtr pointer, System.String key) => LibPython.PyDict_DelItemString(pointer, key); + internal static System.Int32 PyMapping_HasKey(System.IntPtr pointer, System.IntPtr key) => LibPython.PyMapping_HasKey(pointer, key); + internal static System.IntPtr PyDict_Keys(System.IntPtr pointer) => LibPython.PyDict_Keys(pointer); + internal static System.IntPtr PyDict_Values(System.IntPtr pointer) => LibPython.PyDict_Values(pointer); + internal static System.IntPtr PyDict_Items(System.IntPtr pointer) => LibPython.PyDict_Items(pointer); + internal static System.IntPtr PyDict_Copy(System.IntPtr pointer) => LibPython.PyDict_Copy(pointer); + internal static System.Int32 PyDict_Update(System.IntPtr pointer, System.IntPtr other) => LibPython.PyDict_Update(pointer, other); + internal static void PyDict_Clear(System.IntPtr pointer) => LibPython.PyDict_Clear(pointer); + internal static System.IntPtr _PyDict_Size(System.IntPtr pointer) => LibPython._PyDict_Size(pointer); + internal static System.IntPtr PyList_New(System.IntPtr size) => LibPython.PyList_New(size); + internal static System.IntPtr PyList_AsTuple(System.IntPtr pointer) => LibPython.PyList_AsTuple(pointer); + internal static System.IntPtr PyList_GetItem(System.IntPtr pointer, System.IntPtr index) => LibPython.PyList_GetItem(pointer, index); + internal static System.Int32 PyList_SetItem(System.IntPtr pointer, System.IntPtr index, System.IntPtr value) => LibPython.PyList_SetItem(pointer, index, value); + internal static System.Int32 PyList_Insert(System.IntPtr pointer, System.IntPtr index, System.IntPtr value) => LibPython.PyList_Insert(pointer, index, value); + internal static System.Int32 PyList_Append(System.IntPtr pointer, System.IntPtr value) => LibPython.PyList_Append(pointer, value); + internal static System.Int32 PyList_Reverse(System.IntPtr pointer) => LibPython.PyList_Reverse(pointer); + internal static System.Int32 PyList_Sort(System.IntPtr pointer) => LibPython.PyList_Sort(pointer); + internal static System.IntPtr PyList_GetSlice(System.IntPtr pointer, System.IntPtr start, System.IntPtr end) => LibPython.PyList_GetSlice(pointer, start, end); + internal static System.Int32 PyList_SetSlice(System.IntPtr pointer, System.IntPtr start, System.IntPtr end, System.IntPtr value) => LibPython.PyList_SetSlice(pointer, start, end, value); + internal static System.IntPtr _PyList_Size(System.IntPtr pointer) => LibPython._PyList_Size(pointer); + internal static System.IntPtr PyTuple_New(System.IntPtr size) => LibPython.PyTuple_New(size); + internal static System.IntPtr PyTuple_GetItem(System.IntPtr pointer, System.IntPtr index) => LibPython.PyTuple_GetItem(pointer, index); + internal static System.Int32 PyTuple_SetItem(System.IntPtr pointer, System.IntPtr index, System.IntPtr value) => LibPython.PyTuple_SetItem(pointer, index, value); + internal static System.IntPtr PyTuple_GetSlice(System.IntPtr pointer, System.IntPtr start, System.IntPtr end) => LibPython.PyTuple_GetSlice(pointer, start, end); + internal static System.IntPtr _PyTuple_Size(System.IntPtr pointer) => LibPython._PyTuple_Size(pointer); + internal static System.IntPtr PyIter_Next(System.IntPtr pointer) => LibPython.PyIter_Next(pointer); + internal static System.IntPtr PyModule_New(System.String name) => LibPython.PyModule_New(name); + internal static System.String PyModule_GetName(System.IntPtr module) => LibPython.PyModule_GetName(module); + internal static System.IntPtr PyModule_GetDict(System.IntPtr module) => LibPython.PyModule_GetDict(module); + internal static System.String PyModule_GetFilename(System.IntPtr module) => LibPython.PyModule_GetFilename(module); + internal static System.IntPtr PyModule_Create2(System.IntPtr module, System.Int32 apiver) => LibPython.PyModule_Create2(module, apiver); + internal static System.IntPtr PyImport_Import(System.IntPtr name) => LibPython.PyImport_Import(name); + internal static System.IntPtr PyImport_ImportModule(System.String name) => LibPython.PyImport_ImportModule(name); + internal static System.IntPtr PyImport_ReloadModule(System.IntPtr module) => LibPython.PyImport_ReloadModule(module); + internal static System.IntPtr PyImport_AddModule(System.String name) => LibPython.PyImport_AddModule(name); + internal static System.IntPtr PyImport_GetModuleDict() => LibPython.PyImport_GetModuleDict(); + internal static void PySys_SetArgvEx(System.Int32 argc, System.String[] argv, System.Int32 updatepath) => LibPython.PySys_SetArgvEx(argc, argv, updatepath); + internal static System.IntPtr PySys_GetObject(System.String name) => LibPython.PySys_GetObject(name); + internal static System.Int32 PySys_SetObject(System.String name, System.IntPtr ob) => LibPython.PySys_SetObject(name, ob); + internal static void PyType_Modified(System.IntPtr type) => LibPython.PyType_Modified(type); + internal static System.Boolean PyType_IsSubtype(System.IntPtr t1, System.IntPtr t2) => LibPython.PyType_IsSubtype(t1, t2); + internal static System.IntPtr PyType_GenericNew(System.IntPtr type, System.IntPtr args, System.IntPtr kw) => LibPython.PyType_GenericNew(type, args, kw); + internal static System.IntPtr PyType_GenericAlloc(System.IntPtr type, System.IntPtr n) => LibPython.PyType_GenericAlloc(type, n); + internal static System.Int32 PyType_Ready(System.IntPtr type) => LibPython.PyType_Ready(type); + internal static System.IntPtr _PyType_Lookup(System.IntPtr type, System.IntPtr name) => LibPython._PyType_Lookup(type, name); + internal static System.IntPtr PyObject_GenericGetAttr(System.IntPtr obj, System.IntPtr name) => LibPython.PyObject_GenericGetAttr(obj, name); + internal static System.Int32 PyObject_GenericSetAttr(System.IntPtr obj, System.IntPtr name, System.IntPtr value) => LibPython.PyObject_GenericSetAttr(obj, name, value); + internal static System.IntPtr _PyObject_GetDictPtr(System.IntPtr obj) => LibPython._PyObject_GetDictPtr(obj); + internal static System.IntPtr PyObject_GC_New(System.IntPtr tp) => LibPython.PyObject_GC_New(tp); + internal static void PyObject_GC_Del(System.IntPtr tp) => LibPython.PyObject_GC_Del(tp); + internal static void PyObject_GC_Track(System.IntPtr tp) => LibPython.PyObject_GC_Track(tp); + internal static void PyObject_GC_UnTrack(System.IntPtr tp) => LibPython.PyObject_GC_UnTrack(tp); + internal static System.IntPtr PyMem_Malloc(System.IntPtr size) => LibPython.PyMem_Malloc(size); + internal static System.IntPtr PyMem_Realloc(System.IntPtr ptr, System.IntPtr size) => LibPython.PyMem_Realloc(ptr, size); + internal static void PyMem_Free(System.IntPtr ptr) => LibPython.PyMem_Free(ptr); + internal static void PyErr_SetString(System.IntPtr ob, System.String message) => LibPython.PyErr_SetString(ob, message); + internal static void PyErr_SetObject(System.IntPtr ob, System.IntPtr message) => LibPython.PyErr_SetObject(ob, message); + internal static System.IntPtr PyErr_SetFromErrno(System.IntPtr ob) => LibPython.PyErr_SetFromErrno(ob); + internal static void PyErr_SetNone(System.IntPtr ob) => LibPython.PyErr_SetNone(ob); + internal static System.Int32 PyErr_ExceptionMatches(System.IntPtr exception) => LibPython.PyErr_ExceptionMatches(exception); + internal static System.Int32 PyErr_GivenExceptionMatches(System.IntPtr ob, System.IntPtr val) => LibPython.PyErr_GivenExceptionMatches(ob, val); + internal static void PyErr_NormalizeException(System.IntPtr ob, System.IntPtr val, System.IntPtr tb) => LibPython.PyErr_NormalizeException(ob, val, tb); + internal static System.IntPtr PyErr_Occurred() => LibPython.PyErr_Occurred(); + internal static void PyErr_Fetch(ref System.IntPtr ob, ref System.IntPtr val, ref System.IntPtr tb) => LibPython.PyErr_Fetch(ob, val, tb); + internal static void PyErr_Restore(System.IntPtr ob, System.IntPtr val, System.IntPtr tb) => LibPython.PyErr_Restore(ob, val, tb); + internal static void PyErr_Clear() => LibPython.PyErr_Clear(); + internal static void PyErr_Print() => LibPython.PyErr_Print(); + internal static System.IntPtr PyMethod_Self(System.IntPtr ob) => LibPython.PyMethod_Self(ob); + internal static System.IntPtr PyMethod_Function(System.IntPtr ob) => LibPython.PyMethod_Function(ob); + internal static System.Int32 Py_AddPendingCall(System.IntPtr func, System.IntPtr arg) => LibPython.Py_AddPendingCall(func, arg); + internal static System.Int32 Py_MakePendingCalls() => LibPython.Py_MakePendingCalls(); + internal static System.Int32 get_Py_NoSiteFlag() => LibPython.get_Py_NoSiteFlag(); + internal static void set_Py_NoSiteFlag(System.Int32 value) => LibPython.set_Py_NoSiteFlag(value); + } +} diff --git a/Python.Runtime/runtime_.tt b/Python.Runtime/runtime_.tt new file mode 100644 index 000000000..f0cc19c2c --- /dev/null +++ b/Python.Runtime/runtime_.tt @@ -0,0 +1,40 @@ +<#@ template hostspecific="false" language="C#" #> +<#@ output extension=".cs" #> +<#@ assembly name="System.Core" #> +<#@ assembly name="System.Linq" #> +<#@ import namespace="System.Reflection" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.IO" #> + +namespace Python.Runtime { + + partial class Runtime { +<# + string FormatType(Type type) { + if (type == typeof(void)) + return "void"; + + if (type.IsByRef) + return $"ref {type.GetElementType().ToString()}"; + + return type.ToString(); + } + + var path = $"{Directory.GetCurrentDirectory()}/Python.Runtime.Native/bin/Debug/netstandard2.0/Python.Runtime.Native.dll"; + var assembly = Assembly.LoadFile(path); + var type = assembly.GetType("Python.Runtime.Native.ILibPython"); + const BindingFlags flags = BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.Instance; + var methods = type.GetMethods(flags); + + foreach (var method in methods) { +#> + internal static <#= FormatType(method.ReturnParameter.ParameterType) #> <#= method.Name #>(<#= + string.Join(", ", method.GetParameters().Select(x => $"{FormatType(x.ParameterType)} {x.Name}")) + #>) => LibPython.<#= method.Name #>(<#= + string.Join(", ", method.GetParameters().Select(x => x.Name)) + #>); +<# + } +#> + } +} From 0185bcb48d05a8407a41fc5eedae4c4afb27b214 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Mon, 16 Dec 2019 10:34:08 +0100 Subject: [PATCH 16/22] Make the code compile with ILibPython --- Python.Runtime.Native/AssemblyInfo.cs | 6 + .../platform/InternalLoadContext.cs | 24 + Python.Runtime/platform/LibraryLoader.cs | 20 +- Python.Runtime/pythonengine.cs | 25 +- Python.Runtime/runtime.cs | 817 +----------------- Python.Runtime/runtime_.cs | 8 +- Python.Runtime/runtime_.tt | 2 +- 7 files changed, 83 insertions(+), 819 deletions(-) create mode 100644 Python.Runtime.Native/AssemblyInfo.cs create mode 100644 Python.Runtime/platform/InternalLoadContext.cs diff --git a/Python.Runtime.Native/AssemblyInfo.cs b/Python.Runtime.Native/AssemblyInfo.cs new file mode 100644 index 000000000..c8e5a1098 --- /dev/null +++ b/Python.Runtime.Native/AssemblyInfo.cs @@ -0,0 +1,6 @@ +using System; +using System.Runtime.CompilerServices; + +[assembly: CLSCompliant(true)] +[assembly: InternalsVisibleTo("Python.Test.Embed")] +[assembly: InternalsVisibleTo("Python.Runtime")] diff --git a/Python.Runtime/platform/InternalLoadContext.cs b/Python.Runtime/platform/InternalLoadContext.cs new file mode 100644 index 000000000..e6b94ba41 --- /dev/null +++ b/Python.Runtime/platform/InternalLoadContext.cs @@ -0,0 +1,24 @@ +using System; +using System.Reflection; +using System.Runtime.Loader; + +namespace Python.Runtime.Platform +{ + class InternalLoadContext : AssemblyLoadContext + { + protected override Assembly Load(AssemblyName name) => null; + + protected override IntPtr LoadUnmanagedDll(string name) + { + if (name == "__Internal") + { + var loader = LibraryLoader.Get(OperatingSystemType.Linux); + return loader.Load(null); + } + + return IntPtr.Zero; + } + + public static AssemblyLoadContext Instance { get; } = new InternalLoadContext(); + } +} diff --git a/Python.Runtime/platform/LibraryLoader.cs b/Python.Runtime/platform/LibraryLoader.cs index a6d88cd19..d152fcebc 100644 --- a/Python.Runtime/platform/LibraryLoader.cs +++ b/Python.Runtime/platform/LibraryLoader.cs @@ -40,7 +40,15 @@ class LinuxLoader : ILibraryLoader public IntPtr Load(string dllToLoad) { - var filename = $"lib{dllToLoad}.so"; + string filename; + if (dllToLoad != null) + { + filename = $"lib{dllToLoad}.so"; + } + else + { + filename = null; + } ClearError(); var res = dlopen(filename, RTLD_NOW | RTLD_GLOBAL); if (res == IntPtr.Zero) @@ -111,7 +119,15 @@ class DarwinLoader : ILibraryLoader public IntPtr Load(string dllToLoad) { - var filename = $"lib{dllToLoad}.dylib"; + string filename; + if (dllToLoad != null) + { + filename = $"lib{dllToLoad}.dylib"; + } + else + { + filename = null; + } ClearError(); var res = dlopen(filename, RTLD_NOW | RTLD_GLOBAL); if (res == IntPtr.Zero) diff --git a/Python.Runtime/pythonengine.cs b/Python.Runtime/pythonengine.cs index c451a60fc..92a5d2adb 100644 --- a/Python.Runtime/pythonengine.cs +++ b/Python.Runtime/pythonengine.cs @@ -1,9 +1,12 @@ +using System.Runtime.CompilerServices; +using System.Runtime.Loader; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.InteropServices; +using Python.Runtime.Native; namespace Python.Runtime { @@ -254,10 +257,17 @@ static void OnDomainUnload(object _, EventArgs __) /// CPython interpreter process - this bootstraps the managed runtime /// when it is imported by the CLR extension module. /// - public static int InternalInitialize(int size, IntPtr data) + public static int InternalInitialize(IntPtr data, int size) { + + try { + // Console.WriteLine("Before Initialize"); + // Console.Out.Flush(); + + // Python.Runtime.Platform.InternalLoadContext.Instance.EnterContextualReflection(); + Initialize(setSysArgv: false); // Trickery - when the import hook is installed into an already @@ -277,6 +287,9 @@ public static int InternalInitialize(int size, IntPtr data) // still doesn't work if you use the interactive interpreter, // since there is no line info to get the import line ;( + // Console.WriteLine("Initialized"); + // Console.Out.Flush(); + string code = "import traceback\n" + "for item in traceback.extract_stack():\n" + @@ -290,6 +303,10 @@ public static int InternalInitialize(int size, IntPtr data) " break\n"; PythonEngine.Exec(code); + + // Console.WriteLine("Exec'd traceback hack"); + // Console.Out.Flush(); + return 0; } catch (PythonException e) @@ -297,6 +314,12 @@ public static int InternalInitialize(int size, IntPtr data) e.Restore(); return -1; } + catch (Exception e) + { + // Console.Error.WriteLine(e.ToString()); + // Console.Error.Write(e.StackTrace); + return -2; + } } /// diff --git a/Python.Runtime/runtime.cs b/Python.Runtime/runtime.cs index 2eb66b3a8..3164c384b 100644 --- a/Python.Runtime/runtime.cs +++ b/Python.Runtime/runtime.cs @@ -14,7 +14,7 @@ namespace Python.Runtime /// the responsibility of the caller to have acquired the GIL /// before calling any of these methods. /// - public class Runtime + public static partial class Runtime { // C# compiler copies constants to the assemblies that references this library. // We needs to replace all public constants to static readonly fields to allow @@ -363,7 +363,6 @@ internal static int AtExit() internal static IntPtr PyNoneType; internal static IntPtr PyTypeType; - internal static IntPtr Py_NoSiteFlag; internal static IntPtr PyBytesType; internal static IntPtr _PyObject_NextNotImplemented; @@ -512,180 +511,6 @@ internal static unsafe long Refcount(IntPtr op) return Is32Bit ? (*(int*)p) : (*(long*)p); } - /// - /// Export of Macro Py_XIncRef. Use XIncref instead. - /// Limit this function usage for Testing and Py_Debug builds - /// - /// PyObject Ptr - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void Py_IncRef(IntPtr ob); - - /// - /// Export of Macro Py_XDecRef. Use XDecref instead. - /// Limit this function usage for Testing and Py_Debug builds - /// - /// PyObject Ptr - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void Py_DecRef(IntPtr ob); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void Py_Initialize(); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void Py_InitializeEx(int initsigs); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int Py_IsInitialized(); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void Py_Finalize(); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr Py_NewInterpreter(); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void Py_EndInterpreter(IntPtr threadState); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyThreadState_New(IntPtr istate); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyThreadState_Get(); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyThread_get_key_value(IntPtr key); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyThread_get_thread_ident(); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyThread_set_key_value(IntPtr key, IntPtr value); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyThreadState_Swap(IntPtr key); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyGILState_Ensure(); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void PyGILState_Release(IntPtr gs); - - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyGILState_GetThisThreadState(); - -#if !PYTHON2 - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - public static extern int Py_Main( - int argc, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StrArrayMarshaler))] string[] argv - ); -#else - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - public static extern int Py_Main(int argc, string[] argv); -#endif - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void PyEval_InitThreads(); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyEval_ThreadsInitialized(); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void PyEval_AcquireLock(); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void PyEval_ReleaseLock(); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void PyEval_AcquireThread(IntPtr tstate); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void PyEval_ReleaseThread(IntPtr tstate); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyEval_SaveThread(); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void PyEval_RestoreThread(IntPtr tstate); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyEval_GetBuiltins(); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyEval_GetGlobals(); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyEval_GetLocals(); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr Py_GetProgramName(); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void Py_SetProgramName(IntPtr name); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr Py_GetPythonHome(); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void Py_SetPythonHome(IntPtr home); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr Py_GetPath(); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void Py_SetPath(IntPtr home); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr Py_GetVersion(); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr Py_GetPlatform(); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr Py_GetCopyright(); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr Py_GetCompiler(); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr Py_GetBuildInfo(); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyRun_SimpleString(string code); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyRun_String(string code, IntPtr st, IntPtr globals, IntPtr locals); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyEval_EvalCode(IntPtr co, IntPtr globals, IntPtr locals); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr Py_CompileString(string code, string file, IntPtr tok); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyImport_ExecCodeModule(string name, IntPtr code); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyCFunction_NewEx(IntPtr ml, IntPtr self, IntPtr mod); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyCFunction_Call(IntPtr func, IntPtr args, IntPtr kw); - -#if PYTHON2 - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyClass_New(IntPtr bases, IntPtr dict, IntPtr name); -#endif - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyInstance_New(IntPtr cls, IntPtr args, IntPtr kw); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyInstance_NewRaw(IntPtr cls, IntPtr dict); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyMethod_New(IntPtr func, IntPtr self, IntPtr cls); - //==================================================================== // Python abstract object API @@ -703,7 +528,7 @@ internal static unsafe IntPtr PyObject_TYPE(IntPtr op) { return IntPtr.Zero; } -#if PYTHON_WITH_PYDEBUG +#if PYTHON_WITH_PYDEBUG // TODO: Only for Python <3.8 var n = 3; #else var n = 1; @@ -747,45 +572,6 @@ internal static bool PyObject_IsIterable(IntPtr pointer) return tp_iter != IntPtr.Zero; } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyObject_HasAttrString(IntPtr pointer, string name); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyObject_GetAttrString(IntPtr pointer, string name); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyObject_SetAttrString(IntPtr pointer, string name, IntPtr value); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyObject_HasAttr(IntPtr pointer, IntPtr name); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyObject_GetAttr(IntPtr pointer, IntPtr name); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyObject_SetAttr(IntPtr pointer, IntPtr name, IntPtr value); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyObject_GetItem(IntPtr pointer, IntPtr key); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyObject_SetItem(IntPtr pointer, IntPtr key, IntPtr value); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyObject_DelItem(IntPtr pointer, IntPtr key); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyObject_GetIter(IntPtr op); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyObject_Call(IntPtr pointer, IntPtr args, IntPtr kw); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyObject_CallObject(IntPtr pointer, IntPtr args); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyObject_RichCompareBool(IntPtr value1, IntPtr value2, int opid); - internal static int PyObject_Compare(IntPtr value1, IntPtr value2) { int res; @@ -811,73 +597,15 @@ internal static int PyObject_Compare(IntPtr value1, IntPtr value2) return -1; } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyObject_IsInstance(IntPtr ob, IntPtr type); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyObject_IsSubclass(IntPtr ob, IntPtr type); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyCallable_Check(IntPtr pointer); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyObject_IsTrue(IntPtr pointer); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyObject_Not(IntPtr pointer); - internal static long PyObject_Size(IntPtr pointer) { return (long) _PyObject_Size(pointer); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PyObject_Size")] - private static extern IntPtr _PyObject_Size(IntPtr pointer); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyObject_Hash(IntPtr op); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyObject_Repr(IntPtr pointer); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyObject_Str(IntPtr pointer); - -#if !PYTHON2 - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, - EntryPoint = "PyObject_Str")] - internal static extern IntPtr PyObject_Unicode(IntPtr pointer); -#else - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyObject_Unicode(IntPtr pointer); -#endif - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyObject_Dir(IntPtr pointer); - - //==================================================================== // Python number API //==================================================================== -#if !PYTHON2 - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, - EntryPoint = "PyNumber_Long")] - internal static extern IntPtr PyNumber_Int(IntPtr ob); -#else - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyNumber_Int(IntPtr ob); -#endif - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyNumber_Long(IntPtr ob); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyNumber_Float(IntPtr ob); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern bool PyNumber_Check(IntPtr ob); - internal static bool PyInt_Check(IntPtr ob) { return PyObject_TypeCheck(ob, PyIntType); @@ -900,48 +628,11 @@ internal static IntPtr PyInt_FromInt64(long value) return PyInt_FromLong(v); } -#if !PYTHON2 - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, - EntryPoint = "PyLong_FromLong")] - private static extern IntPtr PyInt_FromLong(IntPtr value); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, - EntryPoint = "PyLong_AsLong")] - internal static extern int PyInt_AsLong(IntPtr value); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, - EntryPoint = "PyLong_FromString")] - internal static extern IntPtr PyInt_FromString(string value, IntPtr end, int radix); -#else - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - private static extern IntPtr PyInt_FromLong(IntPtr value); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyInt_AsLong(IntPtr value); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyInt_FromString(string value, IntPtr end, int radix); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyInt_GetMax(); -#endif - internal static bool PyLong_Check(IntPtr ob) { return PyObject_TYPE(ob) == PyLongType; } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyLong_FromLong(long value); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, - EntryPoint = "PyLong_FromUnsignedLong")] - internal static extern IntPtr PyLong_FromUnsignedLong32(uint value); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, - EntryPoint = "PyLong_FromUnsignedLong")] - internal static extern IntPtr PyLong_FromUnsignedLong64(ulong value); - internal static IntPtr PyLong_FromUnsignedLong(object value) { if(Is32Bit || IsWindows) @@ -950,29 +641,6 @@ internal static IntPtr PyLong_FromUnsignedLong(object value) return PyLong_FromUnsignedLong64(Convert.ToUInt64(value)); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyLong_FromDouble(double value); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyLong_FromLongLong(long value); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyLong_FromUnsignedLongLong(ulong value); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyLong_FromString(string value, IntPtr end, int radix); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyLong_AsLong(IntPtr value); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, - EntryPoint = "PyLong_AsUnsignedLong")] - internal static extern uint PyLong_AsUnsignedLong32(IntPtr value); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, - EntryPoint = "PyLong_AsUnsignedLong")] - internal static extern ulong PyLong_AsUnsignedLong64(IntPtr value); - internal static object PyLong_AsUnsignedLong(IntPtr value) { if (Is32Bit || IsWindows) @@ -981,197 +649,60 @@ internal static object PyLong_AsUnsignedLong(IntPtr value) return PyLong_AsUnsignedLong64(value); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern long PyLong_AsLongLong(IntPtr value); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern ulong PyLong_AsUnsignedLongLong(IntPtr value); - internal static bool PyFloat_Check(IntPtr ob) { return PyObject_TYPE(ob) == PyFloatType; } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyFloat_FromDouble(double value); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyFloat_FromString(IntPtr value, IntPtr junk); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern double PyFloat_AsDouble(IntPtr ob); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyNumber_Add(IntPtr o1, IntPtr o2); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyNumber_Subtract(IntPtr o1, IntPtr o2); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyNumber_Multiply(IntPtr o1, IntPtr o2); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyNumber_TrueDivide(IntPtr o1, IntPtr o2); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyNumber_And(IntPtr o1, IntPtr o2); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyNumber_Xor(IntPtr o1, IntPtr o2); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyNumber_Or(IntPtr o1, IntPtr o2); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyNumber_Lshift(IntPtr o1, IntPtr o2); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyNumber_Rshift(IntPtr o1, IntPtr o2); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyNumber_Power(IntPtr o1, IntPtr o2); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyNumber_Remainder(IntPtr o1, IntPtr o2); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyNumber_InPlaceAdd(IntPtr o1, IntPtr o2); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyNumber_InPlaceSubtract(IntPtr o1, IntPtr o2); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyNumber_InPlaceMultiply(IntPtr o1, IntPtr o2); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyNumber_InPlaceTrueDivide(IntPtr o1, IntPtr o2); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyNumber_InPlaceAnd(IntPtr o1, IntPtr o2); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyNumber_InPlaceXor(IntPtr o1, IntPtr o2); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyNumber_InPlaceOr(IntPtr o1, IntPtr o2); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyNumber_InPlaceLshift(IntPtr o1, IntPtr o2); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyNumber_InPlaceRshift(IntPtr o1, IntPtr o2); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyNumber_InPlacePower(IntPtr o1, IntPtr o2); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyNumber_InPlaceRemainder(IntPtr o1, IntPtr o2); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyNumber_Negative(IntPtr o1); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyNumber_Positive(IntPtr o1); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyNumber_Invert(IntPtr o1); - - //==================================================================== // Python sequence API //==================================================================== - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern bool PySequence_Check(IntPtr pointer); - internal static IntPtr PySequence_GetItem(IntPtr pointer, long index) { return PySequence_GetItem(pointer, new IntPtr(index)); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - private static extern IntPtr PySequence_GetItem(IntPtr pointer, IntPtr index); - internal static int PySequence_SetItem(IntPtr pointer, long index, IntPtr value) { return PySequence_SetItem(pointer, new IntPtr(index), value); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - private static extern int PySequence_SetItem(IntPtr pointer, IntPtr index, IntPtr value); - internal static int PySequence_DelItem(IntPtr pointer, long index) { return PySequence_DelItem(pointer, new IntPtr(index)); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - private static extern int PySequence_DelItem(IntPtr pointer, IntPtr index); - internal static IntPtr PySequence_GetSlice(IntPtr pointer, long i1, long i2) { return PySequence_GetSlice(pointer, new IntPtr(i1), new IntPtr(i2)); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - private static extern IntPtr PySequence_GetSlice(IntPtr pointer, IntPtr i1, IntPtr i2); - internal static int PySequence_SetSlice(IntPtr pointer, long i1, long i2, IntPtr v) { return PySequence_SetSlice(pointer, new IntPtr(i1), new IntPtr(i2), v); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - private static extern int PySequence_SetSlice(IntPtr pointer, IntPtr i1, IntPtr i2, IntPtr v); - internal static int PySequence_DelSlice(IntPtr pointer, long i1, long i2) { return PySequence_DelSlice(pointer, new IntPtr(i1), new IntPtr(i2)); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - private static extern int PySequence_DelSlice(IntPtr pointer, IntPtr i1, IntPtr i2); - internal static long PySequence_Size(IntPtr pointer) { return (long) _PySequence_Size(pointer); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PySequence_Size")] - private static extern IntPtr _PySequence_Size(IntPtr pointer); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PySequence_Contains(IntPtr pointer, IntPtr item); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PySequence_Concat(IntPtr pointer, IntPtr other); - internal static IntPtr PySequence_Repeat(IntPtr pointer, long count) { return PySequence_Repeat(pointer, new IntPtr(count)); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - private static extern IntPtr PySequence_Repeat(IntPtr pointer, IntPtr count); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PySequence_Index(IntPtr pointer, IntPtr item); - internal static long PySequence_Count(IntPtr pointer, IntPtr value) { return (long) _PySequence_Count(pointer, value); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PySequence_Count")] - private static extern IntPtr _PySequence_Count(IntPtr pointer, IntPtr value); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PySequence_Tuple(IntPtr pointer); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PySequence_List(IntPtr pointer); - - //==================================================================== // Python string API //==================================================================== @@ -1197,17 +728,11 @@ internal static IntPtr PyString_FromString(string value) } #if !PYTHON2 - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyBytes_FromString(string op); - internal static long PyBytes_Size(IntPtr op) { return (long) _PyBytes_Size(op); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PyBytes_Size")] - private static extern IntPtr _PyBytes_Size(IntPtr op); - internal static IntPtr PyBytes_AS_STRING(IntPtr ob) { return ob + BytesOffset.ob_sval; @@ -1218,34 +743,15 @@ internal static IntPtr PyString_FromStringAndSize(string value, long size) return _PyString_FromStringAndSize(value, new IntPtr(size)); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, - EntryPoint = "PyUnicode_FromStringAndSize")] - internal static extern IntPtr _PyString_FromStringAndSize( - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string value, - IntPtr size - ); - internal static IntPtr PyUnicode_FromStringAndSize(IntPtr value, long size) { return PyUnicode_FromStringAndSize(value, new IntPtr(size)); } - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - private static extern IntPtr PyUnicode_FromStringAndSize(IntPtr value, IntPtr size); #else internal static IntPtr PyString_FromStringAndSize(string value, long size) { return PyString_FromStringAndSize(value, new IntPtr(size)); } - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - private static extern IntPtr PyString_FromStringAndSize(string value, IntPtr size); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyString_AsString(IntPtr op); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyString_Size(IntPtr pointer); #endif internal static bool PyUnicode_Check(IntPtr ob) @@ -1254,24 +760,11 @@ internal static bool PyUnicode_Check(IntPtr ob) } #if !PYTHON2 - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyUnicode_FromObject(IntPtr ob); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyUnicode_FromEncodedObject(IntPtr ob, IntPtr enc, IntPtr err); - internal static IntPtr PyUnicode_FromKindAndData(int kind, string s, long size) { return PyUnicode_FromKindAndData(kind, s, new IntPtr(size)); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - private static extern IntPtr PyUnicode_FromKindAndData( - int kind, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UcsMarshaler))] string s, - IntPtr size - ); - internal static IntPtr PyUnicode_FromUnicode(string s, long size) { return PyUnicode_FromKindAndData(_UCS, s, size); @@ -1282,51 +775,16 @@ internal static long PyUnicode_GetSize(IntPtr ob) return (long)_PyUnicode_GetSize(ob); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PyUnicode_GetSize")] - private static extern IntPtr _PyUnicode_GetSize(IntPtr ob); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyUnicode_AsUnicode(IntPtr ob); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyUnicode_FromOrdinal(int c); #else - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, - EntryPoint = PyUnicodeEntryPoint + "FromObject")] - internal static extern IntPtr PyUnicode_FromObject(IntPtr ob); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, - EntryPoint = PyUnicodeEntryPoint + "FromEncodedObject")] - internal static extern IntPtr PyUnicode_FromEncodedObject(IntPtr ob, IntPtr enc, IntPtr err); - internal static IntPtr PyUnicode_FromUnicode(string s, long size) { return PyUnicode_FromUnicode(s, new IntPtr(size)); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, - EntryPoint = PyUnicodeEntryPoint + "FromUnicode")] - private static extern IntPtr PyUnicode_FromUnicode( - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UcsMarshaler))] string s, - IntPtr size - ); - internal static long PyUnicode_GetSize(IntPtr ob) { return (long) _PyUnicode_GetSize(ob); } - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, - EntryPoint = PyUnicodeEntryPoint + "GetSize")] - internal static extern IntPtr _PyUnicode_GetSize(IntPtr ob); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, - EntryPoint = PyUnicodeEntryPoint + "AsUnicode")] - internal static extern IntPtr PyUnicode_AsUnicode(IntPtr ob); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, - EntryPoint = PyUnicodeEntryPoint + "FromOrdinal")] - internal static extern IntPtr PyUnicode_FromOrdinal(int c); #endif internal static IntPtr PyUnicode_FromString(string s) @@ -1382,59 +840,11 @@ internal static bool PyDict_Check(IntPtr ob) return PyObject_TYPE(ob) == PyDictType; } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyDict_New(); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyDictProxy_New(IntPtr dict); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyDict_GetItem(IntPtr pointer, IntPtr key); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyDict_GetItemString(IntPtr pointer, string key); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyDict_SetItem(IntPtr pointer, IntPtr key, IntPtr value); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyDict_SetItemString(IntPtr pointer, string key, IntPtr value); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyDict_DelItem(IntPtr pointer, IntPtr key); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyDict_DelItemString(IntPtr pointer, string key); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyMapping_HasKey(IntPtr pointer, IntPtr key); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyDict_Keys(IntPtr pointer); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyDict_Values(IntPtr pointer); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyDict_Items(IntPtr pointer); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyDict_Copy(IntPtr pointer); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyDict_Update(IntPtr pointer, IntPtr other); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void PyDict_Clear(IntPtr pointer); - internal static long PyDict_Size(IntPtr pointer) { return (long) _PyDict_Size(pointer); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PyDict_Size")] - internal static extern IntPtr _PyDict_Size(IntPtr pointer); - //==================================================================== // Python list API @@ -1450,69 +860,36 @@ internal static IntPtr PyList_New(long size) return PyList_New(new IntPtr(size)); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - private static extern IntPtr PyList_New(IntPtr size); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyList_AsTuple(IntPtr pointer); - internal static IntPtr PyList_GetItem(IntPtr pointer, long index) { return PyList_GetItem(pointer, new IntPtr(index)); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - private static extern IntPtr PyList_GetItem(IntPtr pointer, IntPtr index); - internal static int PyList_SetItem(IntPtr pointer, long index, IntPtr value) { return PyList_SetItem(pointer, new IntPtr(index), value); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - private static extern int PyList_SetItem(IntPtr pointer, IntPtr index, IntPtr value); - internal static int PyList_Insert(IntPtr pointer, long index, IntPtr value) { return PyList_Insert(pointer, new IntPtr(index), value); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - private static extern int PyList_Insert(IntPtr pointer, IntPtr index, IntPtr value); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyList_Append(IntPtr pointer, IntPtr value); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyList_Reverse(IntPtr pointer); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyList_Sort(IntPtr pointer); - internal static IntPtr PyList_GetSlice(IntPtr pointer, long start, long end) { return PyList_GetSlice(pointer, new IntPtr(start), new IntPtr(end)); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - private static extern IntPtr PyList_GetSlice(IntPtr pointer, IntPtr start, IntPtr end); - internal static int PyList_SetSlice(IntPtr pointer, long start, long end, IntPtr value) { return PyList_SetSlice(pointer, new IntPtr(start), new IntPtr(end), value); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - private static extern int PyList_SetSlice(IntPtr pointer, IntPtr start, IntPtr end, IntPtr value); - internal static long PyList_Size(IntPtr pointer) { return (long) _PyList_Size(pointer); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PyList_Size")] - private static extern IntPtr _PyList_Size(IntPtr pointer); - //==================================================================== // Python tuple API //==================================================================== @@ -1527,42 +904,26 @@ internal static IntPtr PyTuple_New(long size) return PyTuple_New(new IntPtr(size)); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - private static extern IntPtr PyTuple_New(IntPtr size); - internal static IntPtr PyTuple_GetItem(IntPtr pointer, long index) { return PyTuple_GetItem(pointer, new IntPtr(index)); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - private static extern IntPtr PyTuple_GetItem(IntPtr pointer, IntPtr index); - internal static int PyTuple_SetItem(IntPtr pointer, long index, IntPtr value) { return PyTuple_SetItem(pointer, new IntPtr(index), value); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - private static extern int PyTuple_SetItem(IntPtr pointer, IntPtr index, IntPtr value); - internal static IntPtr PyTuple_GetSlice(IntPtr pointer, long start, long end) { return PyTuple_GetSlice(pointer, new IntPtr(start), new IntPtr(end)); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - private static extern IntPtr PyTuple_GetSlice(IntPtr pointer, IntPtr start, IntPtr end); - internal static long PyTuple_Size(IntPtr pointer) { return (long) _PyTuple_Size(pointer); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PyTuple_Size")] - private static extern IntPtr _PyTuple_Size(IntPtr pointer); - - //==================================================================== // Python iterator API //==================================================================== @@ -1579,68 +940,6 @@ internal static bool PyIter_Check(IntPtr pointer) return tp_iternext != IntPtr.Zero && tp_iternext != _PyObject_NextNotImplemented; } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyIter_Next(IntPtr pointer); - - - //==================================================================== - // Python module API - //==================================================================== - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyModule_New(string name); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern string PyModule_GetName(IntPtr module); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyModule_GetDict(IntPtr module); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern string PyModule_GetFilename(IntPtr module); - -#if !PYTHON2 - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyModule_Create2(IntPtr module, int apiver); -#endif - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyImport_Import(IntPtr name); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyImport_ImportModule(string name); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyImport_ReloadModule(IntPtr module); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyImport_AddModule(string name); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyImport_GetModuleDict(); - -#if !PYTHON2 - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void PySys_SetArgvEx( - int argc, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StrArrayMarshaler))] string[] argv, - int updatepath - ); -#else - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void PySys_SetArgvEx( - int argc, - string[] argv, - int updatepath - ); -#endif - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PySys_GetObject(string name); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PySys_SetObject(string name, IntPtr ob); - //==================================================================== // Python type object API @@ -1651,56 +950,17 @@ internal static bool PyType_Check(IntPtr ob) return PyObject_TypeCheck(ob, PyTypeType); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void PyType_Modified(IntPtr type); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern bool PyType_IsSubtype(IntPtr t1, IntPtr t2); - internal static bool PyObject_TypeCheck(IntPtr ob, IntPtr tp) { IntPtr t = PyObject_TYPE(ob); return (t == tp) || PyType_IsSubtype(t, tp); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyType_GenericNew(IntPtr type, IntPtr args, IntPtr kw); - internal static IntPtr PyType_GenericAlloc(IntPtr type, long n) { return PyType_GenericAlloc(type, new IntPtr(n)); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - private static extern IntPtr PyType_GenericAlloc(IntPtr type, IntPtr n); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyType_Ready(IntPtr type); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr _PyType_Lookup(IntPtr type, IntPtr name); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyObject_GenericGetAttr(IntPtr obj, IntPtr name); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyObject_GenericSetAttr(IntPtr obj, IntPtr name, IntPtr value); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr _PyObject_GetDictPtr(IntPtr obj); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyObject_GC_New(IntPtr tp); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void PyObject_GC_Del(IntPtr tp); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void PyObject_GC_Track(IntPtr tp); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void PyObject_GC_UnTrack(IntPtr tp); - //==================================================================== // Python memory API @@ -1711,84 +971,17 @@ internal static IntPtr PyMem_Malloc(long size) return PyMem_Malloc(new IntPtr(size)); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - private static extern IntPtr PyMem_Malloc(IntPtr size); - internal static IntPtr PyMem_Realloc(IntPtr ptr, long size) { return PyMem_Realloc(ptr, new IntPtr(size)); } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - private static extern IntPtr PyMem_Realloc(IntPtr ptr, IntPtr size); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void PyMem_Free(IntPtr ptr); - - - //==================================================================== - // Python exception API - //==================================================================== - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void PyErr_SetString(IntPtr ob, string message); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void PyErr_SetObject(IntPtr ob, IntPtr message); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyErr_SetFromErrno(IntPtr ob); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void PyErr_SetNone(IntPtr ob); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyErr_ExceptionMatches(IntPtr exception); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int PyErr_GivenExceptionMatches(IntPtr ob, IntPtr val); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void PyErr_NormalizeException(IntPtr ob, IntPtr val, IntPtr tb); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyErr_Occurred(); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void PyErr_Fetch(ref IntPtr ob, ref IntPtr val, ref IntPtr tb); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void PyErr_Restore(IntPtr ob, IntPtr val, IntPtr tb); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void PyErr_Clear(); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern void PyErr_Print(); - - - //==================================================================== - // Miscellaneous - //==================================================================== - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyMethod_Self(IntPtr ob); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr PyMethod_Function(IntPtr ob); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int Py_AddPendingCall(IntPtr func, IntPtr arg); - - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] - internal static extern int Py_MakePendingCalls(); internal static void SetNoSiteFlag() { - var loader = LibraryLoader.Get(OperatingSystem); - - Py_NoSiteFlag = loader.GetFunction(IntPtr.Zero, "Py_NoSiteFlag"); - Marshal.WriteInt32(Py_NoSiteFlag, 1); + Py_NoSiteFlag = 1; } + + static Native.ILibPython LibPython; } } diff --git a/Python.Runtime/runtime_.cs b/Python.Runtime/runtime_.cs index 3ab6a3b76..47906dcbe 100644 --- a/Python.Runtime/runtime_.cs +++ b/Python.Runtime/runtime_.cs @@ -205,7 +205,7 @@ partial class Runtime { internal static System.Int32 PyErr_GivenExceptionMatches(System.IntPtr ob, System.IntPtr val) => LibPython.PyErr_GivenExceptionMatches(ob, val); internal static void PyErr_NormalizeException(System.IntPtr ob, System.IntPtr val, System.IntPtr tb) => LibPython.PyErr_NormalizeException(ob, val, tb); internal static System.IntPtr PyErr_Occurred() => LibPython.PyErr_Occurred(); - internal static void PyErr_Fetch(ref System.IntPtr ob, ref System.IntPtr val, ref System.IntPtr tb) => LibPython.PyErr_Fetch(ob, val, tb); + internal static void PyErr_Fetch(ref System.IntPtr ob, ref System.IntPtr val, ref System.IntPtr tb) => LibPython.PyErr_Fetch(ref ob, ref val, ref tb); internal static void PyErr_Restore(System.IntPtr ob, System.IntPtr val, System.IntPtr tb) => LibPython.PyErr_Restore(ob, val, tb); internal static void PyErr_Clear() => LibPython.PyErr_Clear(); internal static void PyErr_Print() => LibPython.PyErr_Print(); @@ -213,7 +213,9 @@ partial class Runtime { internal static System.IntPtr PyMethod_Function(System.IntPtr ob) => LibPython.PyMethod_Function(ob); internal static System.Int32 Py_AddPendingCall(System.IntPtr func, System.IntPtr arg) => LibPython.Py_AddPendingCall(func, arg); internal static System.Int32 Py_MakePendingCalls() => LibPython.Py_MakePendingCalls(); - internal static System.Int32 get_Py_NoSiteFlag() => LibPython.get_Py_NoSiteFlag(); - internal static void set_Py_NoSiteFlag(System.Int32 value) => LibPython.set_Py_NoSiteFlag(value); + internal static System.Int32 Py_NoSiteFlag { + get => LibPython.Py_NoSiteFlag; + set { LibPython.Py_NoSiteFlag = value; } + } } } diff --git a/Python.Runtime/runtime_.tt b/Python.Runtime/runtime_.tt index f0cc19c2c..3382f3d35 100644 --- a/Python.Runtime/runtime_.tt +++ b/Python.Runtime/runtime_.tt @@ -31,7 +31,7 @@ namespace Python.Runtime { internal static <#= FormatType(method.ReturnParameter.ParameterType) #> <#= method.Name #>(<#= string.Join(", ", method.GetParameters().Select(x => $"{FormatType(x.ParameterType)} {x.Name}")) #>) => LibPython.<#= method.Name #>(<#= - string.Join(", ", method.GetParameters().Select(x => x.Name)) + string.Join(", ", method.GetParameters().Select(x => (x.ParameterType.IsByRef ? "ref " : "") + x.Name)) #>); <# } From 908f0f09ba10382fd011471e3f244106c8f68f65 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Mon, 16 Dec 2019 23:13:19 +0100 Subject: [PATCH 17/22] Move interface to separate DLL for simpler dynamic loading --- .../ILibPython.cs | 5 +++-- Python.Runtime.Interfaces/Python.Runtime.Interfaces.csproj | 7 +++++++ Python.Runtime.Native/AssemblyInfo.cs | 6 ------ Python.Runtime.Native/Python.Runtime.Native.csproj | 4 ++++ .../CustomMarshaler.cs | 2 +- Python.Runtime/Python.Runtime.csproj | 1 + Python.Runtime/runtime.cs | 4 ++-- Python.Runtime/runtime_.cs | 6 ++---- Python.Runtime/runtime_.tt | 4 ++-- 9 files changed, 22 insertions(+), 17 deletions(-) rename {Python.Runtime.Native => Python.Runtime.Interfaces}/ILibPython.cs (99%) create mode 100644 Python.Runtime.Interfaces/Python.Runtime.Interfaces.csproj delete mode 100644 Python.Runtime.Native/AssemblyInfo.cs rename {Python.Runtime.Native => Python.Runtime}/CustomMarshaler.cs (98%) diff --git a/Python.Runtime.Native/ILibPython.cs b/Python.Runtime.Interfaces/ILibPython.cs similarity index 99% rename from Python.Runtime.Native/ILibPython.cs rename to Python.Runtime.Interfaces/ILibPython.cs index c30febed9..3709b6cdd 100644 --- a/Python.Runtime.Native/ILibPython.cs +++ b/Python.Runtime.Interfaces/ILibPython.cs @@ -5,7 +5,7 @@ using System.Threading; using System.Collections.Generic; -namespace Python.Runtime.Native +namespace Python.Runtime.Interfaces { public interface ILibPython { @@ -347,6 +347,7 @@ public interface ILibPython int Py_AddPendingCall(IntPtr func, IntPtr arg); int Py_MakePendingCalls(); - int Py_NoSiteFlag { get; set; } + int GetPyNoSiteFlag(); + void SetPyNoSiteFlag(int val); } } diff --git a/Python.Runtime.Interfaces/Python.Runtime.Interfaces.csproj b/Python.Runtime.Interfaces/Python.Runtime.Interfaces.csproj new file mode 100644 index 000000000..72764a664 --- /dev/null +++ b/Python.Runtime.Interfaces/Python.Runtime.Interfaces.csproj @@ -0,0 +1,7 @@ + + + + netstandard2.0 + + + diff --git a/Python.Runtime.Native/AssemblyInfo.cs b/Python.Runtime.Native/AssemblyInfo.cs deleted file mode 100644 index c8e5a1098..000000000 --- a/Python.Runtime.Native/AssemblyInfo.cs +++ /dev/null @@ -1,6 +0,0 @@ -using System; -using System.Runtime.CompilerServices; - -[assembly: CLSCompliant(true)] -[assembly: InternalsVisibleTo("Python.Test.Embed")] -[assembly: InternalsVisibleTo("Python.Runtime")] diff --git a/Python.Runtime.Native/Python.Runtime.Native.csproj b/Python.Runtime.Native/Python.Runtime.Native.csproj index 8cd2f745b..bc0ded96f 100644 --- a/Python.Runtime.Native/Python.Runtime.Native.csproj +++ b/Python.Runtime.Native/Python.Runtime.Native.csproj @@ -9,4 +9,8 @@ + + + + diff --git a/Python.Runtime.Native/CustomMarshaler.cs b/Python.Runtime/CustomMarshaler.cs similarity index 98% rename from Python.Runtime.Native/CustomMarshaler.cs rename to Python.Runtime/CustomMarshaler.cs index 775548b0f..5d2a00294 100644 --- a/Python.Runtime.Native/CustomMarshaler.cs +++ b/Python.Runtime/CustomMarshaler.cs @@ -218,7 +218,7 @@ public static ICustomMarshaler GetInstance(string cookie) internal class Utf8Marshaler : MarshalerBase { private static readonly MarshalerBase Instance = new Utf8Marshaler(); - private static readonly Encoding PyEncoding = Encoding.UTF8; + private static new readonly Encoding PyEncoding = Encoding.UTF8; public override IntPtr MarshalManagedToNative(object managedObj) { diff --git a/Python.Runtime/Python.Runtime.csproj b/Python.Runtime/Python.Runtime.csproj index 1b159e903..0a9b17594 100644 --- a/Python.Runtime/Python.Runtime.csproj +++ b/Python.Runtime/Python.Runtime.csproj @@ -12,6 +12,7 @@ + diff --git a/Python.Runtime/runtime.cs b/Python.Runtime/runtime.cs index 3164c384b..dd1ef7b26 100644 --- a/Python.Runtime/runtime.cs +++ b/Python.Runtime/runtime.cs @@ -979,9 +979,9 @@ internal static IntPtr PyMem_Realloc(IntPtr ptr, long size) internal static void SetNoSiteFlag() { - Py_NoSiteFlag = 1; + SetPyNoSiteFlag(1); } - static Native.ILibPython LibPython; + static Interfaces.ILibPython LibPython; } } diff --git a/Python.Runtime/runtime_.cs b/Python.Runtime/runtime_.cs index 47906dcbe..38ad9e6ad 100644 --- a/Python.Runtime/runtime_.cs +++ b/Python.Runtime/runtime_.cs @@ -213,9 +213,7 @@ partial class Runtime { internal static System.IntPtr PyMethod_Function(System.IntPtr ob) => LibPython.PyMethod_Function(ob); internal static System.Int32 Py_AddPendingCall(System.IntPtr func, System.IntPtr arg) => LibPython.Py_AddPendingCall(func, arg); internal static System.Int32 Py_MakePendingCalls() => LibPython.Py_MakePendingCalls(); - internal static System.Int32 Py_NoSiteFlag { - get => LibPython.Py_NoSiteFlag; - set { LibPython.Py_NoSiteFlag = value; } - } + internal static System.Int32 GetPyNoSiteFlag() => LibPython.GetPyNoSiteFlag(); + internal static void SetPyNoSiteFlag(System.Int32 val) => LibPython.SetPyNoSiteFlag(val); } } diff --git a/Python.Runtime/runtime_.tt b/Python.Runtime/runtime_.tt index 3382f3d35..7239594f4 100644 --- a/Python.Runtime/runtime_.tt +++ b/Python.Runtime/runtime_.tt @@ -20,9 +20,9 @@ namespace Python.Runtime { return type.ToString(); } - var path = $"{Directory.GetCurrentDirectory()}/Python.Runtime.Native/bin/Debug/netstandard2.0/Python.Runtime.Native.dll"; + var path = $"{Directory.GetCurrentDirectory()}/Python.Runtime.Interfaces/bin/Debug/netstandard2.0/Python.Runtime.Interfaces.dll"; var assembly = Assembly.LoadFile(path); - var type = assembly.GetType("Python.Runtime.Native.ILibPython"); + var type = assembly.GetType("Python.Runtime.Interfaces.ILibPython"); const BindingFlags flags = BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.Instance; var methods = type.GetMethods(flags); From 946b9a05c321d510389d037428f5f75a9f535104 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Tue, 17 Dec 2019 09:55:56 +0100 Subject: [PATCH 18/22] Add template to generate PInvoke-based implementation --- Python.Runtime.Native/CustomMarshaler.cs | 252 +++++++ ...oke.cs.dontcompile => LibPythonPInvoke.cs} | 658 +----------------- Python.Runtime.Native/LibPythonPInvoke_.cs | 220 ++++++ Python.Runtime.Native/LibPythonPInvoke_.tt | 41 ++ Python.Runtime/runtime.cs | 22 - 5 files changed, 523 insertions(+), 670 deletions(-) create mode 100644 Python.Runtime.Native/CustomMarshaler.cs rename Python.Runtime.Native/{LibPythonPInvoke.cs.dontcompile => LibPythonPInvoke.cs} (70%) create mode 100644 Python.Runtime.Native/LibPythonPInvoke_.cs create mode 100644 Python.Runtime.Native/LibPythonPInvoke_.tt diff --git a/Python.Runtime.Native/CustomMarshaler.cs b/Python.Runtime.Native/CustomMarshaler.cs new file mode 100644 index 000000000..5d2a00294 --- /dev/null +++ b/Python.Runtime.Native/CustomMarshaler.cs @@ -0,0 +1,252 @@ +using System; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; + +namespace Python.Runtime.Native +{ + /// + /// Abstract class defining boiler plate methods that + /// Custom Marshalers will use. + /// + internal abstract class MarshalerBase : ICustomMarshaler + { + #if UCS2 && PYTHON2 + internal static Encoding PyEncoding = Encoding.Unicode; + internal static int UCS = 2; + #else + internal static Encoding PyEncoding = Encoding.UTF32; + internal static int UCS = 4; + #endif + + public object MarshalNativeToManaged(IntPtr pNativeData) + { + throw new NotImplementedException(); + } + + public abstract IntPtr MarshalManagedToNative(object managedObj); + + public void CleanUpNativeData(IntPtr pNativeData) + { + Marshal.FreeHGlobal(pNativeData); + } + + public void CleanUpManagedData(object managedObj) + { + // Let GC deal with it + } + + public int GetNativeDataSize() + { + return IntPtr.Size; + } + } + + + /// + /// Custom Marshaler to deal with Managed String to Native + /// conversion differences on UCS2/UCS4. + /// + internal class UcsMarshaler : MarshalerBase + { + private static readonly MarshalerBase Instance = new UcsMarshaler(); + + public override IntPtr MarshalManagedToNative(object managedObj) + { + var s = managedObj as string; + + if (s == null) + { + return IntPtr.Zero; + } + + byte[] bStr = PyEncoding.GetBytes(s + "\0"); + IntPtr mem = Marshal.AllocHGlobal(bStr.Length); + try + { + Marshal.Copy(bStr, 0, mem, bStr.Length); + } + catch (Exception) + { + Marshal.FreeHGlobal(mem); + throw; + } + + return mem; + } + + public static ICustomMarshaler GetInstance(string cookie) + { + return Instance; + } + + public static string PtrToStringUni(IntPtr p) + { + if (p == IntPtr.Zero) + { + return null; + } + + int size = GetUnicodeByteLength(p); + var buffer = new byte[size]; + Marshal.Copy(p, buffer, 0, size); + return PyEncoding.GetString(buffer, 0, size); + } + + public static int GetUnicodeByteLength(IntPtr p) + { + var len = 0; + while (true) + { +#if UCS2 && PYTHON2 + int c = Marshal.ReadInt16(p, len * 2); +#else + int c = Marshal.ReadInt32(p, len * 4); +#endif + + if (c == 0) + { + return len * UCS; + } + checked + { + ++len; + } + } + } + + /// + /// Utility function for Marshaling Unicode on PY3 and AnsiStr on PY2. + /// Use on functions whose Input signatures changed between PY2/PY3. + /// Ex. Py_SetPythonHome + /// + /// Managed String + /// + /// Ptr to Native String ANSI(PY2)/Unicode(PY3/UCS2)/UTF32(PY3/UCS4. + /// + /// + /// You MUST deallocate the IntPtr of the Return when done with it. + /// + public static IntPtr Py3UnicodePy2StringtoPtr(string s) + { +#if PYTHON2 + return Marshal.StringToHGlobalAnsi(s); +#else + return Instance.MarshalManagedToNative(s); +#endif + } + + /// + /// Utility function for Marshaling Unicode IntPtr on PY3 and + /// AnsiStr IntPtr on PY2 to Managed Strings. Use on Python functions + /// whose return type changed between PY2/PY3. + /// Ex. Py_GetPythonHome + /// + /// Native Ansi/Unicode/UTF32 String + /// + /// Managed String + /// + public static string PtrToPy3UnicodePy2String(IntPtr p) + { +#if PYTHON2 + return Marshal.PtrToStringAnsi(p); +#else + return PtrToStringUni(p); +#endif + } + } + + + /// + /// Custom Marshaler to deal with Managed String Arrays to Native + /// conversion differences on UCS2/UCS4. + /// + internal class StrArrayMarshaler : MarshalerBase + { + private static readonly MarshalerBase Instance = new StrArrayMarshaler(); + + public override IntPtr MarshalManagedToNative(object managedObj) + { + var argv = managedObj as string[]; + + if (argv == null) + { + return IntPtr.Zero; + } + + int totalStrLength = argv.Sum(arg => arg.Length + 1); + int memSize = argv.Length * IntPtr.Size + totalStrLength * UCS; + + IntPtr mem = Marshal.AllocHGlobal(memSize); + try + { + // Preparing array of pointers to strings + IntPtr curStrPtr = mem + argv.Length * IntPtr.Size; + for (var i = 0; i < argv.Length; i++) + { + byte[] bStr = PyEncoding.GetBytes(argv[i] + "\0"); + Marshal.Copy(bStr, 0, curStrPtr, bStr.Length); + Marshal.WriteIntPtr(mem + i * IntPtr.Size, curStrPtr); + curStrPtr += bStr.Length; + } + } + catch (Exception) + { + Marshal.FreeHGlobal(mem); + throw; + } + + return mem; + } + + public static ICustomMarshaler GetInstance(string cookie) + { + return Instance; + } + } + + + /// + /// Custom Marshaler to deal with Managed String to Native + /// conversion on UTF-8. Use on functions that expect UTF-8 encoded + /// strings like `PyUnicode_FromStringAndSize` + /// + /// + /// If instead we used `MarshalAs(UnmanagedType.LPWStr)` the output to + /// `foo` would be `f\x00o\x00o\x00`. + /// + internal class Utf8Marshaler : MarshalerBase + { + private static readonly MarshalerBase Instance = new Utf8Marshaler(); + private static new readonly Encoding PyEncoding = Encoding.UTF8; + + public override IntPtr MarshalManagedToNative(object managedObj) + { + var s = managedObj as string; + + if (s == null) + { + return IntPtr.Zero; + } + + byte[] bStr = PyEncoding.GetBytes(s + "\0"); + IntPtr mem = Marshal.AllocHGlobal(bStr.Length); + try + { + Marshal.Copy(bStr, 0, mem, bStr.Length); + } + catch (Exception) + { + Marshal.FreeHGlobal(mem); + throw; + } + + return mem; + } + + public static ICustomMarshaler GetInstance(string cookie) + { + return Instance; + } + } +} diff --git a/Python.Runtime.Native/LibPythonPInvoke.cs.dontcompile b/Python.Runtime.Native/LibPythonPInvoke.cs similarity index 70% rename from Python.Runtime.Native/LibPythonPInvoke.cs.dontcompile rename to Python.Runtime.Native/LibPythonPInvoke.cs index 27c2a225e..798b25968 100644 --- a/Python.Runtime.Native/LibPythonPInvoke.cs.dontcompile +++ b/Python.Runtime.Native/LibPythonPInvoke.cs @@ -4,10 +4,11 @@ using System.Text; using System.Threading; using System.Collections.Generic; +using Python.Runtime.Interfaces; namespace Python.Runtime.Native { - public class LibPythonPInvoke : ILibPython + public partial class LibPythonPInvoke : ILibPython { // C# compiler copies constants to the assemblies that references this library. // We needs to replace all public constants to static readonly fields to allow @@ -15,7 +16,7 @@ public class LibPythonPInvoke : ILibPython public static int UCS => _UCS; -#if UCS2 +#if !UCS2 internal const int _UCS = 4; /// @@ -36,419 +37,16 @@ public class LibPythonPInvoke : ILibPython internal const string _PythonDll = "__Internal"; // set to true when python is finalizing - internal static object IsFinalizingLock = new object(); - internal static bool IsFinalizing; - internal static bool Is32Bit = IntPtr.Size == 4; // .NET core: System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Windows) internal static bool IsWindows = Environment.OSVersion.Platform == PlatformID.Win32NT; - public static int MainManagedThreadId { get; private set; } - /// /// Encoding to use to convert Unicode to/from Managed to Native /// internal static readonly Encoding PyEncoding = _UCS == 2 ? Encoding.Unicode : Encoding.UTF32; - /// - /// Initialize the runtime... - /// - internal static void Initialize(bool initSigs = false) - { - if (Py_IsInitialized() == 0) - { - Py_InitializeEx(initSigs ? 1 : 0); - MainManagedThreadId = Thread.CurrentThread.ManagedThreadId; - } - - if (PyEval_ThreadsInitialized() == 0) - { - PyEval_InitThreads(); - } - - IsFinalizing = false; - - CLRModule.Reset(); - GenericUtil.Reset(); - PyScopeManager.Reset(); - ClassManager.Reset(); - ClassDerivedObject.Reset(); - TypeManager.Reset(); - - IntPtr op; - IntPtr dict; - if (IsPython3) - { - op = PyImport_ImportModule("builtins"); - dict = PyObject_GetAttrString(op, "__dict__"); - } - else // Python2 - { - dict = PyImport_GetModuleDict(); - op = PyDict_GetItemString(dict, "__builtin__"); - } - PyNotImplemented = PyObject_GetAttrString(op, "NotImplemented"); - PyBaseObjectType = PyObject_GetAttrString(op, "object"); - - PyNone = PyObject_GetAttrString(op, "None"); - PyTrue = PyObject_GetAttrString(op, "True"); - PyFalse = PyObject_GetAttrString(op, "False"); - - PyBoolType = PyObject_Type(PyTrue); - PyNoneType = PyObject_Type(PyNone); - PyTypeType = PyObject_Type(PyNoneType); - - op = PyObject_GetAttrString(dict, "keys"); - PyMethodType = PyObject_Type(op); - XDecref(op); - - // For some arcane reason, builtins.__dict__.__setitem__ is *not* - // a wrapper_descriptor, even though dict.__setitem__ is. - // - // object.__init__ seems safe, though. - op = PyObject_GetAttrString(PyBaseObjectType, "__init__"); - PyWrapperDescriptorType = PyObject_Type(op); - XDecref(op); - -#if !PYTHON2 - XDecref(dict); -#endif - - op = PyString_FromString("string"); - PyStringType = PyObject_Type(op); - XDecref(op); - - op = PyUnicode_FromString("unicode"); - PyUnicodeType = PyObject_Type(op); - XDecref(op); - -#if !PYTHON2 - op = PyBytes_FromString("bytes"); - PyBytesType = PyObject_Type(op); - XDecref(op); -#endif - - op = PyTuple_New(0); - PyTupleType = PyObject_Type(op); - XDecref(op); - - op = PyList_New(0); - PyListType = PyObject_Type(op); - XDecref(op); - - op = PyDict_New(); - PyDictType = PyObject_Type(op); - XDecref(op); - - op = PyInt_FromInt32(0); - PyIntType = PyObject_Type(op); - XDecref(op); - - op = PyLong_FromLong(0); - PyLongType = PyObject_Type(op); - XDecref(op); - - op = PyFloat_FromDouble(0); - PyFloatType = PyObject_Type(op); - XDecref(op); - - PyClassType = IntPtr.Zero; - PyInstanceType = IntPtr.Zero; - -#if PYTHON2 - IntPtr s = PyString_FromString("_temp"); - IntPtr d = PyDict_New(); - - IntPtr c = PyClass_New(IntPtr.Zero, d, s); - PyClassType = PyObject_Type(c); - - IntPtr i = PyInstance_New(c, IntPtr.Zero, IntPtr.Zero); - PyInstanceType = PyObject_Type(i); - - XDecref(s); - XDecref(i); - XDecref(c); - XDecref(d); -#endif - - Error = new IntPtr(-1); - - // Initialize data about the platform we're running on. We need - // this for the type manager and potentially other details. Must - // happen after caching the python types, above. - InitializePlatformData(); - - IntPtr dllLocal = IntPtr.Zero; - var loader = LibraryLoader.Get(OperatingSystem); - - if (_PythonDll != "__Internal") - { - dllLocal = loader.Load(_PythonDll); - } - _PyObject_NextNotImplemented = loader.GetFunction(dllLocal, "_PyObject_NextNotImplemented"); - PyModuleType = loader.GetFunction(dllLocal, "PyModule_Type"); - - if (dllLocal != IntPtr.Zero) - { - loader.Free(dllLocal); - } - - // Initialize modules that depend on the runtime class. - AssemblyManager.Initialize(); - PyCLRMetaType = MetaType.Initialize(); - Exceptions.Initialize(); - ImportHook.Initialize(); - - // Need to add the runtime directory to sys.path so that we - // can find built-in assemblies like System.Data, et. al. - string rtdir = RuntimeEnvironment.GetRuntimeDirectory(); - IntPtr path = PySys_GetObject("path"); - IntPtr item = PyString_FromString(rtdir); - PyList_Append(path, item); - XDecref(item); - AssemblyManager.UpdatePath(); - } - - /// - /// Initializes the data about platforms. - /// - /// This must be the last step when initializing the runtime: - /// GetManagedString needs to have the cached values for types. - /// But it must run before initializing anything outside the runtime - /// because those rely on the platform data. - /// - private static void InitializePlatformData() - { - IntPtr op; - IntPtr fn; - IntPtr platformModule = PyImport_ImportModule("platform"); - IntPtr emptyTuple = PyTuple_New(0); - - fn = PyObject_GetAttrString(platformModule, "system"); - op = PyObject_Call(fn, emptyTuple, IntPtr.Zero); - OperatingSystemName = GetManagedString(op); - XDecref(op); - XDecref(fn); - - fn = PyObject_GetAttrString(platformModule, "machine"); - op = PyObject_Call(fn, emptyTuple, IntPtr.Zero); - MachineName = GetManagedString(op); - XDecref(op); - XDecref(fn); - - XDecref(emptyTuple); - XDecref(platformModule); - - // Now convert the strings into enum values so we can do switch - // statements rather than constant parsing. - OperatingSystemType OSType; - if (!OperatingSystemTypeMapping.TryGetValue(OperatingSystemName, out OSType)) - { - OSType = OperatingSystemType.Other; - } - OperatingSystem = OSType; - - MachineType MType; - if (!MachineTypeMapping.TryGetValue(MachineName.ToLower(), out MType)) - { - MType = MachineType.Other; - } - Machine = MType; - } - - internal static void Shutdown() - { - AssemblyManager.Shutdown(); - Exceptions.Shutdown(); - ImportHook.Shutdown(); - Finalizer.Shutdown(); - Py_Finalize(); - } - - // called *without* the GIL acquired by clr._AtExit - internal static int AtExit() - { - lock (IsFinalizingLock) - { - IsFinalizing = true; - } - return 0; - } - - internal static IntPtr Py_single_input = (IntPtr)256; - internal static IntPtr Py_file_input = (IntPtr)257; - internal static IntPtr Py_eval_input = (IntPtr)258; - - internal static IntPtr PyBaseObjectType; - internal static IntPtr PyModuleType; - internal static IntPtr PyClassType; - internal static IntPtr PyInstanceType; - internal static IntPtr PyCLRMetaType; - internal static IntPtr PyMethodType; - internal static IntPtr PyWrapperDescriptorType; - - internal static IntPtr PyUnicodeType; - internal static IntPtr PyStringType; - internal static IntPtr PyTupleType; - internal static IntPtr PyListType; - internal static IntPtr PyDictType; - internal static IntPtr PyIntType; - internal static IntPtr PyLongType; - internal static IntPtr PyFloatType; - internal static IntPtr PyBoolType; - internal static IntPtr PyNoneType; - internal static IntPtr PyTypeType; - - internal static IntPtr Py_NoSiteFlag; - - internal static IntPtr PyBytesType; - internal static IntPtr _PyObject_NextNotImplemented; - - internal static IntPtr PyNotImplemented; - internal const int Py_LT = 0; - internal const int Py_LE = 1; - internal const int Py_EQ = 2; - internal const int Py_NE = 3; - internal const int Py_GT = 4; - internal const int Py_GE = 5; - - internal static IntPtr PyTrue; - internal static IntPtr PyFalse; - internal static IntPtr PyNone; - internal static IntPtr Error; - - /// - /// Check if any Python Exceptions occurred. - /// If any exist throw new PythonException. - /// - /// - /// Can be used instead of `obj == IntPtr.Zero` for example. - /// - internal static void CheckExceptionOccurred() - { - if (PyErr_Occurred() != IntPtr.Zero) - { - throw new PythonException(); - } - } - - internal static IntPtr ExtendTuple(IntPtr t, params IntPtr[] args) - { - var size = PyTuple_Size(t); - int add = args.Length; - IntPtr item; - - IntPtr items = PyTuple_New(size + add); - for (var i = 0; i < size; i++) - { - item = PyTuple_GetItem(t, i); - XIncref(item); - PyTuple_SetItem(items, i, item); - } - - for (var n = 0; n < add; n++) - { - item = args[n]; - XIncref(item); - PyTuple_SetItem(items, size + n, item); - } - - return items; - } - - internal static Type[] PythonArgsToTypeArray(IntPtr arg) - { - return PythonArgsToTypeArray(arg, false); - } - - internal static Type[] PythonArgsToTypeArray(IntPtr arg, bool mangleObjects) - { - // Given a PyObject * that is either a single type object or a - // tuple of (managed or unmanaged) type objects, return a Type[] - // containing the CLR Type objects that map to those types. - IntPtr args = arg; - var free = false; - - if (!PyTuple_Check(arg)) - { - args = PyTuple_New(1); - XIncref(arg); - PyTuple_SetItem(args, 0, arg); - free = true; - } - - var n = PyTuple_Size(args); - var types = new Type[n]; - Type t = null; - - for (var i = 0; i < n; i++) - { - IntPtr op = PyTuple_GetItem(args, i); - if (mangleObjects && (!PyType_Check(op))) - { - op = PyObject_TYPE(op); - } - ManagedType mt = ManagedType.GetManagedObject(op); - - if (mt is ClassBase) - { - t = ((ClassBase)mt).type; - } - else if (mt is CLRObject) - { - object inst = ((CLRObject)mt).inst; - if (inst is Type) - { - t = inst as Type; - } - } - else - { - t = Converter.GetTypeByAlias(op); - } - - if (t == null) - { - types = null; - break; - } - types[i] = t; - } - if (free) - { - XDecref(args); - } - return types; - } - - /// - /// Managed exports of the Python C API. Where appropriate, we do - /// some optimization to avoid managed <--> unmanaged transitions - /// (mostly for heavily used methods). - /// - internal static unsafe void XIncref(IntPtr op) - { - Py_IncRef(op); - return; - } - - internal static unsafe void XDecref(IntPtr op) - { - Py_DecRef(op); - return; - } - - internal static unsafe long Refcount(IntPtr op) - { - var p = (void*)op; - if ((void*)0 == p) - { - return 0; - } - return Is32Bit ? (*(int*)p) : (*(long*)p); - } - /// /// Export of Macro Py_XIncRef. Use XIncref instead. /// Limit this function usage for Testing and Py_Debug builds @@ -650,40 +248,6 @@ internal static unsafe IntPtr PyObject_TYPE(IntPtr op) : new IntPtr((void*)(*((ulong*)p + n))); } - /// - /// Managed version of the standard Python C API PyObject_Type call. - /// This version avoids a managed <-> unmanaged transition. - /// This one does incref the returned type object. - /// - internal static IntPtr PyObject_Type(IntPtr op) - { - IntPtr tp = PyObject_TYPE(op); - XIncref(tp); - return tp; - } - - internal static string PyObject_GetTypeName(IntPtr op) - { - IntPtr pyType = Marshal.ReadIntPtr(op, ObjectOffset.ob_type); - IntPtr ppName = Marshal.ReadIntPtr(pyType, TypeOffset.tp_name); - return Marshal.PtrToStringAnsi(ppName); - } - - /// - /// Test whether the Python object is an iterable. - /// - internal static bool PyObject_IsIterable(IntPtr pointer) - { - var ob_type = Marshal.ReadIntPtr(pointer, ObjectOffset.ob_type); -#if PYTHON2 - long tp_flags = Util.ReadCLong(ob_type, TypeOffset.tp_flags); - if ((tp_flags & TypeFlags.HaveIter) == 0) - return false; -#endif - IntPtr tp_iter = Marshal.ReadIntPtr(ob_type, TypeOffset.tp_iter); - return tp_iter != IntPtr.Zero; - } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern int PyObject_HasAttrString(IntPtr pointer, string name); @@ -723,31 +287,6 @@ internal static bool PyObject_IsIterable(IntPtr pointer) [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern int PyObject_RichCompareBool(IntPtr value1, IntPtr value2, int opid); - internal static int PyObject_Compare(IntPtr value1, IntPtr value2) - { - int res; - res = PyObject_RichCompareBool(value1, value2, Py_LT); - if (-1 == res) - return -1; - else if (1 == res) - return -1; - - res = PyObject_RichCompareBool(value1, value2, Py_EQ); - if (-1 == res) - return -1; - else if (1 == res) - return 0; - - res = PyObject_RichCompareBool(value1, value2, Py_GT); - if (-1 == res) - return -1; - else if (1 == res) - return 1; - - Exceptions.SetError(Exceptions.SystemError, "Error comparing objects"); - return -1; - } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern int PyObject_IsInstance(IntPtr ob, IntPtr type); @@ -763,11 +302,6 @@ internal static int PyObject_Compare(IntPtr value1, IntPtr value2) [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern int PyObject_Not(IntPtr pointer); - internal static long PyObject_Size(IntPtr pointer) - { - return (long) _PyObject_Size(pointer); - } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PyObject_Size")] private static extern IntPtr _PyObject_Size(IntPtr pointer); @@ -815,28 +349,6 @@ internal static long PyObject_Size(IntPtr pointer) [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern bool PyNumber_Check(IntPtr ob); - internal static bool PyInt_Check(IntPtr ob) - { - return PyObject_TypeCheck(ob, PyIntType); - } - - internal static bool PyBool_Check(IntPtr ob) - { - return PyObject_TypeCheck(ob, PyBoolType); - } - - internal static IntPtr PyInt_FromInt32(int value) - { - var v = new IntPtr(value); - return PyInt_FromLong(v); - } - - internal static IntPtr PyInt_FromInt64(long value) - { - var v = new IntPtr(value); - return PyInt_FromLong(v); - } - #if !PYTHON2 [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PyLong_FromLong")] @@ -863,11 +375,6 @@ internal static IntPtr PyInt_FromInt64(long value) internal static extern int PyInt_GetMax(); #endif - internal static bool PyLong_Check(IntPtr ob) - { - return PyObject_TYPE(ob) == PyLongType; - } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern IntPtr PyLong_FromLong(long value); @@ -924,11 +431,6 @@ internal static object PyLong_AsUnsignedLong(IntPtr value) [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern ulong PyLong_AsUnsignedLongLong(IntPtr value); - internal static bool PyFloat_Check(IntPtr ob) - { - return PyObject_TYPE(ob) == PyFloatType; - } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern IntPtr PyFloat_FromDouble(double value); @@ -1113,17 +615,6 @@ internal static long PySequence_Count(IntPtr pointer, IntPtr value) // Python string API //==================================================================== - internal static bool IsStringType(IntPtr op) - { - IntPtr t = PyObject_TYPE(op); - return (t == PyStringType) || (t == PyUnicodeType); - } - - internal static bool PyString_Check(IntPtr ob) - { - return PyObject_TYPE(ob) == PyStringType; - } - internal static IntPtr PyString_FromString(string value) { #if !PYTHON2 @@ -1137,24 +628,9 @@ internal static IntPtr PyString_FromString(string value) [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern IntPtr PyBytes_FromString(string op); - internal static long PyBytes_Size(IntPtr op) - { - return (long) _PyBytes_Size(op); - } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PyBytes_Size")] private static extern IntPtr _PyBytes_Size(IntPtr op); - internal static IntPtr PyBytes_AS_STRING(IntPtr ob) - { - return ob + BytesOffset.ob_sval; - } - - internal static IntPtr PyString_FromStringAndSize(string value, long size) - { - return _PyString_FromStringAndSize(value, new IntPtr(size)); - } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PyUnicode_FromStringAndSize")] internal static extern IntPtr _PyString_FromStringAndSize( @@ -1261,20 +737,10 @@ internal static long PyUnicode_GetSize(IntPtr ob) internal static extern IntPtr PyUnicode_FromOrdinal(int c); #endif - internal static IntPtr PyUnicode_FromString(string s) - { - return PyUnicode_FromUnicode(s, s.Length); - } - //==================================================================== // Python dictionary API //==================================================================== - internal static bool PyDict_Check(IntPtr ob) - { - return PyObject_TYPE(ob) == PyDictType; - } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern IntPtr PyDict_New(); @@ -1333,43 +799,18 @@ internal static long PyDict_Size(IntPtr pointer) // Python list API //==================================================================== - internal static bool PyList_Check(IntPtr ob) - { - return PyObject_TYPE(ob) == PyListType; - } - - internal static IntPtr PyList_New(long size) - { - return PyList_New(new IntPtr(size)); - } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] private static extern IntPtr PyList_New(IntPtr size); [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern IntPtr PyList_AsTuple(IntPtr pointer); - internal static IntPtr PyList_GetItem(IntPtr pointer, long index) - { - return PyList_GetItem(pointer, new IntPtr(index)); - } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] private static extern IntPtr PyList_GetItem(IntPtr pointer, IntPtr index); - internal static int PyList_SetItem(IntPtr pointer, long index, IntPtr value) - { - return PyList_SetItem(pointer, new IntPtr(index), value); - } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] private static extern int PyList_SetItem(IntPtr pointer, IntPtr index, IntPtr value); - internal static int PyList_Insert(IntPtr pointer, long index, IntPtr value) - { - return PyList_Insert(pointer, new IntPtr(index), value); - } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] private static extern int PyList_Insert(IntPtr pointer, IntPtr index, IntPtr value); @@ -1382,27 +823,12 @@ internal static int PyList_Insert(IntPtr pointer, long index, IntPtr value) [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern int PyList_Sort(IntPtr pointer); - internal static IntPtr PyList_GetSlice(IntPtr pointer, long start, long end) - { - return PyList_GetSlice(pointer, new IntPtr(start), new IntPtr(end)); - } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] private static extern IntPtr PyList_GetSlice(IntPtr pointer, IntPtr start, IntPtr end); - internal static int PyList_SetSlice(IntPtr pointer, long start, long end, IntPtr value) - { - return PyList_SetSlice(pointer, new IntPtr(start), new IntPtr(end), value); - } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] private static extern int PyList_SetSlice(IntPtr pointer, IntPtr start, IntPtr end, IntPtr value); - internal static long PyList_Size(IntPtr pointer) - { - return (long) _PyList_Size(pointer); - } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PyList_Size")] private static extern IntPtr _PyList_Size(IntPtr pointer); @@ -1410,48 +836,18 @@ internal static long PyList_Size(IntPtr pointer) // Python tuple API //==================================================================== - internal static bool PyTuple_Check(IntPtr ob) - { - return PyObject_TYPE(ob) == PyTupleType; - } - - internal static IntPtr PyTuple_New(long size) - { - return PyTuple_New(new IntPtr(size)); - } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] private static extern IntPtr PyTuple_New(IntPtr size); - internal static IntPtr PyTuple_GetItem(IntPtr pointer, long index) - { - return PyTuple_GetItem(pointer, new IntPtr(index)); - } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] private static extern IntPtr PyTuple_GetItem(IntPtr pointer, IntPtr index); - internal static int PyTuple_SetItem(IntPtr pointer, long index, IntPtr value) - { - return PyTuple_SetItem(pointer, new IntPtr(index), value); - } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] private static extern int PyTuple_SetItem(IntPtr pointer, IntPtr index, IntPtr value); - internal static IntPtr PyTuple_GetSlice(IntPtr pointer, long start, long end) - { - return PyTuple_GetSlice(pointer, new IntPtr(start), new IntPtr(end)); - } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] private static extern IntPtr PyTuple_GetSlice(IntPtr pointer, IntPtr start, IntPtr end); - internal static long PyTuple_Size(IntPtr pointer) - { - return (long) _PyTuple_Size(pointer); - } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PyTuple_Size")] private static extern IntPtr _PyTuple_Size(IntPtr pointer); @@ -1460,18 +856,6 @@ internal static long PyTuple_Size(IntPtr pointer) // Python iterator API //==================================================================== - internal static bool PyIter_Check(IntPtr pointer) - { - var ob_type = Marshal.ReadIntPtr(pointer, ObjectOffset.ob_type); -#if PYTHON2 - long tp_flags = Util.ReadCLong(ob_type, TypeOffset.tp_flags); - if ((tp_flags & TypeFlags.HaveIter) == 0) - return false; -#endif - IntPtr tp_iternext = Marshal.ReadIntPtr(ob_type, TypeOffset.tp_iternext); - return tp_iternext != IntPtr.Zero && tp_iternext != _PyObject_NextNotImplemented; - } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern IntPtr PyIter_Next(IntPtr pointer); @@ -1539,31 +923,15 @@ int updatepath // Python type object API //==================================================================== - internal static bool PyType_Check(IntPtr ob) - { - return PyObject_TypeCheck(ob, PyTypeType); - } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern void PyType_Modified(IntPtr type); [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern bool PyType_IsSubtype(IntPtr t1, IntPtr t2); - internal static bool PyObject_TypeCheck(IntPtr ob, IntPtr tp) - { - IntPtr t = PyObject_TYPE(ob); - return (t == tp) || PyType_IsSubtype(t, tp); - } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern IntPtr PyType_GenericNew(IntPtr type, IntPtr args, IntPtr kw); - internal static IntPtr PyType_GenericAlloc(IntPtr type, long n) - { - return PyType_GenericAlloc(type, new IntPtr(n)); - } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] private static extern IntPtr PyType_GenericAlloc(IntPtr type, IntPtr n); @@ -1599,19 +967,9 @@ internal static IntPtr PyType_GenericAlloc(IntPtr type, long n) // Python memory API //==================================================================== - internal static IntPtr PyMem_Malloc(long size) - { - return PyMem_Malloc(new IntPtr(size)); - } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] private static extern IntPtr PyMem_Malloc(IntPtr size); - internal static IntPtr PyMem_Realloc(IntPtr ptr, long size) - { - return PyMem_Realloc(ptr, new IntPtr(size)); - } - [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] private static extern IntPtr PyMem_Realloc(IntPtr ptr, IntPtr size); @@ -1676,11 +1034,15 @@ internal static IntPtr PyMem_Realloc(IntPtr ptr, long size) [DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)] internal static extern int Py_MakePendingCalls(); - public int ILibPython.Py_MakePendingCalls() => Py_MakePendingCalls(); - public int Py_NoSiteFlag { - get; set; + static void SetPyNoSiteFlag(int val) { + } + + static int GetPyNoSiteFlag() { + return 0; + } + /* { var loader = LibraryLoader.Get(OperatingSystem); diff --git a/Python.Runtime.Native/LibPythonPInvoke_.cs b/Python.Runtime.Native/LibPythonPInvoke_.cs new file mode 100644 index 000000000..a0e643b20 --- /dev/null +++ b/Python.Runtime.Native/LibPythonPInvoke_.cs @@ -0,0 +1,220 @@ +using Python.Runtime.Interfaces; + +namespace Python.Runtime.Native { + + public partial class LibPythonPInvoke { + void ILibPython.Py_IncRef(System.IntPtr ob) => LibPythonPInvoke.Py_IncRef(ob); + void ILibPython.Py_DecRef(System.IntPtr ob) => LibPythonPInvoke.Py_DecRef(ob); + void ILibPython.Py_InitializeEx(System.Int32 initsigs) => LibPythonPInvoke.Py_InitializeEx(initsigs); + System.Int32 ILibPython.Py_IsInitialized() => LibPythonPInvoke.Py_IsInitialized(); + void ILibPython.Py_Finalize() => LibPythonPInvoke.Py_Finalize(); + System.IntPtr ILibPython.PyGILState_Ensure() => LibPythonPInvoke.PyGILState_Ensure(); + void ILibPython.PyGILState_Release(System.IntPtr gs) => LibPythonPInvoke.PyGILState_Release(gs); + void ILibPython.PyEval_InitThreads() => LibPythonPInvoke.PyEval_InitThreads(); + System.Int32 ILibPython.PyEval_ThreadsInitialized() => LibPythonPInvoke.PyEval_ThreadsInitialized(); + void ILibPython.PyEval_AcquireLock() => LibPythonPInvoke.PyEval_AcquireLock(); + void ILibPython.PyEval_ReleaseLock() => LibPythonPInvoke.PyEval_ReleaseLock(); + System.IntPtr ILibPython.PyEval_SaveThread() => LibPythonPInvoke.PyEval_SaveThread(); + void ILibPython.PyEval_RestoreThread(System.IntPtr tstate) => LibPythonPInvoke.PyEval_RestoreThread(tstate); + System.IntPtr ILibPython.PyEval_GetBuiltins() => LibPythonPInvoke.PyEval_GetBuiltins(); + System.IntPtr ILibPython.PyEval_GetGlobals() => LibPythonPInvoke.PyEval_GetGlobals(); + System.IntPtr ILibPython.PyEval_GetLocals() => LibPythonPInvoke.PyEval_GetLocals(); + System.IntPtr ILibPython.Py_GetProgramName() => LibPythonPInvoke.Py_GetProgramName(); + void ILibPython.Py_SetProgramName(System.IntPtr name) => LibPythonPInvoke.Py_SetProgramName(name); + System.IntPtr ILibPython.Py_GetPythonHome() => LibPythonPInvoke.Py_GetPythonHome(); + void ILibPython.Py_SetPythonHome(System.IntPtr home) => LibPythonPInvoke.Py_SetPythonHome(home); + System.IntPtr ILibPython.Py_GetPath() => LibPythonPInvoke.Py_GetPath(); + void ILibPython.Py_SetPath(System.IntPtr home) => LibPythonPInvoke.Py_SetPath(home); + System.IntPtr ILibPython.Py_GetVersion() => LibPythonPInvoke.Py_GetVersion(); + System.IntPtr ILibPython.Py_GetPlatform() => LibPythonPInvoke.Py_GetPlatform(); + System.IntPtr ILibPython.Py_GetCopyright() => LibPythonPInvoke.Py_GetCopyright(); + System.IntPtr ILibPython.Py_GetCompiler() => LibPythonPInvoke.Py_GetCompiler(); + System.IntPtr ILibPython.Py_GetBuildInfo() => LibPythonPInvoke.Py_GetBuildInfo(); + System.Int32 ILibPython.PyRun_SimpleString(System.String code) => LibPythonPInvoke.PyRun_SimpleString(code); + System.IntPtr ILibPython.PyRun_String(System.String code, System.IntPtr st, System.IntPtr globals, System.IntPtr locals) => LibPythonPInvoke.PyRun_String(code, st, globals, locals); + System.IntPtr ILibPython.PyEval_EvalCode(System.IntPtr co, System.IntPtr globals, System.IntPtr locals) => LibPythonPInvoke.PyEval_EvalCode(co, globals, locals); + System.IntPtr ILibPython.Py_CompileString(System.String code, System.String file, System.IntPtr tok) => LibPythonPInvoke.Py_CompileString(code, file, tok); + System.IntPtr ILibPython.PyImport_ExecCodeModule(System.String name, System.IntPtr code) => LibPythonPInvoke.PyImport_ExecCodeModule(name, code); + System.IntPtr ILibPython.PyCFunction_NewEx(System.IntPtr ml, System.IntPtr self, System.IntPtr mod) => LibPythonPInvoke.PyCFunction_NewEx(ml, self, mod); + System.IntPtr ILibPython.PyCFunction_Call(System.IntPtr func, System.IntPtr args, System.IntPtr kw) => LibPythonPInvoke.PyCFunction_Call(func, args, kw); + System.IntPtr ILibPython.PyInstance_New(System.IntPtr cls, System.IntPtr args, System.IntPtr kw) => LibPythonPInvoke.PyInstance_New(cls, args, kw); + System.IntPtr ILibPython.PyInstance_NewRaw(System.IntPtr cls, System.IntPtr dict) => LibPythonPInvoke.PyInstance_NewRaw(cls, dict); + System.IntPtr ILibPython.PyMethod_New(System.IntPtr func, System.IntPtr self, System.IntPtr cls) => LibPythonPInvoke.PyMethod_New(func, self, cls); + System.Int32 ILibPython.PyObject_HasAttrString(System.IntPtr pointer, System.String name) => LibPythonPInvoke.PyObject_HasAttrString(pointer, name); + System.IntPtr ILibPython.PyObject_GetAttrString(System.IntPtr pointer, System.String name) => LibPythonPInvoke.PyObject_GetAttrString(pointer, name); + System.Int32 ILibPython.PyObject_SetAttrString(System.IntPtr pointer, System.String name, System.IntPtr value) => LibPythonPInvoke.PyObject_SetAttrString(pointer, name, value); + System.Int32 ILibPython.PyObject_HasAttr(System.IntPtr pointer, System.IntPtr name) => LibPythonPInvoke.PyObject_HasAttr(pointer, name); + System.IntPtr ILibPython.PyObject_GetAttr(System.IntPtr pointer, System.IntPtr name) => LibPythonPInvoke.PyObject_GetAttr(pointer, name); + System.Int32 ILibPython.PyObject_SetAttr(System.IntPtr pointer, System.IntPtr name, System.IntPtr value) => LibPythonPInvoke.PyObject_SetAttr(pointer, name, value); + System.IntPtr ILibPython.PyObject_GetItem(System.IntPtr pointer, System.IntPtr key) => LibPythonPInvoke.PyObject_GetItem(pointer, key); + System.Int32 ILibPython.PyObject_SetItem(System.IntPtr pointer, System.IntPtr key, System.IntPtr value) => LibPythonPInvoke.PyObject_SetItem(pointer, key, value); + System.Int32 ILibPython.PyObject_DelItem(System.IntPtr pointer, System.IntPtr key) => LibPythonPInvoke.PyObject_DelItem(pointer, key); + System.IntPtr ILibPython.PyObject_GetIter(System.IntPtr op) => LibPythonPInvoke.PyObject_GetIter(op); + System.IntPtr ILibPython.PyObject_Call(System.IntPtr pointer, System.IntPtr args, System.IntPtr kw) => LibPythonPInvoke.PyObject_Call(pointer, args, kw); + System.IntPtr ILibPython.PyObject_CallObject(System.IntPtr pointer, System.IntPtr args) => LibPythonPInvoke.PyObject_CallObject(pointer, args); + System.Int32 ILibPython.PyObject_RichCompareBool(System.IntPtr value1, System.IntPtr value2, System.Int32 opid) => LibPythonPInvoke.PyObject_RichCompareBool(value1, value2, opid); + System.Int32 ILibPython.PyObject_IsInstance(System.IntPtr ob, System.IntPtr type) => LibPythonPInvoke.PyObject_IsInstance(ob, type); + System.Int32 ILibPython.PyObject_IsSubclass(System.IntPtr ob, System.IntPtr type) => LibPythonPInvoke.PyObject_IsSubclass(ob, type); + System.Int32 ILibPython.PyCallable_Check(System.IntPtr pointer) => LibPythonPInvoke.PyCallable_Check(pointer); + System.Int32 ILibPython.PyObject_IsTrue(System.IntPtr pointer) => LibPythonPInvoke.PyObject_IsTrue(pointer); + System.Int32 ILibPython.PyObject_Not(System.IntPtr pointer) => LibPythonPInvoke.PyObject_Not(pointer); + System.IntPtr ILibPython._PyObject_Size(System.IntPtr pointer) => LibPythonPInvoke._PyObject_Size(pointer); + System.IntPtr ILibPython.PyObject_Hash(System.IntPtr op) => LibPythonPInvoke.PyObject_Hash(op); + System.IntPtr ILibPython.PyObject_Repr(System.IntPtr pointer) => LibPythonPInvoke.PyObject_Repr(pointer); + System.IntPtr ILibPython.PyObject_Str(System.IntPtr pointer) => LibPythonPInvoke.PyObject_Str(pointer); + System.IntPtr ILibPython.PyObject_Unicode(System.IntPtr pointer) => LibPythonPInvoke.PyObject_Unicode(pointer); + System.IntPtr ILibPython.PyObject_Dir(System.IntPtr pointer) => LibPythonPInvoke.PyObject_Dir(pointer); + System.IntPtr ILibPython.PyNumber_Int(System.IntPtr ob) => LibPythonPInvoke.PyNumber_Int(ob); + System.IntPtr ILibPython.PyNumber_Long(System.IntPtr ob) => LibPythonPInvoke.PyNumber_Long(ob); + System.IntPtr ILibPython.PyNumber_Float(System.IntPtr ob) => LibPythonPInvoke.PyNumber_Float(ob); + System.Boolean ILibPython.PyNumber_Check(System.IntPtr ob) => LibPythonPInvoke.PyNumber_Check(ob); + System.IntPtr ILibPython.PyInt_FromLong(System.IntPtr value) => LibPythonPInvoke.PyInt_FromLong(value); + System.Int32 ILibPython.PyInt_AsLong(System.IntPtr value) => LibPythonPInvoke.PyInt_AsLong(value); + System.IntPtr ILibPython.PyInt_FromString(System.String value, System.IntPtr end, System.Int32 radix) => LibPythonPInvoke.PyInt_FromString(value, end, radix); + System.IntPtr ILibPython.PyLong_FromLong(System.Int64 value) => LibPythonPInvoke.PyLong_FromLong(value); + System.IntPtr ILibPython.PyLong_FromUnsignedLong32(System.UInt32 value) => LibPythonPInvoke.PyLong_FromUnsignedLong32(value); + System.IntPtr ILibPython.PyLong_FromUnsignedLong64(System.UInt64 value) => LibPythonPInvoke.PyLong_FromUnsignedLong64(value); + System.IntPtr ILibPython.PyLong_FromDouble(System.Double value) => LibPythonPInvoke.PyLong_FromDouble(value); + System.IntPtr ILibPython.PyLong_FromLongLong(System.Int64 value) => LibPythonPInvoke.PyLong_FromLongLong(value); + System.IntPtr ILibPython.PyLong_FromUnsignedLongLong(System.UInt64 value) => LibPythonPInvoke.PyLong_FromUnsignedLongLong(value); + System.IntPtr ILibPython.PyLong_FromString(System.String value, System.IntPtr end, System.Int32 radix) => LibPythonPInvoke.PyLong_FromString(value, end, radix); + System.Int32 ILibPython.PyLong_AsLong(System.IntPtr value) => LibPythonPInvoke.PyLong_AsLong(value); + System.UInt32 ILibPython.PyLong_AsUnsignedLong32(System.IntPtr value) => LibPythonPInvoke.PyLong_AsUnsignedLong32(value); + System.UInt64 ILibPython.PyLong_AsUnsignedLong64(System.IntPtr value) => LibPythonPInvoke.PyLong_AsUnsignedLong64(value); + System.Int64 ILibPython.PyLong_AsLongLong(System.IntPtr value) => LibPythonPInvoke.PyLong_AsLongLong(value); + System.UInt64 ILibPython.PyLong_AsUnsignedLongLong(System.IntPtr value) => LibPythonPInvoke.PyLong_AsUnsignedLongLong(value); + System.IntPtr ILibPython.PyFloat_FromDouble(System.Double value) => LibPythonPInvoke.PyFloat_FromDouble(value); + System.IntPtr ILibPython.PyFloat_FromString(System.IntPtr value, System.IntPtr junk) => LibPythonPInvoke.PyFloat_FromString(value, junk); + System.Double ILibPython.PyFloat_AsDouble(System.IntPtr ob) => LibPythonPInvoke.PyFloat_AsDouble(ob); + System.IntPtr ILibPython.PyNumber_Add(System.IntPtr o1, System.IntPtr o2) => LibPythonPInvoke.PyNumber_Add(o1, o2); + System.IntPtr ILibPython.PyNumber_Subtract(System.IntPtr o1, System.IntPtr o2) => LibPythonPInvoke.PyNumber_Subtract(o1, o2); + System.IntPtr ILibPython.PyNumber_Multiply(System.IntPtr o1, System.IntPtr o2) => LibPythonPInvoke.PyNumber_Multiply(o1, o2); + System.IntPtr ILibPython.PyNumber_TrueDivide(System.IntPtr o1, System.IntPtr o2) => LibPythonPInvoke.PyNumber_TrueDivide(o1, o2); + System.IntPtr ILibPython.PyNumber_And(System.IntPtr o1, System.IntPtr o2) => LibPythonPInvoke.PyNumber_And(o1, o2); + System.IntPtr ILibPython.PyNumber_Xor(System.IntPtr o1, System.IntPtr o2) => LibPythonPInvoke.PyNumber_Xor(o1, o2); + System.IntPtr ILibPython.PyNumber_Or(System.IntPtr o1, System.IntPtr o2) => LibPythonPInvoke.PyNumber_Or(o1, o2); + System.IntPtr ILibPython.PyNumber_Lshift(System.IntPtr o1, System.IntPtr o2) => LibPythonPInvoke.PyNumber_Lshift(o1, o2); + System.IntPtr ILibPython.PyNumber_Rshift(System.IntPtr o1, System.IntPtr o2) => LibPythonPInvoke.PyNumber_Rshift(o1, o2); + System.IntPtr ILibPython.PyNumber_Power(System.IntPtr o1, System.IntPtr o2) => LibPythonPInvoke.PyNumber_Power(o1, o2); + System.IntPtr ILibPython.PyNumber_Remainder(System.IntPtr o1, System.IntPtr o2) => LibPythonPInvoke.PyNumber_Remainder(o1, o2); + System.IntPtr ILibPython.PyNumber_InPlaceAdd(System.IntPtr o1, System.IntPtr o2) => LibPythonPInvoke.PyNumber_InPlaceAdd(o1, o2); + System.IntPtr ILibPython.PyNumber_InPlaceSubtract(System.IntPtr o1, System.IntPtr o2) => LibPythonPInvoke.PyNumber_InPlaceSubtract(o1, o2); + System.IntPtr ILibPython.PyNumber_InPlaceMultiply(System.IntPtr o1, System.IntPtr o2) => LibPythonPInvoke.PyNumber_InPlaceMultiply(o1, o2); + System.IntPtr ILibPython.PyNumber_InPlaceTrueDivide(System.IntPtr o1, System.IntPtr o2) => LibPythonPInvoke.PyNumber_InPlaceTrueDivide(o1, o2); + System.IntPtr ILibPython.PyNumber_InPlaceAnd(System.IntPtr o1, System.IntPtr o2) => LibPythonPInvoke.PyNumber_InPlaceAnd(o1, o2); + System.IntPtr ILibPython.PyNumber_InPlaceXor(System.IntPtr o1, System.IntPtr o2) => LibPythonPInvoke.PyNumber_InPlaceXor(o1, o2); + System.IntPtr ILibPython.PyNumber_InPlaceOr(System.IntPtr o1, System.IntPtr o2) => LibPythonPInvoke.PyNumber_InPlaceOr(o1, o2); + System.IntPtr ILibPython.PyNumber_InPlaceLshift(System.IntPtr o1, System.IntPtr o2) => LibPythonPInvoke.PyNumber_InPlaceLshift(o1, o2); + System.IntPtr ILibPython.PyNumber_InPlaceRshift(System.IntPtr o1, System.IntPtr o2) => LibPythonPInvoke.PyNumber_InPlaceRshift(o1, o2); + System.IntPtr ILibPython.PyNumber_InPlacePower(System.IntPtr o1, System.IntPtr o2) => LibPythonPInvoke.PyNumber_InPlacePower(o1, o2); + System.IntPtr ILibPython.PyNumber_InPlaceRemainder(System.IntPtr o1, System.IntPtr o2) => LibPythonPInvoke.PyNumber_InPlaceRemainder(o1, o2); + System.IntPtr ILibPython.PyNumber_Negative(System.IntPtr o1) => LibPythonPInvoke.PyNumber_Negative(o1); + System.IntPtr ILibPython.PyNumber_Positive(System.IntPtr o1) => LibPythonPInvoke.PyNumber_Positive(o1); + System.IntPtr ILibPython.PyNumber_Invert(System.IntPtr o1) => LibPythonPInvoke.PyNumber_Invert(o1); + System.Boolean ILibPython.PySequence_Check(System.IntPtr pointer) => LibPythonPInvoke.PySequence_Check(pointer); + System.IntPtr ILibPython.PySequence_GetItem(System.IntPtr pointer, System.IntPtr index) => LibPythonPInvoke.PySequence_GetItem(pointer, index); + System.Int32 ILibPython.PySequence_SetItem(System.IntPtr pointer, System.IntPtr index, System.IntPtr value) => LibPythonPInvoke.PySequence_SetItem(pointer, index, value); + System.Int32 ILibPython.PySequence_DelItem(System.IntPtr pointer, System.IntPtr index) => LibPythonPInvoke.PySequence_DelItem(pointer, index); + System.IntPtr ILibPython.PySequence_GetSlice(System.IntPtr pointer, System.IntPtr i1, System.IntPtr i2) => LibPythonPInvoke.PySequence_GetSlice(pointer, i1, i2); + System.Int32 ILibPython.PySequence_SetSlice(System.IntPtr pointer, System.IntPtr i1, System.IntPtr i2, System.IntPtr v) => LibPythonPInvoke.PySequence_SetSlice(pointer, i1, i2, v); + System.Int32 ILibPython.PySequence_DelSlice(System.IntPtr pointer, System.IntPtr i1, System.IntPtr i2) => LibPythonPInvoke.PySequence_DelSlice(pointer, i1, i2); + System.IntPtr ILibPython._PySequence_Size(System.IntPtr pointer) => LibPythonPInvoke._PySequence_Size(pointer); + System.Int32 ILibPython.PySequence_Contains(System.IntPtr pointer, System.IntPtr item) => LibPythonPInvoke.PySequence_Contains(pointer, item); + System.IntPtr ILibPython.PySequence_Concat(System.IntPtr pointer, System.IntPtr other) => LibPythonPInvoke.PySequence_Concat(pointer, other); + System.IntPtr ILibPython.PySequence_Repeat(System.IntPtr pointer, System.IntPtr count) => LibPythonPInvoke.PySequence_Repeat(pointer, count); + System.Int32 ILibPython.PySequence_Index(System.IntPtr pointer, System.IntPtr item) => LibPythonPInvoke.PySequence_Index(pointer, item); + System.IntPtr ILibPython._PySequence_Count(System.IntPtr pointer, System.IntPtr value) => LibPythonPInvoke._PySequence_Count(pointer, value); + System.IntPtr ILibPython.PySequence_Tuple(System.IntPtr pointer) => LibPythonPInvoke.PySequence_Tuple(pointer); + System.IntPtr ILibPython.PySequence_List(System.IntPtr pointer) => LibPythonPInvoke.PySequence_List(pointer); + System.IntPtr ILibPython.PyBytes_FromString(System.String op) => LibPythonPInvoke.PyBytes_FromString(op); + System.IntPtr ILibPython._PyBytes_Size(System.IntPtr op) => LibPythonPInvoke._PyBytes_Size(op); + System.IntPtr ILibPython._PyString_FromStringAndSize(System.String value, System.IntPtr size) => LibPythonPInvoke._PyString_FromStringAndSize(value, size); + System.IntPtr ILibPython.PyUnicode_FromStringAndSize(System.IntPtr value, System.IntPtr size) => LibPythonPInvoke.PyUnicode_FromStringAndSize(value, size); + System.IntPtr ILibPython.PyUnicode_FromOrdinal(System.Int32 c) => LibPythonPInvoke.PyUnicode_FromOrdinal(c); + System.IntPtr ILibPython.PyUnicode_AsUnicode(System.IntPtr ob) => LibPythonPInvoke.PyUnicode_AsUnicode(ob); + System.IntPtr ILibPython.PyUnicode_FromObject(System.IntPtr ob) => LibPythonPInvoke.PyUnicode_FromObject(ob); + System.IntPtr ILibPython.PyUnicode_FromEncodedObject(System.IntPtr ob, System.IntPtr enc, System.IntPtr err) => LibPythonPInvoke.PyUnicode_FromEncodedObject(ob, enc, err); + System.IntPtr ILibPython._PyUnicode_GetSize(System.IntPtr ob) => LibPythonPInvoke._PyUnicode_GetSize(ob); + System.IntPtr ILibPython.PyUnicode_FromKindAndData(System.Int32 kind, System.String s, System.IntPtr size) => LibPythonPInvoke.PyUnicode_FromKindAndData(kind, s, size); + System.IntPtr ILibPython.PyDict_New() => LibPythonPInvoke.PyDict_New(); + System.IntPtr ILibPython.PyDictProxy_New(System.IntPtr dict) => LibPythonPInvoke.PyDictProxy_New(dict); + System.IntPtr ILibPython.PyDict_GetItem(System.IntPtr pointer, System.IntPtr key) => LibPythonPInvoke.PyDict_GetItem(pointer, key); + System.IntPtr ILibPython.PyDict_GetItemString(System.IntPtr pointer, System.String key) => LibPythonPInvoke.PyDict_GetItemString(pointer, key); + System.Int32 ILibPython.PyDict_SetItem(System.IntPtr pointer, System.IntPtr key, System.IntPtr value) => LibPythonPInvoke.PyDict_SetItem(pointer, key, value); + System.Int32 ILibPython.PyDict_SetItemString(System.IntPtr pointer, System.String key, System.IntPtr value) => LibPythonPInvoke.PyDict_SetItemString(pointer, key, value); + System.Int32 ILibPython.PyDict_DelItem(System.IntPtr pointer, System.IntPtr key) => LibPythonPInvoke.PyDict_DelItem(pointer, key); + System.Int32 ILibPython.PyDict_DelItemString(System.IntPtr pointer, System.String key) => LibPythonPInvoke.PyDict_DelItemString(pointer, key); + System.Int32 ILibPython.PyMapping_HasKey(System.IntPtr pointer, System.IntPtr key) => LibPythonPInvoke.PyMapping_HasKey(pointer, key); + System.IntPtr ILibPython.PyDict_Keys(System.IntPtr pointer) => LibPythonPInvoke.PyDict_Keys(pointer); + System.IntPtr ILibPython.PyDict_Values(System.IntPtr pointer) => LibPythonPInvoke.PyDict_Values(pointer); + System.IntPtr ILibPython.PyDict_Items(System.IntPtr pointer) => LibPythonPInvoke.PyDict_Items(pointer); + System.IntPtr ILibPython.PyDict_Copy(System.IntPtr pointer) => LibPythonPInvoke.PyDict_Copy(pointer); + System.Int32 ILibPython.PyDict_Update(System.IntPtr pointer, System.IntPtr other) => LibPythonPInvoke.PyDict_Update(pointer, other); + void ILibPython.PyDict_Clear(System.IntPtr pointer) => LibPythonPInvoke.PyDict_Clear(pointer); + System.IntPtr ILibPython._PyDict_Size(System.IntPtr pointer) => LibPythonPInvoke._PyDict_Size(pointer); + System.IntPtr ILibPython.PyList_New(System.IntPtr size) => LibPythonPInvoke.PyList_New(size); + System.IntPtr ILibPython.PyList_AsTuple(System.IntPtr pointer) => LibPythonPInvoke.PyList_AsTuple(pointer); + System.IntPtr ILibPython.PyList_GetItem(System.IntPtr pointer, System.IntPtr index) => LibPythonPInvoke.PyList_GetItem(pointer, index); + System.Int32 ILibPython.PyList_SetItem(System.IntPtr pointer, System.IntPtr index, System.IntPtr value) => LibPythonPInvoke.PyList_SetItem(pointer, index, value); + System.Int32 ILibPython.PyList_Insert(System.IntPtr pointer, System.IntPtr index, System.IntPtr value) => LibPythonPInvoke.PyList_Insert(pointer, index, value); + System.Int32 ILibPython.PyList_Append(System.IntPtr pointer, System.IntPtr value) => LibPythonPInvoke.PyList_Append(pointer, value); + System.Int32 ILibPython.PyList_Reverse(System.IntPtr pointer) => LibPythonPInvoke.PyList_Reverse(pointer); + System.Int32 ILibPython.PyList_Sort(System.IntPtr pointer) => LibPythonPInvoke.PyList_Sort(pointer); + System.IntPtr ILibPython.PyList_GetSlice(System.IntPtr pointer, System.IntPtr start, System.IntPtr end) => LibPythonPInvoke.PyList_GetSlice(pointer, start, end); + System.Int32 ILibPython.PyList_SetSlice(System.IntPtr pointer, System.IntPtr start, System.IntPtr end, System.IntPtr value) => LibPythonPInvoke.PyList_SetSlice(pointer, start, end, value); + System.IntPtr ILibPython._PyList_Size(System.IntPtr pointer) => LibPythonPInvoke._PyList_Size(pointer); + System.IntPtr ILibPython.PyTuple_New(System.IntPtr size) => LibPythonPInvoke.PyTuple_New(size); + System.IntPtr ILibPython.PyTuple_GetItem(System.IntPtr pointer, System.IntPtr index) => LibPythonPInvoke.PyTuple_GetItem(pointer, index); + System.Int32 ILibPython.PyTuple_SetItem(System.IntPtr pointer, System.IntPtr index, System.IntPtr value) => LibPythonPInvoke.PyTuple_SetItem(pointer, index, value); + System.IntPtr ILibPython.PyTuple_GetSlice(System.IntPtr pointer, System.IntPtr start, System.IntPtr end) => LibPythonPInvoke.PyTuple_GetSlice(pointer, start, end); + System.IntPtr ILibPython._PyTuple_Size(System.IntPtr pointer) => LibPythonPInvoke._PyTuple_Size(pointer); + System.IntPtr ILibPython.PyIter_Next(System.IntPtr pointer) => LibPythonPInvoke.PyIter_Next(pointer); + System.IntPtr ILibPython.PyModule_New(System.String name) => LibPythonPInvoke.PyModule_New(name); + System.String ILibPython.PyModule_GetName(System.IntPtr module) => LibPythonPInvoke.PyModule_GetName(module); + System.IntPtr ILibPython.PyModule_GetDict(System.IntPtr module) => LibPythonPInvoke.PyModule_GetDict(module); + System.String ILibPython.PyModule_GetFilename(System.IntPtr module) => LibPythonPInvoke.PyModule_GetFilename(module); + System.IntPtr ILibPython.PyModule_Create2(System.IntPtr module, System.Int32 apiver) => LibPythonPInvoke.PyModule_Create2(module, apiver); + System.IntPtr ILibPython.PyImport_Import(System.IntPtr name) => LibPythonPInvoke.PyImport_Import(name); + System.IntPtr ILibPython.PyImport_ImportModule(System.String name) => LibPythonPInvoke.PyImport_ImportModule(name); + System.IntPtr ILibPython.PyImport_ReloadModule(System.IntPtr module) => LibPythonPInvoke.PyImport_ReloadModule(module); + System.IntPtr ILibPython.PyImport_AddModule(System.String name) => LibPythonPInvoke.PyImport_AddModule(name); + System.IntPtr ILibPython.PyImport_GetModuleDict() => LibPythonPInvoke.PyImport_GetModuleDict(); + void ILibPython.PySys_SetArgvEx(System.Int32 argc, System.String[] argv, System.Int32 updatepath) => LibPythonPInvoke.PySys_SetArgvEx(argc, argv, updatepath); + System.IntPtr ILibPython.PySys_GetObject(System.String name) => LibPythonPInvoke.PySys_GetObject(name); + System.Int32 ILibPython.PySys_SetObject(System.String name, System.IntPtr ob) => LibPythonPInvoke.PySys_SetObject(name, ob); + void ILibPython.PyType_Modified(System.IntPtr type) => LibPythonPInvoke.PyType_Modified(type); + System.Boolean ILibPython.PyType_IsSubtype(System.IntPtr t1, System.IntPtr t2) => LibPythonPInvoke.PyType_IsSubtype(t1, t2); + System.IntPtr ILibPython.PyType_GenericNew(System.IntPtr type, System.IntPtr args, System.IntPtr kw) => LibPythonPInvoke.PyType_GenericNew(type, args, kw); + System.IntPtr ILibPython.PyType_GenericAlloc(System.IntPtr type, System.IntPtr n) => LibPythonPInvoke.PyType_GenericAlloc(type, n); + System.Int32 ILibPython.PyType_Ready(System.IntPtr type) => LibPythonPInvoke.PyType_Ready(type); + System.IntPtr ILibPython._PyType_Lookup(System.IntPtr type, System.IntPtr name) => LibPythonPInvoke._PyType_Lookup(type, name); + System.IntPtr ILibPython.PyObject_GenericGetAttr(System.IntPtr obj, System.IntPtr name) => LibPythonPInvoke.PyObject_GenericGetAttr(obj, name); + System.Int32 ILibPython.PyObject_GenericSetAttr(System.IntPtr obj, System.IntPtr name, System.IntPtr value) => LibPythonPInvoke.PyObject_GenericSetAttr(obj, name, value); + System.IntPtr ILibPython._PyObject_GetDictPtr(System.IntPtr obj) => LibPythonPInvoke._PyObject_GetDictPtr(obj); + System.IntPtr ILibPython.PyObject_GC_New(System.IntPtr tp) => LibPythonPInvoke.PyObject_GC_New(tp); + void ILibPython.PyObject_GC_Del(System.IntPtr tp) => LibPythonPInvoke.PyObject_GC_Del(tp); + void ILibPython.PyObject_GC_Track(System.IntPtr tp) => LibPythonPInvoke.PyObject_GC_Track(tp); + void ILibPython.PyObject_GC_UnTrack(System.IntPtr tp) => LibPythonPInvoke.PyObject_GC_UnTrack(tp); + System.IntPtr ILibPython.PyMem_Malloc(System.IntPtr size) => LibPythonPInvoke.PyMem_Malloc(size); + System.IntPtr ILibPython.PyMem_Realloc(System.IntPtr ptr, System.IntPtr size) => LibPythonPInvoke.PyMem_Realloc(ptr, size); + void ILibPython.PyMem_Free(System.IntPtr ptr) => LibPythonPInvoke.PyMem_Free(ptr); + void ILibPython.PyErr_SetString(System.IntPtr ob, System.String message) => LibPythonPInvoke.PyErr_SetString(ob, message); + void ILibPython.PyErr_SetObject(System.IntPtr ob, System.IntPtr message) => LibPythonPInvoke.PyErr_SetObject(ob, message); + System.IntPtr ILibPython.PyErr_SetFromErrno(System.IntPtr ob) => LibPythonPInvoke.PyErr_SetFromErrno(ob); + void ILibPython.PyErr_SetNone(System.IntPtr ob) => LibPythonPInvoke.PyErr_SetNone(ob); + System.Int32 ILibPython.PyErr_ExceptionMatches(System.IntPtr exception) => LibPythonPInvoke.PyErr_ExceptionMatches(exception); + System.Int32 ILibPython.PyErr_GivenExceptionMatches(System.IntPtr ob, System.IntPtr val) => LibPythonPInvoke.PyErr_GivenExceptionMatches(ob, val); + void ILibPython.PyErr_NormalizeException(System.IntPtr ob, System.IntPtr val, System.IntPtr tb) => LibPythonPInvoke.PyErr_NormalizeException(ob, val, tb); + System.IntPtr ILibPython.PyErr_Occurred() => LibPythonPInvoke.PyErr_Occurred(); + void ILibPython.PyErr_Fetch(ref System.IntPtr ob, ref System.IntPtr val, ref System.IntPtr tb) => LibPythonPInvoke.PyErr_Fetch(ref ob, ref val, ref tb); + void ILibPython.PyErr_Restore(System.IntPtr ob, System.IntPtr val, System.IntPtr tb) => LibPythonPInvoke.PyErr_Restore(ob, val, tb); + void ILibPython.PyErr_Clear() => LibPythonPInvoke.PyErr_Clear(); + void ILibPython.PyErr_Print() => LibPythonPInvoke.PyErr_Print(); + System.IntPtr ILibPython.PyMethod_Self(System.IntPtr ob) => LibPythonPInvoke.PyMethod_Self(ob); + System.IntPtr ILibPython.PyMethod_Function(System.IntPtr ob) => LibPythonPInvoke.PyMethod_Function(ob); + System.Int32 ILibPython.Py_AddPendingCall(System.IntPtr func, System.IntPtr arg) => LibPythonPInvoke.Py_AddPendingCall(func, arg); + System.Int32 ILibPython.Py_MakePendingCalls() => LibPythonPInvoke.Py_MakePendingCalls(); + System.Int32 ILibPython.GetPyNoSiteFlag() => LibPythonPInvoke.GetPyNoSiteFlag(); + void ILibPython.SetPyNoSiteFlag(System.Int32 val) => LibPythonPInvoke.SetPyNoSiteFlag(val); + } +} diff --git a/Python.Runtime.Native/LibPythonPInvoke_.tt b/Python.Runtime.Native/LibPythonPInvoke_.tt new file mode 100644 index 000000000..8cc1eadcf --- /dev/null +++ b/Python.Runtime.Native/LibPythonPInvoke_.tt @@ -0,0 +1,41 @@ +<#@ template hostspecific="false" language="C#" #> +<#@ output extension=".cs" #> +<#@ assembly name="System.Core" #> +<#@ assembly name="System.Linq" #> +<#@ import namespace="System.Reflection" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.IO" #> +using Python.Runtime.Interfaces; + +namespace Python.Runtime.Native { + + public partial class LibPythonPInvoke { +<# + string FormatType(Type type) { + if (type == typeof(void)) + return "void"; + + if (type.IsByRef) + return $"ref {type.GetElementType().ToString()}"; + + return type.ToString(); + } + + var path = $"{Directory.GetCurrentDirectory()}/Python.Runtime.Interfaces/bin/Debug/netstandard2.0/Python.Runtime.Interfaces.dll"; + var assembly = Assembly.LoadFile(path); + var type = assembly.GetType("Python.Runtime.Interfaces.ILibPython"); + const BindingFlags flags = BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.Instance; + var methods = type.GetMethods(flags); + + foreach (var method in methods) { +#> + <#= FormatType(method.ReturnParameter.ParameterType) #> ILibPython.<#= method.Name #>(<#= + string.Join(", ", method.GetParameters().Select(x => $"{FormatType(x.ParameterType)} {x.Name}")) + #>) => LibPythonPInvoke.<#= method.Name #>(<#= + string.Join(", ", method.GetParameters().Select(x => (x.ParameterType.IsByRef ? "ref " : "") + x.Name)) + #>); +<# + } +#> + } +} diff --git a/Python.Runtime/runtime.cs b/Python.Runtime/runtime.cs index dd1ef7b26..feb1fbca9 100644 --- a/Python.Runtime/runtime.cs +++ b/Python.Runtime/runtime.cs @@ -20,28 +20,6 @@ public static partial class Runtime // 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 int UCS => _UCS; - -#if UCS2 - internal const int _UCS = 4; - - /// - /// EntryPoint to be used in DllImport to map to correct Unicode - /// methods prior to PEP393. Only used for PY27. - /// - private const string PyUnicodeEntryPoint = "PyUnicodeUCS4_"; -#else - internal const int _UCS = 2; - - /// - /// EntryPoint to be used in DllImport to map to correct Unicode - /// methods prior to PEP393. Only used for PY27. - /// - private const string PyUnicodeEntryPoint = "PyUnicodeUCS2_"; -#endif - - internal const string _PythonDll = "__Internal"; - // set to true when python is finalizing internal static object IsFinalizingLock = new object(); internal static bool IsFinalizing; From 60d15cdcf1c8fd67b3138d58da19ef4bcf83a651 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Tue, 17 Dec 2019 09:59:56 +0100 Subject: [PATCH 19/22] Make setup.py work again --- Python.Runtime/runtime.cs | 15 ++++++--------- setup.py | 5 +++++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Python.Runtime/runtime.cs b/Python.Runtime/runtime.cs index feb1fbca9..06d9d6d51 100644 --- a/Python.Runtime/runtime.cs +++ b/Python.Runtime/runtime.cs @@ -87,6 +87,12 @@ public static partial class Runtime public static int MainManagedThreadId { get; private set; } + #if UCS2 && PYTHON2 + static int _UCS = 2; + #else + static int _UCS = 4; + #endif + /// /// Encoding to use to convert Unicode to/from Managed to Native /// @@ -223,18 +229,9 @@ internal static void Initialize(bool initSigs = false) IntPtr dllLocal = IntPtr.Zero; var loader = LibraryLoader.Get(OperatingSystem); - if (_PythonDll != "__Internal") - { - dllLocal = loader.Load(_PythonDll); - } _PyObject_NextNotImplemented = loader.GetFunction(dllLocal, "_PyObject_NextNotImplemented"); PyModuleType = loader.GetFunction(dllLocal, "PyModule_Type"); - if (dllLocal != IntPtr.Zero) - { - loader.Free(dllLocal); - } - // Initialize modules that depend on the runtime class. AssemblyManager.Initialize(); PyCLRMetaType = MetaType.Initialize(); diff --git a/setup.py b/setup.py index b76606026..5abe9ab0a 100644 --- a/setup.py +++ b/setup.py @@ -88,5 +88,10 @@ def finalize_options(self): "Python.Runtime/", output="pythonnet/dlls", ), + DotnetLib( + "python-runtime-native", + "Python.Runtime.Native/", + output="pythonnet/dlls", + ), }, ) From 5753d38f32b7e900ab44e239a343ff0095a0d41c Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Wed, 18 Dec 2019 10:11:56 +0100 Subject: [PATCH 20/22] Drop InitializePlatformData --- .../platform/InternalLoadContext.cs | 9 +- Python.Runtime/platform/LibraryLoader.cs | 29 +++-- Python.Runtime/runtime.cs | 105 +----------------- Python.Runtime/typemanager.cs | 35 +++--- 4 files changed, 36 insertions(+), 142 deletions(-) diff --git a/Python.Runtime/platform/InternalLoadContext.cs b/Python.Runtime/platform/InternalLoadContext.cs index e6b94ba41..566d4000a 100644 --- a/Python.Runtime/platform/InternalLoadContext.cs +++ b/Python.Runtime/platform/InternalLoadContext.cs @@ -10,13 +10,8 @@ class InternalLoadContext : AssemblyLoadContext protected override IntPtr LoadUnmanagedDll(string name) { - if (name == "__Internal") - { - var loader = LibraryLoader.Get(OperatingSystemType.Linux); - return loader.Load(null); - } - - return IntPtr.Zero; + var filtered = name == "__Internal" ? null : name; + return LibraryLoader.Instance.Load(filtered); } public static AssemblyLoadContext Instance { get; } = new InternalLoadContext(); diff --git a/Python.Runtime/platform/LibraryLoader.cs b/Python.Runtime/platform/LibraryLoader.cs index d152fcebc..8a2b56d79 100644 --- a/Python.Runtime/platform/LibraryLoader.cs +++ b/Python.Runtime/platform/LibraryLoader.cs @@ -15,18 +15,27 @@ interface ILibraryLoader static class LibraryLoader { - public static ILibraryLoader Get(OperatingSystemType os) + static ILibraryLoader _instance = null; + + public static ILibraryLoader Instance { - switch (os) + get { - case OperatingSystemType.Windows: - return new WindowsLoader(); - case OperatingSystemType.Darwin: - return new DarwinLoader(); - case OperatingSystemType.Linux: - return new LinuxLoader(); - default: - throw new PlatformNotSupportedException($"This operating system ({os}) is not supported"); + if (_instance == null) + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + _instance = new WindowsLoader(); + else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + _instance = new DarwinLoader(); + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + _instance = new LinuxLoader(); + else + throw new PlatformNotSupportedException( + $"This operating system is not supported" + ); + } + + return _instance; } } } diff --git a/Python.Runtime/runtime.cs b/Python.Runtime/runtime.cs index 06d9d6d51..f81adcc97 100644 --- a/Python.Runtime/runtime.cs +++ b/Python.Runtime/runtime.cs @@ -26,56 +26,7 @@ public static partial class Runtime internal static bool Is32Bit = IntPtr.Size == 4; - // .NET core: System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Windows) - internal static bool IsWindows = Environment.OSVersion.Platform == PlatformID.Win32NT; - - static readonly Dictionary OperatingSystemTypeMapping = new Dictionary() - { - { "Windows", OperatingSystemType.Windows }, - { "Darwin", OperatingSystemType.Darwin }, - { "Linux", OperatingSystemType.Linux }, - }; - - /// - /// Gets the operating system as reported by python's platform.system(). - /// - public static OperatingSystemType OperatingSystem { get; private set; } - - /// - /// Gets the operating system as reported by python's platform.system(). - /// - public static string OperatingSystemName { get; private set; } - - - /// - /// Map lower-case version of the python machine name to the processor - /// type. There are aliases, e.g. x86_64 and amd64 are two names for - /// the same thing. Make sure to lower-case the search string, because - /// capitalization can differ. - /// - static readonly Dictionary MachineTypeMapping = new Dictionary() - { - ["i386"] = MachineType.i386, - ["i686"] = MachineType.i386, - ["x86"] = MachineType.i386, - ["x86_64"] = MachineType.x86_64, - ["amd64"] = MachineType.x86_64, - ["x64"] = MachineType.x86_64, - ["em64t"] = MachineType.x86_64, - ["armv7l"] = MachineType.armv7l, - ["armv8"] = MachineType.armv8, - ["aarch64"] = MachineType.aarch64, - }; - - /// - /// Gets the machine architecture as reported by python's platform.machine(). - /// - public static MachineType Machine { get; private set; }/* set in Initialize using python's platform.machine */ - - /// - /// Gets the machine architecture as reported by python's platform.machine(). - /// - public static string MachineName { get; private set; } + internal static bool IsWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); #if PYTHON2 internal static bool IsPython2 = true; @@ -221,13 +172,8 @@ internal static void Initialize(bool initSigs = false) Error = new IntPtr(-1); - // Initialize data about the platform we're running on. We need - // this for the type manager and potentially other details. Must - // happen after caching the python types, above. - InitializePlatformData(); - IntPtr dllLocal = IntPtr.Zero; - var loader = LibraryLoader.Get(OperatingSystem); + var loader = LibraryLoader.Instance; _PyObject_NextNotImplemented = loader.GetFunction(dllLocal, "_PyObject_NextNotImplemented"); PyModuleType = loader.GetFunction(dllLocal, "PyModule_Type"); @@ -248,53 +194,6 @@ internal static void Initialize(bool initSigs = false) AssemblyManager.UpdatePath(); } - /// - /// Initializes the data about platforms. - /// - /// This must be the last step when initializing the runtime: - /// GetManagedString needs to have the cached values for types. - /// But it must run before initializing anything outside the runtime - /// because those rely on the platform data. - /// - private static void InitializePlatformData() - { - IntPtr op; - IntPtr fn; - IntPtr platformModule = PyImport_ImportModule("platform"); - IntPtr emptyTuple = PyTuple_New(0); - - fn = PyObject_GetAttrString(platformModule, "system"); - op = PyObject_Call(fn, emptyTuple, IntPtr.Zero); - OperatingSystemName = GetManagedString(op); - XDecref(op); - XDecref(fn); - - fn = PyObject_GetAttrString(platformModule, "machine"); - op = PyObject_Call(fn, emptyTuple, IntPtr.Zero); - MachineName = GetManagedString(op); - XDecref(op); - XDecref(fn); - - XDecref(emptyTuple); - XDecref(platformModule); - - // Now convert the strings into enum values so we can do switch - // statements rather than constant parsing. - OperatingSystemType OSType; - if (!OperatingSystemTypeMapping.TryGetValue(OperatingSystemName, out OSType)) - { - OSType = OperatingSystemType.Other; - } - OperatingSystem = OSType; - - MachineType MType; - if (!MachineTypeMapping.TryGetValue(MachineName.ToLower(), out MType)) - { - MType = MachineType.Other; - } - Machine = MType; - } - internal static void Shutdown() { AssemblyManager.Shutdown(); diff --git a/Python.Runtime/typemanager.cs b/Python.Runtime/typemanager.cs index 0f1b1fcda..f424c9a86 100644 --- a/Python.Runtime/typemanager.cs +++ b/Python.Runtime/typemanager.cs @@ -503,11 +503,11 @@ public static NativeCode Active { get { - switch (Runtime.Machine) + switch (RuntimeInformation.ProcessArchitecture) { - case MachineType.i386: + case Architecture.X86: return I386; - case MachineType.x86_64: + case Architecture.X64: return X86_64; default: return null; @@ -600,15 +600,12 @@ int MAP_ANONYMOUS { get { - switch (Runtime.OperatingSystem) - { - case OperatingSystemType.Darwin: - return 0x1000; - case OperatingSystemType.Linux: - return 0x20; - default: - throw new NotImplementedException($"mmap is not supported on {Runtime.OperatingSystemName}"); - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + return 0x1000; + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + return 0x20; + else + throw new NotImplementedException($"mmap is not supported on this operating system"); } } @@ -633,16 +630,10 @@ public void SetReadExec(IntPtr mappedMemory, int numBytes) internal static IMemoryMapper CreateMemoryMapper() { - switch (Runtime.OperatingSystem) - { - case OperatingSystemType.Darwin: - case OperatingSystemType.Linux: - return new UnixMemoryMapper(); - case OperatingSystemType.Windows: - return new WindowsMemoryMapper(); - default: - throw new NotImplementedException($"No support for {Runtime.OperatingSystemName}"); - } + if (Runtime.IsWindows) + return new WindowsMemoryMapper(); + else + return new UnixMemoryMapper(); } /// From 41577fc5d557af2ac8dac56394928063fcf4dcf7 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Wed, 18 Dec 2019 10:13:13 +0100 Subject: [PATCH 21/22] Fix define for interop2, add comment on interop3 --- Python.Runtime/interop/interop2.cs | 2 +- Python.Runtime/interop/interop3.cs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Python.Runtime/interop/interop2.cs b/Python.Runtime/interop/interop2.cs index 4782e9d3b..1a561fd80 100644 --- a/Python.Runtime/interop/interop2.cs +++ b/Python.Runtime/interop/interop2.cs @@ -2,7 +2,7 @@ // DO NOT MODIFIY BY HAND. -#if PYTHON27 +#if PYTHON2 using System; using System.Collections; using System.Collections.Specialized; diff --git a/Python.Runtime/interop/interop3.cs b/Python.Runtime/interop/interop3.cs index 008064c34..3f284894b 100644 --- a/Python.Runtime/interop/interop3.cs +++ b/Python.Runtime/interop/interop3.cs @@ -4,6 +4,7 @@ #if !PYTHON2 +// TODO: Need new dynamic version of this from Python 3.8 onwards using System; using System.Collections; using System.Collections.Specialized; From 22a24a45b795c0671c6630f0e8107ab55c4acf7e Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Wed, 18 Dec 2019 10:43:43 +0100 Subject: [PATCH 22/22] First try on loading the correct 'DLL' on .NET Core --- Python.Runtime/pythonengine.cs | 18 ++++++++---------- Python.Runtime/runtime.cs | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Python.Runtime/pythonengine.cs b/Python.Runtime/pythonengine.cs index 92a5d2adb..0033928ea 100644 --- a/Python.Runtime/pythonengine.cs +++ b/Python.Runtime/pythonengine.cs @@ -7,6 +7,7 @@ using System.Reflection; using System.Runtime.InteropServices; using Python.Runtime.Native; +using Python.Runtime.Interfaces; namespace Python.Runtime { @@ -118,11 +119,6 @@ public static string BuildInfo get { return Marshal.PtrToStringAnsi(Runtime.Py_GetBuildInfo()); } } - public static string Platform - { - get { return Marshal.PtrToStringAnsi(Runtime.Py_GetPlatform()); } - } - public static string Copyright { get { return Marshal.PtrToStringAnsi(Runtime.Py_GetCopyright()); } @@ -263,10 +259,12 @@ public static int InternalInitialize(IntPtr data, int size) try { - // Console.WriteLine("Before Initialize"); - // Console.Out.Flush(); + Console.WriteLine("Running on {0}", RuntimeInformation.FrameworkDescription); + + var ass = Platform.InternalLoadContext.Instance.LoadFromAssemblyName(new AssemblyName("Python.Runtime.Native")); - // Python.Runtime.Platform.InternalLoadContext.Instance.EnterContextualReflection(); + var typ = ass.GetType("Python.Runtime.Native.LibPythonPInvoke"); + Runtime.LibPython = (ILibPython)Activator.CreateInstance(typ); Initialize(setSysArgv: false); @@ -316,8 +314,8 @@ public static int InternalInitialize(IntPtr data, int size) } catch (Exception e) { - // Console.Error.WriteLine(e.ToString()); - // Console.Error.Write(e.StackTrace); + Console.Error.WriteLine(e.ToString()); + Console.Error.Write(e.StackTrace); return -2; } } diff --git a/Python.Runtime/runtime.cs b/Python.Runtime/runtime.cs index f81adcc97..f781158aa 100644 --- a/Python.Runtime/runtime.cs +++ b/Python.Runtime/runtime.cs @@ -856,6 +856,6 @@ internal static void SetNoSiteFlag() SetPyNoSiteFlag(1); } - static Interfaces.ILibPython LibPython; + internal static Interfaces.ILibPython LibPython; } }