a
    ø£Be  ã                   @   sž   d 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 ddlm	Z	 ddl
mZmZ eeeef dœdd„Zeedœd	d
„Zedœdd„Zdd„ Zdd„ ZdS )zQ
Utilities for getting information about IPython and the system it's running in.
é    N)ÚPath)Úrelease)Ú_sysinfoÚencoding)Úpkg_pathÚreturnc                 C   sR   t jrdt jfS tjd d¡tjtj| d�}| ¡ \}}|rNd| ¡  d¡fS dS )a"  Get short form of commit hash given directory `pkg_path`

    We get the commit hash from (in order of preference):

    * IPython.utils._sysinfo.commit
    * git output, if we are in a git repository

    If these fail, we return a not-found placeholder tuple

    Parameters
    ----------
    pkg_path : str
        directory containing package
        only used for getting commit from active repo

    Returns
    -------
    hash_from : str
        Where we got the hash from - description
    hash_str : str
        short form of hash
    Zinstallationzgit rev-parse --short HEADú )ÚstdoutÚstderrÚcwdÚ
repositoryÚascii)z(none found)z<not found>)	r   ÚcommitÚ
subprocessÚPopenÚsplitÚPIPEÚcommunicateÚstripÚdecode)r   ÚprocZrepo_commitÚ_© r   úX/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/IPython/utils/sysinfo.pyÚpkg_commit_hash    s    
ýr   c                 C   s8   t | ƒ\}}ttj| ||tjtjtjt ¡ tjt	j
d�
S )zïReturn dict describing the context of this package

    Parameters
    ----------
    pkg_path : str
        path containing __init__.py for package

    Returns
    -------
    context : dict
        with named parameters of interest
    )
Zipython_versionZipython_pathZcommit_sourceZcommit_hashÚsys_versionZsys_executableÚsys_platformÚplatformÚos_nameZdefault_encoding)r   Údictr   ÚversionÚsysÚ
executabler   ÚosÚnamer   ZDEFAULT_ENCODING)r   ÚsrcZhshr   r   r   Úpkg_infoF   s    ör&   )r   c                  C   s   t tdƒ ¡ j} tt| ƒƒS )zBReturn useful information about IPython and the system, as a dict.z..)r   Ú__file__ÚresolveÚparentr&   Ústr)Úpathr   r   r   Úget_sys_infoa   s    r,   c                   C   s   t  tƒ ¡S )au  Return useful information about IPython and the system, as a string.

    Examples
    --------
    ::
    
        In [2]: print(sys_info())
        {'commit_hash': '144fdae',      # random
         'commit_source': 'repository',
         'ipython_path': '/home/fperez/usr/lib/python2.6/site-packages/IPython',
         'ipython_version': '0.11.dev',
         'os_name': 'posix',
         'platform': 'Linux-2.6.35-22-generic-i686-with-Ubuntu-10.10-maverick',
         'sys_executable': '/usr/bin/python',
         'sys_platform': 'linux2',
         'sys_version': '2.6.6 (r266:84292, Sep 15 2010, 15:52:39) \n[GCC 4.4.5]'}
    )ÚpprintÚpformatr,   r   r   r   r   Úsys_infof   s    r/   c                  C   s$   ddl } | jdtdd� t ¡ p"dS )aœ  DEPRECATED

    Return the effective number of CPUs in the system as an integer.

    This cross-platform function makes an attempt at finding the total number of
    available CPUs in the system, as returned by various underlying system and
    python calls.

    If it can't find a sensible answer, it returns 1 (though an error *may* make
    it return a large positive number that's actually incorrect).
    r   NzG`num_cpus` is deprecated since IPython 8.0. Use `os.cpu_count` instead.é   )Ú
stacklevelé   )ÚwarningsÚwarnÚDeprecationWarningr#   Ú	cpu_count)r3   r   r   r   Únum_cpus{   s    ýr7   )Ú__doc__r#   r   r-   r!   r   Úpathlibr   ZIPython.corer   ZIPython.utilsr   r   r*   Útupler   r   r&   r,   r/   r7   r   r   r   r   Ú<module>   s   &