o
    Ni+                     @   sx  d dl mZ d dlmZ d dlm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 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 ejjjrnd dl
mZ G dd dejZG dd dejZG dd dejZG dd dejZdd ZG dd dejZ G dd dejZ!G dd dejZ"G dd de	j#Z$G dd  d e	j#Z%dS )!    )unicode_literals)install)logN)egg_info)install_scripts)sdist)extra_files)git)options)version)developc                   @   s   e Zd ZdZdd ZdS )LocalDevelopr   c                 C   sF   t jdkrtj| |S | jstjjj	|D ]	}| j
|  qd S d S )Nwin32)sysplatformr   install_wrapper_scriptsexclude_scriptspbr_compateasy_installScriptWriterget_script_argswrite_script)selfdistargs r   H/home/ubuntu/.local/lib/python3.10/site-packages/pbr/_compat/commands.pyr   .   s   

z$LocalDevelop.install_wrapper_scriptsN)__name__
__module____qualname__command_namer   r   r   r   r   r   *   s    r   c                   @      e Zd ZdZdZdd ZdS )LocalInstallScriptsz(Intercepts console scripts entry_points.r   c                 C   s   dd l }| d | jjr|jjj|  ng | _| d}t	j
j|j|j|j|j}| d}t|dt	j
jj}d| jjv rot	j
jjd|}t	j
jjd }t	j
j|d}|D ]\}	}
t	j
jd|
||}| |	| qZ| jrtd S tjdkr}d	| }t	j
jj||D ]}| j|  qd S )
Nr   r   build_scripts
executablebdist_wheel wsgi_scriptsntz"%s")!distutils.command.install_scriptsrun_commanddistributionscriptscommandr   runoutfilesget_finalized_commandr   r   metadatar   egg_baser   egg_nameegg_versiongetattrr   sys_executablehave_runr   
get_headerENTRY_POINTS_MAPget_entry_pointsgenerate_scriptr   no_eposnamer   )r   	distutilsei_cmdr   bs_cmdr%   headerwsgi_script_templater(   r?   epcontentr   r   r   r   r/   ?   sP   





zLocalInstallScripts.runNr   r   r    __doc__r!   r/   r   r   r   r   r#   :       r#   c                   @   s    e Zd ZdZdd Zdd ZdS )LocalManifestMakerz?Add any files that are in git and some standard sensible files.c                 C   s   dD ]}| j | qd S )N)zinclude AUTHORSzinclude ChangeLogzexclude .gitignorezexclude .gitreviewzglobal-exclude *.pyc)filelistprocess_template_line)r   template_liner   r   r   _add_pbr_defaults|   s   z$LocalManifestMaker._add_pbr_defaultsc                 C   s   | j d}tj|  | j| j | j| j | jt	
  t|dd}|s8t }|r7| j| ntj| jrC|   | d}|   | jjd|jd dS )a_  Add all the default files to self.filelist:

        Extends the functionality provided by distutils to also included
        additional sane defaults, such as the ``AUTHORS`` and ``ChangeLog``
        files generated by *pbr*.

        Warns if (``README`` or ``README.txt``) or ``setup.py`` are missing;
        everything else is optional.
        r   skip_git_sdistSKIP_GIT_SDISTr   *)prefixN)r,   get_option_dictr   add_defaultsrK   appendtemplatemanifestextendr   get_extra_filesr
   get_boolean_optionr	   _find_git_filesr>   pathexistsread_manifestr1   rN   include_patternr   )r   option_dictshould_skiprcfilesrA   r   r   r   rT      s$   

zLocalManifestMaker.add_defaultsN)r   r   r    rH   rN   rT   r   r   r   r   rJ   y   s    
rJ   c                   @   r"   )LocalEggInfozAOverride the egg_info command to regenerate SOURCES.txt sensibly.r   c                 C   s   t j| jd}t j|rt jdsdtjv r0td t	| j
}||_|  |j| _dS td t | _t|d}| dD ]}| j| qGW d   dS 1 s[w   Y  dS )	ap  Generate SOURCES.txt only if there isn't one already.

        If we are in an sdist command, then we always want to update
        SOURCES.txt. If we are not in an sdist command, then it doesn't
        matter one flip, and is actually destructive.
        However, if we're in a git context, it's always the right thing to do
        to recreate SOURCES.txt
        zSOURCES.txtz.gitr   z[pbr] Processing SOURCES.txtz"[pbr] Reusing existing SOURCES.txtr
N)r>   r\   joinr   r]   r   argvr   inforJ   r,   rW   r/   rK   FileListopenreadsplitrU   )r   manifest_filenamemmfilentryr   r   r   find_sources   s$   	






