
    c@j                        d Z ddlmZ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
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 ddlmZmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlm Z  ddl!m"Z"  G d de#          Z$d Z% G d de#          Z&d Z'd Z(d Z)d Z*d Z+d Z,d Z-d Z.d Z/d Z0d)dZ1d Z2d  Z3d! Z4d" Z5d# Z6d$ Z7d% Z8 G d& d'e          Z9d*d(Z:dS )+z!Bundle up a project for shipment.    )absolute_importprint_functionN)BytesIO)progressbar)tqdm)NullFrontend_new_error_recorder)logged_subprocess)SimpleStatus)"subdirectory_relative_to_directory)rename_over_existing)makedirs_ok_if_exists)current_platformc                       e Zd Zd ZdS )	_FileInfoc                    t           j                            |          | _        t           j                            | j        |          | _        t          j                    dk    r!| j                            dd          | _	        n| j        | _	        t           j        
                    | j                  | _
        || _        d S )N)startWindows\/)ospathabspath	full_pathrelpathrelative_pathplatformsystemreplaceunixified_relative_pathbasenameis_directory)selfproject_directoryfilenamer"   s       9lib/python3.11/site-packages/anaconda_project/archiver.py__init__z_FileInfo.__init__$   s    22W__T^CT_UU?	) 	>+/+=+E+EdC+P+PD((+/+=D(((88(    N)__name__
__module____qualname__r'    r(   r&   r   r   #   s#        ) ) ) ) )r(   r   c           	      V   	 g }t          j        |           D ]\  }}}g }|D ]h}t          | t           j                            ||          d          }	 ||	          r>|                    |           |                    |	           i||d d <   |D ]R}
t          | t           j                            ||
          d          }	 ||	          s|                    |	           S|S # t          $ r4}|                    d| dt          |          d           Y d }~d S d }~ww xY w)NT)r$   r%   r"   FzCould not list files in : .)	r   walkr   r   joinappendOSErrorerrorstr)r$   ignore_filterfrontend
file_infosrootdirsfilesfiltered_dirsdinfofes               r&   _list_projectrA   /   s   
!#):!;!; 	, 	,D$M , , 3Drw||\`bcOdOdswxxx =&& ,!((+++%%d++++ $DG , , 3D*,',,tQ*?*?.35 5 5 %}T** ,%%d+++,    <M<M<MsSTvvvvVWWWttttts   C'C* *
D(4)D##D(c                       e Zd Zd Zd ZdS )_FilePatternc                 $    |dk    sJ || _         d S N pattern)r#   rH   s     r&   r'   z_FilePattern.__init__N   s    "}r(   c                     d }| j                             d          r| j         }n
d| j         z   }d|j        z   }|                    d          r|j        r |||d d                   S dS  |||          S )Nc                     |                      d          sJ | dk    r<t          j        | |          rdS t          j                            |           } | dk    <dS )Nr   TF)
startswithfnmatchr   r   dirname)r   rH   s     r&   matchz#_FilePattern.matches.<locals>.matchX   si    ??3'''''#+ -?411  4 wt,, #+ - 5r(   r   z*/F)rH   rK   r    endswithr"   )r#   r>   rN   rH   match_againsts        r&   matchesz_FilePattern.matchesS   s    
	 	 	 <""3'' 	*lGG T\)G d:: C   	1  u]GCRCL999u5000r(   N)r)   r*   r+   r'   rR   r,   r(   r&   rC   rC   M   s2          
 1  1  1  1  1r(   rC   c           	         g }	 t          j        | dd          5 }|D ]t}|                                }|                    d          r,|                    d          r
|dd          }|dk    r#|                    t          |                     u	 d d d            n# 1 swxY w Y   |S # t          t          f$ rO}|j        t          j	        k    r|cY d }~S |
                    d| d	t          |                     Y d }~d S d }~ww xY w)
