o
    8} iW                     @  sr  d dl mZ d dl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d	ejv pQd
ejv pQedd ejD ZejejejdZeddkZdZd-d.ddZd-d.ddZd/ddZd0d!d"Z d#ejv rd$ejvre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 )1    )annotationsN)chain)castTYPE_CHECKING)IterableWindowsDarwinLinuxZcondaZ	Continuumc                 c  s    | ]}| d V  qdS )ZCONDAN)
startswith).0x r   9/home/app/PyTorch/test/pytorch/tools/setup_helpers/env.py	<genexpr>   s    r   z..P   build namestrdefaultreturnboolc                 C     t | | dv S )N)ON1ZYESTRUEYosgetenvupperr   r   r   r   r   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)r   vr   r   r   r   (   s   " zgather_paths.<locals>.<genexpr>)listr   )r+   r   r   r   gather_paths'   s   r2   	base_pathc                   s    fdddD S )Nc                   s   g | ]	}t j |qS r   )r   pathjoin)r   sr3   r   r   
<listcomp>,   s    z'lib_paths_from_base.<locals>.<listcomp>)zlib/x64libZlib64r   r7   r   r7   r   lib_paths_from_base+   s   r:   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   r4   r5   	BUILD_DIRisfilecmake_utilsrB   openr   r   environget)selfr>   Zcmake_cache_txtrB   fcmake_cache_varsr   r   r   __init__?   s   

zBuildType.__init__r   c                 C  
   | j dkS )zChecks Debug build.DebugrE   rL   r   r   r   is_debugR      
zBuildType.is_debugc                 C  rP   )zChecks RelWithDebInfo build.RelWithDebInforR   rS   r   r   r   is_rel_with_deb_infoV   rU   zBuildType.is_rel_with_deb_infoc                 C  rP   )zChecks Release build.rD   rR   rS   r   r   r   
is_releaseZ   rU   zBuildType.is_release)N)r>   r?   r   r@   )r   r   )__name__
__module____qualname____doc__rO   rT   rW   rX   r   r   r   r   r=   4   s    


r=   rC   DEBUGrQ   ZREL_WITH_DEB_INFOrV   rD   )r   )r   r   r   r   r   r   )r+   r,   r   r-   )r3   r   r   r-   )#
__future__r   r   platformstructsys	itertoolsr   typingr   r   collections.abcr   system
IS_WINDOWS	IS_DARWINIS_LINUXversionanyrJ   ZIS_CONDAr4   r5   dirname
executableZ	CONDA_DIRcalcsizeIS_64BITrF   r#   r*   r2   r:   r=   
build_typer   r   r   r   <module>   sD    



,

