o
    ‘iT   ã                	   @   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ZddlZddlm	Z
 ddlZddlmZ dZdZdZd	Zej d
¡ZedurDe ¡ ZeeeedœZej d¡rTeZnPej d¡r]eZnGej d¡rfeZn>ej d¡roeZn5ej ¡ pud ¡  d¡r‰edv r„ee Zn dZdZnedu rdZneev r™ee Zned ed e¡¡ƒ‚dd„ Z eeeeefv r´e ƒ  nKedu røerÃe efe efgZ!ne efe efe efe efgZ!e!D ]\Z"Zze"ƒ  W n	 e#yå   Y qÓw  ne#d d dd„ e!D ƒ¡¡ƒ‚ne$de› ƒ‚e%t&j' (¡  )¡ ƒZ*e*dk re#dt&j' (¡  +¡ › dƒ‚ejdkr9e
e ,¡ d ƒe
d ƒkr9e*d!k r9ej -d"d#¡ d$d%„ Z.ej/d&d'„ ƒZ0dS )(a[  
Qt binding and backend selector.

The selection logic is as follows:
- if any of PyQt6, PySide6, PyQt5, or PySide2 have already been
  imported (checked in that order), use it;
- otherwise, if the QT_API environment variable (used by Enthought) is set, use
  it to determine which binding to use;
- otherwise, use whatever the rcParams indicate.
é    N)Úparseé   )Ú_QT_FORCE_QT5_BINDINGÚPyQt6ÚPySide6ÚPyQt5ÚPySide2ÚQT_API)Zpyqt6Zpyside6Úpyqt5Úpyside2zPyQt6.QtCorezPySide6.QtCorezPyQt5.QtCorezPySide2.QtCoreÚ Zqt5)r
   r   TzTThe environment variable QT_API has the unrecognized value {!r}; valid values are {}z, c                     sj  t tkr)ddlmamamam}  tjatj	t_
tjt_tjt_| jat d¡ad S t tkrVddlmamamama dd l‰‡fdd„attƒtdƒkrRt d¡ad S tad S t tkr~ddlmamama dd l} tjatj	t_
tjt_tjt_| jatad S t tkr®ddlmamamama zdd	lm‰  W n ty£   dd l‰ Y nw ‡ fd
d„atad S tdt › ƒ‚)Nr   )ÚQtCoreÚQtGuiÚ	QtWidgetsÚsipÚvalue)r   r   r   Ú__version__c                    ó   ˆ   | ¡ S ©N©ZisValid©Úobj)Ú	shiboken6© úl/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/site-packages/matplotlib/backends/qt_compat.pyÚ
_isdeletedT   s    r   z6.4)r   r   r   ©Ú	shiboken2c                    r   r   r   r   r   r   r   r   h   s   úUnexpected QT_API: ) r	   ÚQT_API_PYQT6r   r   r   r   r   ZPYQT_VERSION_STRr   Z
pyqtSignalZSignalZpyqtSlotZSlotZpyqtPropertyÚPropertyZ	isdeletedr   ÚoperatorÚ
attrgetterZ_to_intÚQT_API_PYSIDE6r   r   Úparse_versionÚintÚQT_API_PYQT5r   ÚQT_API_PYSIDE2r   r   ÚImportErrorÚAssertionError)r   r   )r   r   r   Ú_setup_pyqt5plusE   sD   ÿr*   z<Failed to import any of the following Qt binding modules: {}c                 C   s   g | ]\}}|‘qS r   r   )Ú.0Ú_r	   r   r   r   Ú
<listcomp>‡   s    r-   r   )é   é   zThe Qt version imported is z! but Matplotlib requires Qt>=5.12Údarwinz10.16)r.   é   é   ZQT_MAC_WANTS_LAYERÚ1c                 C   s"   t | dƒr|  ¡  d S |  ¡  d S )NÚexec)Úhasattrr4   Úexec_r   r   r   r   Ú_exec    s   "r7   c              
   #   s<   t  t j¡}|dt jt jfv rdV  dS d‰ t ¡ \}‰| d¡ ˆ d¡ t  | 	¡ ¡}t
 ˆ 	¡ t
jjj¡}|jj‡fdd„ƒ}‡ ‡fdd„}t   t j|¡ z)dV  W | ¡  ˆ ¡  | d¡ t  |¡ t   t j|¡ ˆ dury|ˆ Ž  dS dS | ¡  ˆ ¡  | d¡ t  |¡ t   t j|¡ ˆ dur|ˆ Ž  w w )aN  
    This manager allows to terminate a plot by sending a SIGINT. It is
    necessary because the running Qt backend prevents Python interpreter to
    run and process signals (i.e., to raise KeyboardInterrupt exception). To
    solve this one needs to somehow wake up the interpreter and make it close
    the plot window. We do this by using the signal.set_wakeup_fd() function
    which organizes a write of the signal number into a socketpair connected
    to the QSocketNotifier (since it is part of the Qt backend, it can react
    to that write event). Afterwards, the Qt handler empties the socketpair
    by a recv() command to re-arm it (we need this if a signal different from
    SIGINT was caught by set_wakeup_fd() and we shall continue waiting). If
    the SIGINT was caught indeed, after exiting the on_signal() function the
    interpreter reacts to the SIGINT according to the handle() function which
    had been set up by a signal.signal() call: it causes the qt_object to
    exit by calling its quit() method. Finally, we call the old SIGINT
    handler with the same arguments that were given to our custom handle()
    handler.

    We do this only if the old handler for SIGINT was not None, which means
    that a non-python handler was installed, i.e. in Julia, and not SIG_IGN
    which means we should ignore the interrupts.
    NFc                     s&   zˆ   d¡ W d S  ty   Y d S w )Nr   )ÚrecvÚBlockingIOError©Úargs)Úrsockr   r   Ú_may_clear_sockÐ   s
   ÿz/_maybe_allow_interrupt.<locals>._may_clear_sockc                     s   | ‰ ˆ  ¡  d S r   )Úquitr:   )Úhandler_argsÚqappr   r   Úhandle×   s   z&_maybe_allow_interrupt.<locals>.handle)ÚsignalÚ	getsignalÚSIGINTÚSIG_IGNÚSIG_DFLÚsocketÚ
socketpairÚsetblockingÚset_wakeup_fdÚfilenor   ZQSocketNotifierÚTypeZReadZ	activatedÚconnectÚcloseZ
setEnabled)r@   Zold_sigint_handlerZwsockZold_wakeup_fdZsnr=   rA   r   )r?   r@   r<   r   Ú_maybe_allow_interrupt¥   sB   €



ÿû


ÿrO   )1Ú__doc__r!   ÚosÚplatformÚsysrB   rG   Ú
contextlibZpackaging.versionr   r$   Z
matplotlibZmplr   r   r   r#   r&   r'   ÚenvironÚgetZ
QT_API_ENVÚlowerZ_ETSÚmodulesr	   ZrcParamsZ_get_backend_or_noneÚ
startswithÚRuntimeErrorÚformatÚjoinr*   Ú_candidatesÚ_setupr(   r)   Útupler   ZQLibraryInfoÚversionÚsegmentsZ_version_infoZtoStringÚmac_verÚ
setdefaultr7   ÚcontextmanagerrO   r   r   r   r   Ú<module>   s¤    þ

þ*þü
ÿþþ
ÿÿ
