o
    wi{3                     @   s   d dl Z d dlmZmZmZmZ ddlmZ G dd deZG dd deZ	G d	d
 d
eZ
G dd deZG dd deZG dd deZG dd deZG dd deZdd Zdd Zdd ZdS )    N)ArgumentParserActionSUPPRESSRawDescriptionHelpFormatter   )Optionsc                   @      e Zd ZdddZdS )ParseDirectivesActionNc                 C   s8   t t|| jt }tj|d|d}t|| j| d S )NT)relaxed_boolcurrent_settings)dictgetattrdestr   get_directive_defaultsparse_directive_listsetattr)selfparser	namespacevaluesoption_stringold_directives
directives r   T/home/ubuntu/sommelier/.venv/lib/python3.10/site-packages/Cython/Compiler/CmdLine.py__call__   s   
zParseDirectivesAction.__call__N__name__
__module____qualname__r   r   r   r   r   r	          r	   c                   @   r   )ParseOptionsActionNc           	      C   sl   t t|| ji }|dD ]}d|v r#|dd\}}| dv}n|d}}|||< qt|| j| d S )N,=r   )falsef0noT)r   r   r   splitlowerr   )	r   r   r   r   r   optionsoptnvr   r   r   r      s   

zParseOptionsAction.__call__r   r   r   r   r   r   r"      r!   r"   c                   @   r   )ParseCompileTimeEnvActionNc                 C   s2   t t|| ji }tj||d}t|| j| d S )N)r   )r   r   r   r   parse_compile_time_envr   )r   r   r   r   r   old_envnew_envr   r   r   r   "   s   z"ParseCompileTimeEnvAction.__call__r   r   r   r   r   r   r/   !   r!   r/   c                   @   r   )ActivateAllWarningsActionNc                 C   s"   t |di }|tj ||_d S )Ncompiler_directives)r   updater   extra_warningsr4   )r   r   r   r   r   r   r   r   r   r   )   s   
z"ActivateAllWarningsAction.__call__r   r   r   r   r   r   r3   (   r!   r3   c                   @   r   )SetLenientActionNc                 C   s   d|_ d|_d S )NF)error_on_unknown_nameserror_on_uninitializedr   r   r   r   r   r   r   r   r   0      
zSetLenientAction.__call__r   r   r   r   r   r   r7   /   r!   r7   c                   @   r   )SetGDBDebugActionNc                 C   s   d|_ tj|_d S NT)	gdb_debugoscurdir
output_dirr:   r   r   r   r   6   s   zSetGDBDebugAction.__call__r   r   r   r   r   r   r<   5   r!   r<   c                   @   r   )SetGDBDebugOutputActionNc                 C      d|_ ||_d S r=   )r>   rA   r:   r   r   r   r   <   r;   z SetGDBDebugOutputAction.__call__r   r   r   r   r   r   rB   ;   r!   rB   c                   @   r   )SetAnnotateCoverageActionNc                 C   rC   r=   )annotateannotate_coverage_xmlr:   r   r   r   r   B   r;   z"SetAnnotateCoverageAction.__call__r   r   r   r   r   r   rD   A   r!   rD   c               	   C   s~  d} t | ttdd}|jdddddd	d
 |jddddddd
 |jdddddd |jddddtdd |jddddddd
 |jdd ddd!d"d
 |jd#d$d%d&d'd |jd(d)d*ddd+d
 |jd,d-dtd.d |jd/d0d1d2d |jd3d4d5dtd6d |jd7td!d8d9 |jd:ttd;d< |jd=d>d?d@dAd |jdBdCddDdEdFdG |jdHddIdEdJdG |jdKdLttdMd |jdNdOd1dPd |jdQdRdSdddTd
 |jdUddVdWdX |jdYdZdd[d\d
 |jd]dZdd^d_d
 |jd`dZddadbd
 |jdct	d!ddd9 |jdedfd1dgd |jdhdid1djd |jdkdldmd1dnd |jdodpt
d!dqd9 |jdrdsdtduttdvdw |jdxdydtdzttd{dw |jd|d}tdd~d |jddd1dd |jdddtdd |jdddtdd |jddg d |jddddttd |jddd1td |jddd@td |jddd1td |jddd1td ddlm} t|D ]}|dr|dd}|jd| d1td q|S )Nz|Cython (https://cython.org/) is a compiler for code written in the Cython language.  Cython is based on Pyrex by Greg Ewing.zYEnvironment variables:
  CYTHON_CACHE_DIR: the base directory containing Cython's caches.)descriptionargument_defaultformatter_classepilogz-Vz	--versionshow_versionstore_constr   z)Display version number of cython compiler)r   actionconsthelpz-lz--create-listinguse_listing_filez&Write error messages to a listing filez-Iz--include-dirinclude_pathappendzWSearch for include files in named directory (multiple include directories are allowed).)r   rM   rO   z-oz--output-fileoutput_filestorez Specify name of generated C file)r   rM   typerO   z-tz--timestamps
timestampszOnly compile newer source filesz-fz--forcer   z/Compile all source files (overrides implied -t)z-vz	--verboseverbosecountz4Be verbose, print file names on multiple compilationz-pz--embed-positionsembed_pos_in_docstringzeIf specified, the positions in Cython files of each function definition is embedded in its docstring.z	--cleanupgenerate_cleanup_codezzRelease interned objects on python exit, for memory debugging. Level indicates aggressiveness, default 0 releases nothing.z--cachecache
store_truez!Enables Cython compilation cache.z-wz	--workingworking_pathzOSets the working directory for Cython (the directory modules are searched from)z--gdbz"Output debug information for cygdb)rM   nargsrO   z--gdb-outdirz>Specify gdb debug information output directory. Implies --gdb.)rM   rU   rO   z-Dz--no-docstrings
docstringsstore_falsez*Strip docstrings from the compiled module.z-az
--annotatedefaultrE   z/Produce a colorized HTML version of the source.)rM   rN   r   rO   z--annotate-fullcfullczZProduce a colorized HTML version of the source which includes entire generated C/C++-code.z--annotate-coveragerF   z7Annotate and include coverage information from cov.xml.z--line-directivesemit_linenumsz4Produce #line directives pointing to the .pyx sourcez-+z--cpluscplusz Output a C++ rather than C file.--embedmainzwGenerate a main() function that embeds the Python interpreter. Pass --embed=<method_name> for a name other than main().)rM   rN   rO   z-2language_level   z4Compile based on Python-2 syntax and code semantics.z-3   z4Compile based on Python-3 syntax and code semantics.z--3str3zRCompile based on Python-3 syntax and code semantics (same as -3 since Cython 3.1).z	--lenientzQChange some compile time errors to runtime errors to improve Python compatibilityz--capi-reexport-cincludescapi_reexport_cincludesz9Add cincluded headers to any auto-generated header files.z--fast-fail	fast_failz(Abort the compilation on the first errorz-Werrorz--warning-errorswarning_errorszMake all warnings into errorsz-Wextraz--warning-extrazEnable extra warningsz-Xz--directivezNAME=VALUE,...r4   zOverrides a compiler directive)metavarr   rU   rM   rO   z-Ez--compile-time-envcompile_time_envz,Provides compile time env like DEF would do.z--module-namemodule_namezFully qualified module name. If not given, is deduced from the import path if source file is in a package, or equals the filename otherwise.)r   rU   rM   rO   z-Mz	--depfilez produce depfiles for the sources)rM   rO   z--generate-sharedshared_c_file_pathz,Generates shared module with specified name.z--sharedshared_utility_qualified_namezQImports utility code from shared module specified by fully qualified module name.sources*)r^   ra   z-zz--pre-import
pre_importz--convert-rangeconvert_rangez--no-c-in-tracebackc_line_in_tracebackz--cimport-from-pyxcimport_from_pyxz--old-style-globalsold_style_globals
DebugFlagsdebug_-z--)r   r   r   add_argumentstrintr<   rB   rD   r7   r3   r	   r/    r{   vars
startswithreplace)rG   r   r{   nameoption_namer   r   r   create_cython_argparserF   s   	









r   c                 C   s   dd }||\}}|  |\}}|j}|`|D ]}|dr'| d|  q|| q|D ]}	|	dkr8d}
n|	tdd  }
t|d|
 q/||fS )	Nc                 S   sD   g g }}| D ]}|dks| dr|| q|| q||fS )Nre   --embed=)r   rR   )args
