Nuitka
The Python compiler
Loading...
Searching...
No Matches
unfreezing.h
1// Copyright 2026, Kay Hayen, mailto:kay.hayen@gmail.com find license text at end of file
2
3#ifndef __NUITKA_UNFREEZING_H__
4#define __NUITKA_UNFREEZING_H__
5
6#include <stdbool.h>
7
8/* Modes for loading modules, can be compiled, external shared library, or
9 * bytecode. */
10#define NUITKA_COMPILED_MODULE 0
11#define NUITKA_EXTENSION_MODULE_FLAG 1
12#define NUITKA_PACKAGE_FLAG 2
13#define NUITKA_BYTECODE_FLAG 4
14
15#define NUITKA_ABORT_MODULE_FLAG 8
16
17#define NUITKA_TRANSLATED_FLAG 16
18
19#define NUITKA_PERFECT_SUPPORTED_FLAG 32
20
21#if _NUITKA_STANDALONE_MODE && !defined(_NUITKA_DEPLOYMENT_MODE) && \
22 !defined(_NUITKA_NO_DEPLOYMENT_EXCLUDED_MODULE_USAGE)
23#define NUITKA_EXCLUDED_MODULE_FLAG 64
24#endif
25
27
28typedef PyObject *(*module_init_func)(PyThreadState *tstate, PyObject *module,
29 struct Nuitka_MetaPathBasedLoaderEntry const *loader_entry);
30
31#if PYTHON_VERSION >= 0x370 && _NUITKA_EXE_MODE && !_NUITKA_STANDALONE_MODE && \
32 defined(_NUITKA_FILE_REFERENCE_ORIGINAL_MODE)
33#define _NUITKA_FREEZER_HAS_FILE_PATH
34#endif
35
37 // Full module name, including package name.
38 char const *name;
39
40#if _NUITKA_MODULE_MODE
41 // Runtime module name, updated to match what package we are loaded into.
42 char const *compilation_name;
43#endif
44
45 // Entry function if compiled module, otherwise NULL.
46 module_init_func python_init_func;
47
48 // For bytecode modules, start and size inside the constants blob.
49 int bytecode_index;
50 int bytecode_size;
51
52 // Flags: Indicators if this is compiled, bytecode or shared library.
53 int flags;
54
55 // For accelerated mode, we need to be able to tell where the module "__file__"
56 // lives, so we can resolve resource reader paths, not relative to the binary
57 // but to code location without loading it.
58#if defined(_NUITKA_FREEZER_HAS_FILE_PATH)
59#if defined _WIN32
60 wchar_t const *file_path;
61#else
62 char const *file_path;
63#endif
64#endif
65};
66
67/* For embedded modules, register the meta path based loader. Used by main
68 * program/package only.
69 */
70extern void registerMetaPathBasedLoader(struct Nuitka_MetaPathBasedLoaderEntry *loader_entries,
71 unsigned char **bytecode_data);
72
73// For module mode, embedded modules may have to be shifted to below the
74// namespace they are loaded into.
75#if _NUITKA_MODULE_MODE
76extern void updateMetaPathBasedLoaderModuleRoot(char const *module_root_name);
77#endif
78
79/* Create a loader object responsible for a package. */
80extern PyObject *Nuitka_Loader_New(struct Nuitka_MetaPathBasedLoaderEntry const *entry);
81
82// Create a distribution object from the given metadata.
83extern PyObject *Nuitka_Distribution_New(PyThreadState *tstate, PyObject *name);
84
85// Check if we provide a distribution object ourselves.
86extern bool Nuitka_DistributionNext(Py_ssize_t *pos, PyObject **distribution_name_ptr);
87
88#endif
89
90// Part of "Nuitka", an optimizing Python compiler that is compatible and
91// integrates with CPython, but also works on its own.
92//
93// Licensed under the GNU Affero General Public License, Version 3 (the "License");
94// you may not use this file except in compliance with the License.
95// You may obtain a copy of the License at
96//
97// http://www.gnu.org/licenses/agpl.txt
98//
99// Unless required by applicable law or agreed to in writing, software
100// distributed under the License is distributed on an "AS IS" BASIS,
101// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
102// See the License for the specific language governing permissions and
103// limitations under the License.
Definition unfreezing.h:36