Y@spdZddlZddlZddlZddlZddlZejdZddZdddZ dS) z Archive tools for wheel. Nwheelc CsWtjjtj}tjj|}ztj|t|SWdtj|XdS)zWArchive all files under `base_dir` in a whl file and name it like `base_name`. N)ospathabspathcurdirchdirmake_wheelfile_inner) base_namebase_dirZolddirr ./tmp/pip-build-3puug3g5/wheel/wheel/archive.pyarchive_wheelfiles  r .c s|d}tjd||tjjd}|dkrDd}ntjt|dd}tj t |ddd tj d d d d ddi}g}fdd}xtj |D]\}} } x| D]w} tj jtj j|| } tj j| r|jdrG|j|j| d| fq|| |qWqW|jx!|D]\}} || |qmWj|S)zhCreate a whl file from all the files under 'base_dir'. Places .dist-info at the end of the archive.z.whlz#creating '%s' and adding '%s' to itZSOURCE_DATE_EPOCHNrzwb+w compressionWHEELMETADATARECORDc stj|}|dkr=tj|j}|dd}tj||}|jd>|_tj |_ t |d}j ||j WdQRXtjd|dS)Nrrrbz adding '%s')rstattimegmtimest_mtimezipfileZipInfost_mode external_attr ZIP_DEFLATED compress_typeopenwritestrreadloginfo)r date_timestmtimezinfofp)zipr r writefile4s  z'make_wheelfile_inner..writefilez .dist-info)r'r(renvirongetrrintrZipFiler$r"walkrnormpathjoinisfileendswithappendsortclose) r r zip_filename timestampr)Zscoredeferredr/dirpathdirnames filenamesnamerr )r.r rs.      !"  r) __doc__rrloggingos.pathr getLoggerr'r rr r r r s