
    xheP                    2   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 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 ddlmZmZmZmZ ddlmZmZmZ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Z)d Z*d Z+d Z,d Z-d Z.d d!dZ/dS )"    )annotationsN)	Namespace)glob)chain)abspath
expanduser
expandvars)Path)Sequence)dals)dashlist   )apibuildsourceutils)ArgumentParseradd_parser_channelsbinstar_uploadcc_conda_build)get_channel_urlsget_or_merge_configzstd_compression_level_default)LoggingContext   )KeyValueAction)get_render_parserargsSequence[str] | Nonereturn tuple[ArgumentParser, Namespace]c                   t                      }d|_        t          d          |_        |                    ddd           |                    ddd	d
t
                     |                    ddt          j        d
t
                     |                    ddddt          j	        dd          
                                dk               |                    dddd           |                    dddd           |                    dddd           |                    dddd           |                    dddd            |                    dd!dd"           |                    d#d$d%d&'           |                    d(dd)t          j	        d*d+          
                                dk    ,           |                    d-dd.d/           |                    d0dd1           |                    d2d3dd4t          j	        d5d+          
                                dk    ,           |                    d6dd7           |                    d8d9t          j	        d:          ;           |                    d<d=t          j	        d>          ;           |                    d?d@dAg dBC           |                    dDdEdFdGdH           |                    dIdJt           dKt          t          dLdM          t          j	        dNt                    O           |                    dP          }|                    dQdRS           |                    dTdUdVW           |                    dXdYdZd[\           |                    d]d^S           |                    d_d`t          j	        da          r;t          t!          t#          t          j	        da                                        nt          j	        da          ;           |                    dbdcddt          j	        dedf          ;           |                    dgddhdit          j	        did          
                                dk               |                    djddkdlt          j	        dld          
                                dk               |                    dmdndot          j	        dodp          q           |                    drdsS           |                    dtddut          j	        dvd          
                                dk    ,           |                    dwddvdxt          j	        dvd          
                                dk    y           |                    dzdd{d|t          j	        d{d+          
                                dk    y           |                    d}d~t          j	        d          ;           |                    dddddG           |                    dddddG           |                    ddddt                     |                    dddGdd           |                    dddGdd           |                    ddddt          j	        dd+          
                                dk               |                    ddddt          j	        dd+          
                                dk               |                    ddddt          j	        dd+          
                                dk               |                    ddddt          j	        dd+          
                                dk               |                    dddt          j	        dd          
                                dk    ,           |                    ddddt          j	        dd          
                                dk               |                    dddd           |                    ddt          j	        d          r;t          t!          t#          t          j	        d                                        nt          j	        d          ;           |                    dddt          j	        dd          
                                dk    d           |                    dddt          j	        dd+          
                                dk    ,           |                    ddS           |                    dd%d           |                    ddt$          dd           |                    ddd           t'          |           |                    |           }t+          |j                   ||fS )Nzconda buildap  
        Tool for building conda packages. A conda package is a binary tarball
        containing system-level libraries, Python modules, executable programs, or
        other components. conda keeps track of dependencies between packages and
        platform specifics, making it simple to create working environments from
        different sets of packages.
        z--check
store_truez!Only check (validate) the recipe.)actionhelpz--no-anaconda-uploadstore_falsez1Do not ask to upload the package to anaconda.org.anaconda_upload)r$   r%   destdefaultz--no-binstar-uploadz--no-include-recipez2Don't include the recipe inside the built package.include_recipetruez-sz--sourcez)Only obtain the source (but don't build).z-tz--testztTest package (assumes package is already built).  RECIPE_DIR argument must be a path to built package .tar.bz2 file.z	--no-testnotestzDo not test the package.)r$   r(   r%   z-bz--build-onlyzoOnly run the build, without any post processing or
        testing. Implies --no-test and --no-anaconda-upload.z-pz--postz7Run the post-build logic. Implies --no-anaconda-upload.z--test-run-postz(Run the post-build logic during testing.recipeRECIPE_PATH+zPath to recipe directory.  Pass 'purge' here to clean the work and test intermediates. Pass 'purge-all' to also remove previously built packages.)metavarnargsr%   z--skip-existingz[Skip recipes for which there already exists an existing build (locally or in the channels).skip_existingfalse)r$   r%   r)   z--keep-old-workkeep_old_workzNDo not remove anything from environment, even after successful build and test.z--dirtyzvDo not remove work directory or _build environment, to speed up debugging.  Does not apply patches or download source.z-qz--quietzdo not display progress barquietz--debugz1Show debug output from source checkouts and condaz--tokenz(Token to pass through to anaconda uploadanaconda_token)r%   r)   z--userz?User/organization to upload packages to on anaconda.org or pypiuserz--labelappendlabelsz1Label argument to pass through to anaconda upload)r$   r(   r)   r%   z--no-force-uploadzRDisable force upload to anaconda.org, preventing overwriting any existing packagesforce_uploadT)r%   r(   r)   r$   z--zstd-compression-levelzaWhen building v2 packages, set the compression level used by conda-package-handling. Defaults to .r      zstd_compression_level)r%   typechoicesr)   zPyPI upload parameters (twine)z
--passwordz/password to use when uploading packages to pypi)r%   z--signFz!sign files when uploading to pypi)r)   r%   z--sign-withgpg	sign_withz3program to use to sign files when uploading to pypi)r)   r(   r%   z
--identityz8GPG identity to use to sign files when uploading to pypiz--config-filez2path to .pypirc file to use when uploading to pypipypircz--repositoryz-rzPyPI repository to upload topypi_repositorypypitestz--no-activatez=do not activate the build and test envs; just prepend to PATHactivatez--no-build-idzdo not generate unique build folder names.  Use if having issues with paths being too long.  Deprecated, please use --build-id-pat='' insteadset_build_idz--build-id-patzjspecify a templated pattern to use as build folder names.  Use if having issues with paths being too long.build_id_patz{n}_{t})r%   r(   r)   z--crootz_Build root folder.  Equivalent to CONDA_BLD_PATH, but applies only to this call of conda-build.z--verifyz5run verification on recipes or packages when buildingverifyz--no-verifyz<do not run verification on recipes or packages when building)r$   r(   r%   r)   z--strict-verifyexit_on_verify_errorzBExit if any conda-verify check fail, instead of only printing themz--output-folderzfolder to dump output package to.  Package are moved here if build or test succeeds.  Destination folder must exist prior to using this.output_folderz--no-prefix-length-fallbackprefix_length_fallbackzDisable fallback to older 80 character prefix length if environment creation fails due to insufficient prefix length in dependency packages)r(   r$   r%   r)   z--prefix-length-fallbackz--prefix-length_prefix_lengthax  length of build prefix.  For packages with binaries that embed the path, this is critical to ensuring that your package can run as many places as possible.  Notethat this value can be altered by the OS below conda-build (e.g. encrypted filesystems on Linux), and you should prefer to set --croot to a non-encrypted location instead, so that you maintain a known prefix length.   )r(   r%   r)   r>   z--no-lockinglockingzDisable locking, to avoid unresolved race condition issues.  Unsafe to run multiple builds at once on one system with this set.)r(   r)   r$   r%   z--no-remove-work-dirremove_work_dirzDisable removal of the work dir before testing.  Be careful using this option, as you package may depend on files that are not included in the package, and may pass tests, but ultimately fail on installed systems.z--error-overlinkingerror_overlinkingzEnable error when shared libraries from transitive dependencies are directly linked to any executables or shared libraries in built packages.  This is disabled by default, but will be enabled by default in conda-build 4.0.z--no-error-overlinkingzDisable error when shared libraries from transitive dependencies are directly linked to any executables or shared libraries in built packages.  This is currently the default behavior, but will change in conda-build 4.0.z--error-overdependingerror_overdependingzEnable error when packages with names beginning `lib` or which have `run_exports` are not auto-loaded by the OSes DSO loading mechanism by any of the files in this package.z--no-error-overdependingzDisable error when packages with names beginning `lib` or which have `run_exports` are not auto-loaded by the OSes DSO loading mechanism by any of the files in this package.z--long-test-prefixzUse a long prefix for the test prefix, as well as the build prefix.  Affects only Linux and Mac.  Prefix length matches the --prefix-length flag.  This is on by default in conda-build 3.0+long_test_prefixz--no-long-test-prefixzDo not use a long prefix for the test prefix, as well as the build prefix.  Affects only Linux and Mac.  Prefix length matches the --prefix-length flag.  z--keep-goingz-kz\When running tests, keep going after each failure.  Default is to stop on the first failure.z--cache-dirzMPath to store the source files (archives, git clones, etc.) during the build.	cache_dirz--no-copy-test-source-filescopy_test_source_filesa1  Disables copying the files necessary for testing the package into the info/test folder.  Passing this argument means it may not be possible to test the package without internet access.  There is also a danger that the source archive(s) containing the files could become unavailable sometime in the future.)r(   r$   r)   r%   z--merge-build-hostzZMerge the build and host directories, even when host section or compiler jinja2 is presentmerge_build_hostz--stats-filez@File path to save build statistics to.  Stats are in JSON formatz--extra-depszExtra dependencies to add to all environment creation steps.  This is only enabled for testing with the -t or --test flag.  Change meta.yaml or use templates otherwise.)r1   r%   z--extra-meta*zsKey value pairs of metadata to add to about.json. Should be defined as Key=Value with a space separating each pair.z	KEY=VALUE)r1   r$   r%   r0   z--suppress-variableszLDo not display value of environment variables specified in build.script_env.)r   progr   descriptionadd_argumentr   argparseSUPPRESSr   getlowerr   intrangeadd_argument_groupr   r   r	   r   r   
parse_argscheck_reciper-   )r   parserpypi_grpparseds       :lib/python3.11/site-packages/conda_build/cli/main_build.pyra   ra   $   s     FFK	 F 0    
 @          A"#3V<<BBDDN     8	     /	     '	     @	     F	     7	     %	     , "?G<<BBDDN     	     M     *"7G44::<<F     @    
 7"#344    
 N"6**    
 @     a     "=9= = = a"$&D
 
     (()IJJH>     %&I     B	     U     A !(++.GJz.*<X*F*FGGHHIII#H--     +"#4jAA	     L":v66<<>>&H     V ">6::@@BBfL  
 
 
 $ ">9==     +     D"8V44::<<F	     K"8V44::<<F     #Q"#97CCIIKKvU     C "?33     %%N   	 	 	 "%N
      L      :  	 	 	 ?  
 
 
  M "#6@@FFHHFR  
 
 
   H "#6@@FFHHFR  
 
 
 "0 "#8'BBHHJJfT  
 
 
 ""0 "#8'BBHHJJfT  
 
 
 * "#5v>>DDFF&P  	 	 	 _ "#5v>>DDFF&P  	 	 	      [ !+..1GJz.*<[*I*IJJKKLLL#K00  
 
 
 %%"#;VDDJJLLPVV       "#5w??EEGG6Q     O     4	     B     Z	     t$$F6>    c                    t          t          |           D ]G}|                                r1|j        t          j        v rt          j        d| dt                     HdS )zVerify if the list of recipes received contain a path to a directory,
    if a path to a recipe is found it will give an warning.

    :param path_list: list of paths to recipes
    z RECIPE_PATH received is a file (zO).
It should be a path to a folder.
Forcing conda-build to use the recipe file.N)	mapr
   is_filenamer   VALID_METASwarningswarnUserWarning)	path_listr-   s     rf   rb   rb     s|     dI&& 	 	>> 	u/@ @ @MBv B B B   	 	rg   c                   t          t          j        dz             5  d|_        d|_        t          j        | |          }t          d                    t          |                               d d d            d S # 1 swxY w Y   d S )Nr   Fconfig
)
r   loggingCRITICALverbosedebugr   get_output_file_pathsprintjoinsorted)r-   rs   pathss      rf   output_actionr~     s    	(1,	-	- ( ()&@@@diiu&&'''	( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( (s   AA>>BBc                    t          j        | |          d         d         }t          j        |           t	          d|j        j                   d S )Nrr   r   zSource tree in:)r   renderr   providerz   rs   work_dir)r-   rs   metadatas      rf   source_actionr     sL    z&0003A6H
N8	
X_566666rg   c                0    t          j        | d|          S )NF)move_brokenrs   )r   testr-   rs   s     rf   test_actionr     s    8Ff====rg   c                .    t          j        | |          S )Nrr   )r   checkr   s     rf   check_actionr   	  s    9VF++++rg   r^   c                   t          |           \  }}t          d
i |j        }t          j                     t          |j                  |_        |j        |_        |j         p|j	        |_
        d|j        v rt          j        |           dS d|j        v r*t          j        |           |                                 dS |j        r1d|_
        d|_        d|_	        |j        D ]}t          ||           dS |j        rg }t#          j        d |j        D                       }|D ]7}	 t'          ||           #  |j        s |                    |           Y 5xY w|r@t-          d           t/          |           t1          j        t5          |                     nt-          d           n|j        r|j        D ]}t9          ||           nh|j        r|j        D ]}t=          ||           nFt?          j        |j        |j         |j!        |j"        |j#        d ||j$        |j%        |j&        	
  
         tO          j(        |j)                  rt          j*        |           dS )Npurger   z	purge-allFTc              3  `   K   | ])}d |v rt          t          |          d          n|gV  *dS )rV   T)	recursiveN)r   r   ).0r-   s     rf   	<genexpr>zexecute.<locals>.<genexpr>+  sX       &
 &
 69F]]DD1111&
 &
 &
 &
 &
 &
