NL ibdUdZddlmZddlZddlZddlZddlZddlZddl m Z ddl m Z m Z mZmZmZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lm Z ddl!m"Z"m#Z#m$Z$ddl%m&Z&ddl'm(Z(ddl)m*Z*ddl+m,Z, ddl-Z-e r4ej^dk\rddl-m0Z0nddl1m0Z2ddl3m4Z4ddl-m0Z5ee5e2fZ0de6d<ej^dk\r ddl7m8Z8m9Z9nddl7m8Z8m9Z9d.dZ:d/dZ;d0dZ d4dZ?d5d Z@d6d!ZA d7d"ZB d8d#ZC d9d$ZDd:d%ZE d;d&ZFdd-ZIy#e.$rY%wxYw)?aSupport for building extensions using mypyc with distutils or setuptools The main entry point is mypycify, which produces a list of extension modules to be passed to setup. A trivial setup.py for a mypyc built project, then, looks like: from setuptools import setup from mypyc.build import mypycify setup(name='test_module', ext_modules=mypycify(['foo.py']), ) See the mypycify docs for additional arguments. mypycify can integrate with either distutils or setuptools, but needs to know at import-time whether it is using distutils or setuputils. We hackily decide based on whether setuptools has been imported already. ) annotationsN)Iterable) TYPE_CHECKINGAnyNoReturnUnioncast) BuildSource) CompileError)FileSystemCache)process_options)Options)write_junit_xml)generate_annotated_html) emitmodule)IS_FREE_THREADEDRUNTIME_C_FILESshared_lib_name)Errors)format_modules) exported_name)CompilerOptions ) Extension) TypeAliasrr) ccompiler sysconfigcdtjv}tjdkr|sddl}|jj }|S|stj dtj }|S)N setuptoolsrrzerror: setuptools not installed)sysmodules version_infodistutils.corecorerexitr!)use_setuptools distutilsextension_classs Q/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/mypyc/build.py get_extensionr,Esa"S[[0N '!.#..22   HH6 7$.. cttttftj}t j dk(rI|djdd|d<|djdd|d<|djdd|d<yy)z6Rewrite a bunch of config vars in pretty dubious ways.darwinLDSHAREDz -arch i386LDFLAGSCFLAGSN)r dictstrrget_config_varsr"platformreplace)varss r+setup_mypycify_varsr:Ws S#X 9 9 ; zmypyc_build..s61sahh6sz6If using custom group_name, only one group is expected)r_zops.txtz.c)r rfranyrrvrrqrlrRrE target_dirmypyc_skip_c_generationsplitextrr)pathsr_rSr^rrrMrcr`rFrr group_cfilesops_textgroup_cfilenamesr cfilenamescfilerdeprs r+ mypyc_buildrsG*9 !#3W+'M; MQ ! 6 6 6 !  mX~GWGbGb cF"".6{aY!YY !+ &'DT"  h 277<< 0 ; ;YGR& ;= 4 " )LE5GGLL!1!bbT 23 4 # ##cs!1F-31)r^r opt_level debug_level strip_asserts multi_filerSrrinclude_runtime_filesstrict_dunder_typingrv log_tracedepends_on_native_internalinstall_native_libsc t||||du| | | | | | }t|||||\}}ttj}t j ||j}g}|jdk(r+|d|d|ddd d d d d dddg z }| rq|jdn_|jdk(rP|dk(rd}n|dvrd}|dk(rd}n|dk(rd}n|dvrd}|d|d|ddd gz }|r|d!d"gz }| r|jd#g}|jstD]}tjj||}ttjjt!|d$%5}t#||j%d&d&d&|j|g}t'||D]O\\}}\}}|r#|j)t+||||z|||1|j)t-|||z|Q|rd'gtzD]x}tjj||}ttjjt!|d$%5}t#||j%d&d&d&z|jt/d(d'gtzDcgc]"}tjj||$c}t!g|)|S#1swYfxYw#1swYxYwcc}w)*a Main entry point to building using mypyc. This produces a list of Extension objects that should be passed as the ext_modules parameter to setup. Arguments: paths: A list of file paths to build. It may also contain mypy options. only_compile_paths: If not None, an iterable of paths that are to be the only modules compiled, even if other modules appear in the mypy command line given to paths. (These modules must still be passed to paths.) verbose: Should mypyc be more verbose. Defaults to false. opt_level: The optimization level, as a string. Defaults to '3' (meaning '-O3'). debug_level: The debug level, as a string. Defaults to '1' (meaning '-g1'). strip_asserts: Should asserts be stripped from the generated code. multi_file: Should each Python module be compiled into its own C source file. This can reduce compile time and memory requirements at the likely cost of runtime performance of compiled code. Defaults to false. separate: Should compiled modules be placed in separate extension modules. If False, all modules are placed in a single shared library. If True, every module is placed in its own library. Otherwise, separate should be a list of (file name list, optional shared library name) pairs specifying groups of files that should be placed in the same shared library (while all other modules will be placed in its own library). Each group can be compiled independently, which can speed up compilation, but calls between groups can be slower than calls within a group and can't be inlined. target_dir: The directory to write C output files. Defaults to 'build'. include_runtime_files: If not None, whether the mypyc runtime library should be directly #include'd instead of linked separately in order to reduce compiler invocations. Defaults to False in multi_file mode, True otherwise. strict_dunder_typing: If True, force dunder methods to have the return type of the method strictly, which can lead to more optimization opportunities. Defaults to False. group_name: If set, override the default group name derived from the hash of module names. This is used for the names of the output C files and the shared library. This is only supported if there is a single group. [Experimental] log_trace: If True, compiled code writes a trace log of events in mypyc_trace.txt (derived from executed operations). This is useful for performance analysis, such as analyzing which primitive ops are used the most and on which lines. depends_on_native_internal: This is True only for mypy itself. install_native_libs: If True, also build the native extension modules. Normally, those are build and published on PyPI separately, but during tests, we want to use their development versions (i.e. from current commit). F) rrrrSrrrrvrr)r^r_rSrunixz-Oz-gz-Werrorz-Wno-unused-functionz-Wno-unused-labelz-Wno-unreachable-codez-Wno-unused-variablez!-Wno-unused-command-line-argumentz-Wno-unknown-warning-optionz-Wno-unused-but-set-variablez"-Wno-ignored-optimization-argumentz-Wno-cppz-DMYPYC_LOG_TRACEmsvc0d)r2rrNONErFASTLINK)rrFULLz/Oz/DEBUG:z/wd4102z/wd4101z/wd4146z/GL-z/wd9025z/DMYPYC_LOG_TRACEr)encodingNznative_internal.cnative_internalr)rrr:r new_compilerrcustomize_compilerr compiler_typerrrrlrRrErnrorqrpziprrrr,) rr^rrrrrrSrrrrrvrrrr_rrcompilerrcflagsshared_cfilenamesrrt_filerzrrlib_namerrfiles r+mypycifyr sqX'#&31#=  + -)'  F  **,H   * ++IF'    "  # " / ) * 0     MM- .   6 )  I / )I #  K C $K J & K k] #        vy) )F  MM- .   1 1# .Dggll9d3Gbggll;=$7'J .a7AFFH- .  $ $W -  . J9r-sk(# $<<"$(% %2$KK*')  7"(D/A$%: