a oeo@s:dZddlZddlmZddlmZddlmZmZm Z m Z m Z ddl m Z ddlmZdd lmZe d ZeedfZeZe jZee eefe eeeeeeffd d d Zee eeefdddZee eeefe eeeeeeffd ddZddZddZddZddZddZddZ dS)aSHelper code used to generate ``requires.txt`` files in the egg-info directory. The ``requires.txt`` file has an specific format: - Environment markers need to be part of the section headers and should not be part of the requirement spec itself. See https://setuptools.pypa.io/en/latest/deprecated/python_eggs.html#requires-txt N) defaultdict) filterfalse)DictListTupleMappingTypeVar)_reqs) yield_lines) Requirement_T)install_requiresextras_requirereturncCst|}t||S)zGiven values for ``install_requires`` and ``extras_require`` create modified versions in a way that can be written in ``requires.txt`` )_convert_extras_requirements"_move_install_requirements_markers)rrextrasr@C:\Program Files\Certbot\pkgs\setuptools\command\_requirestxt.py_preparesr)rrcCsLtt}|D]6\}}||t|D]}||t||q*q|S)z Convert requirements in `extras_require` of the form `"extra": ["barbazquux; {marker}"]` to `"extra:{marker}": ["barbazquux"]`. )rdictitemsr parse _suffix_for setdefault)routputsectionvrrrrr$s rcCsptt|}tt|}tt|}ttt|}|D]}|dt|j |q4t dd| D}||fS)a+ The ``requires.txt`` file has an specific format: - Environment markers need to be part of the section headers and should not be part of the requirement spec itself. Move requirements in ``install_requires`` that are using environment markers ``extras_require``. :c ss4|],\}}|ttddtt|DfVqdS)css|]}t|VqdSN)str).0rrrr Oz?_move_install_requirements_markers...N)listrfromkeysmap _clean_req)r#krrrrr$Msz5_move_install_requirements_markers..) r&r rfilter _no_markerrr(r"markerrrr)rrZ inst_reqsZ simple_reqsZ complex_reqsZsimple_install_requiresrZexpanded_extrasrrrr6s  rcCs|jrdt|jSdS)z;Return the 'extras_require' suffix for a given requirement.r )r-r"reqrrrrVsrcCstt|}d|_|S)z=Given a Requirement, remove environment markers and return itN)r r"r-)r0rrrrr)[s r)cCs|j Sr!)r-r/rrrr,bsr,cCs,t|pd}dd}t||}||dS)NrcSs|dS)N r)linerrr append_crisz&_write_requirements..append_cr)r r( writelines)streamZreqslinesr3rrr_write_requirementsfs  r7cCs||j}t}t|jpd|jp i\}}t||t|D]*}|dj fit t|||q:| d|| dS)Nrz [{extra}] Z requirements) distributionioStringIOrrrr7sortedwriteformatvarswrite_or_delete_filegetvalue)cmdbasenamefilenameZdistdatarrZextrarrrwrite_requirementsps  rEcCs,t}t||jj|d||dS)Nzsetup-requirements)r9r:r7r8Zsetup_requiresr?r@)rArBrCrDrrrwrite_setup_requirements}srF)!__doc__r9 collectionsr itertoolsrtypingrrrrrr.r Zextern.jaraco.textr Zextern.packaging.requirementsr r Z_OrderedrZ_orderedZ _StrOrIterr"rrrrr)r,r7rErFrrrrs4