a
    bF                     @   s   d Z ddlZddlZddlmZmZmZ ddlmZ ddl	m
Z
 zddlmZ dZW n eyj   dZY n0 dZi add	d
Zedkred ddlmZ dS )zBuild a Pyrex file from .pyx source to .so loadable module using
the installed distutils infrastructure. Call:

out_fname = pyx_to_dll("foo.pyx")
    N)DistutilsArgErrorDistutilsErrorCCompilerError)	Extension)grok_environment_error)old_build_extTFc           $   	   C   s  t j| s J dt j|  t jt j| \}}	|st j|	\}
}|dv s\J |tsv| dt|  d } t|
| gd}|du ri }|st j	|d}|}|j
dddd	 D ]$}t j|\}}||krd} qq|d
g }tsd|v rd}nd}|dg}|r|d |r|r|d|g |j
dksR|j
drt|dsjddi|_nd|jvrd|jd< tr|r|d | }|d|| d ddlm} ||}|jsg |_|j| trdti|_|d}||_| }|| z| }W n ty4    Y n0 trLtd |   |sVJ zL|d}|!  |" d }|j#rt j	t j$| t j%|}|r|}t j&|}t'|d\}}}||kr|}nt j%|}|dk r|d7 }t j	|j(|d|  } zVddl)}!zt j*| r0t +|  W n t,yN   Y W qY n0 |!-||  | }W n t.y|   Y qY n0 qqt/d| |||ft'|< |W S  t0y   t12d Y nF t.t j3fy   t14 d }"t5|"}#tr t1j67|#d    Y n0 dS )!zUCompile a PYX file to a DLL and return the name of the generated .so
       or .dll .zCould not find %s)z.pyxz.pyNz.c)namesourcesZ_pyxbld.script_argsz	--verbosez--quiet	build_extz--forcez--build-lib__init__z	.__init__cython_directivesZset_initial_pathZ
SOURCEFILEz--pyrex-c-in-temp)script_namer   r   )Distributionbuildz%options (after parsing command line):)NNr   d      z	.reload%sz#reload count for %s reached maximum
)8ospathexistsabspathsplitsplitext
HAS_CYTHONlenr   joinr   getDEBUGappendextendendswithhasattrr   copyupdatedistutils.distr   ext_modulesr   cmdclassget_command_obj
build_basefind_config_filesparse_config_filesparse_command_liner   printdump_option_dictsrun_commandsget_outputsinplacedirnamebasenamegetmtime_reloads	build_libshutilisfileunlinkOSErrorcopy2IOErrorImportErrorKeyboardInterruptsysexiterrorexc_infor   stderrwrite)$filenameextZforce_rebuildZbuild_in_tempZpyxbuild_dirZ
setup_argsZreload_supportr4   r   r   modname	extensionZpackage_base_dirpackage_nameZpnamer   quietargsZsargsr   distr   ZcfgfilesokZobj_build_extZso_pathZorg_path	timestampZlast_timestampZ	last_pathcountr6   Zr_pathr:   excrD    rT   b/Users/vegardjervell/Documents/master/model/venv/lib/python3.9/site-packages/pyximport/pyxbuild.py
pyx_to_dll   s     












rV   __main__z	dummy.pyxr   )test)Nr   FNNFF)__doc__r   rB   distutils.errorsr   r   r   distutils.extensionr   distutils.utilr   ZCython.Distutils.old_build_extr   r   r   r@   r!   r8   rV   __name__ rX   rT   rT   rT   rU   <module>   s&   
  
 