o
    iR                  	   @   s  d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddlZddlZddlZejd dkrKeed e = ed zddlZddlmZ ddlmZ W n ey   d	ejv rt dZddlmZ ddlmZ Y nw W d   n1 sw   Y  ejejeZej dej!ed
d 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( 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ej.v Z/ejdd dkZ0ejdd dkZ1e0oej2j3dkZ4e1oej2j3dkZ5e6dZ7g dZ8e8g d Z9g Z:e*r/e:;d e$r7e:;d e	<d d!krEe:;d" ne:;d# eej!ed$Z=e*rde=>eej!ed% d&d' Z?e? Z@e:;d(eAe@Bd)d*f ere4re'se&re7sd+d,iZCd-d+d.iiZDe:;d/ n ere5re,re7sd+d,iZCd-d+d0iiZDe:;d1 ni ZCi ZDd2d3 ZEejFd4d5 ZGd6d7 ZHd8d9 ZId:d; ZJd<d= ZKe,r.d>d? ZLeM d d@k rdAZNeNdB7 ZNeNdC7 ZNeOeNe:;dD e:>dEeL fdFeL fdGdHg e7re:;dI e	Jdye=ej!edKg eej!edL e:g dMdNeCZPnLe'rZe:>dOdPg e	Qdze=ej!edRg eej!edS e:g dTdUeCZPn e%re:;dV e	Wd{e=ej!edXg eej!edY eej!edZ e:d[gdNeCZPne)re:;d\ e	Wd{e=ej!edXg eej!edY eej!ed] e:d^gdNeCZPne(re:;d_ e	Wd{e=ej!edXg eej!edY eej!ed` e:d^gdNeCZPne&r eKdase:;db e:;dc e	dd|e=ej!edeg eej!edf e:dgeCZPnZe+rIe:;dh e	id}e=ej!edjg eej!edk e:g dldNeCZPn1e#rqe:;dm e	nd~e=ej!edog eej!edp dqge:dreCZPn	edsQejR dtdu ZSdvdw ZTeUdxkreS  dS dS )zCross-platform lib for process and system monitoring in Python.

NOTE: the syntax of this script MUST be kept compatible with Python 2.7.
    )print_functionN   a          As of version 7.0.0 psutil no longer supports Python 2.7, see:
        https://github.com/giampaolo/psutil/issues/2480
        Latest version supporting Python 2.7 is psutil 6.1.X.
        Install it with:

            python2 -m pip install psutil==6.1.*        ignore)	Extension)setupCIBUILDWHEELz..psutil)AIX)BSD)FREEBSD)LINUX)MACOS)NETBSD)OPENBSD)POSIX)SUNOS)WINDOWS)hilite__pypy__)      )r      cpythonPy_GIL_DISABLED)pytestzpytest-instafailzpytest-subtestszpytest-xdist