Nrutf-8#z\#   rF   rG   zFailed to read r.   )codecsopenstriprK   r2   rC   r3   IOErrorerrnoENOENTr4   r5   )r%   r7   patternsr?   liner@   s         r&   _parse_ignore_filer`   v   s   H[300 	@A @ @zz|| ??3''  ??5)) $8D2: @OOL$>$>$>???@	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ W    7el" 	OOOOOONNNhhhAGHHH44444sG   B, A8BB, B##B, &B#'B, ,D=DD(DDc                 b    t           j                            | d          }t          ||          S )Nz.projectignore)r   r   r1   r`   )r$   r7   ignore_files      r&   _load_ignore_filerc      s)    ',,02BCCKk8444r(   c                    t           j                            t           j                            | d                    sTt           j                            t           j                            | d                    r|                    d           g S 	 t          j        g d|           }dg|                    d                                          z   S # t          j
        $ rQ}|j                            d                              dd          }|                    d	|z             Y d }~d S d }~wt          $ r0}|                    d
t          |          z             Y d }~d S d }~ww xY w)Nz.gitz
.gitignorez]Warning: the .gitignore file is being ignored because this directory is not a Git repository.)gitzls-filesz--othersz	--ignoredz--exclude-standardz--directory)cwdrU   
 z0'git ls-files' failed to list ignored files: %s.z Failed to run 'git ls-files'; %s)r   r   existsr1   r4   r
   check_outputdecode
splitlines
subprocessCalledProcessErroroutputr   r3   r5   )r$   r7   ro   r@   messages        r&   _git_ignored_filesrq      so   7>>"',,'8&AABB 7>>"',,'8,GGHH 	qNNoq q q	"/]]]ctv v v x&--00;;====(   (//'**224==IWUVVVttttt   9CFFBCCCttttts&   AC E.%AD11E.>%E))E.c                 X    t          | |          d S t                    fd}|S )Nc                     | j         }|dk    r:|dk    sJ |v s|dz   v rdS t          j                            |          }|dk    :dS )NrF   r   TF)r   r   r   rM   )r>   r   git_ignoreds     r&   is_git_ignoredz#_git_filter.<locals>.is_git_ignored   sq    !bj 	)3;{" tczk&A t7??4((D bj 	) ur(   )rq   set)r$   r7   ru   rt   s      @r&   _git_filterrw      sN    $%6AAK tk""K     r(   c                 :    t          | |          d S fd}|S )Nc                 B    D ]}|                     |           r dS dS NTFrR   )r>   rH   r^   s     r&   matches_some_patternz1_ignore_file_filter.<locals>.matches_some_pattern   s7     	 	Gt$$ ttur(   )rc   )r$   r7   r|   r^   s      @r&   _ignore_file_filterr}      sA     !2H==H t      r(   c                    	 t          | |          t          | |          d S dh	|D ]}	                    |j                   d 	D             		fdfd}t	          | ||          }|d S |S )Nz/anaconda-project-local.ymlc                 ,    g | ]}t          |          S r,   )rC   ).0ss     r&   
<listcomp>z,_enumerate_archive_files.<locals>.<listcomp>   s    @@@1|A@@@r(   c                 B    D ]}|                     |           r dS dS rz   r{   )r>   rH   plugin_patternss     r&   is_plugin_generatedz5_enumerate_archive_files.<locals>.is_plugin_generated   s7    & 	 	Gt$$ ttur(   c                 F     |           p |           p
 |           S Nr,   )r>   
