o
    ;i                     @  s*  d dl mZ d dlZd dlZd dlZd dlmZ d dlmZm	Z	 e	r(d dl
mZ e dkZe dkZe dkZed	d
kZdZd(d)ddZd(d)ddZd*ddZd+ddZdejv rkdejvrkejd ejd< G d d! d!Zd"ejvred#rd$ejd"< ned%rd&ejd"< nd'ejd"< e ZdS ),    )annotationsN)chain)castTYPE_CHECKING)IterableWindowsDarwinLinuxP   build namestrdefaultreturnboolc                 C     t | | dv S )N)ON1ZYESTRUEYosgetenvupperr   r    r   4/home/app/PyTorch/pytorch/tools/setup_helpers/env.pycheck_env_flag      r   c                 C  r   )N)OFF0NOFALSENr   r   r   r   r   check_negative_env_flag   r    r&   env_varsIterable[str]	list[str]c                 C  s   t tdd | D  S )Nc                 s  s$    | ]}t |d t jV  qdS )r   N)r   r   splitpathsep).0vr   r   r   	<genexpr>    s   " zgather_paths.<locals>.<genexpr>)listr   )r'   r   r   r   gather_paths   s   r0   	base_pathc                   s    fdddD S )Nc                   s   g | ]	}t j |qS r   )r   pathjoin)r,   sr1   r   r   
<listcomp>$   s    z'lib_paths_from_base.<locals>.<listcomp>)zlib/x64libZlib64r   r5   r   r5   r   lib_paths_from_base#   s   r8   CFLAGSCXXFLAGSc                   @  s:   e Zd ZdZddddZdd
dZdddZdddZdS )	BuildTypea  Checks build type. The build type will be given in :attr:`cmake_build_type_env`. If :attr:`cmake_build_type_env`
    is ``None``, then the build type will be inferred from ``CMakeCache.txt``. If ``CMakeCache.txt`` does not exist,
    os.environ['CMAKE_BUILD_TYPE'] will be used.

    Args:
      cmake_build_type_env (str): The value of os.environ['CMAKE_BUILD_TYPE']. If None, the actual build type will be
        inferred.

    Ncmake_build_type_env
str | Noner   Nonec                 C  s   |d ur	|| _ d S tjtd}tj|r>ddlm} t|}||}W d    n1 s/w   Y  t	t
|d | _ d S tjdd| _ d S )NzCMakeCache.txt   )#get_cmake_cache_variables_from_fileCMAKE_BUILD_TYPERelease)build_type_stringr   r2   r3   	BUILD_DIRisfilecmake_utilsr@   openr   r   environget)selfr<   Zcmake_cache_txtr@   fcmake_cache_varsr   r   r   __init__7   s   

zBuildType.__init__r   c                 C  
   | j dkS )zChecks Debug build.DebugrC   rJ   r   r   r   is_debugJ      
zBuildType.is_debugc                 C  rN   )zChecks RelWithDebInfo build.RelWithDebInforP   rQ   r   r   r   is_rel_with_deb_infoN   rS   zBuildType.is_rel_with_deb_infoc                 C  rN   )zChecks Release build.rB   rP   rQ   r   r   r   
is_releaseR   rS   zBuildType.is_release)N)r<   r=   r   r>   )r   r   )__name__
__module____qualname____doc__rM   rR   rU   rV   r   r   r   r   r;   ,   s    


r;   rA   DEBUGrO   ZREL_WITH_DEB_INFOrT   rB   )r   )r   r   r   r   r   r   )r'   r(   r   r)   )r1   r   r   r)   )
__future__r   r   platformstruct	itertoolsr   typingr   r   collections.abcr   system
IS_WINDOWS	IS_DARWINIS_LINUXcalcsizeIS_64BITrD   r   r&   r0   r8   rH   r;   
build_typer   r   r   r   <module>   s6    


,

