
    MhB                        d 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Zddl	Z	ddl
Z
ddlmZ 	 ddlmZmZ n# e$ r ddlmZmZ Y nw xY wddlmZmZ ddlmZ ddl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! n# e$ r	 ddl"m!Z! Y nw xY wddl#m$Z$  e%            Z& ej'         ej(        e)                    Z*	 	 	 	 	 	 	 ddZ+	 	 	 	 	 	 ddZ,	 ddZ-	 ddZ.d Z/ddZ0ddZ1ddZ2d Z3dS )z?Utilities for installing Javascript extensions for the notebook    N)Path)PackageNotFoundErrorversion)basenamenormpath)join)ENV_JUPYTER_PATHSYSTEM_JUPYTER_PATHjupyter_data_dir)ensure_dir_exists)ArgumentConflict)get_federated_extensions)load   )_test_overlapTFc                    d}t          |||          }	t          |	           t          | t          t          f          rd}
t          |
          |st          t          |                     }t          t          |	|                    }|rt          j
                            |          r|r|                    d|            t          j
                            |          r4t          j
                            |          st          j        |           nt          j        |           t          j        t          j
                            |          d           |rt          j
                            |           } t          j
                            |          s|r|                    d| d|             	 t          j        | |           n# t.          $ r>}t1          j                                        d	          rd
}
t/          |
          | d}~ww xY wt          j
                            |          s| d}
t5          |
          n%t          j
                            |           rt          t          j
                            |           d          } t          j        |           D ]\  }}}t          ||t9          |           d                   }t          j
                            |          s.|r|                    d|            t          j        |           |D ]4}t          ||          }t          ||          }t;          |||           5n| }t;          |||           |S )aZ  Install a prebuilt extension for JupyterLab

    Stages files and/or directories into the labextensions directory.
    By default, this compares modification time, and only stages files that need updating.
    If `overwrite` is specified, matching files are purged before proceeding.

    Parameters
    ----------

    path : path to file, directory, zip or tarball archive, or URL to install
        By default, the file will be installed with its base name, so '/path/to/foo'
        will install to 'labextensions/foo'. See the destination argument below to change this.
        Archives (zip or tarballs) will be extracted into the labextensions directory.
    user : bool [default: False]
        Whether to install to the user's labextensions directory.
        Otherwise do a system-wide install (e.g. /usr/local/share/jupyter/labextensions).
    overwrite : bool [default: False]
        If True, always install the files, regardless of what may already be installed.
    symlink : bool [default: True]
        If True, create a symlink in labextensions, rather than copying files.
        Windows support for symlinks requires a permission bit which only admin users
        have by default, so don't rely on it.
    labextensions_dir : str [optional]
        Specify absolute path of labextensions directory explicitly.
    destination : str [optional]
        name the labextension is installed to.  For example, if destination is 'foo', then
        the source file will be installed to 'labextensions/foo', regardless of the source name.
    logger : Jupyter logger [optional]
        Logger instance to use
    N)user
sys_prefixlabextensions_dirzpath must be a string pointing to a single extension to install; call this function multiple times to install multiple extensionsz
Removing: T)exist_okzSymlinking:  -> WindowszSymlinks can be activated on Windows 10 for Python version 3.8 or higher by activating the 'Developer Mode'. That may not be allowed by your administrators.
See https://docs.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-developmentz exists and is not a symlink zMaking directory: logger)_get_labextension_dirr   
isinstancelisttuple	TypeErrorr   r   pjoinospathlexistsinfoisdirislinkshutilrmtreeremovemakedirsdirnameabspathexistssymlinkOSErrorplatform
startswith
ValueErrorwalklen_maybe_copy)r#   r/   	overwriter   r   destinationr   r   	full_destlabextmsgeparent_filesdest_dir	file_namesrc	dest_files                      b/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/jupyterlab/federated_labextensions.pydevelop_labextensionrE   .   s{   R I"j<M  F f$u&&  Rnn /x~~..v{3344I !RW__Y// ! 	2KK0Y001117==## 	!BGNN9,E,E 	!M)$$$$Ii    K	**T:::: #3wt$$w~~i(( 	" B@9@@$@@AAA