git_filterignore_file_filterr   s    r&   all_filtersz-_enumerate_archive_files.<locals>.all_filters   s6    z$X#5#5d#;#;X?R?RSW?X?XXr(   )rw   r}   updateignore_patternsrA   )
r$   r7   requirementsreqr   infosr   r   r   r   s
         @@@@r&   _enumerate_archive_filesr      s    .99J,->II / t45O 4 4s23333@@@@@O    Y Y Y Y Y Y Y +[(CCE tLr(   c                 J   t                      }| D ]}|||j        <   | D ]`}t          j                            |j                  }|dk    r4|dk    sJ ||v r||= t          j                            |          }|dk    4at          |                                d           S )NrF   r   c                     | j         S r   r   )xs    r&   <lambda>z_leaf_infos.<locals>.<lambda>  s    ao r(   )key)dictr   r   r   rM   sortedvalues)r   all_by_namer>   parents       r&   _leaf_infosr      s    &&K / /*.D&'' - -!344l 	-S=   $ ('W__V,,F	 l 	- +$$&&,E,EFFFFr(   c                 b   |d}nd|z   }t          j        |d|z            5 }t          |          D ][}t          j                            | |j                  }|                    d|z             |                    |j	        |           \|D ]}	t          j        
                    |	          }
t          d                    |
                     t          j        |	dd	          5 }t          |                                          5 }|D ]S}	 |                    |          }|                    ||           /# t"          $ r |                    |           Y Pw xY w|
                    d
          d                             d          d         }t          j                            | d|dd          }d                    t'                                }t)                      }|                     |j                               t          j        |          }|                                |_        |                    d           |                    ||           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   	 d d d            d S # 1 swxY w Y   d S )NrF   :zw%s
  added %sarcnameJoining packed env {}rT   F)modedereferencer/   r   _rO   envs
conda-meta.packed{}
)fileobj)tarfilerY   r   r   r   r1   r   r>   addr   r!   printformatr   
getmembersextractfileaddfileKeyErrorsplitr   r   writeencodeTarInfotellsizeseek)archive_root_namer   r%   compressionpacked_envsr7   tfr>   r   packenv_nameenvenv_pfiledataenv_spec
dot_packedr   r?   tinfos                       r&   
_write_tarr     sE    (K'	h!4	6	6 1"&& 	4 	4Dgll#4d6HIIGMM,0111FF4>7F3333 	1 	1Dw''--H)00::;;;d%@@@ 1C !1!122 1e % - --#&??4#8#8DJJtT2222' - - -JJt,,,,,-'~~c2215;;C@@DH!#.?S_aj!k!kJ%}}-=-?-?@@H		AGGOHO--...#OJ77E!"EJFF1IIIJJuaJ000#1 1 1 1 1 1 1 1 1 1 1 1 1 1 11 1 1 1 1 1 1 1 1 1 1 1 1 1 1	11 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1s   C	J$,"J	I2	+E 
?I2	 E"I2	!E""DI2	&J	2I66J	9I6:J	=J$	JJ$JJ$$J(+J(c                    t          j        |d          5 }t          |          D ][}t          j                            | |j                  }|                    d|z             |                    |j	        |           \|D ]g}t          j        
                    |          }	t          d                    |	                     t          j        |d          5 }
t          |
                                          5 }|D ]-}|
                    |          }|                    ||           .|	                    d          d                             d	          d
         }t          j                            | d|dd          }|                    |d                    t%                                           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   i	 d d d            d S # 1 swxY w Y   d S )Nwr   r   r   rT   r   r/   r   r   rO   r   r   r   r   )zipfileZipFiler   r   r   r1   r   r>   r   r   r!   r   r   r   infolistreadwritestrr   r   )r   r   r%   r   r7   zfr>   r   r   r   r   r   r   r   r   r   s                   r&   
_write_zipr   (  s   	3	'	' O2&& 	6 	6Dgll#4d6HIIGMM,0111HHT^WH5555 
	O 
	ODw''--H)00::;;;C000 OC 00 OH ( 0 0"xx~~D$////'~~c2215;;C@@DH!#.?S_aj!k!kJKK
FMM:J:L:L,M,MNNNO O O O O O O O O O O O O O OO O O O O O O O O O O O O O O
	OO O O O O O O O O O O O O O O O O Os[   CG;"G  B=G		=G 	GG GG G; G$$G;'G$(G;;G?G?c                 F    t          | ||          }|d S d |D             S )Nr   c                     g | ]	}|j         
S r,   r   )r   r>   s     r&   r   zD_list_relative_paths_for_unignored_project_files.<locals>.<listcomp>A  s    1114D111r(   )r   )r$   r7   r   r   s       r&   0_list_relative_paths_for_unignored_project_filesr   =  s8    $%6|\\\E t1151111r(   Fc           	         |                                  }|&|j        D ]}| j                            |           |S t	          | j                  }t
          j                            | j        j	                  sF|                    d| j        j
        z             t          dd|                                          S | j        j        rF|                    d| j        j
        z             t          dd|                                          S t
          j                            | j        j        d          }g }|r6t
          j                            |          rt#          j                    }ddl}	t          j        |          D ]}
|                                                    d	          rd
nd}t
          j                            |d                    t1                      |
|                    }|d
k    rdnd}|	                    t
          j                            ||
          t
          j                            | j        d|
          ||dd          }|                    |           t9          | j        || j                  }|$t          dd|                                          S t?          || j                  t
          j                                       sfd|D             }|dz   tC          tE          j#                              z   }	 |                                                    d	          rtI          | j        ||||           nF|                                                    d          rtK          | j        ||d||           n|                                                    d          rtK          | j        ||d||           n|                                                    d          rtK          | j        ||d||           n|                    d|z             t          dd|                                          	 t          j&        |           |rt          j&        |           S S # tN          tP          f$ r Y S w xY wtS          ||           n# tN          $ r}|                    tC          |                     t          dd|z  |                                          cY d}~	 t          j&        |           |rt          j&        |           S S # tN          tP          f$ r Y S w xY wd}~ww xY w	 	 t          j&        |           |rt          j&        |           n_# tN          tP          f$ r Y nLw xY w# 	 t          j&        |           |rt          j&        |           w w # tN          tP          f$ r Y w w xY wxY wg }| j*        +                                D ](}|j,        j-        r|                    |j                   )t]          |          dk    r|/                    d           |/                    d           t]          |          t]          | j*                  k    r8|/                    dd                     ta          |                    z              t          dd!|z  "          S )#zMake an archive of the non-ignored files in the project.

    Args:
        project (``Project``): the project
        filename (str): name for the new zip or tar.gz archive file

    Returns:
        a ``Status``, if failed has ``errors``
    Nz%s does not exist.FzCan't create an archive.successdescriptionerrorsz#%s has been modified but not saved.r   r   .zipziptarz{}_envs_{}.{}T)prefixarcrootro   zip_symlinksverboseforcer   z$Failed to list files in the project.c                 *    g | ]}|j         k    |S r,   r   )r   r>   relative_dest_files     r&   r   z$_archive_project.<locals>.<listcomp>  s'    TTT$4+=AS+STTTTr(   z.tmp-)r   r7   .tar.gzgz)r   r   r7   .tar.bz2bz2.tarz Unsupported archive filename %s.z>Project archive filename must be a .zip, .tar.gz, or .tar.bz2.z#Failed to write project archive %s.zjWarning: env specs are not locked, which means they may not work consistently for others or when deployed.zI  Consider using the 'anaconda-project lock' command to lock the project.z  Unlocked env specs are: z, zCreated project archive %sr   r   )1problems_statusr   r7   r4   r	   r   r   ri   project_filer%   r!   r   
pop_errorshas_unsaved_changesr1   project_dirisdirtempfilemkdtemp
conda_packlistdirlowerrP   r   r   r   namer2   r   directory_path"union_of_requirements_for_all_envsr   isabsr5   uuiduuid4r   r   remover[   r3   r   	env_specsr   lock_setdisabledlenr>   r   )projectr%   	pack_envsfailedr4   r7   	envs_pathr   conda_pack_dirr   r   extr   r   fnr   tmp_filenamer@   unlockedr   r   s                       @r&   _archive_projectr
  E  s?    $$&&F ] 	* 	*E""5))))"7#344H7>>'.788 q+g.B.KKLLLE7QZbZmZmZoZopppp / q<w?S?\\]]]E7QZbZmZmZoZoppppW1=vFFIK #RW]]9-- #!)++:i(( 
	# 
	#C#>>++44V<<G%%%C7<<0F0FGWGYGY[^`c0d0deeD#&%<:44ULY(D(D)+glFC)P)P(,.:)-'+ ! - -B r""""$W%;%-292\^ ^ ^E  :E(N#+#6#6#8#8: : : 	: <HgF\]]7==+,, UTTTT%TTTg%DJLL(9(99L>>$$V,, 	>w|ULk\deeeee^^&&y11 
	>w|ULdXcnvwwwww^^&&z22 	>w|ULeYdowxxxxx^^&&v.. 	>w|ULdXcnvwwwwwNN=JKKK,l'/':':'<'<> > >	Il### *	.))))*! 	 	 	D	 	\84444 : : :s1vvE)NRZ)[#+#6#6#8#8: : : 	: 	: 	: 	: 	:	Il### *	.))))*! 	 	 	D	: 	5	Il### *	.)))! 	 	 	D			Il### *	.))))*! 	 	 	D	 H%,,.. + +% 	+OOHM***
