
    tAf=                        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mZ 	 ddl	m
Z
 n# e$ r dZ
Y nw xY w	 ddlZd Zn# e$ r d ZY nw xY wdZdZd	Zd
ez  Zd Zd Zd Zeeej        ddfdZeeej        dfdZd Zd Z ee          Zd Zd Zd Z ee          Zd Zd Z ee          Zd Z ee          Zd Z d Z!d Z"d Z#d#dZ$efd Z%e&d!k    r e%ej'        d"d                    dS dS )$a  Bootstrap distribute installation

If you want to use setuptools in your package's setup.py, just include this
file in the same directory with it, and add this to the top of your setup.py::

    from distribute_setup import use_setuptools
    use_setuptools()

If you want to require a specific version of setuptools, set a download
mirror, or use an alternate download directory, you can do so by supplying
the appropriate options to ``use_setuptools()``.

This file can also be run as a script to install or upgrade setuptools.
    N)log)	USER_SITEc                  R    t           j        f| z   } t          j        |           dk    S )Nr   )sys
executable
subprocesscallargss    O/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/distribute_setup.py_python_cmdr       s&     4't$$))    c                      t           j        f| z   } t           j        dk    rd fd| D             } t          j        t          j        t           j        g| R  dk    S )Nwin32c                     d| v rd| z  S | S )N z"%s" )args    r   quotez_python_cmd.<locals>.quote*   s    #::!C<'
r   c                 &    g | ]} |          S r   r   ).0r   r   s     r   
<listcomp>z_python_cmd.<locals>.<listcomp>.   s!    ///3EE#JJ///r   r   )r   r   platformosspawnlP_WAIT)r   r   s    @r   r   r   &   sl     4'<7""   0///$///DyCN:T:::a??r   z0.6.14z4http://pypi.python.org/packages/source/d/distribute/z0.6c11zMetadata-Version: 1.0
Name: setuptools
Version: %s
Summary: xxxx
Home-page: xxx
Author: xxx
Author-email: xxx
License: xxx
Description: xxx
c                    t          j                    }t          j        d|           t	          j                    }	 t	          j        |           t          j        |           }t          |           |
                                 t          j                            |t	          j        |          d                   }t	          j        |           t          j        d|           t          j        d           t          dd          s(t          j        d           t          j        d           t	          j        |           d S # t	          j        |           w xY w)	NExtracting in %sr   Now working in %szInstalling Distributesetup.pyinstallz-Something went wrong during the installation.zSee the error message above.)tempfilemkdtempr   warnr   getcwdchdirtarfileopen_extractallclosepathjoinlistdirr   )tarballtmpdirold_wdtarsubdirs        r   _installr3   B   s)   FH(((Y[[F
l7##C		 fbj&8&8&;<<
$f--- 	())):y11 	5HDEEEH3444
s   C8E E!c                    t          j                    }t          j        d|           t	          j                    }	 t	          j        |           t          j        |          }t          |           |
                                 t          j                            |t	          j        |          d                   }t	          j        |           t          j        d|           t          j        d|           t          dddd|           t	          j        |           n# t	          j        |           w xY wt          j        |            t          j                            |           st!          d	          d S )
