Nuitka
The Python compiler
Loading...
Searching...
No Matches
unfreezing.h
1// Copyright 2025, 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
22
23typedef PyObject *(*module_init_func)(PyThreadState *tstate, PyObject *module,
24 struct Nuitka_MetaPathBasedLoaderEntry const *loader_entry);
25
26#if PYTHON_VERSION >= 0x370 && _NUITKA_EXE_MODE && !_NUITKA_STANDALONE_MODE && \
27 defined(_NUITKA_FILE_REFERENCE_ORIGINAL_MODE)
28#define _NUITKA_FREEZER_HAS_FILE_PATH
29#endif
30
32 // Full module name, including package name.
33 char const *name;
34
35 // Entry function if compiled module, otherwise NULL.
36 module_init_func python_init_func;
37
38 // For bytecode modules, start and size inside the constants blob.
39 int bytecode_index;
40 int bytecode_size;
41
42 // Flags: Indicators if this is compiled, bytecode or shared library.
43 int flags;
44
45 // For accelerated mode, we need to be able to tell where the module "__file__"
46 // lives, so we can resolve resource reader paths, not relative to the binary
47 // but to code location without loading it.
48#if defined(_NUITKA_FREEZER_HAS_FILE_PATH)
49#if defined _WIN32
50 wchar_t const *file_path;
51#else
52 char const *file_path;
53#endif
54#endif
55};
56
57/* For embedded modules, register the meta path based loader. Used by main
58 * program/package only.
59 */
60extern void registerMetaPathBasedLoader(struct Nuitka_MetaPathBasedLoaderEntry *loader_entries,
61 unsigned char **bytecode_data);
62
63// For module mode, embedded modules may have to be shifted to below the
64// namespace they are loaded into.
65#if _NUITKA_MODULE_MODE
66extern void updateMetaPathBasedLoaderModuleRoot(char const *module_root_name);
67#endif
68
69/* Create a loader object responsible for a package. */
70extern PyObject *Nuitka_Loader_New(struct Nuitka_MetaPathBasedLoaderEntry const *entry);
71
72// Create a distribution object from the given metadata.
73extern PyObject *Nuitka_Distribution_New(PyThreadState *tstate, PyObject *name);
74
75// Check if we provide a distribution object ourselves.
76extern bool Nuitka_DistributionNext(Py_ssize_t *pos, PyObject **distribution_name_ptr);
77
78#endif
79
80// Part of "Nuitka", an optimizing Python compiler that is compatible and
81// integrates with CPython, but also works on its own.
82//
83// Licensed under the Apache License, Version 2.0 (the "License");
84// you may not use this file except in compliance with the License.
85// You may obtain a copy of the License at
86//
87// http://www.apache.org/licenses/LICENSE-2.0
88//
89// Unless required by applicable law or agreed to in writing, software
90// distributed under the License is distributed on an "AS IS" BASIS,
91// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
92// See the License for the specific language governing permissions and
93// limitations under the License.
Definition unfreezing.h:31