rg   zFailed recipes:zAll tests passed)	posttest_run_post
build_onlyr,   already_builtrs   rH   variantsrS   N)+ra   r   __dict__r   check_externalr   channel_urlsoverride_channelsr5   rx   rw   r-   clean_build
clean_pkgsoutputr~   r   r   from_iterabler   
keep_goingr8   rz   r   sysexitlenr   r   r   r   r   r   r   r   r,   rH   r   rS   r   get_build_folderscroot print_build_intermediate_warning)r   _re   rs   r-   failed_recipesrecipess          rf   executer     s   4  IAv 9999F	 +6?;;F%7F%5FN&-&!!!qfm##&!!!q} m 	* 	*F&&))))q{ '
% &
 &
 -&
 &
 &
 
 
  	 	FFF++++( "))&111H 	&#$$$^$$$HS(())))$%%%%	 
m 	* 	*F&&))))	*	 
m 	) 	)F((((	) 		M .(==_&	
 	
 	
 	
 v|,, 7.v6661s   +D<<E)r   r   r    r!   r   )r   r   r    r^   )0
__future__r   rZ   ru   r   rm   r   r   	itertoolsr   os.pathr   r   r	   pathlibr
   typingr   conda.auxlib.ishr   conda.common.ior    r   r   r   r   conda_interfacer   r   r   r   rs   r   r   r   r   actionsr   main_renderr   ra   rb   r~   r   r   r   r    rg   rf   <module>r      s1   # " " " " "   



                    3 3 3 3 3 3 3 3 3 3             ! ! ! ! ! ! $ $ $ $ $ $ ( ( ( ( ( ( ( ( ( ( ( (                    
 # " " " " " # # # # # # * * * * * *~ ~ ~ ~B  $( ( (7 7 7> > >, , ,H H H H H H Hrg   