setuptoolszFpywin32 ; os_name == 'nt' and platform_python_implementation != 'PyPy'zDwheel ; os_name == 'nt' and platform_python_implementation != 'PyPy'zBwmi ; os_name == 'nt' and platform_python_implementation != 'PyPy')	abi3auditblackzcheck-manifestzcolorama ; os_name == 'nt'coverage	packagingpylintpyperfpypinfozpyreadline ; os_name == 'nt'z
pytest-covrequestsrstcheckruffsphinxsphinx_rtd_themez	toml-sorttwinezvalidate-pyproject[all]
virtualenvvulturewheel)PSUTIL_POSIX   )
PSUTIL_BSDr-   l   )PSUTIL_SIZEOF_PID_T4)r1   8zarch/all/*.czarch/posix/*.cc                  C   s   t jtd} t| C}|D ]9}|drGt| 	dd }|
ddks,J ||	dD ]
}| s;J |q1|  W  d    S qd}t|1 sQw   Y  d S )Nz__init__.py__version__z = r-   .r   zcouldn't find version string)ospathjoinHEREopen
startswithastliteral_evalstripsplitcountisdigit
ValueError)INITflineretnummsg rI   O/home/ubuntu/.local/lib/python3.10/site-packages/ddtrace/vendor/psutil/setup.pyget_version   s   

rK   PSUTIL_VERSIONr5    py_limited_apiTbdist_wheelcp36)Py_LIMITED_API
0x03060000cp37)rQ   
0x03070000c                  C   s`   t jtddd} t jtd}tjtj| |gtjtjdd}|	 \}}|j
dkr.t||S )Nscriptsinternalzconvert_readme.pyz
README.rstT)stdoutstderruniversal_newlinesr   )r6   r7   r8   r9   
subprocessPopensys
executablePIPEcommunicate
returncodeRuntimeError)scriptreadmeprW   rX   rI   rI   rJ   get_long_description   s   

re   c                	   c   sz    t t + t t  d V  W d    n1 sw   Y  W d    d S W d    d S 1 s6w   Y  d S )N)
contextlibredirect_stdoutioStringIOredirect_stderrrI   rI   rI   rJ   silenced_output   s   "rk   c                  C   s    t d} tjtj| dS )NincludezPython.h)	sysconfigget_pathr6   r7   existsr8   )include_dirrI   rI   rJ   has_python_h   s   
rq   c                  C   s   t r/trdnd} tdrd| S tdrd| S tdr#dS td	r-d
| S d S tr3dS trEtdr<dS tdrCdS d S trIdS trMdS t	rQdS d S )Npypypythondpkgz sudo apt-get install gcc {}3-devrpmzsudo yum install gcc {}3-develpacmanzsudo pacman -S gcc pythonapkz/sudo apk add gcc {}3-dev musl-dev linux-headerszxcode-select --installpkgzpkg install gcc python3mportzmport install gcc python3zpkg_add -v gcc python3zpkgin install gcc python3zpkg install gcc)
r   PYPYshutilwhichformatr   r   r   r   r   )pyimplrI   rI   rJ   get_sysdeps   s4   








r   c                  C   s   g } t ds| d t s| d | r=t }|r?d}|d| 7 }|d7 }|d|7 }tt|dd	d
t	j
d d S d S d S )Ngcczgcc is not installed.z&Python header files are not installed.z+psutil could not be compiled from sources.  z Try running:
z  {}redT)colorbold)file)r{   r|   appendrq   r   r8   r}   printr   r\   rX   )reasonssysdepssrI   rI   rJ   print_install_instructions   s   


r   c              	   C   s.  ddl m} ddlm} tjdddd}||  W d    n1 s$w   Y  t }z]z8| }t	dr@|
d	t	d t  |j|jg|d
 W d    n1 sWw   Y  |j|jg|d
 W n |y|   Y W t|j t| dS w W t|j t| dS t|j t| w )Nr   )CompileError)UnixCCompilerz.cFwt)suffixdeletemodeCCcompiler_so)
output_dirT)distutils.errorsr   distutils.unixccompilerr   tempfileNamedTemporaryFilewritemkdtempr6   getenvset_executablerk   compilenameremover{   rmtree)c_coder   r   rD   tempdircompilerrI   rI   rJ   unix_can_compile   s0   
r   c                  C   s&   t  dd \} }d| d | S )Nr   r   z0x0{}d   )r\   getwindowsversionr}   )majminrI   rI   rJ   
get_winver  s   r   r   z3this Windows version is too old (< Windows Vista); z:psutil 3.4.2 is the latest version which supports Windows z2000, XP and 2003 server)PSUTIL_WINDOWSr-   _WIN32_WINNT_AVAIL_WINVER_)_CRT_SECURE_NO_WARNINGSN)PSAPI_VERSIONr-   )r   r-   psutil._psutil_windowsz_psutil_windows.czarch/windows/*.c)advapi32kernel32netapi32pdhPowrProfpsapishell32ws2_32sourcesdefine_macros	libraries)
PSUTIL_OSXr-   )PSUTIL_MACOSr-   psutil._psutil_osxz_psutil_osx.czarch/osx/*.c)
-frameworkCoreFoundationr   IOKit)r   r   extra_link_args)PSUTIL_FREEBSDr-   psutil._psutil_bsdz_psutil_bsd.czarch/bsd/*.czarch/freebsd/*.cdevstat)PSUTIL_OPENBSDr-   zarch/openbsd/*.ckvm)PSUTIL_NETBSDr-   zarch/netbsd/*.cz#include <linux/ethtool.h>)PSUTIL_ETHTOOL_MISSING_TYPESr-   )PSUTIL_LINUXr-   psutil._psutil_linuxz_psutil_linux.czarch/linux/*.c)r   r   )PSUTIL_SUNOSr-   psutil._psutil_sunosz_psutil_sunos.czarch/sunos/*.c)kstatnslsocket)
PSUTIL_AIXr-   psutil._psutil_aixz_psutil_aix.czarch/aix/*.cperfstat)r   r   r   platform {} is not supportedc                  C   s   t dtdt dg dddddd	dd
gtgtg dd} td ur,ttd}| jd|dd d}z,t	di |  d}W t
tjdkrEtjd nd}|sUtrW|drYt  d S d S d S d S t
tjdkrgtjd nd}|svtrw|drxt  w w w w )Nr   z5Cross-platform lib for process and system monitoring.z
text/x-rst)pstopkillfreelsofnetstatnicettyioniceuptimetaskmgrprocessdfiotopiostatifconfigtasksetwhopidofpmapsmempstree
monitoringulimitprlimitr   performancemetricsagentobservabilityzGiampaolo Rodolazg.rodola@gmail.comz#https://github.com/giampaolo/psutilzPlatform IndependentzBSD-3-Clausezpsutil.tests))z+Development Status :: 5 - Production/StablezEnvironment :: ConsolezIntended Audience :: Developersz+Intended Audience :: Information Technologyz*Intended Audience :: System Administratorsz$Operating System :: MacOS :: MacOS Xz6Operating System :: Microsoft :: Windows :: Windows 10z6Operating System :: Microsoft :: Windows :: Windows 11z5Operating System :: Microsoft :: Windows :: Windows 7z5Operating System :: Microsoft :: Windows :: Windows 8z7Operating System :: Microsoft :: Windows :: Windows 8.1z?Operating System :: Microsoft :: Windows :: Windows Server 2003z?Operating System :: Microsoft :: Windows :: Windows Server 2008z9Operating System :: Microsoft :: Windows :: Windows Vistaz(Operating System :: Microsoft :: WindowszOperating System :: Microsoftz"Operating System :: OS Independentz Operating System :: POSIX :: AIXz+Operating System :: POSIX :: BSD :: FreeBSDz*Operating System :: POSIX :: BSD :: NetBSDz+Operating System :: POSIX :: BSD :: OpenBSDz Operating System :: POSIX :: BSDz"Operating System :: POSIX :: Linuxz*Operating System :: POSIX :: SunOS/SolariszOperating System :: POSIXzProgramming Language :: Cz#Programming Language :: Python :: 3z;Programming Language :: Python :: Implementation :: CPythonz8Programming Language :: Python :: Implementation :: PyPyzProgramming Language :: Pythonz<Topic :: Software Development :: Libraries :: Python Modulesz*Topic :: Software Development :: LibrarieszTopic :: System :: BenchmarkzTopic :: System :: HardwarezTopic :: System :: Monitoringz@Topic :: System :: Networking :: Monitoring :: Hardware Watchdogz+Topic :: System :: Networking :: MonitoringzTopic :: System :: Networkingz#Topic :: System :: Operating Systemz)Topic :: System :: Systems AdministrationzTopic :: Utilities)r   versiondescriptionlong_descriptionlong_description_content_typekeywordsauthorauthor_emailurl	platformslicensepackagesext_modulesoptionsclassifiers)devtestz>=3.6F)python_requiresextras_requirezip_safeTr   r-   rM   )buildinstallsdistbdistdeveloprI   )dictVERSIONre   extr   r   DEV_DEPS	TEST_DEPSupdater   lenr\   argvr   r;   r   )kwargsr  successcmdrI   rI   rJ   main  sL   !\
r  c            	      C   s
  dd } t r	d}n#trd}ntrd}ntrd}ntrd}ntr"d}n
d	tj}t	|| t
|}trg }tD ]6}tj|rZtj|t}tjd
dd|}||tjd q7tjd
dd|}||tjd q7td|tg d}tr~|jd ||gS |gS )a+  Return list of Extension objects for dd-trace-py build system.

    This function adapts the extensions defined above to work with the
    dd-trace-py build system by:
    1. Renaming modules to use ddtrace.vendor.psutil namespace
    2. Updating source paths to use ddtrace/vendor/psutil paths
    c              	   S   s   g }| j D ]6}tj|r(tj|t}tjddd|}||tj	d qtjddd|}||tj	d qt
||| jt| dg t| dg d}|S )z$Adapt an extension for vendored use.ddtracevendorr   /r   r   )r   r   r   r   )r   r6   r7   isabsrelpathr9   r8   r   replacesepr   r   getattr)original_extnew_namenew_sourcessrcrel_from_herenew_pathadaptedrI   rI   rJ   adapt_extension;  s    


z'get_extensions.<locals>.adapt_extensionz%ddtrace.vendor.psutil._psutil_windowsz!ddtrace.vendor.psutil._psutil_osxz!ddtrace.vendor.psutil._psutil_bsdz#ddtrace.vendor.psutil._psutil_linuxz#ddtrace.vendor.psutil._psutil_sunosz!ddtrace.vendor.psutil._psutil_aixr   r  r  r   r  z#ddtrace.vendor.psutil._psutil_posixr   r   )r   r   r
   r   r   r	   r}   r\   platformra   r  r   r   r6   r7   r  r  r9   r8   r   r  r  r   macrosr   )	r%  ext_namerH   adapted_extposix_sourcesr!  r"  r#  	posix_extrI   rI   rJ   get_extensions1  sF   
 
r,  __main__)r   )r   )r   )r   )r   )r   )V__doc__
__future__r   r<   rf   globrh   r6   r{   structrZ   r\   rm   r   textwrapwarningsversion_infoexitdedentcatch_warningssimplefilterr   r   r   ImportErrorenvirondistutils.corer7   abspathdirname__file__r9   insertr8   _commonr	   r
   r   r   r   r   r   r   r   r   r   builtin_module_namesrz   	PY36_PLUS	PY37_PLUSimplementationr   	CP36_PLUS	CP37_PLUSget_config_varr   r  r  r'  r   calcsizer   extendrK   r  intr  rN   r   re   contextmanagerrk   rq   r   r   r   r   r   rH   ra   r  r}   r&  r  r,  __name__rI   rI   rI   rJ   <module>   s  










&
&






&

&
&q
]