4++++   $&&11)<< .{ 
 "#,,A- 	** 	"<<<CS//!	" 
t		 3RW__T**B// " 		; 		;FAuYs4yy{{(;<<H7>>(++ & AKK ?X ? ?@@@H%%%" ; ;	FI..!(I66	C6:::::;		; C62222s   ?G 
H 9HHc                    t          |           \  }}t          j                            |j                  d         }	g }
|D ]}t          j                            |	|d                   }|d         }|r|                    d| d|            t          j                            |          st          |	|           t          ||||||||          }|

                    |           |
S )zDevelop a labextension bundled in a Python package.

    Returns a list of installed/updated directories.

    See develop_labextension for parameter information.r   rB   destzInstalling r   r   )r7   r/   r   r   r   r8   r   )_get_labextension_metadatar"   r#   split__file__r   r%   r.   build_labextensionrE   append)moduler   r   r7   r/   r   r   mlabexts	base_path
full_destsr:   rB   rG   r9   s                  rD   develop_labextension_pyrR      s    ,F33JAwaj))!,IJ % %gll9fUm44f~ 	7KK5c55t55666w~~c"" 	9y8888(!/	
 	
 	
	 	)$$$$    c                    |t          j        t          d          n-t          t	          |                                                    }t          t	          |                                                     }|r|                    d|             t          ||          }d|d||g}||                    d|g           |r|	                    d           |r|	                    d           t          j        ||	           dS )
z&Build a labextension in the given pathNstagingBuilding extension in node--core-pathz--static-url--development--source-mapcwd)ospr   HEREstrr   resolver%   _ensure_builderextendrL   
subprocess
check_call)	r#   r   development
static_url
source_map	core_pathext_pathbuilder	argumentss	            rD   rK   rK      s    .7->y)))CYH_H_HaHaDbDbI4::%%''((H 53T33444h	22G-HEI.*5666 *))) )((()222222rS   c                    |t          j        t          d          n-t          t	          |                                                    }t          t	          |                                                     }|r|                    d|             t          |          }t          t          |d                    5 }t          j        |          }	ddd           n# 1 swxY w Y   |	d         |vrt          |d           nt          ||	d                  d         |	d                   }
t          ||	d	                             d
d                    }t          j        |
          s)t          j        |
           t#          j        ||
           t'          ||          }d|d|d|g}|r|                    d           |r|                    d           t+          j        ||           dS )z$Watch a labextension in a given pathNrU   rV   package.jsonnameT)r   ext_dir
