blob: 1b7fe0a73c3a0bded1d216aca6412dbe2a8c6a3e [file] [log] [blame]
Guido van Rossumf70e43a1991-02-19 12:39:46 +00001
Guido van Rossum85a5fbb1990-10-14 12:07:46 +00002/* Module definition and import interface */
3
Fred Drake5eb6d4e2000-07-08 23:37:28 +00004#ifndef Py_IMPORT_H
5#define Py_IMPORT_H
6#ifdef __cplusplus
7extern "C" {
8#endif
Guido van Rossum34679b71993-01-26 13:33:44 +00009
Mark Hammond8235ea12002-07-19 06:55:41 +000010PyAPI_FUNC(long) PyImport_GetMagicNumber(void);
11PyAPI_FUNC(PyObject *) PyImport_ExecCodeModule(char *name, PyObject *co);
12PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleEx(
Fred Drake5eb6d4e2000-07-08 23:37:28 +000013 char *name, PyObject *co, char *pathname);
Mark Hammond8235ea12002-07-19 06:55:41 +000014PyAPI_FUNC(PyObject *) PyImport_GetModuleDict(void);
Jeremy Hyltonaf68c872005-12-10 18:50:16 +000015PyAPI_FUNC(PyObject *) PyImport_AddModule(const char *name);
16PyAPI_FUNC(PyObject *) PyImport_ImportModule(const char *name);
Christian Heimes000a0742008-01-03 22:16:32 +000017PyAPI_FUNC(PyObject *) PyImport_ImportModuleNoBlock(const char *);
Thomas Woutersf7f438b2006-02-28 16:09:29 +000018PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevel(char *name,
19 PyObject *globals, PyObject *locals, PyObject *fromlist, int level);
20
Thomas Woutersf7f438b2006-02-28 16:09:29 +000021#define PyImport_ImportModuleEx(n, g, l, f) \
Neal Norwitz8a267062006-08-19 04:25:29 +000022 PyImport_ImportModuleLevel(n, g, l, f, -1)
Thomas Woutersf7f438b2006-02-28 16:09:29 +000023
Nick Coghlan327a39b2007-11-18 11:56:28 +000024PyAPI_FUNC(PyObject *) PyImport_GetImporter(PyObject *path);
Mark Hammond8235ea12002-07-19 06:55:41 +000025PyAPI_FUNC(PyObject *) PyImport_Import(PyObject *name);
26PyAPI_FUNC(PyObject *) PyImport_ReloadModule(PyObject *m);
27PyAPI_FUNC(void) PyImport_Cleanup(void);
28PyAPI_FUNC(int) PyImport_ImportFrozenModule(char *);
Fred Drake5eb6d4e2000-07-08 23:37:28 +000029
Thomas Woutersc4dcb382009-09-16 19:55:54 +000030#ifdef WITH_THREAD
31PyAPI_FUNC(void) _PyImport_AcquireLock(void);
32PyAPI_FUNC(int) _PyImport_ReleaseLock(void);
33#else
34#define _PyImport_AcquireLock()
35#define _PyImport_ReleaseLock() 1
36#endif
37
Raymond Hettingerdb29e0f2004-10-07 06:46:25 +000038PyAPI_FUNC(struct filedescr *) _PyImport_FindModule(
39 const char *, PyObject *, char *, size_t, FILE **, PyObject **);
40PyAPI_FUNC(int) _PyImport_IsScript(struct filedescr *);
Guido van Rossum8ee3e5a2005-09-14 18:09:42 +000041PyAPI_FUNC(void) _PyImport_ReInitLock(void);
Raymond Hettingerdb29e0f2004-10-07 06:46:25 +000042
Mark Hammonda2905272002-07-29 13:42:14 +000043PyAPI_FUNC(PyObject *)_PyImport_FindExtension(char *, char *);
44PyAPI_FUNC(PyObject *)_PyImport_FixupExtension(char *, char *);
Guido van Rossum29e46a91997-08-02 02:56:48 +000045
Guido van Rossum39c2aae1996-05-22 17:25:28 +000046struct _inittab {
Fred Drake5eb6d4e2000-07-08 23:37:28 +000047 char *name;
Thomas Wouters5f375912000-07-22 23:30:03 +000048 void (*initfunc)(void);
Guido van Rossum39c2aae1996-05-22 17:25:28 +000049};
50
Nick Coghlan327a39b2007-11-18 11:56:28 +000051PyAPI_DATA(PyTypeObject) PyNullImporter_Type;
Mark Hammonda2905272002-07-29 13:42:14 +000052PyAPI_DATA(struct _inittab *) PyImport_Inittab;
Guido van Rossuma3309961993-07-28 09:05:47 +000053
Brett Cannon238cedc2009-04-02 03:34:53 +000054PyAPI_FUNC(int) PyImport_AppendInittab(const char *name, void (*initfunc)(void));
Mark Hammonda2905272002-07-29 13:42:14 +000055PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab *newtab);
Guido van Rossum16926bd1998-06-29 20:34:46 +000056
Guido van Rossum4ee68d91996-06-17 17:05:01 +000057struct _frozen {
Fred Drake5eb6d4e2000-07-08 23:37:28 +000058 char *name;
59 unsigned char *code;
60 int size;
Guido van Rossum4ee68d91996-06-17 17:05:01 +000061};
62
63/* Embedding apps may change this pointer to point to their favorite
64 collection of frozen modules: */
65
Mark Hammonda2905272002-07-29 13:42:14 +000066PyAPI_DATA(struct _frozen *) PyImport_FrozenModules;
Guido van Rossum4ee68d91996-06-17 17:05:01 +000067
Guido van Rossuma3309961993-07-28 09:05:47 +000068#ifdef __cplusplus
69}
70#endif
71#endif /* !Py_IMPORT_H */