| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1dbded1 commit decf508
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,13 +9,13 @@ For more information read: | |||
| 9 | 9 | --> | |
| 10 | 10 | ||
| 11 | 11 | <configuration> | |
| 12 | - <dllmap dll="python23" target="libpython2.3.so" os="!windows" /> | ||
| 13 | - <dllmap dll="python24" target="libpython2.4.so" os="!windows" /> | ||
| 14 | - <dllmap dll="python25" target="libpython2.5.so" os="!windows" /> | ||
| 15 | - <dllmap dll="python26" target="libpython2.6.so" os="!windows" /> | ||
| 16 | - <dllmap dll="python23.dll" target="libpython2.3.so" os="!windows" /> | ||
| 17 | - <dllmap dll="python24.dll" target="libpython2.4.so" os="!windows" /> | ||
| 18 | - <dllmap dll="python25.dll" target="libpython2.5.so" os="!windows" /> | ||
| 19 | - <dllmap dll="python26.dll" target="libpython2.6.so" os="!windows" /> | ||
| 12 | + <dllmap dll="python23" target="/usr/lib/libpython2.3.dylib" os="!windows" /> | ||
| 13 | + <dllmap dll="python24" target="/usr/lib/libpython2.4.dylib" os="!windows" /> | ||
| 14 | + <dllmap dll="python25" target="/usr/lib/libpython2.5.dylib" os="!windows" /> | ||
| 15 | + <dllmap dll="python26" target="/usr/lib/libpython2.6.dylib" os="!windows" /> | ||
| 16 | + <dllmap dll="python23.dll" target="/usr/lib/libpython2.3.dylib" os="!windows" /> | ||
| 17 | + <dllmap dll="python24.dll" target="/usr/lib/libpython2.4.dylib" os="!windows" /> | ||
| 18 | + <dllmap dll="python25.dll" target="/usr/lib/libpython2.5.dylib" os="!windows" /> | ||
| 19 | + <dllmap dll="python26.dll" target="/usr/lib/libpython2.6.dylib" os="!windows" /> | ||
| 20 | 20 | </configuration> | |
| 21 | 21 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,7 +5,7 @@ BASENAME = $(shell $(PYTHON) -c "import sys; print 'python%i.%i' % sys.version_i | |||
| 5 | 5 | GCC = gcc | |
| 6 | 6 | ||
| 7 | 7 | PY_LIBS = $(shell $(PYTHON) -c "from distutils.sysconfig import get_config_vars; \ | |
| 8 | - print get_config_vars('BLDLIBRARY')[0]") | ||
| 8 | + print get_config_vars('BLDLIBRARY')[0]") -lpython | ||
| 9 | 9 | PY_CFLAGS = -I$(shell $(PYTHON) -c "from distutils.sysconfig import get_config_vars; \ | |
| 10 | 10 | print get_config_vars('CFLAGS')[0] + ' -I' + get_config_vars('CONFINCLUDEPY')[0]") | |
| 11 | 11 | ||
@@ -15,10 +15,10 @@ MONO_CFLAGS = $(shell pkg-config --cflags mono) | |||
| 15 | 15 | LIBS = $(MONO_LIBS) $(PY_LIBS) | |
| 16 | 16 | CFLAGS = $(MONO_CFLAGS) $(PY_CFLAGS) | |
| 17 | 17 | ||
| 18 | - all: clr$(BASENAME) $(BASENAME) | ||
| 18 | + all: clr$(BASENAME) $(BASENAME) clr.so | ||
| 19 | 19 | ||
| 20 | - clr$(BASENAME): clrpython.o pynetinit.o | ||
| 21 | - $(GCC) $(LIBS) clrpython.o pynetinit.o -o clr$(BASENAME) | ||
| 20 | + clrmod.o: pynetclr.h clrmod.c | ||
| 21 | + $(GCC) $(CFLAGS) -c clrmod.c -o clrmod.o | ||
| 22 | 22 | ||
| 23 | 23 | clrpython.o: pynetclr.h clrpython.c | |
| 24 | 24 | $(GCC) $(CFLAGS) -c clrpython.c -o clrpython.o | |
@@ -29,6 +29,12 @@ pynetinit.o: pynetclr.h pynetinit.c | |||
| 29 | 29 | $(BASENAME): python.c | |
| 30 | 30 | $(GCC) $(PY_CFLAGS) $(PY_LIBS) python.c -o $(BASENAME) | |
| 31 | 31 | ||
| 32 | + clr.so: clrmod.o pynetinit.o | ||
| 33 | + $(GCC) $(LIBS) -dynamiclib pynetinit.o clrmod.o -o clr.so | ||
| 34 | + | ||
| 35 | + clr$(BASENAME): clrpython.o pynetinit.o | ||
| 36 | + $(GCC) $(LIBS) clrpython.o pynetinit.o -o clr$(BASENAME) | ||
| 37 | + | ||
| 32 | 38 | clean: | |
| 33 | 39 | rm -f *.o | |
| 34 | 40 | rm -f *.so | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,5 @@ | |||
| 1 | + This has been updated to work with MonoFramework 1.9. | ||
| 2 | + | ||
| 1 | 3 | 1. On MacOS X, create the following directory structure: | |
| 2 | 4 | ||
| 3 | 5 | /PythonNET/src/monoclr | |
@@ -11,3 +13,5 @@ | |||
| 11 | 13 | $ python setup.py build | |
| 12 | 14 | ||
| 13 | 15 | 5. This creates the clr.so | |
| 16 | + | ||
| 17 | + 6. Copy the clr.so, the Python.Runtime.dll, and the Python.Runtime.dll.config to the site-packages folder. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,6 +23,7 @@ PyDoc_STRVAR(clr_module_doc, | |||
| 23 | 23 | ); | |
| 24 | 24 | ||
| 25 | 25 | static PyNet_Args *pn_args; | |
| 26 | + char** environ = NULL; | ||
| 26 | 27 | ||
| 27 | 28 | PyMODINIT_FUNC | |
| 28 | 29 | initclr(void) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,6 +10,7 @@ | |||
| 10 | 10 | // Author: Christian Heimes <christian(at)cheimes(dot)de> | |
| 11 | 11 | ||
| 12 | 12 | #include "pynetclr.h" | |
| 13 | + #include "dirent.h" | ||
| 13 | 14 | ||
| 14 | 15 | // initialize Mono and PythonNet | |
| 15 | 16 | PyNet_Args* PyNet_Init(int ext) { | |
@@ -18,22 +19,23 @@ PyNet_Args* PyNet_Init(int ext) { | |||
| 18 | 19 | pn_args->pr_file = PR_ASSEMBLY; | |
| 19 | 20 | pn_args->error = NULL; | |
| 20 | 21 | pn_args->shutdown = NULL; | |
| 22 | + | ||
| 21 | 23 | if (ext == 0) { | |
| 22 | 24 | pn_args->init_name = "Python.Runtime:Initialize()"; | |
| 23 | 25 | } else { | |
| 24 | 26 | pn_args->init_name = "Python.Runtime:InitExt()"; | |
| 25 | 27 | } | |
| 26 | 28 | pn_args->shutdown_name = "Python.Runtime:Shutdown()"; | |
| 27 | 29 | ||
| 30 | + pn_args->domain = mono_jit_init_version(MONO_DOMAIN, MONO_VERSION); | ||
| 31 | + | ||
| 28 | 32 | /* | |
| 29 | 33 | * Load the default Mono configuration file, this is needed | |
| 30 | 34 | * if you are planning on using the dllmaps defined on the | |
| 31 | 35 | * system configuration | |
| 32 | 36 | */ | |
| 33 | 37 | mono_config_parse(NULL); | |
| 34 | 38 | ||
| 35 | - pn_args->domain = mono_jit_init_version(MONO_DOMAIN, MONO_VERSION); | ||
| 36 | - | ||
| 37 | 39 | /* I can't use this call to run the main_thread_handler. The function | |
| 38 | 40 | * runs it in another thread but *this* thread holds the Python | |
| 39 | 41 | * import lock -> DEAD LOCK. | |
@@ -87,11 +89,55 @@ void main_thread_handler (gpointer user_data) { | |||
| 87 | 89 | MonoClass *pythonengine; | |
| 88 | 90 | MonoObject *exception = NULL; | |
| 89 | 91 | ||
| 92 | + //get python path system variable | ||
| 93 | + PyObject* syspath = PySys_GetObject("path"); | ||
| 94 | + char* runtime_full_path = (char*) malloc(1024); | ||
| 95 | + const char* slash = "/"; | ||
| 96 | + int found = 0; | ||
| 97 | + | ||
| 98 | + int ii = 0; | ||
| 99 | + for (ii = 0; ii < PyList_Size(syspath); ++ii) { | ||
| 100 | + const char* pydir = PyString_AsString(PyList_GetItem(syspath, ii)); | ||
| 101 | + char* curdir = (char*) malloc(1024); | ||
| 102 | + if (strlen(pydir) == 0) pydir = "."; | ||
| 103 | + | ||
| 104 | + strcpy(curdir, pydir); | ||
| 105 | + strcat(curdir, slash); | ||
| 106 | + | ||
| 107 | + //look in this directory for the pn_args->pr_file | ||
| 108 | + DIR* dirp = opendir(curdir); | ||
| 109 | + if (dirp != NULL) { | ||
| 110 | + | ||
| 111 | + struct dirent *dp; | ||
| 112 | + while ((dp = readdir(dirp)) != NULL) { | ||
| 113 | + if (strcmp(dp->d_name, pn_args->pr_file) == 0) { | ||
| 114 | + strcpy(runtime_full_path, curdir); | ||
| 115 | + strcat(runtime_full_path, pn_args->pr_file); | ||
| 116 | + found = 1; | ||
| 117 | + break; | ||
| 118 | + } | ||
| 119 | + } | ||
| 120 | + closedir(dirp); | ||
| 121 | + } | ||
| 122 | + free(curdir); | ||
| 123 | + | ||
| 124 | + if (found) { | ||
| 125 | + pn_args->pr_file = runtime_full_path; | ||
| 126 | + break; | ||
| 127 | + } | ||
| 128 | + } | ||
| 129 | + | ||
| 130 | + if (!found) { | ||
| 131 | + fprintf(stderr, "Could not find assembly %s. \n", pn_args->pr_file); | ||
| 132 | + return; | ||
| 133 | + } | ||
| 134 | + | ||
| 90 | 135 | pn_args->pr_assm = mono_domain_assembly_open(pn_args->domain, pn_args->pr_file); | |
| 91 | 136 | if (!pn_args->pr_assm) { | |
| 92 | 137 | pn_args->error = "Unable to load assembly"; | |
| 93 | 138 | return; | |
| 94 | 139 | } | |
| 140 | + free(runtime_full_path); | ||
| 95 | 141 | ||
| 96 | 142 | pr_image = mono_assembly_get_image(pn_args->pr_assm); | |
| 97 | 143 | if (!pr_image) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,7 +30,7 @@ internal class TypeManager { | |||
| 30 | 30 | ||
| 31 | 31 | static TypeManager() { | |
| 32 | 32 | tbFlags = BindingFlags.Public | BindingFlags.Static; | |
| 33 | - obSize = 4 * IntPtr.Size; | ||
| 33 | + obSize = 5 * IntPtr.Size; | ||
| 34 | 34 | cache = new Dictionary<Type, IntPtr>(128); | |
| 35 | 35 | } | |
| 36 | 36 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments