Todo: 集成多平台 解决因SaiNiu线程抢占资源问题 本地提交测试环境打包 和 正式打包脚本与正式环境打包bat 提交Python32环境包 改进多日志文件生成情况修改打包日志细节

This commit is contained in:
2025-09-18 15:52:03 +08:00
parent 8b9fc925fa
commit 7cfc0c22b7
7608 changed files with 2424791 additions and 25 deletions

View File

@@ -0,0 +1 @@
__version__ = '0.17'

View File

@@ -0,0 +1,89 @@
import sys
import os
import argparse
from .modulegraph import ModuleGraph
def parse_arguments():
parser = argparse.ArgumentParser(
conflict_handler='resolve', prog='%s -mmodulegraph' % (
os.path.basename(sys.executable)))
parser.add_argument(
'-d', action='count', dest='debug', default=1,
help='Increase debug level')
parser.add_argument(
'-q', action='store_const', dest='debug', const=0,
help='Clear debug level')
parser.add_argument(
'-m', '--modules', action='store_true',
dest='domods', default=False,
help='arguments are module names, not script files')
parser.add_argument(
'-x', metavar='NAME', action='append', dest='excludes',
default=[], help='Add NAME to the excludes list')
parser.add_argument(
'-p', action='append', metavar='PATH', dest='addpath', default=[],
help='Add PATH to the module search path')
parser.add_argument(
'-g', '--dot', action='store_const', dest='output', const='dot',
help='Output a .dot graph')
parser.add_argument(
'-h', '--html', action='store_const',
dest='output', const='html', help='Output a HTML file')
parser.add_argument(
'scripts', metavar='SCRIPT', nargs='+', help='scripts to analyse')
opts = parser.parse_args()
return opts
def create_graph(scripts, domods, debuglevel, excludes, path_extras):
# Set the path based on sys.path and the script directory
path = sys.path[:]
if domods:
del path[0]
else:
path[0] = os.path.dirname(scripts[0])
path = path_extras + path
if debuglevel > 1:
print("path:", file=sys.stderr)
for item in path:
print(" ", repr(item), file=sys.stderr)
# Create the module finder and turn its crank
mf = ModuleGraph(path, excludes=excludes, debug=debuglevel)
for arg in scripts:
if domods:
if arg[-2:] == '.*':
mf.import_hook(arg[:-2], None, ["*"])
else:
mf.import_hook(arg)
else:
mf.add_script(arg)
return mf
def output_graph(output_format, mf):
if output_format == 'dot':
mf.graphreport()
elif output_format == 'html':
mf.create_xref()
else:
mf.report()
def main():
opts = parse_arguments()
mf = create_graph(
opts.scripts, opts.domods, opts.debug,
opts.excludes, opts.addpath)
output_graph(opts.output, mf)
if __name__ == '__main__': # pragma: no cover
try:
main()
except KeyboardInterrupt:
print("\n[interrupt]")

View File

@@ -0,0 +1,61 @@
"""
modulegraph.find_modules - High-level module dependency finding interface
=========================================================================
History
........
Originally (loosely) based on code in py2exe's build_exe.py by Thomas Heller.
"""
import os
import pkgutil
from .modulegraph import Alias
def get_implies():
def _xml_etree_modules():
import xml.etree
return [
f"xml.etree.{module_name}"
for _, module_name, is_package in pkgutil.iter_modules(xml.etree.__path__)
if not is_package
]
result = {
# imports done from C code in built-in and/or extension modules
# (untrackable by modulegraph).
"_curses": ["curses"],
"posix": ["resource"],
"gc": ["time"],
"time": ["_strptime"],
"datetime": ["time"],
"parser": ["copyreg"],
"codecs": ["encodings"],
"_sre": ["copy", "re"],
"zipimport": ["zlib"],
# _frozen_importlib is part of the interpreter itself
"_frozen_importlib": None,
# os.path is an alias for a platform specific module,
# ensure that the graph shows this.
"os.path": Alias(os.path.__name__),
# Python >= 3.2:
"_datetime": ["time", "_strptime"],
"_json": ["json.decoder"],
"_pickle": ["codecs", "copyreg", "_compat_pickle"],
"_posixsubprocess": ["gc"],
"_ssl": ["socket"],
# Python >= 3.3:
"_elementtree": ["pyexpat"] + _xml_etree_modules(),
# This is not C extension, but it uses __import__
"anydbm": ["dbhash", "gdbm", "dbm", "dumbdbm", "whichdb"],
# Known package aliases
"wxPython.wx": Alias('wx'),
}
return result

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,21 @@
import dis
import inspect
def iterate_instructions(code_object):
"""Delivers the byte-code instructions as a continuous stream.
Yields `dis.Instruction`. After each code-block (`co_code`), `None` is
yielded to mark the end of the block and to interrupt the steam.
"""
# The arg extension the EXTENDED_ARG opcode represents is automatically handled by get_instructions() but the
# instruction is left in. Get rid of it to make subsequent parsing easier/safer.
yield from (i for i in dis.get_instructions(code_object) if i.opname != "EXTENDED_ARG")
yield None
# For each constant in this code object that is itself a code object,
# parse this constant in the same manner.
for constant in code_object.co_consts:
if inspect.iscode(constant):
yield from iterate_instructions(constant)