
    y/Yh                         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 j                  e	      Z
 ej                  d      ZdefdZdefdZdefdZdeee      fdZdefd	Zdefd
ZdefdZy)    N)ListOptionalz8include-system-site-packages\s*=\s*(?P<value>true|false)returnc                  b    t         j                  t        t         dt         j                        k7  S )znChecks if sys.base_prefix and sys.prefix match.

    This handles PEP 405 compliant virtual environments.
    base_prefix)sysprefixgetattr     _/var/www/html/profi_bot/bot/venv/lib/python3.12/site-packages/pip/_internal/utils/virtualenv.py_running_under_venvr      s     
 ::mSZZ@@@r   c                  "    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    _running_under_legacy_virtualenvr      s     3&&r   c                  .    t               xs
 t               S )zDTrue if we're running inside a virtual environment, False otherwise.)r   r   r   r   r   running_under_virtualenvr      s     F$D$FFr   c                      t         j                  j                  t        j                  d      } 	 t        | d      5 }|j                         j                         cddd       S # 1 sw Y   yxY w# t        $ r Y yw xY 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fs     r   _get_pyvenv_cfg_linesr    $   s^    
 ggll3::|<O /G4668&&( 544 s.   A1 A%	A1 %A.*A1 .A1 1	A=<A=c                      t               } | t        j                  d       y| D ]0  }t        j	                  |      }||j                  d      dk(  s0 y y)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.
    zCould 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'   s      r   _no_global_under_venvr+   3   sb     &'I 	#	

 399$?W!5!@  r   c                     t         j                  j                  t         j                  j                  t        j
                              } t         j                  j                  | d      }t         j                  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_files     r   "_no_global_under_legacy_virtualenvr4   P   sV     77??277??4==#ABL#%77<<%$  77>>677r   c                  T    t               r
t               S t               r
t               S y)zHReturns a boolean, whether running in venv with no system site-packages.F)r   r+   r   r4   r   r   r   virtualenv_no_globalr6   ^   s%     $&&')133r   )loggingr   rer/   r   typingr   r   	getLogger__name__r$   compiler&   boolr   r   r   strr    r+   r4   r6   r   r   r   <module>r?      s     	 	  
 !			8	$&0bjj?' #
AT A'$ 'G$ G
xS	2 t :8D 8
d 
r   