
    xheh-                     \   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mZmZ dd
lmZ ddlmZ ddlmZ  G d de	          Z G d de          Z G d de          Zej                            ddg           ej                            dg           dS )    N)defaultdict)install)Distribution)	BaseErrorOptionError   )api)handle_anaconda_upload)StringIOconfigparserspec_from_line)Config)MetaData)pypic                       e Zd ZdZdS )GetoptErrorz7The option table provided to 'fancy_getopt()' is bogus.N)__name__
__module____qualname____doc__     7lib/python3.11/site-packages/conda_build/bdist_conda.pyr   r      s        AAAAr   r   c            	       :     e Zd ZdZdddddddddZd fd	Z xZS )CondaDistributionaS  
    Distribution subclass that supports bdist_conda options

    This class is required if you want to pass any bdist_conda specific
    options to setup().  To use, set distclass=CondaDistribution in setup().

    Options that can be passed to setup() (must include
    distclass=CondaDistribution):

    - conda_buildnum: The build number. Defaults to 0. Can be overridden on
      the command line with the --buildnum flag.

    - conda_buildstr: The build string. Default is generated automatically
      from the Python version, NumPy version if relevant, and the build
      number, like py34_0.

    - conda_import_tests: Whether to automatically run import tests. The
      default is True, which runs import tests for the all the modules in
      "packages". Also allowed are False, which runs no tests, or a list of
      module names to be tested on import.

    - conda_command_tests: Command line tests to run. Default is True, which
      runs ``command --help`` for each ``command`` in the console_scripts and
      gui_scripts entry_points. Also allowed are False, which doesn't run any
      command tests, or a list of command tests to run.

    - conda_binary_relocation: Whether binary files should be made relocatable
      (using install_name_tool on OS X or patchelf on Linux). The default is
      True. See the "making packages relocatable" section in the conda build
      documentation for more information on this.

    - conda_preserve_egg_dir: Whether to preserve the egg directory as
      installed by setuptools.  The default is True if the package depends on
      setuptools or has a setuptools entry_points other than console_scripts
      and gui_scripts.

    Command line options:

    --buildnum: Set the build number. Defaults to the conda_buildnum passed to
      setup(), or 0. Overrides any conda_buildnum passed to setup().

    r   NT)conda_buildnumconda_buildstrconda_import_testsconda_command_testsconda_binary_relocationconda_preserve_egg_dirconda_featuresconda_track_featuresc           
         i }|r&| j         D ]}||v r|                    |          ||<   t                                          |           | j         D ]7}t	          | j        ||                    || j         |                              8d S N)conda_attrspopsuper__init__setattrmetadataget)selfattrsgiven_attrsattr	__class__s       r   r)   zCondaDistribution.__init__V   s      	8( 8 85==(-		$K%$ 	X 	XDDM4t?OPT?U)V)VWWWW	X 	Xr   r%   )r   r   r   r   r&   r)   __classcell__r1   s   @r   r   r      sx        ) )d "##'"& $	 	KX X X X X X X X X Xr   r   c            	            e Zd ZdZ ed e e ej                    dz                      z   d          Z fdZ	 fdZ
 fdZ xZS )	bdist_condazcreate a conda packagebdist_conda_i  T)build_idbuild_is_hostc                 d    t                                                       d | _        d| _        d S )NF)r(   initialize_optionsbuildnumanaconda_upload)r-   r1   s    r   r:   zbdist_conda.initialize_optionsk   s.    ""$$$$r   c                     | j                             d          }| j        rt          d          d| j        j        f|d<   t                                                       d S )Nr   z--prefix is not allowedr5   prefix)distributionget_option_dictr>   r   confighost_prefixr(   finalize_options)r-   opt_dictr1   s     r   rC   zbdist_conda.finalize_optionsp   sb    $44Y??; 	97888+T[-DE  """""r   c                      j         j        }t          j        D ]3}t	          ||          s!t          ||t          j        |                    4 j         j        |_        t          t                    }|j
                                        |d         d<   |j        |d         d<   |j        |d         d<   |j        |d         d<   |j        |d         d<   |j        |d         d<   |j        |d         d	<   |j        |d         d
<   d |j        pg t'           j         dg           pg z   D             dgz   x|d         d<   |d         d<   t	           j         d          r!d  j         j        pg D             |d         d<   |j        |d         d<   |j        |d         d<   |j        |d         d<   t'           j         dg           }|rNt1          |t2                    rd                    d |                                D                       }t9          j                    i }	                     t?          |                                                      D ]3dv r(fd!                              D             }||<   .d |<   4n7# tD          $ r*}tG          dt3          |          z   dz   |z             d }~ww xY wt1          |t                    stG          d|z             |$                    d g           }|$                    d!g           }	|$                    d"g           }
|sY|	sW|
sUtK          |          d#k    rB|d         d         &                    d$           |d         d         &                    d$           ||	z   |
z   }|
r j'        j(        d%k    rd&|d         d'<   tK          |	|
z             d(k    rQ||d         d<   |j)        d&u r=tU          tW          t2          tY          j-        |                              |d         d)<   d$|d         d         v rd&|d         d<   |j.        r@|j.        d&u r' j         j/        pg  j         j0        pg z   |d         d*<   n|j.        |d         d*<   |j)        rJt1          |j)        tb                    s0tU          tW          t2          |j)                            |d         d)<   t          |          }d& j'        _2        tg          j4        | j'        +          }|5                                 d,|j'        _6        d-                    t3          tn          j8        j9                  t3          tn          j8        j:                  f          |j'        j;        d<   ty          j=        |d&d&.           |j'         _'        t}                      ?                                 ty          j=        |d&d&/          d(         }ty          j@        ||j'        +           |j'        A                                  jB        r! G  fd0d1          }t          ||           d S d2|z  }t          |           d S )3Npackagenameversionbuildnumberstringbinary_relocationpreserve_egg_dirfeaturestrack_featuresc                 ,    g | ]}t          |          S r   r   .0is     r   
<listcomp>z#bdist_conda.run.<locals>.<listcomp>   s6     A
 A
 A
 1A
 A
 A
r   install_requirespythonrequirementsruntests_requirec                 ,    g | ]}t          |          S r   rQ   rR   s     r   rU   z#bdist_conda.run.<locals>.<listcomp>   s-     % % %&'q!!% % %r   testrequiresabouthomelicensesummaryentry_points
c              3   >   K   | ]}|                                 V  d S r%   )strip)rS   xs     r   	<genexpr>z"bdist_conda.run.<locals>.<genexpr>   s*      "P"P17799"P"P"P"P"P"Pr   )console_scriptsgui_scriptsc                 F    g | ]}| d                      |           S )=)r,   )rS   optioncsections     r   rU   z#bdist_conda.run.<locals>.<listcomp>   sE     % % %$* $* D DAEE'6,B,B D D% % %r   z$ERROR: entry-points not understood: z
The string wasz.ERROR: Could not add entry points. They were:
scriptsrh   ri   r   
setuptoolsosxT
osx_is_appr   commandsimports)rA   F.)
build_onlynotest)postrw   c                       e Zd Z j        ZdS )bdist_conda.run.<locals>.argsN)r   r   r   r<   )r-   s   r   argsrz     s        "&"6r   r{   z[# If you want to upload this package to anaconda.org later, type:
#
# $ anaconda upload %s
)Er?   r+   r   r&   hasattrr*   r;   r   r   dictrG   lowerrH   r   r    r!   r"   r#   r]   getattrrZ   urlr`   description
isinstancestrjoin
splitlinesr   ConfigParser	read_filer   sectionsoptions	Exceptionr   r,   lenappendrA   platformr   listmapr   make_entry_testsr   packages
py_modulesboolkeep_old_workr   fromdictcheck_fieldsset_build_idsysversion_infomajorminorvariantr	   rI   r(   rY   r\   cleanr<   r
   print)r-   r+   r0   drb   newstrvalueerrrscsgs
entry_listmoutputr{   no_upload_messagerm   rn   r1   s   `               @@r   rY   zbdist_conda.runw   s   
 $-%1 	M 	MD8T** M$(9(Ed(KLLL =$&*mH#  (}2244)V"*"2)Y'6'
8  (6'
8*2*J'
&')1)H'
%&!)!8'
:'/'D'
#$A
 A
'-2t(*<bAAGRIA
 A
 A
 J	A 	.% 1^#4W#=
 4$o66 	% %+/+<+J+Pb% % %AfIj! &\'
6
 !) 0'
9 ( 4'
9 t0."EE 1	,,, 9"P"Pl6M6M6O6O"P"P"PPP -//!9KK 0 0111 $%::<< 	9 	9"&HHH% % % % %./ii.@.@% % %E 5:L11 59L11	9 !   %>c((#,- !!  ( lD11 !ET   "%%i44!%%&7<<!%%mR88  D" DR DC4E4E4I4In%e,33LAAAn%g.55lCCC"Wr\
 4$+.%77/3AgJ|,rBw<<1$$1;AgJ~.3t;;04T%::%F%FGG1 1&	*- 1^,U333-1AgJ)*& 	C*d22(,(9(B(Hb%06B(&	)$$ (0'B&	)$' 	Q
($1
 1
 	Q %)S(2N)O)O$P$PAfIj!GG$(!a444	 %%(XX!'((#c.>.D*E*EF&
 &
" 		!T2222h 	14555a8))))	 	%7 7 7 7 7 7 7 7 7 7 #6400000
   #$$$$$s   )"J 
K%KK)r   r   r   r   r   r   inttimerA   r:   rC   rY   r2   r3   s   @r   r5   r5   e   s        *KV$ss33yty{{T/A+B+B'C'CCSW  F% % % % %
# # # # #Z% Z% Z% Z% Z% Z% Z% Z% Z%r   r5   )z	buildnum=NzThe build number of
    the conda package. Defaults to 0, or the conda_buildnum specified in the
    setup() function. The command line flag overrides the option to
    setup().)anaconda-uploadNz+Upload the finished package to anaconda.orgr   )r   r   collectionsr   setuptools.command.installr   setuptools.distr   setuptools.errorsr   r    r	   rI   r
   conda_interfacer   r   r   rA   r   r+   r   	skeletonsr   r   r   r5   user_optionsextendboolean_optionsr   r   r   <module>r      s   


  # # # # # # . . . . . . ( ( ( ( ( ( 4 4 4 4 4 4 4 4       ) ) ) ) ) ) C C C C C C C C C C                  
B B B B B) B B BIX IX IX IX IX IX IX IXXl% l% l% l% l%' l% l% l%h    	
 	W
     " "$5#6 7 7 7 7 7r   