3
”Rez ã @ s¬ d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlm Z e r\d dl
mZmZ ej
eƒZejdƒZdd„ Zdd „ Zd
d„ Zdd
„ Zdd„ Zdd„ Zdd„ ZdS )é )Úabsolute_importN)ÚMYPY_CHECK_RUNNING)ÚListÚOptionalz8include-system-site-packages\s*=\s*(?Ptrue|false)c C s t jtt dt jƒkS )znChecks if sys.base_prefix and sys.prefix match.
This handles PEP 405 compliant virtual environments.
Úbase_prefix)ÚsysÚprefixÚgetattr© r
r
ú�/builddir/build/BUILDROOT/alt-python36-pip-20.2.4-5.el8.x86_64/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/utils/virtualenv.pyÚ_running_under_venv s r c C s
t tdƒ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 )zGReturn True if we're running inside a virtualenv, False otherwise.
)r r r
r
r
r Úrunning_under_virtualenv( s r c C sP t jjtjdƒ} y&tj| dd��}|jƒ jƒ S Q R X W n t k
rJ dS X dS )z…Reads {sys.prefix}/pyvenv.cfg and returns its contents as list of lines
Returns None, if it could not read/access the file.
z
pyvenv.cfgzutf-8)ÚencodingN)
ÚosÚpathÚjoinr r ÚioÚopenÚreadÚ
splitlinesÚIOError)Úpyvenv_cfg_fileÚfr
r
r Ú_get_pyvenv_cfg_lines/ s r c C sR t ƒ } | dkrtjdƒ dS x0| D ](}tj|ƒ}|dk r"|jdƒdkr"dS q"W dS )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.
NzŽCould 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_venv? s
r&