blob: bb6beba67b738f8031c16cbd37001751d2f36883 [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
Serhiy Storchaka9fab79b2016-09-11 11:03:14 +030010#ifndef Py_LIMITED_API
Brett Cannonfd074152012-04-14 14:10:13 -040011PyAPI_FUNC(void) _PyImportZip_Init(void);
12
13PyMODINIT_FUNC PyInit_imp(void);
Serhiy Storchaka34d0ac82016-12-27 14:57:39 +020014#endif /* !Py_LIMITED_API */
Mark Hammond8235ea12002-07-19 06:55:41 +000015PyAPI_FUNC(long) PyImport_GetMagicNumber(void);
Barry Warsaw28a691b2010-04-17 00:19:56 +000016PyAPI_FUNC(const char *) PyImport_GetMagicTag(void);
Victor Stinnerd7e76402011-02-22 23:38:34 +000017PyAPI_FUNC(PyObject *) PyImport_ExecCodeModule(
Serhiy Storchakac6792272013-10-19 21:03:34 +030018 const char *name, /* UTF-8 encoded string */
Victor Stinnerd7e76402011-02-22 23:38:34 +000019 PyObject *co
20 );
Mark Hammond8235ea12002-07-19 06:55:41 +000021PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleEx(
Serhiy Storchakac6792272013-10-19 21:03:34 +030022 const char *name, /* UTF-8 encoded string */
Victor Stinnerd7e76402011-02-22 23:38:34 +000023 PyObject *co,
Serhiy Storchakac6792272013-10-19 21:03:34 +030024 const char *pathname /* decoded from the filesystem encoding */
Victor Stinnerd7e76402011-02-22 23:38:34 +000025 );
Barry Warsaw28a691b2010-04-17 00:19:56 +000026PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleWithPathnames(
Serhiy Storchakac6792272013-10-19 21:03:34 +030027 const char *name, /* UTF-8 encoded string */
Victor Stinnerd7e76402011-02-22 23:38:34 +000028 PyObject *co,
Serhiy Storchakac6792272013-10-19 21:03:34 +030029 const char *pathname, /* decoded from the filesystem encoding */
30 const char *cpathname /* decoded from the filesystem encoding */
Victor Stinnerd7e76402011-02-22 23:38:34 +000031 );
Serhiy Storchaka34d0ac82016-12-27 14:57:39 +020032#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
Victor Stinner27ee0892011-03-04 12:57:09 +000033PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleObject(
34 PyObject *name,
35 PyObject *co,
36 PyObject *pathname,
37 PyObject *cpathname
38 );
Serhiy Storchaka34d0ac82016-12-27 14:57:39 +020039#endif
Mark Hammond8235ea12002-07-19 06:55:41 +000040PyAPI_FUNC(PyObject *) PyImport_GetModuleDict(void);
Serhiy Storchaka34d0ac82016-12-27 14:57:39 +020041#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
Victor Stinner27ee0892011-03-04 12:57:09 +000042PyAPI_FUNC(PyObject *) PyImport_AddModuleObject(
43 PyObject *name
44 );
Serhiy Storchaka34d0ac82016-12-27 14:57:39 +020045#endif
Victor Stinnerd7e76402011-02-22 23:38:34 +000046PyAPI_FUNC(PyObject *) PyImport_AddModule(
47 const char *name /* UTF-8 encoded string */
48 );
49PyAPI_FUNC(PyObject *) PyImport_ImportModule(
50 const char *name /* UTF-8 encoded string */
51 );
52PyAPI_FUNC(PyObject *) PyImport_ImportModuleNoBlock(
53 const char *name /* UTF-8 encoded string */
54 );
55PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevel(
Benjamin Peterson04778a82011-05-25 09:29:00 -050056 const char *name, /* UTF-8 encoded string */
Victor Stinnerd7e76402011-02-22 23:38:34 +000057 PyObject *globals,
58 PyObject *locals,
59 PyObject *fromlist,
60 int level
61 );
Serhiy Storchaka34d0ac82016-12-27 14:57:39 +020062#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
Victor Stinnerfe93faf2011-03-14 15:54:52 -040063PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevelObject(
64 PyObject *name,
65 PyObject *globals,
66 PyObject *locals,
67 PyObject *fromlist,
68 int level
69 );
Serhiy Storchaka34d0ac82016-12-27 14:57:39 +020070#endif
Thomas Woutersf7f438b2006-02-28 16:09:29 +000071
Thomas Woutersf7f438b2006-02-28 16:09:29 +000072#define PyImport_ImportModuleEx(n, g, l, f) \
Brett Cannon522267e2012-08-10 18:55:08 -040073 PyImport_ImportModuleLevel(n, g, l, f, 0)
Thomas Woutersf7f438b2006-02-28 16:09:29 +000074
Christian Heimes9cd17752007-11-18 19:35:23 +000075PyAPI_FUNC(PyObject *) PyImport_GetImporter(PyObject *path);
Mark Hammond8235ea12002-07-19 06:55:41 +000076PyAPI_FUNC(PyObject *) PyImport_Import(PyObject *name);
77PyAPI_FUNC(PyObject *) PyImport_ReloadModule(PyObject *m);
78PyAPI_FUNC(void) PyImport_Cleanup(void);
Serhiy Storchaka34d0ac82016-12-27 14:57:39 +020079#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
Victor Stinner53dc7352011-03-20 01:50:21 +010080PyAPI_FUNC(int) PyImport_ImportFrozenModuleObject(
81 PyObject *name
82 );
Serhiy Storchaka34d0ac82016-12-27 14:57:39 +020083#endif
Victor Stinnerd7e76402011-02-22 23:38:34 +000084PyAPI_FUNC(int) PyImport_ImportFrozenModule(
Serhiy Storchakac6792272013-10-19 21:03:34 +030085 const char *name /* UTF-8 encoded string */
Victor Stinnerd7e76402011-02-22 23:38:34 +000086 );
Fred Drake5eb6d4e2000-07-08 23:37:28 +000087
Martin v. Löwis4d0d4712010-12-03 20:14:31 +000088#ifndef Py_LIMITED_API
Benjamin Peterson0df35a92009-10-04 20:32:25 +000089#ifdef WITH_THREAD
90PyAPI_FUNC(void) _PyImport_AcquireLock(void);
91PyAPI_FUNC(int) _PyImport_ReleaseLock(void);
92#else
93#define _PyImport_AcquireLock()
94#define _PyImport_ReleaseLock() 1
95#endif
96
Guido van Rossum8ee3e5a2005-09-14 18:09:42 +000097PyAPI_FUNC(void) _PyImport_ReInitLock(void);
Raymond Hettingerdb29e0f2004-10-07 06:46:25 +000098
Victor Stinnerd860d5c2013-12-10 01:19:58 +010099PyAPI_FUNC(PyObject *) _PyImport_FindBuiltin(
Victor Stinner501c09a2011-02-23 00:02:00 +0000100 const char *name /* UTF-8 encoded string */
Victor Stinnerd7e76402011-02-22 23:38:34 +0000101 );
Victor Stinnerd860d5c2013-12-10 01:19:58 +0100102PyAPI_FUNC(PyObject *) _PyImport_FindExtensionObject(PyObject *, PyObject *);
103PyAPI_FUNC(int) _PyImport_FixupBuiltin(
Victor Stinnerd7e76402011-02-22 23:38:34 +0000104 PyObject *mod,
Serhiy Storchakac6792272013-10-19 21:03:34 +0300105 const char *name /* UTF-8 encoded string */
Victor Stinnerd7e76402011-02-22 23:38:34 +0000106 );
Victor Stinnerd860d5c2013-12-10 01:19:58 +0100107PyAPI_FUNC(int) _PyImport_FixupExtensionObject(PyObject*, PyObject *, PyObject *);
Guido van Rossum29e46a91997-08-02 02:56:48 +0000108
Guido van Rossum39c2aae1996-05-22 17:25:28 +0000109struct _inittab {
Serhiy Storchakac6792272013-10-19 21:03:34 +0300110 const char *name; /* ASCII encoded string */
Martin v. Löwis1a214512008-06-11 05:26:20 +0000111 PyObject* (*initfunc)(void);
Guido van Rossum39c2aae1996-05-22 17:25:28 +0000112};
Martin v. Löwis4d0d4712010-12-03 20:14:31 +0000113PyAPI_DATA(struct _inittab *) PyImport_Inittab;
114PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab *newtab);
115#endif /* Py_LIMITED_API */
Guido van Rossum39c2aae1996-05-22 17:25:28 +0000116
Christian Heimes9cd17752007-11-18 19:35:23 +0000117PyAPI_DATA(PyTypeObject) PyNullImporter_Type;
Guido van Rossuma3309961993-07-28 09:05:47 +0000118
Victor Stinnerd7e76402011-02-22 23:38:34 +0000119PyAPI_FUNC(int) PyImport_AppendInittab(
120 const char *name, /* ASCII encoded string */
121 PyObject* (*initfunc)(void)
122 );
Guido van Rossum16926bd1998-06-29 20:34:46 +0000123
Martin v. Löwis4d0d4712010-12-03 20:14:31 +0000124#ifndef Py_LIMITED_API
Guido van Rossum4ee68d91996-06-17 17:05:01 +0000125struct _frozen {
Benjamin Peterson7701e6e2013-03-13 14:06:39 -0500126 const char *name; /* ASCII encoded string */
127 const unsigned char *code;
Fred Drake5eb6d4e2000-07-08 23:37:28 +0000128 int size;
Guido van Rossum4ee68d91996-06-17 17:05:01 +0000129};
130
131/* Embedding apps may change this pointer to point to their favorite
132 collection of frozen modules: */
133
Benjamin Peterson7701e6e2013-03-13 14:06:39 -0500134PyAPI_DATA(const struct _frozen *) PyImport_FrozenModules;
Martin v. Löwis4d0d4712010-12-03 20:14:31 +0000135#endif
Guido van Rossum4ee68d91996-06-17 17:05:01 +0000136
Guido van Rossuma3309961993-07-28 09:05:47 +0000137#ifdef __cplusplus
138}
139#endif
140#endif /* !Py_IMPORT_H */