Anonymous committed c43f070

added implementation of Py_Initialize

Comments (0)

Files changed (4)


 extern "C" {
+void Py_Initialize(void);
   void Py_FatalError(const char *msg);
 /* the -3 option will probably not be implemented */


     def compile(self):
         export_symbols = ([self.db.get(ep) for ep in self.getentrypointptr()] +
-                          ['RPython_StartupCode'])
+                          ['RPython_StartupCode', 'Py_Initialize'])
         extsymeci = ExternalCompilationInfo(export_symbols=export_symbols)
         self.eci = self.eci.merge(extsymeci)
         files = [self.c_source_filename] + self.extrafiles


             if self.config.translation.shared:
                 defines['PYPY_MAIN_FUNCTION'] = "pypy_main_startup"
                 self.eci = self.eci.merge(ExternalCompilationInfo(
-                    export_symbols=["pypy_main_startup"]))
+                    export_symbols=["pypy_main_startup", "Py_Initialize"]))
         self.eci, cfile, extra = gen_source(db, modulename, targetdir,
                                             self.eci, defines=defines,
         assert self.c_source_filename 
         assert not self._compiled
         export_symbols = [self.db.get(self.getentrypointptr()),
-                          'RPython_StartupCode',
+                          'RPython_StartupCode', 'Py_Initialize',
         if self.config.translation.countmallocs:


 int pypy_main_function(int argc, char *argv[]) __attribute__((__noinline__));
+void Py_Initialize(void) {
+    pypy_asm_stack_bottom();
+    char *errmsg = RPython_StartupCode();
+    if (errmsg) {
+    	fprintf(stderr, "unable to initialize PyPy: %s\n", errmsg);
+        abort();
+        return;
+    }
+    pypy_g_call_startup();
+    pypy_g_State_startup(&pypy_g_pypy_module_cpyext_state_State);
 int pypy_main_function(int argc, char *argv[])
     char *errmsg;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.