3 F\u@sdZddlmZddlmZddlmZddlZddl Zddl Z ddl Z ddl Z ddl Z ddlZddlZddlmZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlZddlmZddlmZdYZdddZDZd[ZddZ ddZ!ddZ"ddZ#d\d!d"Z$d]d#d$Z%Gd%d&d&ejZ&Gd'd(d(ejZ'Gd)d*d*ej(Z)Gd+d,d,ej*Z+Gd-d.d.ej*Z,d/d0Z-y&dd1l.m/Z/Gd2d3d3e/j0Z1d4Z2Wne3k rd Z2YnXd5d6Z4d7Z5d8Z6e6e6e5d9Z7d:d;Z8e j9j:e j;d fdd?d?ejZ=Gd@dAdAejZ>GdBdCdCej?Z@GdDdEdEejZAdFdGZBGdHdIdIejZCyddJlmDZDd4ZEeDjFZFWne3k rd ZEdZFYnXdKdLZGdMdNZHdOdPZIdQdRZJd^dSdTZKdUdVZLd_dWdXZMejNjOZOdS)`z4 Utilities with minimum-depends for use in setup.py )unicode_literals)install)logN)develop) easy_install)egg_info)install_scripts)sdist) extra_files)git)options) testr_command)versionrequirements.txttools/pip-requirescCsg|]}|tjdqS)r)sys version_info).0xrb/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-install-emcbgzcf/pbr/pbr/packaging.py 1srrequirements-py%d.txttools/pip-requires-py%dtest-requirements.txttools/test-requirescCs4tjjd}|r(tdd|jdDStttS)NZPBR_REQUIREMENTS_FILEScss|]}|jVqdS)N)strip)rfrrr 9sz)get_requirements_files..,)osenvirongettuplesplitPY_REQUIREMENTS_FILESlistREQUIREMENTS_FILES)filesrrrget_requirements_files6s r)cCs:g}|j|d}|r|j||j|dj|||<dS)z5Append a separated list to possibly existing value. N)r"appendextendjoin)configkeyZ text_listZ new_valueZ current_valuerrrappend_text_listBs    r1cCsdd|DS)NcSsg|]}tjj|r|qSr)r pathexists)rrrrrrMsz!_any_existing..r) file_listrrr _any_existingLsr5c Csjt|}dd|D}|r*tjd|tdd|D}x,|D]$}t|d}|jjdSQRXq>WgS)NcSsg|]}|tkr|qSr)r%)rrrrrrUsz'get_reqs_from_files..zSupport for '-pyN'-suffixed requirements files is removed in pbr 5.0 and these files are now ignored. Use environment markers instead. Conflicting files: %rcSsg|]}|tkr|qSr)r%)rrrrrr]srr+)r5warningswarnDeprecationWarningopenreadr$)requirements_filesexisting deprecatedZrequirements_fileZfilrrrget_reqs_from_filesQs  r?Fc Cs\|dkrt}dd}g}x:t|D],}|j s&|jdrBq&tjd|rPq&|jdr||jdd}|t|g|d7}q&ytj j |j }Wnt k rd}YnXtjd |rtj d ||}n0tjd |rtj d ||}ntjd |rd}d}|dk rBtj dd|}|r6|jd}|dkr*d}|d|}|j|q&tjd||fq&W|S)NcSstjdd|jdS)Nz([\w.]+)-([\w.-]+)z\1>=\2)resubgroups)matchrrr egg_fragmentjsz(parse_requirements..egg_fragment#z5^\s*(-i|--index-url|--extra-index-url|--find-links).*z-r ) strip_markersz\s*-e\s+z\s*-e\s+.*#egg=([^&]+).*$z \s*(https?|git(\+(https|ssh))?):z1\s*(https?|git(\+(https|ssh))?):.*#egg=([^&]+).*$z\s*-f\s+zIndex Locationz#.*$r*;rz[pbr] Excluding %s: %s)r)r?r startswithrBrE partitionparse_requirements pkg_resources Requirementparse project_name ValueErrorrCfindr,rinfo) r<rJrF requirementslinereq_filerRreasonZsemi_posrrrrNesL           rNcCsn|dkrt}g}xVt|D]J}tjd|r.qtjd|rP|jtjdd|qtjd|r|j|qW|S)Nz (\s*#)|(\s*$)z \s*-[ef]\s+r*z \s*(https?|git(\+(https|ssh))?):)r)r?rBrEr,rC)r<Zdependency_linksrWrrrparse_dependency_linkss   rZc@seZdZdZdZddZdS)InstallWithGitzExtracts ChangeLog and AUTHORS from git then installs. This is useful for e.g. readthedocs where the package is installed and then docs built. rcCst|jtjj|S)N) _from_git distributionrrun)selfrrrr^s zInstallWithGit.runN)__name__ __module__ __qualname____doc__ command_namer^rrrrr[sr[c@seZdZdZdZddZdS) 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. rcCst|jtjj|S)N)r\r] du_installrr^)r_rrrr^s zLocalInstall.runN)r`rarbrcrdr^rrrrresrec@s eZdZdZdZdZddZdS) TestrTestz&Make setup.py test do the right thing.testz&DEPRECATED: Run unit tests using testrcCstjdttjj|dS)Nzytestr integration is deprecated in pbr 4.2 and will be removed in a future release. Please call your test runner directly)r7r8r9r Testrr^)r_rrrr^sz TestrTest.runN)r`rarbrcrd descriptionr^rrrrrgsrgc@s4eZdZdZeZgZdZddZddZddZ d S) LocalRPMVersionz:Output the rpm *compatible* version string of this packageZ rpm_versioncCs.tjd|jj}ttj|jjdS)Nz[pbr] Extracting rpm version) rrUr]get_nameprintr VersionInfosemantic_versionZ rpm_string)r_namerrrr^s  zLocalRPMVersion.runcCsdS)Nr)r_rrrinitialize_optionssz"LocalRPMVersion.initialize_optionscCsdS)Nr)r_rrrfinalize_optionssz LocalRPMVersion.finalize_optionsN) r`rarbrcrj user_optionsrdr^rqrrrrrrrksrkc@s4eZdZdZeZgZdZddZddZddZ d S) LocalDebVersionz:Output the deb *compatible* version string of this packageZ deb_versioncCs.tjd|jj}ttj|jjdS)Nz[pbr] Extracting deb version) rrUr]rlrmrrnroZ debian_string)r_rprrrr^s  zLocalDebVersion.runcCsdS)Nr)r_rrrrq sz"LocalDebVersion.initialize_optionscCsdS)Nr)r_rrrrrsz LocalDebVersion.finalize_optionsN) r`rarbrcrjrsrdr^rqrrrrrrrtsrtcCstjS)N)r have_testrrrrrrusru)commandsc@s eZdZdZdZdZddZdS)NoseTestz)Fallback test runner if testr is a no-go.rhz%DEPRECATED: Run unit tests using nosecCstjdttjj|dS)Nzpnose integration in pbr is deprecated. Please use the native nose setuptools configuration or call nose directly)r7r8r9rv nosetestsr^)r_rrrr^ sz NoseTest.runN)r`rarbrcrdrjr^rrrrrwsrwTcCstS)N) _have_noserrrr have_nose/srza#PBR Generated from %(group)r import threading from %(module_name)s import %(import_target)s if __name__ == "__main__": import argparse import socket import sys import wsgiref.simple_server as wss parser = argparse.ArgumentParser( description=%(import_target)s.__doc__, formatter_class=argparse.ArgumentDefaultsHelpFormatter, usage='%%(prog)s [-h] [--port PORT] [--host IP] -- [passed options]') parser.add_argument('--port', '-p', type=int, default=8000, help='TCP port to listen on') parser.add_argument('--host', '-b', default='', help='IP to bind the server to') parser.add_argument('args', nargs=argparse.REMAINDER, metavar='-- [passed options]', help="'--' is the separator of the arguments used " "to start the WSGI server and the arguments passed " "to the WSGI application.") args = parser.parse_args() if args.args: if args.args[0] == '--': args.args.pop(0) else: parser.error("unrecognized arguments: %%s" %% ' '.join(args.args)) sys.argv[1:] = args.args server = wss.make_server(args.host, args.port, %(invoke_target)s()) print("*" * 80) print("STARTING test server %(module_name)s.%(invoke_target)s") url = "http://%%s:%%d/" %% (server.server_name, server.server_port) print("Available at %%s" %% url) print("DANGER! For testing only, do not use in production") print("*" * 80) sys.stdout.flush() server.serve_forever() else: application = None app_lock = threading.Lock() with app_lock: if application is None: application = %(invoke_target)s() z# PBR Generated from %(group)r import sys from %(module_name)s import %(import_target)s if __name__ == "__main__": sys.exit(%(invoke_target)s()) )console_scripts gui_scripts wsgi_scriptscCsJ|j st|jdkrtd|t||j|jddj|jd}||S)a`Generate the script based on the template. :param str group: The entry-point group name, e.g., "console_scripts". :param str header: The first line of the script, e.g., "!#/usr/bin/env python". :param str template: The script template. :returns: The templated script content :rtype: str rIzBScript targets must be of the form 'func' or 'Class.class_method'.r.)group module_nameZ import_targetZ invoke_target)attrslenrSdictrr.)rZ entry_pointheadertemplate script_textrrrgenerate_script}srccsXtjd||}xDtjD]8\}}x.|j|jD]\}}|t||||fVq0WqWdS)z$Override entrypoints console_script.r*N)rget_script_headerENTRY_POINTS_MAPitems get_entry_mapr)dist executable is_wininstrrrrpeprrroverride_get_script_argssrc@seZdZdZddZdS) LocalDeveloprcCs>tjdkrtjj||S|js:xt|D]}|j|q(WdS)Nwin32)rplatformrinstall_wrapper_scriptsZexclude_scriptsr write_script)r_rargsrrrrs  z$LocalDevelop.install_wrapper_scriptsN)r`rarbrdrrrrrrsrc@s$eZdZdZdZddZddZdS)LocalInstallScriptsz(Intercepts console scripts entry_points.rc CsPtjd||}td}x4|jdjD]"\}}td|||}|j||q&WdS)Nr*r})rrrrrrr) r_rrrrZwsgi_script_templaterprcontentrrr_make_wsgi_scripts_onlys  z+LocalInstallScripts._make_wsgi_scripts_onlyc Csddl}|jd|jjr,|jjjj|ng|_|jd}t j |j t j |j |j |j|j}|jd}t|dtj}t|jddd}d|jjkr|j||||jrdStjd krt}ntj}d |}x||||D]}|j|qWdS) Nrr build_scriptsr bdist_wininstZ _is_runningF bdist_wheelntz"%s")Z!distutils.command.install_scripts run_commandr]scriptscommandrr^outfilesget_finalized_commandrO DistributionZegg_base PathMetadataregg_nameZ egg_versiongetattrrZsys_executablehave_runrZno_epr rprget_script_argsr) r_ distutilsei_cmdrZbs_cmdrrrrrrrr^s2       zLocalInstallScripts.runN)r`rarbrcrdrr^rrrrrsrc@s eZdZdZddZddZdS)LocalManifestMakerz?Add any files that are in git and some standard sensible files.cCsxdD]}|jj|qWdS)Ninclude AUTHORSinclude ChangeLogexclude .gitignoreexclude .gitreviewglobal-exclude *.pyc)rrrrr)filelistprocess_template_line)r_Z template_linerrr_add_pbr_defaultssz$LocalManifestMaker._add_pbr_defaultscCs|jjd}tjj||jj|j|jj|j|jjt j t j |dd}|spt j}|r|jj|ntjj|jr|j|jd}|j|jjd|jddS)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. pbrZskip_git_sdistZSKIP_GIT_SDISTr*)prefixN)r]get_option_dictr add_defaultsrr,rmanifestr-r Zget_extra_filesr get_boolean_optionr Z_find_git_filesr r2r3Z read_manifestrrZinclude_patternr)r_ option_dict should_skipZrcfilesrrrrrs   zLocalManifestMaker.add_defaultsN)r`rarbrcrrrrrrrs rc@seZdZdZdZddZdS) LocalEggInfozAOverride the egg_info command to regenerate SOURCES.txt sensibly.rcCstjj|jd}tjj| s4tjjds4dtjkr`tjdt |j }||_ |j |j |_ n>tjdtj|_ x(t|djjdD]}|j j|qWdS) apGenerate 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.txtr6r+N)r r2r.rr3rargvrrUrr]rr^rFileListr:r;r$r,)r_Zmanifest_filenamemmentryrrr find_sourcess        zLocalEggInfo.find_sourcesN)r`rarbrcrdrrrrrrsrcCs>|jd}tj}|r tj|}tj||dtj|ddS)Nr)r changelog)r)rr _iter_log_onelineZ_iter_changelogZwrite_git_changelogZgenerate_authors)r]rrrrrr\.s   r\c@s>eZdZdZdZddZdefgejjZddZdd Z d S) LocalSDistz5Builds the ChangeLog and Authors files from VC first.r c Cst|dr|jS|jjd}tj|dd}|r8d|_dSyddlm}Wn$tk rlt j dd|_dSX|j |j\}}}t j jt j j|j|jst j d d|_dS||g|_t j 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_renorZ skip_renoZSKIP_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)hasattrrr]rr rZrenor ImportErrorrrUZ load_configr r2r3r.ZreporootZ notespath_files)r_rrrconfZ output_fileZ cache_filerrr checking_reno<s0      zLocalSDist.checking_renoZ build_renocCst|jtjj|dS)N)r\r]r r^)r_rrrr^hs zLocalSDist.runcCs0|jr |jj|j|jjtjj|dS)N)rrr-rsortr make_distribution)r_rrrrms zLocalSDist.make_distributionN) r`rarbrcrdrr sub_commandsr^rrrrrr7s *r)builddoccCstS)N) _have_sphinxrrrr have_sphinxsrc si|r|d}nd}tjdd|g|}tdfdd|jdD}t}x&|D]}|jd d|jd DqTWfd d }|d |d|d|d|d|d|d|dx|D]}tjd|qWjddS)aCalculate the sort of semver increment needed from git history. Every commit from HEAD to tag is consider for Sem-Ver metadata lines. See the pbr docs for their syntax. :return: a dict of kwargs for passing into SemanticVersion.increment. z..HEADHEADrz --pretty=%Bzsem-ver:cs*g|]"}|jjdr|djqS)zsem-ver:N)lowerrLr)rrW) header_lenrrrsz)_get_increment_kwargs..r+cSsg|] }|jqSr)r)rsymbolrrrrsrcs||krd|<|j|dS)NT)discard)rsymbolsZimpact)resultrr_handle_symbolsz-_get_increment_kwargs.._handle_symbolZbugfixpatchZfeatureminor deprecationz api-breakmajorz[pbr] Unknown Sem-Ver symbol %rN) r _run_git_commandrr$setupdaterrUpop) git_dirtagZ version_specrrvrrrrr)rrr_get_increment_kwargss(          rc Cstj|d}d}xt|D]x\}\}}}t}t}xHt|D]<}y"tjj|}|||<|j |Wq>t k rxYq>Xq>W|r|t ||fSqWd|fS)zReturn the commit data about the most recent tag. We use git-describe to find this out, but if there are no tags then we fall back to counting commits since the beginning of time. )rrr*) r r enumeraterrr&rSemanticVersionfrom_pip_stringadd Exceptionmax) rrZ row_countZignoredZtag_setZ version_tagsZ semver_to_tagrZsemverrrr_get_revno_and_last_tags   rcCst|\}}tjj|pd}|dkr*|}n|jft||}|dk r`||kr`tdt||d|dkrl|S|j|}|dk r|j|}||kr|S|S)aCalculate a version from a target version in git_dir. This is used for untagged versions only. A new version is calculated as necessary based on git metadata - distance to tags, current hash, contents of commit messages. :param git_dir: The git directory we're working from. :param target_version: If None, the last tagged version (or 0 if there are no tags yet) is incremented as needed to produce an appropriate target version following semver rules. Otherwise target_version is used as a constraint - if semver rules would result in a newer version then an exception is raised. :return: A semver version object. 0rNzRgit history requires a target version of %(new)s, but target version is %(target)s)newtarget) rrrr incrementrrSrZto_dev)rtarget_versionrZdistanceZ last_semverZ new_versionZnew_devZ target_devrrr_get_version_from_git_targets$    rcCstj}|rvy,tjddg|ddjdd}tjj|}Wn*tk rb|rZtjj|}nd}YnXt||}|j Syt St k rdSXdS) aCalculate a version string from git. If the revision is tagged, return that. Otherwise calculate a semantic version description of the tree. The number of revisions since the last tag is included in the dev counter in the version for untagged versions. :param pre_version: If supplied use this as the target version rather than inferring one from the last tag + commit messages. Zdescribez --exact-matchT)Zthrow_on_error-r~Nr*) r Z_run_git_functionsrreplacerrrrrZrelease_stringunicode NameError) pre_versionrZtaggedrrrrr_get_version_from_gits$   rcCsddg}i}x`|D]X}yt|d}Wnttfk r>wYnXytj|}Wqtjjk rhwYqXqW|jdd|krdS|jddS)zGet the version from package metadata if present. This looks for PKG-INFO if present (for sdists), and if not looks for METADATA (for wheels) and failing that will return None. zPKG-INFOMETADATAr6NameNVersion)r:IOErrorOSErroremailmessage_from_fileerrors MessageErrorr") package_nameZpkg_metadata_filenamesZ pkg_metadatafilenameZpkg_metadata_filerrr_get_version_from_pkg_metadatas  rcCsltjjdtjjdd}|r |St|}|r0|St|}tjddkrP|jd}|rX|Stdj |ddS) a Get the version of the project. First, try getting it from PKG-INFO or METADATA, if it exists. If it does, that means we're in a distribution tarball or that install has happened. Otherwise, if there is no PKG-INFO or METADATA file, pull the version from git. We do not support setup.py version sanity in git archive tarballs, nor do we support packagers directly sucking our git repo into theirs. We expect that a source tarball be made from our git repo - or that if someone wants to make a source tarball from a fork of our repo with additional tags in it that they understand and desire the results of doing that. :param pre_version: The version field from setup.cfg - if set then this version will be the next release. Z PBR_VERSIONZOSLO_PACKAGE_VERSIONNrrIzutf-8a(Versioning for this project requires either an sdist tarball, or access to an upstream git repository. It's also possible that there is a mismatch between the package name in setup.cfg and the argument given to pbr.version.VersionInfo. Project name {name} was given, but was not able to be found.)rp) r r!r"rrrrencoderformat)rrrrrr get_version)s r)rr)rr)rr)NF)N)N)N)Prc __future__rdistutils.commandrrfrrrZ email.errorsr rBrr7rO setuptoolsZsetuptools.commandrrrrr rr r r Z pbr.pbr_jsonr rr'r%ZTEST_REQUIREMENTS_FILESr)r1r5r?rNrZr[rerirgCommandrkrtruZnoservrxrwryrrzZ _wsgi_textZ _script_textrrr2normpathrrrrZmanifest_makerrrr\rrrZ LocalBuildDocrrrrrrrZpbr_jsonZwrite_pbr_jsonrrrrs                 H   7  :* ?   )% & /