Skip to content

Commit

Permalink
Module: Fix, the create ".pyi" files were incomplete
Browse files Browse the repository at this point in the history
* The list of imported modules created in finalization step was incomplete.

* Instead now go over the done modules and mark non-included modules as dependencies
  • Loading branch information
kayhayen committed May 15, 2024
1 parent e8ab90d commit a99c632
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
15 changes: 15 additions & 0 deletions nuitka/ModuleRegistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,21 @@ def getModuleOptimizationTimingInfos(module_name):
return module_timing_infos.get(module_name, ())


def getImportedModuleNames():
result = OrderedSet()

for module in getDoneModules():
for used_module in module.getUsedModules():
module_name = used_module.module_name

if hasDoneModule(module_name):
continue

result.add(module_name)

return result


# Part of "Nuitka", an optimizing Python compiler that is compatible and
# integrates with CPython, but also works on its own.
#
Expand Down
5 changes: 3 additions & 2 deletions nuitka/PostProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from nuitka import Options, OutputDirectories
from nuitka.build.DataComposerInterface import getConstantBlobFilename
from nuitka.finalizations.FinalizeMarkups import getImportedNames
from nuitka.ModuleRegistry import getImportedModuleNames
from nuitka.PythonVersions import (
getPythonABI,
getTargetPythonDLLPath,
Expand Down Expand Up @@ -420,7 +420,8 @@ def executePostProcessing():
"""
% {
"imports": "\n".join(
"import %s" % module_name for module_name in getImportedNames()
"import %s" % module_name
for module_name in getImportedModuleNames()
)
},
encoding="utf-8",
Expand Down
18 changes: 0 additions & 18 deletions nuitka/finalizations/FinalizeMarkups.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,9 @@
"""

from nuitka import Tracing
from nuitka.__past__ import unicode
from nuitka.containers.OrderedSets import OrderedSet
from nuitka.PythonVersions import python_version
from nuitka.tree.Operations import VisitorNoopMixin

imported_names = OrderedSet()


def getImportedNames():
return imported_names


class FinalizeMarkups(VisitorNoopMixin):
def onEnterNode(self, node):
Expand Down Expand Up @@ -66,16 +58,6 @@ def _onEnterNode(self, node):
else:
search.markAsNeedsGeneratorReturnHandling(1)

if node.isExpressionBuiltinImport() and node.follow_attempted:
module_name = node.subnode_name

if module_name.isCompileTimeConstant():
imported_module_name = module_name.getCompileTimeConstant()

if type(imported_module_name) in (str, unicode):
if imported_module_name:
imported_names.add(imported_module_name)

if node.isExpressionFunctionCreation():
if (
not node.getParent().isExpressionFunctionCall()
Expand Down

0 comments on commit a99c632

Please sign in to comment.