with_embedwithout_embedxr   r   r   filter_out_embed_options   s   
z8parse_command_line_raw.<locals>.filter_out_embed_optionsr~   zunknown option re   rf   r   embed)parse_known_argsrs   r   errorrR   lenr   )r   r   r   r   args_without_embed	argumentsunknownrs   optionr   r   r   r   r   parse_command_line_raw   s   	
r   c                 C   s  t  }t|| \}}t|dd}|D ]&}|r#tj|s#tj||}tj|s8dd l}t	|j
t|j
|qttj}t| D ]6\}}	|driddlm}
 |t|
v rat|
||	 qE|d|  qEtt|rutt||	 qEt|||	 qE|jrt|dkr|d |jrt|dkr|d	 nt|dkr|js|d
 tjrt|dkr|d |jr|jr|d t|dkr|d ||fS )Nr]   r   r   r|   r   rz   zUnknown debug flag: %s
z3cython: Only one source file allowed when using -o
z=cython: Source file not allowed when using --generate-shared
z&cython: Need at least one source file
z8cython: Only one source file allowed when using --embed
z3cython: Cannot use --module-name with --timestamps
z>cython: Only one source file allowed when using --module-name
)r   r   r   r?   pathisabsjoinexistserrnoFileNotFoundErrorENOENTstrerrorr   CompilationOptionsdefault_optionsr   itemsr   r   r{   dirr   r   hasattrrP   r   rq   rK   r   rp   rV   )r   r   r   rs   work_dirsourcer   r+   r   valuer{   r   r   r   parse_command_line   sH   







r   )r?   argparser   r   r   r   r   r   r	   r"   r/   r3   r7   r<   rB   rD   r   r   r   r   r   r   r   <module>   s   	r$