
    xhe                        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mZm	Z	m
Z
mZ ddlmZ ddlmZ  ej        ddded	
            eddd
          d             Z edd          d             Zd Zd ZddZd ZdS )    N)basenamedirnameisdirisfilejoin   )
deprecated)on_winz24.1z24.3ISWINz'Use `conda_build.utils.on_win` instead.)addendumz)Use `os.makedirs(exist_ok=True)` instead.c                 P    t          |           st          j        |            d S d S N)r   osmakedirs)r   s    9lib/python3.11/site-packages/conda_build/noarch_python.py
_force_dirr      s0    >> 
G     c                 4    t          j        d| z             d S )Nz[noarch_python] %s)sysexit)exit_messages    r   _error_exitr      s    H!L011111r   c                    t          |t          rdnd|           }t          j                    }|dk    rd}t	          ||          5 }	 |                                }n'# t          $ r t          j        d| z             Y nw xY wddd           n# 1 swxY w Y   t          j
        |          j        }t          j        |           t          r|                     d          r
| dd	         } t          |d
          }t          j        |d           t          ||           }t	          |d          5 }	|	                    |           ddd           n# 1 swxY w Y   t          j        ||           | S )zTake a file from the bin directory and rewrite it into the python-scripts
    directory with the same permissions after it passes some sanity checks for
    noarch pacakgesScriptsbinzANSI_X3.4-1968zUTF-8)encodingz9[noarch_python] Noarch package contains binary script: %sN
-script.pyipython-scriptsTexist_okw)r   r
   localegetpreferredencodingopenreadUnicodeDecodeErrorr   r   r   statst_modeunlinkendswithr   writechmod)
fnprefixsrcr   fidatasrc_modedst_dirdstfos
             r   rewrite_scriptr6   "   s    vF5yyr
:
:C*,,H###	cH	%	%	% W	W7799DD! 	W 	W 	WHPSUUVVVVV	WW W W W W W W W W W W W W W W
 ws||#HIcNNN  "++l++ X 6+,,GK$''''
w

C	c3 2
              HS(IsH   B	AB!B?BBBBB5EEEc                 d   t          ||           }|                     d          rt          j        |           dS |                     d          rmt	          t          j                             || dd         dz                       st          | dd                   |d         v rt          j        |           dS d| v rt          |d          }t          j        |d	           | |                     d          d         }t          ||          }t          |          }t          j        |d	           t          j        ||           |d                             |d
d                    dS |                     d          r<t          |          }t          ||          }|d                             |           dS |                     d          r%|d                             | dd                    dS t          j        t"                    }	|	                    d| z             dS )z8Process a file for inclusion in a noarch python package.)z	.egg-infoz.pycz.pyoz.exeNr   r   site-packagesTr      )zbin/r   )z	Examples/z	Examples\Examples	   z7Don't know how to handle file: %s.  Including it as-is.)r   r*   r   r)   r   pathr   r   findr   shutilmoveappend
startswithr6   logging	getLogger__name__debug)
fdr.   r=   nspgr4   r3   r-   logs
             r   handle_filerL   C   s   ??D 	zz/00 "Q
	$	
F		 Qrw||FAcrcF\$9::;;QAcrcFq!1222
	$	A		6?++
C$''''aff_%%''(61oo#,,
Gd++++D#	/!!!BCC&))))) 
)	*	* Qd^^B''	
""2&&&&& 
1	2	2 Q	*QqrrU#####
 ))		KaOPPPPPr   c                    |                                  g g g d}|D ]}t          |||           t          rA|d         |d         fD ]0}t          |          D ]\  }}|                    dd          ||<   1|rH|D ]E}	t          ||	          }
t          j                            |
          rt          j	        |
           F|S )N)distr9   r   r;   r9   r;   \/)
rN   rL   r
   	enumeratereplacer   r   r=   r   r)   )mfilesr.   entry_point_scriptsrH   rG   fnsir-   entry_pointr/   s              r   populate_filesrY   m   s    B"RTUUA  " "Aq&!!!!  /o&*6 	/ 	/C"3 / /2D#..A/  . 	 	Kv{++Cw~~c"" 	#Hr   c                    t          |d          }t          j        |d           t          |d          }t          j        |d           |                                 }t	          t          |d|z            d          5 }|                    d           d d d            n# 1 swxY w Y   t	          t          |d|z            d          5 }|                    d	                    d
d                              d                     d d d            n# 1 swxY w Y   t          | ||          }t          t                    }|d         r6dD ]3}	t          j        t          ||	          t          ||	                     4t	          t          |d                    5 }
|
                                }d d d            n# 1 swxY w Y   t	          t          |d          d          5 }|                    d           t          j        ||dd           |                    d           |                    |           d d d            d S # 1 swxY w Y   d S )Nr   Tr   r   z.%s-pre-link.shwbs?       #!/bin/bash
    $PREFIX/bin/python $SOURCE_DIR/link.py
    z.%s-pre-link.batzC    @echo off
    "%PREFIX%\python.exe" "%SOURCE_DIR%\link.py"
    
z
zutf-8r   )z
cli-32.exez
cli-64.exez_link.pyzlink.pyr!   zDATA =    )indent	sort_keysz
## END DATA

)r   r   r   namer$   r+   rR   encoderY   r   __file__r?   copyfiler%   jsondump)rS   rT   r.   bin_dirscripts_dirr`   r5   rH   this_dirr-   r0   	link_codes               r   	transformrj      sC   65!!GK$''''vy))KKd++++6688D 
d7-455t	<	< 

	
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d; 2T 9::D	A	A 
R
 	fffWoo		
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 	q%((A x  H 		 B, 	B 	BBOD2..VR0@0@AAAA 
d8Z((	)	) RGGII	               
d69%%s	+	+ r
	!RT2222
$%%%
	                 sI   B$$B(+B(=DD D$GG	G	.AIIIr   )rd   r"   rC   r   r?   r   os.pathr   r   r   r   r   deprecationsr	   utilsr
   constantr   r   r6   rL   rY   rj    r   r   <module>rp      s]      				  



 : : : : : : : : : : : : : : $ $ $ $ $ $       
 


6    FF%PQQQ  RQ
 FF2 2 2  B'Q 'Q 'QT   ,/ / / / /r   