jupyterlab	outputDirstaticrW   rX   z--watchrY   rZ   r[   )r]   r   r^   r_   r   r`   r%   r   openr!   jsonr   rR   getr'   r(   r)   r"   r/   ra   rL   rc   rd   )r#   labextensions_pathr   re   rg   rh   ri   federated_extensionsfidext_datar9   
output_dirrj   rk   s                 rD   watch_labextensionr{      s    .7->y)))CYH_H_HaHaDbDbI4::%%''((H 53T33444 44FGG	eHn--	.	. "#9S>>" " " " " " " " " " " " " " " 333T:::::.x/?@KXV\M]^^	8Xl%;%?%?X%V%VWW
z)$$ 	.M)$$$Jz9---h	22G-IxPI *))) )((()222222s   ?C  C$'C$c           	         t          t          j        |d                    5 }t          j        |          }ddd           n# 1 swxY w Y   t          t          j        | d                    5 }t          j        |          }ddd           n# 1 swxY w Y   |d         d         }|                    di                               d          }|p(|                    di                               d          }|d| }t          |          d|v rbt          t          j        | |d                    5 }t          j        |                              d          }ddd           n# 1 swxY w Y   t          j        t          j        | d	                    st          j	        d
g|            | }t          j        t          j        |d	dd                    sft          j
        |          |k    rd}t          |          t          j
        |          }t          j        t          j        |d	dd                    ft          ||dd          }	|	swt          t          j        |d	ddd                    5 }t          j        |                              d          }ddd           n# 1 swxY w Y   t          ||dd          }	|	sd| d| }t          |          t          j        |d	dddd          S )zIEnsure that we can build the extension and return the builder script pathrm   NdevDependenciesz@jupyterlab/builderdependenciesz:Extensions require a devDependency on @jupyterlab/builder@/r   node_modulesjlpmr[   z@jupyterlabrj   z"Could not find @jupyterlab/builderT)drop_prerelease1drop_prerelease2z, you have a dependency on libzbuild-labextension.js)rs   r]   r   rt   r   ru   r3   r.   rc   rd   r,   r   )
ri   rh   rx   	core_datary   dep_version1dep_version2r;   targetoverlaps
             rD   ra   ra     s    
chy.11	2	2 #cIcNN	# # # # # # # # # # # # # # #	chx00	1	1 "S9S>>" " " " " " " " " " " " " " "./0EFL<< 1266::;PQQL^8<<#C#C#G#GH]#^#^LY<YYoo l#(8\>BBCC 	9s9S>>--i88L	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9:chx8899 6vhH5555 Fj&.-SSTT %;v&((6CS//!V$$	 j&.-SSTT % lTD  G  
HV^]I~VV
 
 	99S>>--i88L	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9  ,PT
 
 
   C<  C  C  uA  C  Coo8y%AX  sG   AAA1BBB<(E00E47E4(J88J<?J<c                 "   t           j                            |          sdS t          j        |           j        t          j        |          j        z
  dk    r|r|                    d|            dS |r|                    d|            dS )am  Should a file be copied, if it doesn't exist, or is newer?

    Returns whether the file needs to be updated.

    Parameters
    ----------

    src : string
        A path that should exist from which to copy a file
    src : string
        A path that might exist to which to copy a file
    logger : Jupyter logger [optional]
        Logger instance to use
    Tgư>zOut of date: zUp to date: F)r"   r#   r.   statst_mtimewarningr%   rB   rG   r   s      rD   _should_copyr   9  s     7>>$ t	ws||rwt}}55<<  	3NN1411222t +)4))***5rS   c                     t          | ||          r4|r|                    d|  d|            t          j        | |           dS dS )a!  Copy a file if it needs updating.

    Parameters
    ----------

    src : string
        A path that should exist from which to copy a file
    src : string
        A path that might exist to which to copy a file
    logger : Jupyter logger [optional]
        Logger instance to use
    r   z	Copying: r   N)r   r%   r(   copy2r   s      rD   r6   r6   U  sh     Cf---   	5KK3C33T33444S$   rS   c                    d| fd|fd|fd|fg}d |D             }t          |          dk    r7d                    d                    |                    }t          |          | rt	          t                      d	          }nS|rt	          t          d
         d	          }n5|rt	          |ddd	          }n |r|}nt	          t          d
         d	          }|S )a  Return the labextension directory specified

    Parameters
    ----------

    user : bool [default: False]
        Get the user's .jupyter/labextensions directory
    sys_prefix : bool [default: False]
        Get sys.prefix, i.e. ~/.envs/my-env/share/jupyter/labextensions
    prefix : str [optional]
        Get custom prefix
    labextensions_dir : str [optional]
        Get what you put in
    r   prefixr   r   c                 &    g | ]\  }}|| d |S )= ).0nvs      rD   
<listcomp>z)_get_labextension_dir.<locals>.<listcomp>}  s+    AAA1qA!||a||AAArS   r   z[cannot specify more than one of user, sys_prefix, prefix, or labextensions_dir, but got: {}z, labextensionsr   sharejupyter)r5   formatr   r   r!   r   r	   r
   )r   r   r   r   conflictingconflicting_setr;   r:   s           rD   r   r   h  s     
	6	/0	z"	K BAAAAO
?akrrIIo&&
 
 s### 	@'))?;;	 @'*O<<	 @vw	?CC	 @"*1-??MrS   c           	      >   t          j        |           }t          j        |          sd| d}t          |          g }	 t	          j        |           }t          |d          r||                                fS n,# t          $ r}|	                    |           Y d}~nd}~ww xY wd}t          j                            t          j                            |d                    r~t          t          j                            |d          d          5 }t          |          }ddd           n# 1 swxY w Y   |                    di                               d          }|ss	 t!          j        t$          j        d	d
g|                              d                                          }n)# t           j        $ r d|  d}t          |          dw xY w	 t/          |           nT# t0          $ rG t!          j        t$          j        dddd|g           t$          j                            d|           Y nw xY wddlm}	m}
 |                    dd          g}|                     |
|                     |                     |	|                     |D ]k}	 t	          j        |          }t          |d          r||                                fc S @# t          $ r}|	                    |           Y d}~dd}~ww xY wd|  d| }tA          |          )af  Get the list of labextension paths associated with a Python module.

    Returns a tuple of (the module path,             [{
        'src': 'mockextension',
        'dest': '_mockdestination'
    }])

    Parameters
    ----------

    module : str
        Importable Python module exposing the
        magic-named `_jupyter_labextension_paths` function
    z
The path `z` does not exist._jupyter_labextension_pathsNzpyproject.tomlrbprojectrn   zsetup.pyz--namer[   utf8zThe Python package `z<` is not a valid package, it is missing the `setup.py` file.z-mpipinstallz-er   )find_namespace_packagesfind_packages-r>   zThere is no labextension at z. Errors encountered: )!r]   r-   r.   FileNotFoundError	importlibimport_modulehasattrr   	ExceptionrL   r"   r#   r   rs   r   ru   rc   check_outputsys
executabledecodestripCalledProcessErrorr   r   rd   insert
setuptoolsr   r   replacerb   ModuleNotFoundError)rM   mod_pathr;   errorsrN   excpackagerx   datar   r   package_candidatess               rD   rH   rH     s    {6""H:h %68666$$$F#F++1344 	6a335555	6   c G 
w~~bgll8-=>>?? 6"',,x)9::DAA 	S99D	 	 	 	 	 	 	 	 	 	 	 	 	 	 	((9b))--f55  3	3'^Z:     G , 	3 	3 	35v 5 5 5  $C((d2	3% % % %s~tUItXVWWW8$$$$$% BAAAAAAA 	S!! mmH55666))   &  	'00Aq788 :!77999999: 	 	 	MM#	 P
O
Ov
O
OC
c
"
""sb   9A< <
B%B  B%D11D58D5(AF1 1&GG+ +AH<;H<9K
L&L  L)TFFNNNF)FFTTNN)NFNFN)NFFN)N)FFNN)4__doc__r   rt   r"   os.pathr#   r]   r1   r(   rc   r   pathlibr   importlib.metadatar   r   ImportErrorimportlib_metadatar   r   r   r!   jupyter_core.pathsr	   r
   r   jupyter_core.utilsr   (jupyter_server.extension.serverextensionr   jupyterlab_server.configr   tomllibr   tomlicommandsr   objectDEPRECATED_ARGUMENTr-   r,   rJ   r^   rE   rR   rK   r{   ra   r   r6   r   rH   r   rS   rD   <module>r      s   E E
      				             



      A@@@@@@@@@ A A A@@@@@@@@@@A ' & & & & & & & ! ! ! ! ! ! V V V V V V V V V V 0 0 0 0 0 0 E E E E E E = = = = = =    $ # # # # #fhh s{;3;x(()) 	i i i i\ 
( ( ( (X X\3 3 3 32 [_ 3  3  3  3P1 1 1h   8       &% % % %PS# S# S# S# S#s!   5 AA3A: :BB