Nr   r   r   zBuilding a Distribute egg in %sr    z-q	bdist_eggz
--dist-dirzCould not build the egg.)r"   r#   r   r$   r   r%   r&   r'   r(   r)   r*   r+   r,   r-   r   existsIOError)eggr.   to_dirr/   r0   r1   r2   s          r   
_build_eggr:   [   sH   FH(((Y[[F
l7##C		 fbj&8&8&;<<
$f--- 	2F;;;Jk<HHH 	HSMMM7>># 201112 2s   CD& &D<c                 l   t           j                            |d| t          j        d         t          j        d         fz            }t           j                            |          s#t          | |||          }t          |||           t          j                            d|           dd l	}||_
        d S )Nzdistribute-%s-py%d.%d.eggr      )r   r+   r,   r   version_infor6   download_setuptoolsr:   insert
setuptoolsbootstrap_install_from)versiondownload_baser9   download_delayr8   r.   r@   s          r   _do_downloadrE   w   s    
',,v:!3#3A#68H8KL M N NC7>># )%g}&,n> >3(((HOOAs(+J%%%r      Tc                    t           j                            |          }dt          j        v pdt          j        v }	 	 dd l}t          |d          s|st                       t          n4# t          $ r' t          | |||          cY |st          |           S S w xY w	 |                    d| z              	 |st          |           d S d S # |j        $ r t          j                    d         }|rFt          j                            d| d|j        d         d	           t          j        d
           n4~t          j        d= t          | |||          cY |st          |           S S Y n3|j        $ r' t          | |||          cY |st          |           S S w xY w	 |st          |           d S d S # |st          |           w w xY w)Npkg_resourcesr@   r   _distributezdistribute>=r<   z&The required version of distribute (>=z) is not available,
and can't be installed while this script is running. Please
install a more recent version first, using
'easy_install -U distribute'.

(Currently using z)
   )r   r+   abspathr   modulesrH   hasattr_fake_setuptoolsImportErrorrE    _create_fake_setuptools_pkg_inforequireVersionConflictexc_infostderrwriter   exitDistributionNotFound)rB   rC   r9   rD   no_fakewas_importedrH   es           r   use_setuptoolsr[      s    W__V$$F"ck1 $# 5	P    =-88 " '$&&&!!"  	P 	P 	POOOO,  	5,V4444	5/	P	0!!."8999&  	5,V44444	5 	5% , 	4 	4 	4q!A 4
   
 18	DE E E !3;#?#G]F$24 4 4 4  	5,V4444	5 
 1 	0 	0 	0 .0 0 0 0  	5,V4444	5		0   	5,V44444	5 	5w 	5,V4444	5sZ   +A* )F7 *BF7 BF7 C BFF7 ,F7 .F	F7 FF7 7Gc                    t           j                            |          }	 ddlm} n# t
          $ r	 ddlm} Y nw xY wd| z  }||z   }t           j                            ||          }dx}}	t           j                            |          s	 t          j
        d|            ||          }|                                }
t          |d          }	|	                    |
           |r|                                 |	r|	                                 n2# |r|                                 |	r|	                                 w w xY wt           j                            |          S )a  Download distribute from a specified location and return its filename

    `version` should be a valid distribute version number that is available
    as an egg for download under the `download_base` URL (which should end
    with a '/'). `to_dir` is the directory where the egg will be downloaded.
    `delay` is the number of seconds to pause before an actual download
    attempt.
    r   )urlopenzdistribute-%s.tar.gzNzDownloading %swb)r   r+   rK   urllib.requestr]   rO   urllib2r,   r6   r   r$   readr(   rU   r*   realpath)rB   rC   r9   delayr]   tgz_nameurlsavetosrcdstdatas              r   r>   r>      sw    W__V$$F$******* $ $ $########$%/H
(
"CW\\&(++FC#7>>&!! 	H%s+++'#,,C 88::Dvt$$CIIdOOO 		 		  		 		7F###s   ( ;;AD /Ec                       fd}|S )Nc                      	 ddl m} t          |d          sd }|j        |_        ||_        d}nd}n# t
          $ r d}Y nw xY w	  | i ||r|j        |_        |`S S # |r|j        |_        |`w xY w)Nr   )DirectorySandbox_oldc                      d S Nr   r
   s    r   	violationz4_no_sandbox.<locals>.__no_sandbox.<locals>.violation   s    Dr   TF)setuptools.sandboxrl   rM   
