o
    Eh                     @  s   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m	Z	 e	r,d dl
mZ d dlmZmZmZ ddd	ZdddZdddZddddZdS )    )annotationsN)TYPE_CHECKING)JSONSerializable)VERSIONSget_versionimport_optional_dependencyreturn
str | Nonec                  C  s@   z	ddl m}  | W S  ty   ddlm} | }|d  Y S w )za
    Use vendored versioneer code to get git hash, which handles
    git worktree correctly.
    r   )__git_version__)get_versionszfull-revisionid)Zpandas._version_mesonr
   ImportErrorZpandas._versionr   )r
   r   Zversions r   ;lib/python3.10/site-packages/pandas/util/_print_versions.py_get_commit_hash   s   r   dict[str, JSONSerializable]c                  C  sd   t  } t \}}t t  tdd | j| j	| j
| j| jtjtjdtjd||ddS )zG
    Returns system information as a JSON serializable dictionary.
    P   LC_ALLLANG)language-codeencoding)ZcommitZpythonzpython-bitsZOSz
OS-releaseZVersionmachine	processor	byteorderr   r   LOCALE)platformunamelocale	getlocaler   Zpython_versionstructZcalcsizesystemreleaseversionr   r   sysr   osenvironget)uname_resultlanguage_coder   r   r   r   _get_sys_info'   s   

r)   c               	   C  sh   g d} |  tt i }| D ]"}zt|dd}W n ty&   d||< Y qw |r-t|nd||< q|S )zK
    Returns dependency information as a JSON serializable dictionary.
    )ZpandasZnumpyZpytzZdateutilZpipZCythonZsphinxZIPythonignore)errorszN/AN)extendlistr   r   	Exceptionr   )depsresultmodnamemodr   r   r   _get_dependency_info=   s   r3   Fas_json
str | boolNonec           
      C  sP  t  }t }| rG||d}| du rtjtj|dd dS t| ts%J t	| ddd}tj
||dd W d   dS 1 s@w   Y  dS t|d	 tsPJ |d	 d
 }|d	 d }| d| |d	< tdd |D }td td | D ]\}}	t|d| d|	  qztd | D ]\}}	t|d| d|	  qdS )a  
    Provide useful information, important for bug reports.

    It comprises info about hosting operation system, pandas version,
    and versions of other installed relative packages.

    Parameters
    ----------
    as_json : str or bool, default False
        * If False, outputs info in a human readable form to the console.
        * If str, it will be considered as a path to a file.
          Info will be written to that file in JSON format.
        * If True, outputs info in JSON format to the console.

    Examples
    --------
    >>> pd.show_versions()  # doctest: +SKIP
    Your output may look something like this:
    INSTALLED VERSIONS
    ------------------
    commit           : 37ea63d540fd27274cad6585082c91b1283f963d
    python           : 3.10.6.final.0
    python-bits      : 64
    OS               : Linux
    OS-release       : 5.10.102.1-microsoft-standard-WSL2
    Version          : #1 SMP Wed Mar 2 00:30:59 UTC 2022
    machine          : x86_64
    processor        : x86_64
    byteorder        : little
    LC_ALL           : None
    LANG             : en_GB.UTF-8
    LOCALE           : en_GB.UTF-8
    pandas           : 2.0.1
    numpy            : 1.24.3
    ...
    )r    ZdependenciesT   )indentwzutf-8)r   Nr   r   r   .c                 s  s    | ]}t |V  qd S )N)len).0xr   r   r   	<genexpr>   s    z show_versions.<locals>.<genexpr>z
INSTALLED VERSIONSz------------------<z:  )r)   r3   r#   stdout
writelinesjsondumps
isinstancestropendumpdictmaxprintitems)
r4   Zsys_infor/   jfr(   r   maxlenkvr   r   r   show_versions^   s.   %
"rR   )r   r	   )r   r   )F)r4   r5   r   r6   )Z
__future__r   rC   r   r$   r   r   r#   typingr   Zpandas._typingr   Zpandas.compat._optionalr   r   r   r   r)   r3   rR   r   r   r   r   <module>   s    


!