blob: aeef3efd0bcee8e20183c91c41c1cda50ff7888f [file] [log] [blame]
Guido van Rossum85a5fbb1990-10-14 12:07:46 +00001/* Module definition and import interface */
2
Fred Drake5eb6d4e2000-07-08 23:37:28 +00003#ifndef Py_IMPORT_H
4#define Py_IMPORT_H
5#ifdef __cplusplus
6extern "C" {
7#endif
Guido van Rossum34679b71993-01-26 13:33:44 +00008
Mark Hammond8235ea12002-07-19 06:55:41 +00009PyAPI_FUNC(long) PyImport_GetMagicNumber(void);
Barry Warsaw28a691b2010-04-17 00:19:56 +000010PyAPI_FUNC(const char *) PyImport_GetMagicTag(void);
Victor Stinnerd7e76402011-02-22 23:38:34 +000011PyAPI_FUNC(PyObject *) PyImport_ExecCodeModule(
Serhiy Storchakac6792272013-10-19 21:03:34 +030012 const char *name, /* UTF-8 encoded string */
Victor Stinnerd7e76402011-02-22 23:38:34 +000013 PyObject *co
14 );
Mark Hammond8235ea12002-07-19 06:55:41 +000015PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleEx(
Serhiy Storchakac6792272013-10-19 21:03:34 +030016 const char *name, /* UTF-8 encoded string */
Victor Stinnerd7e76402011-02-22 23:38:34 +000017 PyObject *co,
Serhiy Storchakac6792272013-10-19 21:03:34 +030018 const char *pathname /* decoded from the filesystem encoding */
Victor Stinnerd7e76402011-02-22 23:38:34 +000019 );
Barry Warsaw28a691b2010-04-17 00:19:56 +000020PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleWithPathnames(
Serhiy Storchakac6792272013-10-19 21:03:34 +030021 const char *name, /* UTF-8 encoded string */
Victor Stinnerd7e76402011-02-22 23:38:34 +000022 PyObject *co,
Serhiy Storchakac6792272013-10-19 21:03:34 +030023 const char *pathname, /* decoded from the filesystem encoding */
24 const char *cpathname /* decoded from the filesystem encoding */
Victor Stinnerd7e76402011-02-22 23:38:34 +000025 );
Serhiy Storchaka34d0ac82016-12-27 14:57:39 +020026#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
Victor Stinner27ee0892011-03-04 12:57:09 +000027PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleObject(
28 PyObject *name,
29 PyObject *co,
30 PyObject *pathname,
31 PyObject *cpathname
32 );
Serhiy Storchaka34d0ac82016-12-27 14:57:39 +020033#endif
Mark Hammond8235ea12002-07-19 06:55:41 +000034PyAPI_FUNC(PyObject *) PyImport_GetModuleDict(void);
Serhiy Storchaka4e29f562018-05-22 20:59:42 +030035#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03070000
Eric Snow3f9eee62017-09-15 16:35:20 -060036PyAPI_FUNC(PyObject *) PyImport_GetModule(PyObject *name);
Serhiy Storchaka4e29f562018-05-22 20:59:42 +030037#endif
Serhiy Storchaka34d0ac82016-12-27 14:57:39 +020038#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
Victor Stinner27ee0892011-03-04 12:57:09 +000039PyAPI_FUNC(PyObject *) PyImport_AddModuleObject(
40 PyObject *name
41 );
Serhiy Storchaka34d0ac82016-12-27 14:57:39 +020042#endif
Victor Stinnerd7e76402011-02-22 23:38:34 +000043PyAPI_FUNC(PyObject *) PyImport_AddModule(
44 const char *name /* UTF-8 encoded string */
45 );
46PyAPI_FUNC(PyObject *) PyImport_ImportModule(
47 const char *name /* UTF-8 encoded string */
48 );
49PyAPI_FUNC(PyObject *) PyImport_ImportModuleNoBlock(
50 const char *name /* UTF-8 encoded string */
51 );
52PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevel(
Benjamin Peterson04778a82011-05-25 09:29:00 -050053 const char *name, /* UTF-8 encoded string */
Victor Stinnerd7e76402011-02-22 23:38:34 +000054 PyObject *globals,
55 PyObject *locals,
56 PyObject *fromlist,
57 int level
58 );
Serhiy Storchaka34d0ac82016-12-27 14:57:39 +020059#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
Victor Stinnerfe93faf2011-03-14 15:54:52 -040060PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevelObject(
61 PyObject *name,
62 PyObject *globals,
63 PyObject *locals,
64 PyObject *fromlist,
65 int level
66 );
Serhiy Storchaka34d0ac82016-12-27 14:57:39 +020067#endif
Thomas Woutersf7f438b2006-02-28 16:09:29 +000068
Thomas Woutersf7f438b2006-02-28 16:09:29 +000069#define PyImport_ImportModuleEx(n, g, l, f) \
Brett Cannon522267e2012-08-10 18:55:08 -040070 PyImport_ImportModuleLevel(n, g, l, f, 0)
Thomas Woutersf7f438b2006-02-28 16:09:29 +000071
Christian Heimes9cd17752007-11-18 19:35:23 +000072PyAPI_FUNC(PyObject *) PyImport_GetImporter(PyObject *path);
Mark Hammond8235ea12002-07-19 06:55:41 +000073PyAPI_FUNC(PyObject *) PyImport_Import(PyObject *name);
74PyAPI_FUNC(PyObject *) PyImport_ReloadModule(PyObject *m);
Serhiy Storchaka34d0ac82016-12-27 14:57:39 +020075#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
Victor Stinner53dc7352011-03-20 01:50:21 +010076PyAPI_FUNC(int) PyImport_ImportFrozenModuleObject(
77 PyObject *name
78 );
Serhiy Storchaka34d0ac82016-12-27 14:57:39 +020079#endif
Victor Stinnerd7e76402011-02-22 23:38:34 +000080PyAPI_FUNC(int) PyImport_ImportFrozenModule(
Serhiy Storchakac6792272013-10-19 21:03:34 +030081 const char *name /* UTF-8 encoded string */
Victor Stinnerd7e76402011-02-22 23:38:34 +000082 );
Fred Drake5eb6d4e2000-07-08 23:37:28 +000083
Victor Stinnerd7e76402011-02-22 23:38:34 +000084PyAPI_FUNC(int) PyImport_AppendInittab(
85 const char *name, /* ASCII encoded string */
86 PyObject* (*initfunc)(void)
87 );
Guido van Rossum16926bd1998-06-29 20:34:46 +000088
Martin v. Löwis4d0d4712010-12-03 20:14:31 +000089#ifndef Py_LIMITED_API
Victor Stinner01b63ec2019-06-19 00:48:09 +020090# define Py_CPYTHON_IMPORT_H
91# include "cpython/import.h"
92# undef Py_CPYTHON_IMPORT_H
Martin v. Löwis4d0d4712010-12-03 20:14:31 +000093#endif
Guido van Rossum4ee68d91996-06-17 17:05:01 +000094
Guido van Rossuma3309961993-07-28 09:05:47 +000095#ifdef __cplusplus
96}
97#endif
98#endif /* !Py_IMPORT_H */