
    !<i4                        d dl Z d dlZd dlZd dlmZmZmZmZmZ d dl	m
Z
 d dlmZ d dlmZ d dlmZ d dlmZ d dlmZmZ  ej        e          Zd	 Zed
             Zd Zd Zd Zd Zd Z 	 	 dde
e!         de
e!         ddfdZ"dS )    N)PIPECalledProcessErrorPopenSubprocessError
check_call)Optional)Requirement)default_instrumentations)	libraries)__version__)PackageNotFoundErrorversionc                      d fd	}|S )Nc                     	 | r |           S              S # t           $ rJ}t          |dd           }|rdd                    |           d}| r| d|  d}t          |          d }~ww xY w)NcmdzError calling system command " "z for package ")r   getattrjoinRuntimeError)packageexpr   msgfuncs       /Users/kimhansen/Desktop/03 Workspace/ceo-agents/chl-effectiveness/mcp-servers/whoop/.venv/lib/python3.11/site-packages/opentelemetry/instrumentation/bootstrap.pywrapperz_syscall.<locals>.wrapper-   s    
	$ %tG}}$466M 	$ 	$ 	$#ud++C HGsxx}}GGG 766G666s###	$s    	 
A.AA))A.N )r   r   s   ` r   _syscallr   ,   s(    $ $ $ $ $ $ N    c           
          	 t          t          j        dddddd| g           d S # t          $ r}t	          |           Y d }~d S d }~ww xY w)N-mpipinstallz-Uz--upgrade-strategyzonly-if-needed)r   sys
executabler   print)r   errors     r   _sys_pip_installr)   =   sz    $ 		
 	
 	
 	
 	
    es   !% 
A	AA	c                 b   t          t          j        dddgt                    5 }|                                d                                         }|                                }ddd           n# 1 swxY w Y   | D ]/}|D ]*}|                                |v rt          d|           +0dS )aw  Ensures none of the instrumentations have dependency conflicts.
    Clean check reported as:
    'No broken requirements found.'
    Dependency conflicts are reported as:
    'opentelemetry-instrumentation-flask 1.0.1 has requirement opentelemetry-sdk<2.0,>=1.0, but you have opentelemetry-sdk 0.5.'
    To not be too restrictive, we'll only check for relevant packages.
    r"   r#   check)stdoutr   NzDependency conflict found: )r   r%   r&   r   communicatedecodelowerr   )r   
check_pipe	pip_checkpip_check_lowerpackage_tupr   s         r   
_pip_checkr4   Q   s    
	ug.t
 
 
 ,	**,,Q/6688	#//++	, , , , , , , , , , , , , , ,
 ! N N" 	N 	NG}}/11"#L#L#LMMM 2	NN Ns   AA22A69A6c                     t          |           } 	 t          | j                  }n# t          $ r Y dS w xY w| j                            |          st                              d| |           dS dS )NFzRinstrumentation for package %s is available but version %s is installed. Skipping.T)r	   r   namer   	specifierfilterloggerwarning)reqdist_versions     r   _is_installedr=   d   s    
c

Csx((   uu =-- 6		
 	
 	
 u4s   & 
44c              #   d   K   | D ]}|V  |D ]!}t          |d                   r
|d         V  "d S )Nlibraryinstrumentation)r=   r
   r   libs      r   _find_installed_librariesrC   w   s`      '  				 ) )Y(( 	)'(((() )r    c                     t                               t          j                   t	          d                    t          | |                               d S )N
)r9   setLevelloggingERRORr'   r   rC   )r
   r   s     r   _run_requirementsrI      sQ    
OOGM"""			%&>	JJ	
 	
    r    c                 h    t          | |          D ]}t          |           t          |           d S r   )rC   r)   r4   rA   s      r   _run_installrK      sA    ()A9MM  yr    r
   r   returnc                 L   d}d}t          j        d          }|                    ddddt          z   	           |                    d
d||g|d           |                                }|t
          }| t          } |t          |t          i|j	                 } || |           d S )Nr$   requirementsz
        opentelemetry-bootstrap detects installed libraries and automatically
        installs the relevant instrumentation packages for them.
        )descriptionz	--versionzprint version informationr   z	%(prog)s )helpactionr   z-az--actiona  
        install - uses pip to install the new requirements using to the
                  currently active site-package.
        requirements - prints out the new requirements to stdout. Action can
                       be piped and appended to a requirements.txt file.
        )choicesdefaultrP   )
argparseArgumentParseradd_argumentr   
parse_argsgen_librariesgen_default_instrumentationsrK   rI   rQ   )r
   r   action_installaction_requirementsparserargsr   s          r   runr^      s     N($  F (k)	     !45#     D!	'#?  	. kC C ),,,,,r    )NN)#rT   rG   r%   
subprocessr   r   r   r   r   typingr   packaging.requirementsr	   +opentelemetry.instrumentation.bootstrap_genr
   rY   r   rX   %opentelemetry.instrumentation.versionr   &opentelemetry.util._importlib_metadatar   r   	getLogger__name__r9   r   r)   r4   r=   rC   rI   rK   listr^   r   r    r   <module>rh      s     



                    . . . . . .           > = = = = =       
 
	8	$	$  " 
  
&N N N&  &) ) )     04 $+- +-&tn+-~+- 
+- +- +- +- +- +-r    