o
    :ήcW                     @   sv   d dl Z d dlZd dlmZ d dlmZ dZze W n ey+   G dd de	ZY nw dd Z
dd
dZdd ZdS )    N)version)	cpu_countz0.23.4c                   @   s   e Zd ZdS )WindowsErrorN)__name__
__module____qualname__ r   r   5/tmp/pip-target-vg8gfxp4/lib/python/skimage/_build.pyr      s    r   c                 C   sF   |  dd dd}dD ]}|| }tj|r|  S qtdt )z;Check for the presence of a .pyx[.in] file as a .c or .cpp.z.in .pyx)z.cz.cppz@Cython >= %s is required to build scikit-image from git checkout)replaceospathexistsRuntimeErrorCYTHON_VERSION)fbasenameextfilenamer   r   r	   _compiled_filename   s   r   r
   c              	      s  t tjdkrtjd dkrdS zddlm} t|ttk r'tdt ddl	m
} W n tyL    fd	d
| D }tdtd|f  Y dS w  fdd
| D } t| D ]\}}|drot| |dd| |< qZdtjvr|| t ddid dS dS )zUse Cython to convert the given files to C.

    Parameters
    ----------
    pyx_files : list of str
        The input .pyx files.

          cleanNr   )__version__z)Cython >= %s needed to build scikit-image)	cythonizec                    s   g | ]}t tj |qS r   )r   r   r   join.0r   working_pathr   r	   
<listcomp>3   s    zcython.<locals>.<listcomp>z4Cython >= %s not found; falling back to pre-built %s c                    s   g | ]	}t j |qS r   )r   r   r   r   r   r   r	   r!   9   s    .pyx.inr   sdistlanguage_level   )nthreadscompiler_directives)lensysargvCythonr   r   parser   r   Cython.Buildr   ImportErrorprintr   	enumerateendswithprocess_tempita_pyxr   r   )	pyx_filesr    r   r   c_files_usedipyxfiler   r   r	   cython   s4   

	


r8   c                 C   s   zzddl m} W n ty   dd l}Y nw W n ty#   tdw |jj| t d}|	 }| 
ds=td|  tj| d }t|d}|| W d    d S 1 s[w   Y  d S )Nr   )Tempitaz5Building requires Tempita: pip install --user Tempita)encodingr#   zUnexpected extension of %s.w)r,   r9   r/   tempita	ExceptionTemplatefrom_filenamer*   getdefaultencoding
substituter2   
ValueErrorr   r   splitextopenwrite)fromfiler<   template
pyxcontentr7   r   r   r   r	   r3   H   s(   
"r3   )r
   )r*   r   	packagingr   multiprocessingr   r   r   	NameErrorr=   r   r8   r3   r   r   r   r	   <module>   s    
+