o
    0g                     @   s   d dl Z d dlZd dlZd dlZd dlZd dlmZmZ e e	Z
edZdd Zdd Zdd	 Zd
d Zdd Zdd Zdd ZdS )    N)ListOptionalz8include-system-site-packages\s*=\s*(?P<value>true|false)c                   C   s   t jtt dt jkS )znChecks if sys.base_prefix and sys.prefix match.

    This handles PEP 405 compliant virtual environments.
    base_prefix)sysprefixgetattr r   r   e/home/www/bk.finsightngr.online/venv20/lib/python3.10/site-packages/pip/_internal/utils/virtualenv.py_running_under_venv   s   r
   c                   C   s
   t tdS )zmChecks if sys.real_prefix is set.

    This handles virtual environments created with pypa's virtualenv.
    real_prefix)hasattrr   r   r   r   r	   !_running_under_regular_virtualenv   s   
r   c                   C   s   t  pt S )zBReturn True if we're running inside a virtualenv, False otherwise.)r
   r   r   r   r   r	   running_under_virtualenv!   s   r   c                  C   sf   t jtjd} z t| dd}|  W  d   W S 1 s!w   Y  W dS  ty2   Y dS w )zReads {sys.prefix}/pyvenv.cfg and returns its contents as list of lines

    Returns None, if it could not read/access the file.
    z
pyvenv.cfgzutf-8)encodingN)	ospathjoinr   r   openread
splitlinesOSError)pyvenv_cfg_filefr   r   r	   _get_pyvenv_cfg_lines'   s   
(r   c                  C   sP   t  } | du rtd dS | D ]}t|}|dur%|ddkr% dS qdS )aZ  Check `{sys.prefix}/pyvenv.cfg` for system site-packages inclusion

    PEP 405 specifies that when system site-packages are not supposed to be
    visible from a virtual environment, `pyvenv.cfg` must contain the following
    line:

        include-system-site-packages = false

    Additionally, log a warning if accessing the file fails.
    NzCould not access 'pyvenv.cfg' despite a virtual environment being active. Assuming global site-packages is not accessible in this environment.TvaluefalseF)r   loggerwarning#_INCLUDE_SYSTEM_SITE_PACKAGES_REGEXmatchgroup)	cfg_linesliner   r   r   r	   _no_global_under_venv7   s   
r#   c                  C   s0   t jt jtj} t j| d}t j|S )zCheck if "no-global-site-packages.txt" exists beside site.py

    This mirrors logic in pypa/virtualenv for determining whether system
    site-packages are visible in the virtual environment.
    zno-global-site-packages.txt)r   r   dirnameabspathsite__file__r   exists)site_mod_dirno_global_site_packages_filer   r   r	   #_no_global_under_regular_virtualenvU   s   r+   c                   C   s   t  rt S t rt S dS )zHReturns a boolean, whether running in venv with no system site-packages.F)r
   r#   r   r+   r   r   r   r	   virtualenv_no_globald   s
   r,   )loggingr   rer&   r   typingr   r   	getLogger__name__r   compiler   r
   r   r   r   r#   r+   r,   r   r   r   r	   <module>   s"    
	