_violationrm   rO   )r   kwrl   rp   patchedfunctions        r   __no_sandboxz!_no_sandbox.<locals>.__no_sandbox   s    	;;;;;;+V44    (8(C %.7 + 	 	 	GGG		*8T(R(( *.>.C +$))*w *.>.C +$)))))s   15 AAA! !A3r   )ru   rv   s   ` r   _no_sandboxrw      s$    * * * * ** r   c                 n   t          |                                           }||k    rt          j        d           dS t          j        d           t	          |            t          | d          }	 |                    |           |                                 n# |                                 w xY wdS )z"Will backup the file then patch itAlready patched.FPatching...wT)r(   ra   r   r$   _rename_pathrU   r*   )r+   contentexisting_contentfs       r   _patch_filer      s    Dzz((7""#$$$uH]T3A										4s   2B B2c                 L    t          |                                           |k    S ro   )r(   ra   )r+   r}   s     r   _same_contentr      s    ::??''r   c                     | dt          j                     z  z   }t          j        d| |           t          j        | |           |S )Nz.OLD.%szRenaming %s into %s)timer   r$   r   rename)r+   new_names     r   r|   r|      sC    i$)++--HH"D(333IdHOr   c                    t           j                            |           st          j        d|            dS d}t          j        |           D ]}t          j        |d          rd} n|st          j        d           d S t          j        d           t           j                            | |          }t           j                            |          rt          |          }nt          |t                    }|st          j        d|           dS dD ]f}t           j                            | |          }t           j                            |          rt          |           Qt          j        d	|           gdS )
NzUnkown installation at %sFzsetuptools*.egg-infoTz%Could not locate setuptools*.egg-infoz#Removing elements out of the way...%s already patched.)r@   zpkg_resources.pyzsite.pyz<Could not find the %s element of the Setuptools distribution)r   r+   isdirr   r$   r-   fnmatchr,   _patch_egg_dirr   SETUPTOOLS_PKG_INFOr6   r|   )placeholderfoundfilepkg_infort   elements         r   _remove_flat_installationr     s~   7==%% ,k:::uE
;''  ?4!788 	EE	  8999H2333w||K..H	w}}X = **h(;<< &111u@ 9 9',,{G447>>'"" 	9!!!!H /079 9 9 94r   c                     t          j        d           |                     d          j        }t	          |           d S )NzAfter install bootstrap.r!   )r   r$   get_command_objinstall_purelibrP   )distr   s     r   _after_installr   $  s=    H'(((&&y11AK$[11111r   c                    | rt           j                            |           st          j        d           d S t
          j        d         dt
          j        d         }dt          d|d}t           j                            | |          }t           j                            |          rt          j        d|           d S t          j        d	|           t          |d
          }	 |
                    t                     |                                 n# |                                 w xY wt           j                            | d          }t          j        d	|           t          |d
          }	 |
                    t           j                            t           j        |                     |                                 d S # |                                 w xY w)Nz#Could not find the install locationr   .r<   zsetuptools-z-pyz	.egg-infoz%s already existszCreating %sr{   zsetuptools.pth)r   r+   r6   r   r$   r   r=   SETUPTOOLS_FAKED_VERSIONr,   r(   rU   r   r*   curdir)r   pyversetuptools_filer   r   pth_files         r   rP   rP   )  s    bgnn[99 6777'***C,<Q,?,?@EE%%%uuu.Ow||K99H	w~~h $h///H]H%%%XsA	#$$$									w||K)9::HH]H%%%XsA	RY88999										s   )D D.7=G
 
G c                 |   t           j                            | dd          }t           j                            |          r,t	          |t
                    rt          j        d|           dS t          |            t          j	        |            t          j	        t           j                            | d                     t           j                            | dd          }t          |d          }	 |                    t
                     |                                 n# |                                 w xY wdS )NEGG-INFOPKG-INFOr   Fr{   T)r   r+   r,   r6   r   r   r   r$   r|   mkdirr(   rU   r*   )r+   r   r   s      r   r   r   F  s    w||D*j99H	w~~h #677 	H*H5555HTNNNHRW\\$
++,,,w||D*j99HXsA	#$$$									4s   4D# #D9c                  J    t          j        d           t                       d S )NzBefore install bootstrap.)r   r$   rN   r   r   r   _before_installr   Z  s%    H()))r   c                 &   dt           j        vrdS t           j        t           j                            d          dz   d          }t          |          D ]\  }}dD ]}|                    d|z            r4|                    d          d         }|                     |          c c S ||k    r7t          |          |k    r$||dz            }|                     |          c c S |dk    r#t          |                     t                    c S dS )	Nr!   Tr<   )z--rootz--prefixz%s=zroot=z--user)r   argvindex	enumerate
startswithsplitlenr   )locationr   r   r   optiontop_dirs         r   _under_prefixr   _  s%     t8CHNN9--a/001Doo 
2 
2
s, 	8 	8F~~efn-- 8))G,,R0**73333333t99u$$"57mG#..w7777777(??y4&&y111114r   c                  *   t          j        d           	 dd l} n%# t          $ r t          j        d           Y d S w xY w| j        }	 |                    | j                            dd                    }n=# t          $ r0 |                    | j                            d                    }Y nw xY w|t          j        d           d S |j	        }t          j        d|           t          |          st          j        d	           d S |                    d
          s(t          j        d           t          |          }|sd S nt          j        d           t          j                            |dd          }t          j                            |          r+t#          |t$                    rt          j        d           d S t          j        d           t'          |          }|sd S t          j        d           t)                       d S )NzScanning installed packagesr   z7Setuptools or Distribute does not seem to be installed.r@   F)replacementz No setuptools distribution foundz&Setuptools installation detected at %szMNot patching, --root or --prefix is installing Distribute in another locationz.eggzNon-egg installationzEgg installationr   r   ry   rz   zPatched done.)r   r$   rH   rO   working_setfindRequirementparse	TypeErrorr   r   endswithr   r   r+   r,   r6   r   r   r   	_relaunch)rH   wssetuptools_distsetuptools_locationresr   s         r   rN   rN   q  sK   H*+++   JKKK 
	"BQ''-";"A"A,.3 #B #5 #5 6 6 Q Q Q''-";"A"A,"O"OPPQ 3444)2H57JKKK ,--  ( 	) 	) 	) ''// '((('(;<< 	F	 	#$$$7<< 3ZLLGNN8$$ 	($788	H'(((F011 	FH_KKKKKs    ==/A8 87B21B2c                      t          j        d           t          j        d d         g dk    rdt          j        d<   t          j        gt          j        z   } t          j        t          j        |                      d S )NzRelaunching...   )z-cr!   z#--single-version-externally-managedr    r   )r   r$   r   r   r   rV   r   r	   r
   s    r   r   r     sm    H x|OOOOO Nch&DHZ_T""#####r   r   c                 (   ddl }ddl}ddlm} g }|| }|D ]]}|                                r1|                    |           |                     |          }d|_        |                     ||           ^t          j	        dk     r-d }|
                    |           |                                 n*|
                    |                    d          d	           |D ]}t          j                            ||j                  }		 |                     ||	           |                     ||	           |                     ||	           k# |$ rA t          j                    d
         }
| j        d
k    r |                     d
d|
z             Y w xY wdS )a9  Extract all members from the archive to the current working
       directory and set owner, modification time and permissions on
       directories afterwards. `path' specifies a different directory
       to extract to. `members' is optional and must be a subset of the
       list returned by getmembers().
    r   N)ExtractErrori  )rJ      c                 6    t          | j        |j                  S ro   )cmpname)dir1dir2s     r   sorterz_extractall.<locals>.sorter  s    ty$),,,r   r   T)keyreverser<   ztarfile: %s)copyoperatorr'   r   r   appendmodeextractr   r=   sortr   
attrgetterr   r+   r,   r   chownutimechmodrS   
errorlevel_dbg)selfr+   membersr   r   r   directoriestarinfor   dirpathrZ   s              r   r)   r)     s    KKKOOO$$$$$$K $ $==?? 	w'''ii((GGLWd#### &  	- 	- 	-   X0088$GGG  0 0',,tW\22		0JJw(((JJw(((JJw(((( 	0 	0 	0q!A""		!]Q./////	00 0s   AE		AFFc                 @    t                      }t          |           dS )z-Install or upgrade setuptools and EasyInstallN)r>   r3   )r   rB   r.   s      r   mainr     s!    !##GWr   __main__r<   )r   N)(__doc__r   r   r   r   r"   r'   	distutilsr   siter   rO   r   r   DEFAULT_VERSIONDEFAULT_URLr   r   r3   r:   rE   r   r[   r>   rw   r   r   r|   r   r   rP   r   r   r   rN   r   r)   r   __name__r   r   r   r   <module>r      s    
			 



             III@* * * *  @ @ @	@ 	@ 	@ 	@ 	@@ D# 
 
   22 2 28	, 	, 	, ++)B%5 %5 %5 %5N !0{!y"$ "$ "$ "$H  0    k+&&( ( (    B (K(ABB 2 2 2
  6 $/;/O#P#P    $ ^,,  
  $1 1 1h$ $ $,0 ,0 ,0 ,0^ '     zD!"" s   ) 33? A
	A
