a fWc@sdZddlmZmZmZddlZddlmZddlZddl Z ddl Z ddl Z gdZ ddZ dd Zd d Zd d ZdddZdddZddZddZddZddZdS)z"update version string during build)absolute_importdivisionprint_functionN) Distribution) stamp_sourcestamp_distutils_outputappend_hg_revisionas_boolcCs|d|pt|S)Ncmdclass)getrget_command_class)optsnamer8/usr/lib/python3.9/site-packages/passlib/_setup/stamp.pyr sr cCs|di|iS)Noptions) setdefault)r commandrrrget_command_optionssrcKst|||dSN)rupdate)r rkwdsrrrset_command_optionssrcCs6t|d}|WdS1s(0YdS)Nr)openread)pathfhrrr _get_file!s rFcCsV|rdStj|rt|t|d}||Wdn1sH0YdS)Nw)osrexistsunlinkrwrite)rcontentdry_runrrrr _replace_file&s    r&cCstj|dd}t|}tddt||\}}|dksBJdt|||dtj|d}tj|rt|}td d |\}}|dksJd t|||dd S) z/ update version info in passlib source Zpasslibz __init__.pyz(?m)^__version__\s*=.*$z__version__ = z failed to replace version string)r%zsetup.pyz(?m)^stamp_build\s*=.*$zstamp_build = Falsez#failed to update 'stamp_build' flagN) r rjoinrresubnreprr&r!)base_dirversionr%rr$countrrrr1s   rcs\t|dGfddd}||dd<t|dGfddd}||dd<dS)Nbuild_pycseZdZfddZdS)z(stamp_distutils_output..build_pycs|t|j|jdSr)build_packagesrZ build_libr%)self _build_pyr-rrr0Rs z7stamp_distutils_output..build_py.build_packagesN)__name__ __module__ __qualname__r0rr2rrr/Qsr sdistcseZdZfddZdS)z%stamp_distutils_output..sdistcs |||t||jdSr)make_release_treerr%)r1r,files_sdistr-rrr8Zsz7stamp_distutils_output..sdist.make_release_treeN)r4r5r6r8rr:rrr7Ysr )r r-r/r7r)r3r;r-rrMs    rcCs|pddvS)Nzyes y true t 1)lowersplit)valuerrrr `sr c Csz@tjgdtjd}|\}}|jr4tdg|d}WnFttjfytt j dpht }t j |}|d}Yn0|dr|dd|}n |d |7}|S) N)ZhgZtipz --templatez,{date(date, '%Y%m%d%H%M%S')}+hg.{node|short})stdoutr'asciiSOURCE_DATE_EPOCHz %Y%m%d%H%M%S)z.dev0z.post0z.post) subprocessPopenPIPEZ communicate returncodeZCalledProcessErrordecodeOSErrorintr environr timedatetimeZutcfromtimestampstrftimeendswith)r-procZstamp_ZnowZ build_daterrrrds       rcs.t|dGfddd}||dd<dS)Nr/cs(eZdZjdgZdZfddZdS)z*install_build_py_exclude..build_py)zexclude-packages=Nzexclude packages from buildsNcs6||j}|jpgD]}||vr||qdSr)finalize_optionsZpackagesexclude_packagesremove)r1targetpackager3rrrSs  z;install_build_py_exclude..build_py.finalize_options)r4r5r6Z user_optionsrTrSrrXrrr/s r r<)r r/rrXrinstall_build_py_exclude}s rY)F)F)__doc__Z __future__rrrrNZdistutils.distrr r)rErM__all__r rrrr&rrr rrYrrrrs$