"zLocalEggInfo.find_sourcesN)r   r   r    rH   r!   rq   r   r   r   r   rc      rI   rc   c                 C   s>   |  d}t }|rt|}tj||d tj|d d S )Nr   )r`   	changelog)r`   )rS   r	   _iter_log_oneline_iter_changelogwrite_git_changeloggenerate_authors)r,   r`   rr   r   r   r   	_from_git   s   

rw   c                   @   r"   )InstallWithGitzExtracts ChangeLog and AUTHORS from git then installs.

    This is useful for e.g. readthedocs where the package is
    installed and then docs built.
    r   c                 C   s   t | j tj| S N)rw   r,   r   r/   r   r   r   r   r/         
zInstallWithGit.runNrG   r   r   r   r   rx      s    rx   c                   @   r"   )LocalInstallzRuns python setup.py install in a sensible manner.

    Force a non-egg installed in the manner of
    single-version-externally-managed, which allows us to install manpages
    and config files.
    r   c                 C   s   t | j tj| S ry   )rw   r,   
du_installr   r/   rz   r   r   r   r/      r{   zLocalInstall.runNrG   r   r   r   r   r|      s    r|   c                   @   s>   e Zd ZdZdZdd Zdefgejj Zdd Zdd	 Z	d
S )
LocalSDistz5Builds the ChangeLog and Authors files from VC first.r   c                 C   s   t | dr| jS | jd}t|dd}|rd| _dS zddlm} W n ty6   t	
d d| _Y dS w || j\}}}tjtj|j|jsWt	
d	 d| _dS ||g| _t	
d
 d| _dS )zEnsure reno is installed and configured.

        We can't run reno-based commands if reno isn't installed/available, and
        don't want to if the user isn't using it.
        	_has_renor   	skip_renoSKIP_GENERATE_RENOFr   )setup_commandz>[pbr] reno was not found or is too old. Skipping release noteszC[pbr] reno does not appear to be configured. Skipping release notesz[pbr] Generating release notesT)hasattrr   r,   rS   r
   rZ   renor   ImportErrorr   rh   load_configr>   r\   r]   rf   reporoot	notespath_files)r   r`   ra   r   confoutput_file
cache_filer   r   r   checking_reno   s>   



zLocalSDist.checking_reno
build_renoc                 C   s   t | j tj|  d S ry   )rw   r,   r   r/   rz   r   r   r   r/   "  s   
zLocalSDist.runc                 C   s0   |   r| j| j | j  tj|  d S ry   )r   rK   rX   r   sortr   make_distributionrz   r   r   r   r   '  s   
zLocalSDist.make_distributionN)
r   r   r    rH   r!   r   r   sub_commandsr/   r   r   r   r   r   r~      s    0r~   c                   @   4   e Zd ZdZeZg ZdZdd Zdd Zdd Z	d	S )
LocalRPMVersionz:Output the rpm *compatible* version string of this packagerpm_versionc                 C   .   t d | j }tt|   d S )Nz[pbr] Extracting rpm version)	r   rh   r,   get_nameprintr   VersionInfosemantic_version
rpm_stringr   r?   r   r   r   r/   8     

zLocalRPMVersion.runc                 C      d S ry   r   rz   r   r   r   initialize_options=     z"LocalRPMVersion.initialize_optionsc                 C   r   ry   r   rz   r   r   r   finalize_options@  r   z LocalRPMVersion.finalize_optionsN
r   r   r    rH   descriptionuser_optionsr!   r/   r   r   r   r   r   r   r   1      r   c                   @   r   )
LocalDebVersionz:Output the deb *compatible* version string of this packagedeb_versionc                 C   r   )Nz[pbr] Extracting deb version)	r   rh   r,   r   r   r   r   r   debian_stringr   r   r   r   r/   K  r   zLocalDebVersion.runc                 C   r   ry   r   rz   r   r   r   r   P  r   z"LocalDebVersion.initialize_optionsc                 C   r   ry   r   rz   r   r   r   r   S  r   z LocalDebVersion.finalize_optionsNr   r   r   r   r   r   D  r   r   )&
__future__r   distutils.commandr   r}   r@   r   r>   r   
setuptoolssetuptools.commandr   r   r   pbr._compat.easy_installr   pbr._compat.metadatapbr._compat.versionsr   r	   r
   r   r   versionssetuptools_has_develop_commandr   r   r#   manifest_makerrJ   rc   rw   rx   r|   r~   Commandr   r   r   r   r   r   <module>   s:   
?+!	F