8}}q X G 	H 	H 	Habbbx==C 1222 	XMM6$))F8DTDT:U:UVWWW3ORZ3Z\\\\s   #ER< (*RR('R(+R< ;V# <
UAUUV# *U  UUUV# !*V V V #W(%*WW(W%"W($W%%W(c                     t          j        | d          5 }t          |                                          cd d d            S # 1 swxY w Y   d S )NrT   r   )r   r   r   namelist)zip_pathr   s     r&   _list_files_zipr    s    		,	,	, %bkkmm$$% % % % % % % % % % % % % % % % % %s   !AA	A	c                     t          j        | d          5 }t          d |                                D                       cd d d            S # 1 swxY w Y   d S )NrT   r   c                 l    g | ]1}|                                 s|                                *|j        2S r,   )isregr   r   )r   members     r&   r   z#_list_files_tar.<locals>.<listcomp>  s9    eeevFLLNNeV\VbVbVdVdev{eeer(   )r   rY   r   r   )tar_pathr   s     r&   _list_files_tarr    s    	hS	)	)	) gReeeeeffg g g g g g g g g g g g g g g g g gs   +AAAc                     |                                  D ]C}|                     |j        |          }|j        dz	  }|dk    st	          j        ||           Dd S )N)r      r   )r   extractr%   external_attrr   chmod)r   destinationzinfoout_pathr   s        r&   _extractall_chmodr    sf     % %::en;:??"b(	 	%HXt$$$	% %r(   c                 N   t          j                    }	 t          j        | d          5 }t	          ||           t          |j        t                    rt          |d          }|D ]\  }}|	                    d|d|           t          j                            ||          }t          j                            |          r%t          |           t          j        ||           t          t          j                            |                     t          j        ||           	 d d d            n# 1 swxY w Y   	 t          j        |           d S # t(          t*          f$ r Y d S w xY w# 	 t          j        |           w # t(          t*          f$ r Y w w xY wxY w)NrT   r   Extract desc
Unpacking  to )r   r   r   r   r  
isinstance
underlyingr   r   r>   r   r   r1   r   r   shutilcopystatrM   copy2rmtreer[   r3   )r  src_and_destr7   tmpdirr   srcdestsrc_paths           r&   _extract_files_zipr/    s    F_XC000 	1Bb&)))(-|<< C#LzBBB+ 1 1dccc44@AAA7<<447==** 1)$///OHd3333)"'//$*?*?@@@L400001		1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1	M&!!!!!! 	 	 	DD		M&!!!!! 	 	 	D	se   E6 DD<0E6 <E  E6 E E6 E E32E36F$8FF$F!F$ F!!F$c                    t          j        | d          5 }t          |j        t                    rt          |d          }|D ]\  }}|                    d|d|           |                    |          }|                                rCt          t          j                            |                     |                    ||           n%|                                sJ t          |           	 |                    ||d           n&# t           $ r |                    ||           Y nw xY w|                    ||           |                    ||           	 d d d            d S # 1 swxY w Y   d S )NrT   r   r  r   r"  r#  F)r   rY   r$  r%  r   r   r>   	getmemberr  r   r   r   rM   makefiler   chown	TypeErrorr  utime)r  r*  r7   r   r,  r-  r  s          r&   _extract_files_tarr6    s   	hS	)	)	) #Rh)<88 	?:>>>L' 	# 	#KS$MMM###tt<===\\#&&F ||~~ ,%bgood&;&;<<<FD))))||~~%%%%d+++'u---- ' ' '&&&&&'HHVT"""HHVT""""%	## # # # # # # # # # # # # # # # # #s6   C E28DE2 D30E22D331E22E69E6c                 f    |                      dt          j                  } fd | d           S )Nr   c                     t           j                            |           \  }}|dk    r| |fS | ||          S  |t           j                            ||                    S rE   )r   r   r   r1   )headtailrM   r%   _helpers       r&   r;  z#_split_after_first.<locals>._helper  sq     gmmD11(b= 	B$< 	B77H--- 77BGLL4$@$@AAAr(   )r   r   sep)r   r;  s    @r&   _split_after_firstr=    sJ    <<RV$$D
B 
B 
B 
B 
B 74r(   c           
      H    ||           }t          |          dk    r|                    d           d S d t          |d |D                       D             }|d         d         }|dk    r&|                    d|d         d         z             d S ||}t          j                            |          r`|J t          j                            t          j                            |                    }t          j                            |          }	n|t          j	                    }t          j                            t          j                            |                    }	t          j                            t          j                            t          j        
                    |	|                              }|                    |	          sJ t          j                            |          rMt          j                            |          rt          j        |          r|                    d|z             d S g }
|D ]\  }}}||k    r|                    d	|d
|d            d S |.t          j                            t          j                            t          j        
                    ||                              }|                    |          s"|                    d|d|d|d            d S |
                    ||f           ||
fS )Nr   z7A valid project archive must contain at least one file.c                 $    g | ]\  }\  }}|||fS r,   r,   )r   r   r   	remainders       r&   r   z._get_source_and_dest_files.<locals>.<listcomp>  s>     j j j,$+ FI& j j jr(   c                 ,    g | ]}t          |          S r,   )r=  )r   r   s     r&   r   z._get_source_and_dest_files.<locals>.<listcomp>  s"    ;g;g;gY]<Nt<T<T;g;g;gr(   rW   z..z9Archive contains relative path '%s' which is not allowed.z>Destination '%s' already exists and is not an empty directory.zcA valid project archive contains only one project directory with all files inside that directory. 'z' is outside 'z'.zArchive entry 'z' would end up at 'z' which is outside ')r   r4   r   r   r   r   realpathr   rM   getcwdr1   rK   ri   r   r   r2   )archive_path
list_filesr   
parent_dirr7   namesitemscandidate_prefixcanonical_project_dircanonical_parent_dirr*  r   r   r@  r-  s                  r&   _get_source_and_dest_filesrL    s0   J|$$E
5zzQ PQQQtj j03E;g;gaf;g;g;g0h0hj j jEQx{4 RV[\]V^_`Vabccct '&	w}}[!! 	s!!! " 0 01M1M N N!w/DEE 	%J!w//
0K0KLL " 0 0NbdoApAp1q1q r r !++,@AAAAA	w~~+,, w}}233 	rzBW7X7X 	 NN[^ssttt4L%* * *!vy%% 	NNN^b^b^bdtdtdtv w w w44 	 w=RT]0^0^ _ _``455 	NNN DD$$$(=(=(=? @ @ @44T4L))))!<00r(   c                        e Zd Z fdZ xZS )_UnarchiveStatusc                 j    t          t          |                               ||           || _        d S )Nr   )superrN  r'   r   )r#   r   r   r   	__class__s       r&   r'   z_UnarchiveStatus.__init__B  s5    %%..wK.XXX&r(   )r)   r*   r+   r'   __classcell__)rQ  s   @r&   rN  rN  A  s8        ' ' ' ' ' ' ' ' 'r(   rN  c                     |0t           j                            |          r|t          d          t	          |          }d}d}                     d          rt          }t          }nit           fddD                       rt          }t          }n?|                    d z             t          dd z  |                                	          S 	 t           ||||          }|'t          dd z  |                                	          S |\  }}t          |          d
k    r<|                    d           t          dd z  |                                	          S t           j                            |          st          j        |           	  | ||           nA# t$          $ r4}		 t'          j        |           n# t*          t,          f$ r Y nw xY w|	d}	~	ww xY wt/          dd|z  |          S # t*          t,          t0          j        t2          j        f$ rP}	|                    t7          |	                     t          dd|                                	          cY d}	~	S d}	~	ww xY w)a  Unpack an archive of files in the project.

    This takes care of several details, for example it deals with
    hostile archives containing files outside of the dest
    directory, and it handles both tar and zip.

    It does not load or validate the unpacked project.

    project_dir can be None to auto-choose one.

    If parent_dir is non-None, place the project_dir in it. This is most useful
    if project_dir is None.

    Args:
        archive_filename (str): the tar or zip archive file
        project_dir (str): the directory that will contain the project config file
        parent_dir (str): place project directory in here

    Returns:
        a ``Status``, if failed has ``errors``, on success has a ``project_dir`` property
    NzJIf supplying parent_dir to unarchive, project_dir must be relative or Noner   c                 :    g | ]}                     |          S r,   )rP   )r   suffixarchive_filenames     r&   r   z&_unarchive_project.<locals>.<listcomp>h  s(    ^^^F''//^^^r(   )r   r   r   zEUnsupported archive filename %s, must be a .zip, .tar.gz, or .tar.bz2FzCould not unpack archive %sr   r   z9Archive does not contain a project directory or is empty.TzProject archive unpacked to %s.)r   r   r   zFailed to read project archive.)r   r   r   
ValueErrorr	   rP   r  r/  anyr  r6  r4   r   r   rL  r   ri   makedirs	Exceptionr&  r)  r[   r3   rN  r   r   TarErrorr5   )
rV  r   r7   rF  rE  extract_filesresultrJ  r*  r@   s
   `         r&   _unarchive_projectr^  H  s   ,  g27==#=#= g* gefff"8,,HJM  (( 
:$
*	^^^^>]^^^	_	_ :$
*^brstttE)FIY)Y#+#6#6#8#8: : : 	:x+,<j+Wackll 	>-JM]-]'/':':'<'<> > > > 17-	|! 	>NNVWWW-JM]-]'/':':'<'<> > > > w~~344 	/K-...	M*L(CCCC 	 	 	34444W%   G	  -NQf-f,AC C C 	C WgmW-=> x x xs1vvE7Xaiatatavavwwwwwwwwwxsn   ;G= AG= %3G= F' &G= '
G%2GG GG GG  G%%G= ='I4$AI/)I4/I4)Fr   );__doc__
__future__r   r   rX   r\   rL   r   r   r&  rm   r   r   r   r   ior   conda_pack._progressr   r   anaconda_project.frontendr   r	   anaconda_project.internalr
   'anaconda_project.internal.simple_statusr   ,anaconda_project.internal.directory_containsr    anaconda_project.internal.renamer   "anaconda_project.internal.makedirsr   #anaconda_project.internal.conda_apir   objectr   rA   rC   r`   rc   rq   rw   r}   r   r   r   r   r   r
  r  r  r  r/  r6  r=  rL  rN  r^  r,   r(   r&   <module>rk     s%   ( ' 6 6 6 6 6 6 6 6    				                 , , , , , ,       G G G G G G G G 7 7 7 7 7 7 @ @ @ @ @ @ [ [ [ [ [ [ A A A A A A D D D D D D @ @ @ @ @ @	) 	) 	) 	) 	) 	) 	) 	)  <&1 &1 &1 &1 &16 &1 &1 &1R  <5 5 5
  @  (       6G G G 1  1  1FO O O*2 2 2e] e] e] e]P% % %
g g g% % %  4# # #2  &81 81 81v' ' ' ' '| ' ' 'Hx Hx Hx Hx Hx Hxr(   