asda?‰PNG  IHDR ? f ??C1 sRGB ??é gAMA ±? üa pHYs ? ??o¨d GIDATx^íüL”÷e÷Y?a?("Bh?_ò???¢§?q5k?*:t0A-o??¥]VkJ¢M??f?±8\k2íll£1]q?ù???T mercurial.pyc000064400000010776151027772600007266 0ustar00 abc@@sddlmZddlZddlZddlZddlmZmZddlm Z m Z ddl m Z ddl mZejeZde fdYZe jedS( i(tabsolute_importN(t display_pathtrmtree(tvcstVersionControl(t path_to_url(t configparsert MercurialcB@sqeZdZdZdZdZdZdZd Zd Z d Z d Z d Z dZ dZRS(thgs.hgtcloneshg+httpshg+httpsshg+sshshg+static-httpcC@sTtjdd}|j|z#|jd|gdtd|Wdt|XdS(s?Export the Hg repository at the url to the destination locations-exportspip-tarchivet show_stdouttcwdN(ttempfiletmkdtemptunpackt run_commandtFalseR(tselftlocationttemp_dir((s5/usr/lib/python2.7/site-packages/pip/vcs/mercurial.pytexports  cC@stjj||jd}tj}yI|j||jdd|t|d}|j |WdQXWn/t tj fk r}t j d||nX|jddg|d|dS( Nthgrctpathstdefaulttws/Could not switch Mercurial repository to %s: %stupdates-qR (tostpathtjointdirnameRtSafeConfigParsertreadtsettopentwritetOSErrortNoSectionErrortloggertwarningR(Rtdestturlt rev_optionst repo_configtconfigt config_filetexc((s5/usr/lib/python2.7/site-packages/pip/vcs/mercurial.pytswitch s  cC@s:|jddgd||jddg|d|dS(Ntpulls-qR R(R(RR(R*((s5/usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyR/scC@s|j\}}|r.|g}d|}n g}d}|j||||rtjd||t||jddd||g|jddg|d|ndS( Ns (to revision %s)tsCloning hg %s%s to %sR s --noupdates-qRR (t get_url_revtcheck_destinationR&tinfoRR(RR(R)trevR*t rev_display((s5/usr/lib/python2.7/site-packages/pip/vcs/mercurial.pytobtain3s   cC@sO|jddgdtd|j}|j|rEt|}n|jS(Nt showconfigs paths.defaultR R (RRtstript_is_local_repositoryR(RRR)((s5/usr/lib/python2.7/site-packages/pip/vcs/mercurial.pytget_urlEs  cC@s+|jddgdtd|j}|S(Ntparentss--template={rev}R R (RRR9(RRtcurrent_revision((s5/usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyt get_revisionMs cC@s+|jddgdtd|j}|S(NR<s--template={node}R R (RRR9(RRtcurrent_rev_hash((s5/usr/lib/python2.7/site-packages/pip/vcs/mercurial.pytget_revision_hashSs cC@sw|j|}|jjds1d|}n|jjddd}|sWdS|j|}d|||fS(Nshg:shg+t-iis %s@%s#egg=%s(R;tlowert startswithtegg_nametsplittNoneR@(RtdistRtrepotegg_project_nameR?((s5/usr/lib/python2.7/site-packages/pip/vcs/mercurial.pytget_src_requirementYs cC@stS(s&Always assume the versions don't match(R(RR(R*((s5/usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyt check_versioncs(Rshg+httpshg+httpsshg+sshshg+static-http(t__name__t __module__tnameRt repo_nametschemesRR/RR7R;R>R@RJRK(((s5/usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyRs       (t __future__RtloggingRR t pip.utilsRRtpip.vcsRRt pip.downloadRtpip._vendor.six.movesRt getLoggerRLR&Rtregister(((s5/usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyts   Wmercurial.pyo000064400000010776151027772600007302 0ustar00 abc@@sddlmZddlZddlZddlZddlmZmZddlm Z m Z ddl m Z ddl mZejeZde fdYZe jedS( i(tabsolute_importN(t display_pathtrmtree(tvcstVersionControl(t path_to_url(t configparsert MercurialcB@sqeZdZdZdZdZdZdZd Zd Z d Z d Z d Z dZ dZRS(thgs.hgtcloneshg+httpshg+httpsshg+sshshg+static-httpcC@sTtjdd}|j|z#|jd|gdtd|Wdt|XdS(s?Export the Hg repository at the url to the destination locations-exportspip-tarchivet show_stdouttcwdN(ttempfiletmkdtemptunpackt run_commandtFalseR(tselftlocationttemp_dir((s5/usr/lib/python2.7/site-packages/pip/vcs/mercurial.pytexports  cC@stjj||jd}tj}yI|j||jdd|t|d}|j |WdQXWn/t tj fk r}t j d||nX|jddg|d|dS( Nthgrctpathstdefaulttws/Could not switch Mercurial repository to %s: %stupdates-qR (tostpathtjointdirnameRtSafeConfigParsertreadtsettopentwritetOSErrortNoSectionErrortloggertwarningR(Rtdestturlt rev_optionst repo_configtconfigt config_filetexc((s5/usr/lib/python2.7/site-packages/pip/vcs/mercurial.pytswitch s  cC@s:|jddgd||jddg|d|dS(Ntpulls-qR R(R(RR(R*((s5/usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyR/scC@s|j\}}|r.|g}d|}n g}d}|j||||rtjd||t||jddd||g|jddg|d|ndS( Ns (to revision %s)tsCloning hg %s%s to %sR s --noupdates-qRR (t get_url_revtcheck_destinationR&tinfoRR(RR(R)trevR*t rev_display((s5/usr/lib/python2.7/site-packages/pip/vcs/mercurial.pytobtain3s   cC@sO|jddgdtd|j}|j|rEt|}n|jS(Nt showconfigs paths.defaultR R (RRtstript_is_local_repositoryR(RRR)((s5/usr/lib/python2.7/site-packages/pip/vcs/mercurial.pytget_urlEs  cC@s+|jddgdtd|j}|S(Ntparentss--template={rev}R R (RRR9(RRtcurrent_revision((s5/usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyt get_revisionMs cC@s+|jddgdtd|j}|S(NR<s--template={node}R R (RRR9(RRtcurrent_rev_hash((s5/usr/lib/python2.7/site-packages/pip/vcs/mercurial.pytget_revision_hashSs cC@sw|j|}|jjds1d|}n|jjddd}|sWdS|j|}d|||fS(Nshg:shg+t-iis %s@%s#egg=%s(R;tlowert startswithtegg_nametsplittNoneR@(RtdistRtrepotegg_project_nameR?((s5/usr/lib/python2.7/site-packages/pip/vcs/mercurial.pytget_src_requirementYs cC@stS(s&Always assume the versions don't match(R(RR(R*((s5/usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyt check_versioncs(Rshg+httpshg+httpsshg+sshshg+static-http(t__name__t __module__tnameRt repo_nametschemesRR/RR7R;R>R@RJRK(((s5/usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyRs       (t __future__RtloggingRR t pip.utilsRRtpip.vcsRRt pip.downloadRtpip._vendor.six.movesRt getLoggerRLR&Rtregister(((s5/usr/lib/python2.7/site-packages/pip/vcs/mercurial.pyts   Wgit.pyc000064400000025427151027772600006065 0ustar00 abc@@sddlmZddlZddlZddlZddlmZddlm Z ddl m Z ddl m Zddlm ZddlmZmZddlmZmZe jZe jZejeZd efd YZejedS( i(tabsolute_importN(tsamefile(t BadCommand(tparse(trequest(t display_pathtrmtree(tvcstVersionControltGitcB@seZdZdZdZdZddZd Zd Z d Z d Z d Z dZ dZdZdZdZdZdZdZdZdZdZdZdZdZdZedZRS( tgits.gittclonesgit+https git+httpssgit+sshsgit+gitsgit+filec O@s|rt|\}}}}}|jdr|t|jd } | tj|jddjd} t||| ||f}|jdd} || t|| || ||f}qnt t |j |||dS(Ntfilet/s\t+i( turlsplittendswithtlentlstripturllib_requestt url2pathnametreplacet urlunsplittfindtsuperR t__init__( tselfturltargstkwargstschemetnetloctpathtquerytfragmenttinitial_slashestnewpatht after_plus((s//usr/lib/python2.7/site-packages/pip/vcs/git.pyR s #cC@sld}|jdgdt}|j|r@|t|}nd}dj|jdd }t|S(Ns git version tversiont show_stdouttt.i(t run_commandtFalset startswithRtjointsplitt parse_version(Rt VERSION_PFXR&((s//usr/lib/python2.7/site-packages/pip/vcs/git.pytget_git_version5scC@sytjdd}|j|zH|jds>|d}n|jdddd|gdtd |Wd t|Xd S( s@Export the Git repository at the url to the destination locations-exportspip-R scheckout-indexs-as-fs--prefixR'tcwdN(ttempfiletmkdtemptunpackRR*R+R(Rtlocationttemp_dir((s//usr/lib/python2.7/site-packages/pip/vcs/git.pytexportBs  cC@s_|j|}d|}||kr0||gS||krG||gStjd||SdS(sCheck the revision options before checkout to compensate that tags and branches may need origin/ as a prefix. Returns the SHA1 of the branch or tag if found. s origin/%ss5Could not find a tag or branch '%s', assuming commit.N(tget_short_refstloggertwarning(Rtrevtdestt rev_optionst revisionst origin_rev((s//usr/lib/python2.7/site-packages/pip/vcs/git.pytcheck_rev_optionsOs      cC@s|j|j|dS(s  Compare the current sha to the ref. ref may be a branch or tag name, but current rev will always point to a sha. This means that a branch or tag will never compare as True. So this ultimately only matches against exact shas. i(t get_revisionR,(RR=R>((s//usr/lib/python2.7/site-packages/pip/vcs/git.pyt check_versioncscC@sJ|jdd|gd||jddg|d||j|dS(Ntconfigsremote.origin.urlR2tcheckouts-q(R*tupdate_submodules(RR=RR>((s//usr/lib/python2.7/site-packages/pip/vcs/git.pytswitchlscC@s|jtdkr7|jdddgd|n|jddgd||rr|j|d||}n|jdddg|d||j|dS( Ns1.9.0tfetchs-qs--tagsR2itresets--hard(R1R/R*RARF(RR=R>((s//usr/lib/python2.7/site-packages/pip/vcs/git.pytupdaters cC@s|j\}}|r.|g}d|}ndg}d}|j||||rtjd||t||jdd||g|r|j|||}|j||s|jddg|d|qn|j|ndS( Ns (to %s)s origin/masterR(sCloning %s%s to %sR s-qRER2( t get_url_revtcheck_destinationR:tinfoRR*RARCRF(RR=RR<R>t rev_display((s//usr/lib/python2.7/site-packages/pip/vcs/git.pytobtains"    cC@s|jdddgdtd|}|j}|d}x'|D]}|jdrA|}PqAqAW|jdd }|jS( s+Return URL of the first remote encountered.RDs --get-regexpsremote\..*\.urlR'R2isremote.origin.url t i(R*R+t splitlinesR,R.tstrip(RR6tremotest found_remotetremoteR((s//usr/lib/python2.7/site-packages/pip/vcs/git.pytget_urls   cC@s+|jddgdtd|}|jS(Ns rev-parsetHEADR'R2(R*R+RR(RR6t current_rev((s//usr/lib/python2.7/site-packages/pip/vcs/git.pyRBscc@sn|jdgdtd|}xI|jjD]5}|jdd\}}|j|jfVq1WdS(s4Yields tuples of (commit, ref) for branches and tagssshow-refR'R2RPiN(R*R+RRRQR.(RR6toutputtlinetcommittref((s//usr/lib/python2.7/site-packages/pip/vcs/git.pyt get_full_refss cC@s |jdS(Ns refs/remotes/(R,(RR\((s//usr/lib/python2.7/site-packages/pip/vcs/git.pyt is_ref_remotescC@s |jdS(Ns refs/heads/(R,(RR\((s//usr/lib/python2.7/site-packages/pip/vcs/git.pyt is_ref_branchscC@s |jdS(Ns refs/tags/(R,(RR\((s//usr/lib/python2.7/site-packages/pip/vcs/git.pyt is_ref_tagscC@s/t|j||j||j|f S(s0A ref is a commit sha if it is not anything else(tanyR^R_R`(RR\((s//usr/lib/python2.7/site-packages/pip/vcs/git.pyt is_ref_commits  cC@s |j|S(N(R9(RR6((s//usr/lib/python2.7/site-packages/pip/vcs/git.pytget_refsscC@si}x|j|D]\}}d}|j|rJ|td}nD|j|rl|td}n"|j|r|td}n|dk r|||s      subversion.py000064400000022206151027772600007326 0ustar00from __future__ import absolute_import import logging import os import re from pip._vendor.six.moves.urllib import parse as urllib_parse from pip.index import Link from pip.utils import rmtree, display_path from pip.utils.logging import indent_log from pip.vcs import vcs, VersionControl _svn_xml_url_re = re.compile('url="([^"]+)"') _svn_rev_re = re.compile('committed-rev="(\d+)"') _svn_url_re = re.compile(r'URL: (.+)') _svn_revision_re = re.compile(r'Revision: (.+)') _svn_info_xml_rev_re = re.compile(r'\s*revision="(\d+)"') _svn_info_xml_url_re = re.compile(r'(.*)') logger = logging.getLogger(__name__) class Subversion(VersionControl): name = 'svn' dirname = '.svn' repo_name = 'checkout' schemes = ('svn', 'svn+ssh', 'svn+http', 'svn+https', 'svn+svn') def get_info(self, location): """Returns (url, revision), where both are strings""" assert not location.rstrip('/').endswith(self.dirname), \ 'Bad directory: %s' % location output = self.run_command( ['info', location], show_stdout=False, extra_environ={'LANG': 'C'}, ) match = _svn_url_re.search(output) if not match: logger.warning( 'Cannot determine URL of svn checkout %s', display_path(location), ) logger.debug('Output that cannot be parsed: \n%s', output) return None, None url = match.group(1).strip() match = _svn_revision_re.search(output) if not match: logger.warning( 'Cannot determine revision of svn checkout %s', display_path(location), ) logger.debug('Output that cannot be parsed: \n%s', output) return url, None return url, match.group(1) def export(self, location): """Export the svn repository at the url to the destination location""" url, rev = self.get_url_rev() rev_options = get_rev_options(url, rev) url = self.remove_auth_from_url(url) logger.info('Exporting svn repository %s to %s', url, location) with indent_log(): if os.path.exists(location): # Subversion doesn't like to check out over an existing # directory --force fixes this, but was only added in svn 1.5 rmtree(location) self.run_command( ['export'] + rev_options + [url, location], show_stdout=False) def switch(self, dest, url, rev_options): self.run_command(['switch'] + rev_options + [url, dest]) def update(self, dest, rev_options): self.run_command(['update'] + rev_options + [dest]) def obtain(self, dest): url, rev = self.get_url_rev() rev_options = get_rev_options(url, rev) url = self.remove_auth_from_url(url) if rev: rev_display = ' (to revision %s)' % rev else: rev_display = '' if self.check_destination(dest, url, rev_options, rev_display): logger.info( 'Checking out %s%s to %s', url, rev_display, display_path(dest), ) self.run_command(['checkout', '-q'] + rev_options + [url, dest]) def get_location(self, dist, dependency_links): for url in dependency_links: egg_fragment = Link(url).egg_fragment if not egg_fragment: continue if '-' in egg_fragment: # FIXME: will this work when a package has - in the name? key = '-'.join(egg_fragment.split('-')[:-1]).lower() else: key = egg_fragment if key == dist.key: return url.split('#', 1)[0] return None def get_revision(self, location): """ Return the maximum revision for all files under a given location """ # Note: taken from setuptools.command.egg_info revision = 0 for base, dirs, files in os.walk(location): if self.dirname not in dirs: dirs[:] = [] continue # no sense walking uncontrolled subdirs dirs.remove(self.dirname) entries_fn = os.path.join(base, self.dirname, 'entries') if not os.path.exists(entries_fn): # FIXME: should we warn? continue dirurl, localrev = self._get_svn_url_rev(base) if base == location: base_url = dirurl + '/' # save the root url elif not dirurl or not dirurl.startswith(base_url): dirs[:] = [] continue # not part of the same svn tree, skip it revision = max(revision, localrev) return revision def get_url_rev(self): # hotfix the URL scheme after removing svn+ from svn+ssh:// readd it url, rev = super(Subversion, self).get_url_rev() if url.startswith('ssh://'): url = 'svn+' + url return url, rev def get_url(self, location): # In cases where the source is in a subdirectory, not alongside # setup.py we have to look up in the location until we find a real # setup.py orig_location = location while not os.path.exists(os.path.join(location, 'setup.py')): last_location = location location = os.path.dirname(location) if location == last_location: # We've traversed up to the root of the filesystem without # finding setup.py logger.warning( "Could not find setup.py for directory %s (tried all " "parent directories)", orig_location, ) return None return self._get_svn_url_rev(location)[0] def _get_svn_url_rev(self, location): from pip.exceptions import InstallationError entries_path = os.path.join(location, self.dirname, 'entries') if os.path.exists(entries_path): with open(entries_path) as f: data = f.read() else: # subversion >= 1.7 does not have the 'entries' file data = '' if (data.startswith('8') or data.startswith('9') or data.startswith('10')): data = list(map(str.splitlines, data.split('\n\x0c\n'))) del data[0][0] # get rid of the '8' url = data[0][3] revs = [int(d[9]) for d in data if len(d) > 9 and d[9]] + [0] elif data.startswith('= 1.7 xml = self.run_command( ['info', '--xml', location], show_stdout=False, ) url = _svn_info_xml_url_re.search(xml).group(1) revs = [ int(m.group(1)) for m in _svn_info_xml_rev_re.finditer(xml) ] except InstallationError: url, revs = None, [] if revs: rev = max(revs) else: rev = 0 return url, rev def get_src_requirement(self, dist, location): repo = self.get_url(location) if repo is None: return None # FIXME: why not project name? egg_project_name = dist.egg_name().split('-', 1)[0] rev = self.get_revision(location) return 'svn+%s@%s#egg=%s' % (repo, rev, egg_project_name) def check_version(self, dest, rev_options): """Always assume the versions don't match""" return False @staticmethod def remove_auth_from_url(url): # Return a copy of url with 'username:password@' removed. # username/pass params are passed to subversion through flags # and are not recognized in the url. # parsed url purl = urllib_parse.urlsplit(url) stripped_netloc = \ purl.netloc.split('@')[-1] # stripped url url_pieces = ( purl.scheme, stripped_netloc, purl.path, purl.query, purl.fragment ) surl = urllib_parse.urlunsplit(url_pieces) return surl def get_rev_options(url, rev): if rev: rev_options = ['-r', rev] else: rev_options = [] r = urllib_parse.urlsplit(url) if hasattr(r, 'username'): # >= Python-2.5 username, password = r.username, r.password else: netloc = r[1] if '@' in netloc: auth = netloc.split('@')[0] if ':' in auth: username, password = auth.split(':', 1) else: username, password = auth, None else: username, password = None, None if username: rev_options += ['--username', username] if password: rev_options += ['--password', password] return rev_options vcs.register(Subversion) __init__.pyc000064400000031653151027772600007037 0ustar00 abc@@sdZddlmZddlZddlZddlZddlZddlZddlm Z ddl m Z ddl mZmZmZmZmZddgZejeZd efd YZeZd efd YZd ZdS(s)Handles all VCS (version control) supporti(tabsolute_importN(tparse(t BadCommand(t display_patht backup_dirtcall_subprocesstrmtreetask_path_existstvcstget_src_requirementt VcsSupportcB@seZiZddddddgZdZdZedZed Zed Z d Z ddd Z d Z dZdZRS(tsshtgitthgtbzrtsftptsvncC@sRtjj|jttddr;tjj|jntt|j dS(Nt uses_fragment( t urllib_parset uses_netloctextendtschemestgetattrtNoneRtsuperR t__init__(tself((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyRscC@s |jjS(N(t _registryt__iter__(R((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR$scC@st|jjS(N(tlistRtvalues(R((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pytbackends'scC@sg|jD]}|j^q S(N(Rtdirname(Rtbackend((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pytdirnames+scC@s.g}x!|jD]}|j|jqW|S(N(RRR(RRR!((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt all_schemes/scC@sbt|ds&tjd|jdS|j|jkr^||j|js  cC@sJxC|jjD]2}|j|rtjd||j|jSqWdS(s Return the name of the version control backend if found at given location, e.g. vcs.get_backend_name('/path/to/vcs/checkout') sDetermine that %s uses VCS: %sN(RRtcontrols_locationR&R)R$R(Rtlocationtvc_type((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pytget_backend_nameFs    cC@s*|j}||jkr&|j|SdS(N(tlowerR(RR$((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt get_backendRs cC@s&|j|}|r"|j|SdS(N(R0R2R(RR.R/((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pytget_backend_from_locationWs N(R(t __module__RRRRtpropertyRR"R#R+RR,R0R2R3(((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR s   tVersionControlcB@seZdZdZdZddZdZdZdZ dZ dZ dZ dZ d Zd Zd Zd Zd ZdZdZdZdZeddddddZedZRS(tcO@s&||_tt|j||dS(N(turlRR6R(RR8targstkwargs((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyRgs cC@s1tjj|\}}|jtjjp0|S(sy posix absolute paths start with os.path.sep, win32 ones start with drive (like c:\folder) (tostpatht splitdrivet startswithtsep(Rtrepotdrivettail((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt_is_local_repositorykscC@s|jddS(Nt/t_(treplace(Rtsurname((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyttranslate_egg_surnameuscC@s tdS(s Export the repository at the url to the destination location i.e. only download the files, without vcs informations N(tNotImplementedError(RR.((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pytexportysc C@sd}d|jks(t||j|jjddd}tj|\}}}}}d}d|kr|jdd\}}ntj||||df}||fS(sm Returns the correct repository URL and revision by parsing the given repository URL svSorry, '%s' is a malformed VCS url. The format is +://, e.g. svn+http://myrepo/svn/MyApp#egg=MyAppt+it@R7N(R8tAssertionErrortsplitRturlsplitRtrsplitt urlunsplit( Rt error_messageR8tschemetnetlocR<tquerytfragtrev((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt get_url_revs" cC@sH|jdj|j s,td||j||j|fS(sA Returns (url, revision), where both are strings RDsBad directory: %s(trstriptendswithR RMtget_urlt get_revision(RR.((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pytget_infos cC@stj|jdS(si Normalize a URL for comparison by unquoting it and removing any trailing slash. RD(RtunquoteRY(RR8((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt normalize_urlscC@s|j||j|kS(sV Compare two repo URLs for identity, ignoring incidental differences. (R_(Rturl1turl2((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt compare_urlsscC@s tdS(sx Called when installing or updating an editable package, takes the source path of the checkout. N(RI(Rtdest((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pytobtainscC@s tdS(sB Switch the repo at ``dest`` to point to ``URL``. N(RI(RRcR8t rev_options((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pytswitchscC@s tdS(sO Update an already-existing repo to the given ``rev_options``. N(RI(RRcRe((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pytupdatescC@s tdS(sp Return True if the version is identical to what exists and doesn't need to be updated. N(RI(RRcRe((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt check_versionsc C@smt}t}tjj|rAt}tjjtjj||jr|j|}|j||rt j d|j j t |||j||st jdt ||j ||j||qt jdq>t jd|j|j t ||ddf}qAt jd ||j|j d df}n|rit jd |j|td |d|d}|dkrt jd|j t ||||j|||qi|dkrqi|dkrt jdt |t|t}qi|d krJt|} t jdt || tj|| t}qi|dkritjdqin|S(s Prepare a location to receive a checkout/clone. Return True if the location is ready for (and requires) a checkout/clone, False otherwise. s)%s in %s exists, and has correct URL (%s)sUpdating %s %s%ss$Skipping because already up-to-date.s%s %s in %s exists with URL %ss%(s)witch, (i)gnore, (w)ipe, (b)ackup tstitwtbs0Directory %s already exists, and is not a %s %s.s(i)gnore, (w)ipe, (b)ackup s+The plan is to install the %s repository %ssWhat to do? %siisSwitching %s %s to %s%ss Deleting %ssBacking up %s to %stai(RiRjRkRl(RjRkRl(tTruetFalseR;R<texiststjoinR R[RbR&R)t repo_namettitleRRhtinfoRgR'R$RRfRRtshutiltmovetsystexit( RRcR8Ret rev_displaytcheckouttpromptt existing_urltresponsetdest_dir((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pytcheck_destinations$                  cC@s0tjj|rt|n|j|dS(sq Clean up current location and download the url repository (and vcs infos) into location N(R;R<RpRRd(RR.((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pytunpacks cC@s tdS(s Return a string representing the requirement needed to redownload the files currently present in location, something like: {repository_url}@{revision}#egg={project_name}-{version_identifier} N(RI(RtdistR.((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR scC@s tdS(s_ Return the url used at location Used in get_info or check_destination N(RI(RR.((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR[)scC@s tdS(s_ Return the current revision of the files at location Used in get_info N(RI(RR.((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR\0straisec C@su|jg|}y t|||||||SWn>tk rp}|jtjkrjtd|jqqnXdS(s Run a VCS subcommand This is simply a wrapper around call_subprocess that adds the VCS command name, and checks that the VCS is available sCannot find command %rN(R$RtOSErrorterrnotENOENTR( Rtcmdt show_stdouttcwdt on_returncodet command_desct extra_environtspinnerte((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt run_command7s   cC@sDtjd||j|jtjj||j}tjj|S(s Check if a location is controlled by the vcs. It is meant to be overridden to implement smarter detection mechanisms for specific vcs. sChecking in %s for %s (%s)...(R&R)R R$R;R<RqRp(R*R.R<((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR-Ns (N(R(R4R$R RRRRCRHRJRXR]R_RbRdRfRgRhRRR R[R\RnRt classmethodR-(((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR6as2            U  cC@sztj|}|r`y|j||SWq`tk r\tjd||j|jSXntjd||jS(NsPcannot determine version of editable source in %s (%s command not found in path)stcannot determine version of editable source in %s (is not SVN checkout, Git clone, Mercurial clone or Bazaar branch)(RR3R RR&R'R$tas_requirement(RR.tversion_control((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR [s    (t__doc__t __future__RRtloggingR;RuRwtpip._vendor.six.moves.urllibRRtpip.exceptionsRt pip.utilsRRRRRt__all__t getLoggerR(R&tobjectR RR6R (((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyts     ( G git.pyo000064400000025343151027772600006076 0ustar00 abc@@sddlmZddlZddlZddlZddlmZddlm Z ddl m Z ddl m Zddlm ZddlmZmZddlmZmZe jZe jZejeZd efd YZejedS( i(tabsolute_importN(tsamefile(t BadCommand(tparse(trequest(t display_pathtrmtree(tvcstVersionControltGitcB@seZdZdZdZdZddZd Zd Z d Z d Z d Z dZ dZdZdZdZdZdZdZdZdZdZdZdZdZdZedZRS( tgits.gittclonesgit+https git+httpssgit+sshsgit+gitsgit+filec O@s|rt|\}}}}}|jdr|t|jd } | tj|jddjd} t||| ||f}|jdd} || t|| || ||f}qnt t |j |||dS(Ntfilet/s\t+i( turlsplittendswithtlentlstripturllib_requestt url2pathnametreplacet urlunsplittfindtsuperR t__init__( tselfturltargstkwargstschemetnetloctpathtquerytfragmenttinitial_slashestnewpatht after_plus((s//usr/lib/python2.7/site-packages/pip/vcs/git.pyR s #cC@sld}|jdgdt}|j|r@|t|}nd}dj|jdd }t|S(Ns git version tversiont show_stdouttt.i(t run_commandtFalset startswithRtjointsplitt parse_version(Rt VERSION_PFXR&((s//usr/lib/python2.7/site-packages/pip/vcs/git.pytget_git_version5scC@sytjdd}|j|zH|jds>|d}n|jdddd|gdtd |Wd t|Xd S( s@Export the Git repository at the url to the destination locations-exportspip-R scheckout-indexs-as-fs--prefixR'tcwdN(ttempfiletmkdtemptunpackRR*R+R(Rtlocationttemp_dir((s//usr/lib/python2.7/site-packages/pip/vcs/git.pytexportBs  cC@s_|j|}d|}||kr0||gS||krG||gStjd||SdS(sCheck the revision options before checkout to compensate that tags and branches may need origin/ as a prefix. Returns the SHA1 of the branch or tag if found. s origin/%ss5Could not find a tag or branch '%s', assuming commit.N(tget_short_refstloggertwarning(Rtrevtdestt rev_optionst revisionst origin_rev((s//usr/lib/python2.7/site-packages/pip/vcs/git.pytcheck_rev_optionsOs      cC@s|j|j|dS(s  Compare the current sha to the ref. ref may be a branch or tag name, but current rev will always point to a sha. This means that a branch or tag will never compare as True. So this ultimately only matches against exact shas. i(t get_revisionR,(RR=R>((s//usr/lib/python2.7/site-packages/pip/vcs/git.pyt check_versioncscC@sJ|jdd|gd||jddg|d||j|dS(Ntconfigsremote.origin.urlR2tcheckouts-q(R*tupdate_submodules(RR=RR>((s//usr/lib/python2.7/site-packages/pip/vcs/git.pytswitchlscC@s|jtdkr7|jdddgd|n|jddgd||rr|j|d||}n|jdddg|d||j|dS( Ns1.9.0tfetchs-qs--tagsR2itresets--hard(R1R/R*RARF(RR=R>((s//usr/lib/python2.7/site-packages/pip/vcs/git.pytupdaters cC@s|j\}}|r.|g}d|}ndg}d}|j||||rtjd||t||jdd||g|r|j|||}|j||s|jddg|d|qn|j|ndS( Ns (to %s)s origin/masterR(sCloning %s%s to %sR s-qRER2( t get_url_revtcheck_destinationR:tinfoRR*RARCRF(RR=RR<R>t rev_display((s//usr/lib/python2.7/site-packages/pip/vcs/git.pytobtains"    cC@s|jdddgdtd|}|j}|d}x'|D]}|jdrA|}PqAqAW|jdd }|jS( s+Return URL of the first remote encountered.RDs --get-regexpsremote\..*\.urlR'R2isremote.origin.url t i(R*R+t splitlinesR,R.tstrip(RR6tremotest found_remotetremoteR((s//usr/lib/python2.7/site-packages/pip/vcs/git.pytget_urls   cC@s+|jddgdtd|}|jS(Ns rev-parsetHEADR'R2(R*R+RR(RR6t current_rev((s//usr/lib/python2.7/site-packages/pip/vcs/git.pyRBscc@sn|jdgdtd|}xI|jjD]5}|jdd\}}|j|jfVq1WdS(s4Yields tuples of (commit, ref) for branches and tagssshow-refR'R2RPiN(R*R+RRRQR.(RR6toutputtlinetcommittref((s//usr/lib/python2.7/site-packages/pip/vcs/git.pyt get_full_refss cC@s |jdS(Ns refs/remotes/(R,(RR\((s//usr/lib/python2.7/site-packages/pip/vcs/git.pyt is_ref_remotescC@s |jdS(Ns refs/heads/(R,(RR\((s//usr/lib/python2.7/site-packages/pip/vcs/git.pyt is_ref_branchscC@s |jdS(Ns refs/tags/(R,(RR\((s//usr/lib/python2.7/site-packages/pip/vcs/git.pyt is_ref_tagscC@s/t|j||j||j|f S(s0A ref is a commit sha if it is not anything else(tanyR^R_R`(RR\((s//usr/lib/python2.7/site-packages/pip/vcs/git.pyt is_ref_commits  cC@s |j|S(N(R9(RR6((s//usr/lib/python2.7/site-packages/pip/vcs/git.pytget_refsscC@si}x|j|D]\}}d}|j|rJ|td}nD|j|rl|td}n"|j|r|td}n|dk r|||s      bazaar.py000064400000007333151027772600006373 0ustar00from __future__ import absolute_import import logging import os import tempfile # TODO: Get this into six.moves.urllib.parse try: from urllib import parse as urllib_parse except ImportError: import urlparse as urllib_parse from pip.utils import rmtree, display_path from pip.vcs import vcs, VersionControl from pip.download import path_to_url logger = logging.getLogger(__name__) class Bazaar(VersionControl): name = 'bzr' dirname = '.bzr' repo_name = 'branch' schemes = ( 'bzr', 'bzr+http', 'bzr+https', 'bzr+ssh', 'bzr+sftp', 'bzr+ftp', 'bzr+lp', ) def __init__(self, url=None, *args, **kwargs): super(Bazaar, self).__init__(url, *args, **kwargs) # Python >= 2.7.4, 3.3 doesn't have uses_fragment or non_hierarchical # Register lp but do not expose as a scheme to support bzr+lp. if getattr(urllib_parse, 'uses_fragment', None): urllib_parse.uses_fragment.extend(['lp']) urllib_parse.non_hierarchical.extend(['lp']) def export(self, location): """ Export the Bazaar repository at the url to the destination location """ temp_dir = tempfile.mkdtemp('-export', 'pip-') self.unpack(temp_dir) if os.path.exists(location): # Remove the location to make sure Bazaar can export it correctly rmtree(location) try: self.run_command(['export', location], cwd=temp_dir, show_stdout=False) finally: rmtree(temp_dir) def switch(self, dest, url, rev_options): self.run_command(['switch', url], cwd=dest) def update(self, dest, rev_options): self.run_command(['pull', '-q'] + rev_options, cwd=dest) def obtain(self, dest): url, rev = self.get_url_rev() if rev: rev_options = ['-r', rev] rev_display = ' (to revision %s)' % rev else: rev_options = [] rev_display = '' if self.check_destination(dest, url, rev_options, rev_display): logger.info( 'Checking out %s%s to %s', url, rev_display, display_path(dest), ) self.run_command(['branch', '-q'] + rev_options + [url, dest]) def get_url_rev(self): # hotfix the URL scheme after removing bzr+ from bzr+ssh:// readd it url, rev = super(Bazaar, self).get_url_rev() if url.startswith('ssh://'): url = 'bzr+' + url return url, rev def get_url(self, location): urls = self.run_command(['info'], show_stdout=False, cwd=location) for line in urls.splitlines(): line = line.strip() for x in ('checkout of branch: ', 'parent branch: '): if line.startswith(x): repo = line.split(x)[1] if self._is_local_repository(repo): return path_to_url(repo) return repo return None def get_revision(self, location): revision = self.run_command( ['revno'], show_stdout=False, cwd=location) return revision.splitlines()[-1] def get_src_requirement(self, dist, location): repo = self.get_url(location) if not repo: return None if not repo.lower().startswith('bzr:'): repo = 'bzr+' + repo egg_project_name = dist.egg_name().split('-', 1)[0] current_rev = self.get_revision(location) return '%s@%s#egg=%s' % (repo, current_rev, egg_project_name) def check_version(self, dest, rev_options): """Always assume the versions don't match""" return False vcs.register(Bazaar) git.py000064400000025675151027772600005727 0ustar00from __future__ import absolute_import import logging import tempfile import os.path from pip.compat import samefile from pip.exceptions import BadCommand from pip._vendor.six.moves.urllib import parse as urllib_parse from pip._vendor.six.moves.urllib import request as urllib_request from pip._vendor.packaging.version import parse as parse_version from pip.utils import display_path, rmtree from pip.vcs import vcs, VersionControl urlsplit = urllib_parse.urlsplit urlunsplit = urllib_parse.urlunsplit logger = logging.getLogger(__name__) class Git(VersionControl): name = 'git' dirname = '.git' repo_name = 'clone' schemes = ( 'git', 'git+http', 'git+https', 'git+ssh', 'git+git', 'git+file', ) def __init__(self, url=None, *args, **kwargs): # Works around an apparent Git bug # (see http://article.gmane.org/gmane.comp.version-control.git/146500) if url: scheme, netloc, path, query, fragment = urlsplit(url) if scheme.endswith('file'): initial_slashes = path[:-len(path.lstrip('/'))] newpath = ( initial_slashes + urllib_request.url2pathname(path) .replace('\\', '/').lstrip('/') ) url = urlunsplit((scheme, netloc, newpath, query, fragment)) after_plus = scheme.find('+') + 1 url = scheme[:after_plus] + urlunsplit( (scheme[after_plus:], netloc, newpath, query, fragment), ) super(Git, self).__init__(url, *args, **kwargs) def get_git_version(self): VERSION_PFX = 'git version ' version = self.run_command(['version'], show_stdout=False) if version.startswith(VERSION_PFX): version = version[len(VERSION_PFX):] else: version = '' # get first 3 positions of the git version becasue # on windows it is x.y.z.windows.t, and this parses as # LegacyVersion which always smaller than a Version. version = '.'.join(version.split('.')[:3]) return parse_version(version) def export(self, location): """Export the Git repository at the url to the destination location""" temp_dir = tempfile.mkdtemp('-export', 'pip-') self.unpack(temp_dir) try: if not location.endswith('/'): location = location + '/' self.run_command( ['checkout-index', '-a', '-f', '--prefix', location], show_stdout=False, cwd=temp_dir) finally: rmtree(temp_dir) def check_rev_options(self, rev, dest, rev_options): """Check the revision options before checkout to compensate that tags and branches may need origin/ as a prefix. Returns the SHA1 of the branch or tag if found. """ revisions = self.get_short_refs(dest) origin_rev = 'origin/%s' % rev if origin_rev in revisions: # remote branch return [revisions[origin_rev]] elif rev in revisions: # a local tag or branch name return [revisions[rev]] else: logger.warning( "Could not find a tag or branch '%s', assuming commit.", rev, ) return rev_options def check_version(self, dest, rev_options): """ Compare the current sha to the ref. ref may be a branch or tag name, but current rev will always point to a sha. This means that a branch or tag will never compare as True. So this ultimately only matches against exact shas. """ return self.get_revision(dest).startswith(rev_options[0]) def switch(self, dest, url, rev_options): self.run_command(['config', 'remote.origin.url', url], cwd=dest) self.run_command(['checkout', '-q'] + rev_options, cwd=dest) self.update_submodules(dest) def update(self, dest, rev_options): # First fetch changes from the default remote if self.get_git_version() >= parse_version('1.9.0'): # fetch tags in addition to everything else self.run_command(['fetch', '-q', '--tags'], cwd=dest) else: self.run_command(['fetch', '-q'], cwd=dest) # Then reset to wanted revision (maybe even origin/master) if rev_options: rev_options = self.check_rev_options( rev_options[0], dest, rev_options, ) self.run_command(['reset', '--hard', '-q'] + rev_options, cwd=dest) #: update submodules self.update_submodules(dest) def obtain(self, dest): url, rev = self.get_url_rev() if rev: rev_options = [rev] rev_display = ' (to %s)' % rev else: rev_options = ['origin/master'] rev_display = '' if self.check_destination(dest, url, rev_options, rev_display): logger.info( 'Cloning %s%s to %s', url, rev_display, display_path(dest), ) self.run_command(['clone', '-q', url, dest]) if rev: rev_options = self.check_rev_options(rev, dest, rev_options) # Only do a checkout if rev_options differs from HEAD if not self.check_version(dest, rev_options): self.run_command( ['checkout', '-q'] + rev_options, cwd=dest, ) #: repo may contain submodules self.update_submodules(dest) def get_url(self, location): """Return URL of the first remote encountered.""" remotes = self.run_command( ['config', '--get-regexp', 'remote\..*\.url'], show_stdout=False, cwd=location) remotes = remotes.splitlines() found_remote = remotes[0] for remote in remotes: if remote.startswith('remote.origin.url '): found_remote = remote break url = found_remote.split(' ')[1] return url.strip() def get_revision(self, location): current_rev = self.run_command( ['rev-parse', 'HEAD'], show_stdout=False, cwd=location) return current_rev.strip() def get_full_refs(self, location): """Yields tuples of (commit, ref) for branches and tags""" output = self.run_command(['show-ref'], show_stdout=False, cwd=location) for line in output.strip().splitlines(): commit, ref = line.split(' ', 1) yield commit.strip(), ref.strip() def is_ref_remote(self, ref): return ref.startswith('refs/remotes/') def is_ref_branch(self, ref): return ref.startswith('refs/heads/') def is_ref_tag(self, ref): return ref.startswith('refs/tags/') def is_ref_commit(self, ref): """A ref is a commit sha if it is not anything else""" return not any(( self.is_ref_remote(ref), self.is_ref_branch(ref), self.is_ref_tag(ref), )) # Should deprecate `get_refs` since it's ambiguous def get_refs(self, location): return self.get_short_refs(location) def get_short_refs(self, location): """Return map of named refs (branches or tags) to commit hashes.""" rv = {} for commit, ref in self.get_full_refs(location): ref_name = None if self.is_ref_remote(ref): ref_name = ref[len('refs/remotes/'):] elif self.is_ref_branch(ref): ref_name = ref[len('refs/heads/'):] elif self.is_ref_tag(ref): ref_name = ref[len('refs/tags/'):] if ref_name is not None: rv[ref_name] = commit return rv def _get_subdirectory(self, location): """Return the relative path of setup.py to the git repo root.""" # find the repo root git_dir = self.run_command(['rev-parse', '--git-dir'], show_stdout=False, cwd=location).strip() if not os.path.isabs(git_dir): git_dir = os.path.join(location, git_dir) root_dir = os.path.join(git_dir, '..') # find setup.py orig_location = location while not os.path.exists(os.path.join(location, 'setup.py')): last_location = location location = os.path.dirname(location) if location == last_location: # We've traversed up to the root of the filesystem without # finding setup.py logger.warning( "Could not find setup.py for directory %s (tried all " "parent directories)", orig_location, ) return None # relative path of setup.py to repo root if samefile(root_dir, location): return None return os.path.relpath(location, root_dir) def get_src_requirement(self, dist, location): repo = self.get_url(location) if not repo.lower().startswith('git:'): repo = 'git+' + repo egg_project_name = dist.egg_name().split('-', 1)[0] if not repo: return None current_rev = self.get_revision(location) req = '%s@%s#egg=%s' % (repo, current_rev, egg_project_name) subdirectory = self._get_subdirectory(location) if subdirectory: req += '&subdirectory=' + subdirectory return req def get_url_rev(self): """ Prefixes stub URLs like 'user@hostname:user/repo.git' with 'ssh://'. That's required because although they use SSH they sometimes doesn't work with a ssh:// scheme (e.g. Github). But we need a scheme for parsing. Hence we remove it again afterwards and return it as a stub. """ if '://' not in self.url: assert 'file:' not in self.url self.url = self.url.replace('git+', 'git+ssh://') url, rev = super(Git, self).get_url_rev() url = url.replace('ssh://', '') else: url, rev = super(Git, self).get_url_rev() return url, rev def update_submodules(self, location): if not os.path.exists(os.path.join(location, '.gitmodules')): return self.run_command( ['submodule', 'update', '--init', '--recursive', '-q'], cwd=location, ) @classmethod def controls_location(cls, location): if super(Git, cls).controls_location(location): return True try: r = cls().run_command(['rev-parse'], cwd=location, show_stdout=False, on_returncode='ignore') return not r except BadCommand: logger.debug("could not determine if %s is under git control " "because git is not available", location) return False vcs.register(Git) subversion.pyo000064400000020532151027772600007505 0ustar00 abc@@s)ddlmZddlZddlZddlZddlmZddlm Z ddl m Z m Z ddl mZddlmZmZejdZejd Zejd Zejd Zejd Zejd ZejeZdefdYZdZejedS(i(tabsolute_importN(tparse(tLink(trmtreet display_path(t indent_log(tvcstVersionControls url="([^"]+)"scommitted-rev="(\d+)"s URL: (.+)sRevision: (.+)s\s*revision="(\d+)"s(.*)t SubversioncB@seZdZdZdZdZdZdZd Zd Z d Z d Z d Z dZ dZdZdZdZedZRS(tsvns.svntcheckoutssvn+sshssvn+https svn+httpsssvn+svncC@s|jd|gdtdidd6}tj|}|sgtjdt|tjd|d S|j dj }t j|}|stjd t|tjd||d fS||j dfS( s/Returns (url, revision), where both are stringstinfot show_stdoutt extra_environtCtLANGs'Cannot determine URL of svn checkout %ss!Output that cannot be parsed: %sis,Cannot determine revision of svn checkout %sN(NN( t run_commandtFalset _svn_url_retsearchtloggertwarningRtdebugtNonetgrouptstript_svn_revision_re(tselftlocationtoutputtmatchturl((s6/usr/lib/python2.7/site-packages/pip/vcs/subversion.pytget_infos(    cC@s|j\}}t||}|j|}tjd||tHtjj|rlt |n|j dg|||gdt WdQXdS(s@Export the svn repository at the url to the destination locations!Exporting svn repository %s to %stexportR N( t get_url_revtget_rev_optionstremove_auth_from_urlRR RtostpathtexistsRRR(RRRtrevt rev_options((s6/usr/lib/python2.7/site-packages/pip/vcs/subversion.pyR!;s  cC@s"|jdg|||gdS(Ntswitch(R(RtdestRR)((s6/usr/lib/python2.7/site-packages/pip/vcs/subversion.pyR*JscC@s|jdg||gdS(Ntupdate(R(RR+R)((s6/usr/lib/python2.7/site-packages/pip/vcs/subversion.pyR,MscC@s|j\}}t||}|j|}|rCd|}nd}|j||||rtjd||t||jddg|||gndS(Ns (to revision %s)tsChecking out %s%s to %sR s-q(R"R#R$tcheck_destinationRR RR(RR+RR(R)t rev_display((s6/usr/lib/python2.7/site-packages/pip/vcs/subversion.pytobtainPs  cC@sx|D]{}t|j}|s(qnd|krYdj|jdd j}n|}||jkr|jdddSqWdS(Nt-it#ii(Rt egg_fragmenttjointsplittlowertkeyR(Rtdisttdependency_linksRR3R7((s6/usr/lib/python2.7/site-packages/pip/vcs/subversion.pyt get_locationas  %c C@sd}xtj|D]\}}}|j|krAg|(qn|j|jtjj||jd}tjj|sqn|j|\}}||kr|d} n$| s|j|  rg|(qnt ||}qW|S(sR Return the maximum revision for all files under a given location itentriest/( R%twalktdirnametremoveR&R4R't_get_svn_url_revt startswithtmax( RRtrevisiontbasetdirstfilest entries_fntdirurltlocalrevtbase_url((s6/usr/lib/python2.7/site-packages/pip/vcs/subversion.pyt get_revisionos"  cC@sAtt|j\}}|jdr7d|}n||fS(Nsssh://ssvn+(tsuperRR"RA(RRR(((s6/usr/lib/python2.7/site-packages/pip/vcs/subversion.pyR"s cC@sw|}x]tjjtjj|dse|}tjj|}||kr tjd|dSq W|j|dS(Nssetup.pysGCould not find setup.py for directory %s (tried all parent directories)i( R%R&R'R4R>RRRR@(RRt orig_locationt last_location((s6/usr/lib/python2.7/site-packages/pip/vcs/subversion.pytget_urls$ c C@sIddlm}tjj||jd}tjj|rat|}|j}WdQXnd}|j ds|j ds|j drt t t j |jd}|dd=|dd }g|D]2}t|d kr|d rt|d ^qdg}n |j d rtj|} | sNtd |n| jd }gtj|D]} t| jd ^qmdg}nyk|jdd|gdt} tj| jd }gtj| D]} t| jd ^q}Wn|k r#dg}}nX|r9t|} nd} || fS(Ni(tInstallationErrorR;R-t8t9t10s ii sR'topentreadRAtlisttmaptstrt splitlinesR5tlentintt_svn_xml_url_reRt ValueErrorRt _svn_rev_retfinditerRRt_svn_info_xml_url_ret_svn_info_xml_rev_reRRB( RRRPt entries_pathtftdataRtdtrevsRtmtxmlR(((s6/usr/lib/python2.7/site-packages/pip/vcs/subversion.pyR@s>! I; 5 cC@s[|j|}|dkrdS|jjddd}|j|}d|||fS(NR1iissvn+%s@%s#egg=%s(RORtegg_nameR5RK(RR8Rtrepotegg_project_nameR(((s6/usr/lib/python2.7/site-packages/pip/vcs/subversion.pytget_src_requirements  cC@stS(s&Always assume the versions don't match(R(RR+R)((s6/usr/lib/python2.7/site-packages/pip/vcs/subversion.pyt check_versionscC@sYtj|}|jjdd}|j||j|j|jf}tj|}|S(Nt@i( t urllib_parseturlsplittnetlocR5tschemeR&tquerytfragmentt urlunsplit(Rtpurltstripped_netloct url_piecestsurl((s6/usr/lib/python2.7/site-packages/pip/vcs/subversion.pyR$s !(R ssvn+sshssvn+https svn+httpsssvn+svn(t__name__t __module__tnameR>t repo_nametschemesR R!R*R,R0R:RKR"ROR@RmRnt staticmethodR$(((s6/usr/lib/python2.7/site-packages/pip/vcs/subversion.pyRs"          , cC@s|rd|g}ng}tj|}t|drO|j|j}}nl|d}d|kr|jdd}d|kr|jdd\}}q|d}}n d \}}|r|d|g7}n|r|d|g7}n|S( Ns-rtusernameiRoit:s --usernames --password(NN(RpRqthasattrRtpasswordR5R(RR(R)trRRRrtauth((s6/usr/lib/python2.7/site-packages/pip/vcs/subversion.pyR#s$    (t __future__RtloggingR%tretpip._vendor.six.moves.urllibRRpt pip.indexRt pip.utilsRRtpip.utils.loggingRtpip.vcsRRtcompileR]R_RRRbRat getLoggerR{RRR#tregister(((s6/usr/lib/python2.7/site-packages/pip/vcs/subversion.pyts$    mercurial.py000064400000006620151027772600007114 0ustar00from __future__ import absolute_import import logging import os import tempfile from pip.utils import display_path, rmtree from pip.vcs import vcs, VersionControl from pip.download import path_to_url from pip._vendor.six.moves import configparser logger = logging.getLogger(__name__) class Mercurial(VersionControl): name = 'hg' dirname = '.hg' repo_name = 'clone' schemes = ('hg', 'hg+http', 'hg+https', 'hg+ssh', 'hg+static-http') def export(self, location): """Export the Hg repository at the url to the destination location""" temp_dir = tempfile.mkdtemp('-export', 'pip-') self.unpack(temp_dir) try: self.run_command( ['archive', location], show_stdout=False, cwd=temp_dir) finally: rmtree(temp_dir) def switch(self, dest, url, rev_options): repo_config = os.path.join(dest, self.dirname, 'hgrc') config = configparser.SafeConfigParser() try: config.read(repo_config) config.set('paths', 'default', url) with open(repo_config, 'w') as config_file: config.write(config_file) except (OSError, configparser.NoSectionError) as exc: logger.warning( 'Could not switch Mercurial repository to %s: %s', url, exc, ) else: self.run_command(['update', '-q'] + rev_options, cwd=dest) def update(self, dest, rev_options): self.run_command(['pull', '-q'], cwd=dest) self.run_command(['update', '-q'] + rev_options, cwd=dest) def obtain(self, dest): url, rev = self.get_url_rev() if rev: rev_options = [rev] rev_display = ' (to revision %s)' % rev else: rev_options = [] rev_display = '' if self.check_destination(dest, url, rev_options, rev_display): logger.info( 'Cloning hg %s%s to %s', url, rev_display, display_path(dest), ) self.run_command(['clone', '--noupdate', '-q', url, dest]) self.run_command(['update', '-q'] + rev_options, cwd=dest) def get_url(self, location): url = self.run_command( ['showconfig', 'paths.default'], show_stdout=False, cwd=location).strip() if self._is_local_repository(url): url = path_to_url(url) return url.strip() def get_revision(self, location): current_revision = self.run_command( ['parents', '--template={rev}'], show_stdout=False, cwd=location).strip() return current_revision def get_revision_hash(self, location): current_rev_hash = self.run_command( ['parents', '--template={node}'], show_stdout=False, cwd=location).strip() return current_rev_hash def get_src_requirement(self, dist, location): repo = self.get_url(location) if not repo.lower().startswith('hg:'): repo = 'hg+' + repo egg_project_name = dist.egg_name().split('-', 1)[0] if not repo: return None current_rev_hash = self.get_revision_hash(location) return '%s@%s#egg=%s' % (repo, current_rev_hash, egg_project_name) def check_version(self, dest, rev_options): """Always assume the versions don't match""" return False vcs.register(Mercurial) subversion.pyc000064400000020725151027772600007475 0ustar00 abc@@s)ddlmZddlZddlZddlZddlmZddlm Z ddl m Z m Z ddl mZddlmZmZejdZejd Zejd Zejd Zejd Zejd ZejeZdefdYZdZejedS(i(tabsolute_importN(tparse(tLink(trmtreet display_path(t indent_log(tvcstVersionControls url="([^"]+)"scommitted-rev="(\d+)"s URL: (.+)sRevision: (.+)s\s*revision="(\d+)"s(.*)t SubversioncB@seZdZdZdZdZdZdZd Zd Z d Z d Z d Z dZ dZdZdZdZedZRS(tsvns.svntcheckoutssvn+sshssvn+https svn+httpsssvn+svncC@s|jdj|j s,td||jd|gdtdidd6}tj|}|stj dt |tj d |d S|j d j}tj|}|stj d t |tj d ||d fS||j d fS(s/Returns (url, revision), where both are stringst/sBad directory: %stinfot show_stdoutt extra_environtCtLANGs'Cannot determine URL of svn checkout %ss!Output that cannot be parsed: %sis,Cannot determine revision of svn checkout %sN(NN(trstriptendswithtdirnametAssertionErrort run_commandtFalset _svn_url_retsearchtloggertwarningRtdebugtNonetgrouptstript_svn_revision_re(tselftlocationtoutputtmatchturl((s6/usr/lib/python2.7/site-packages/pip/vcs/subversion.pytget_infos,     cC@s|j\}}t||}|j|}tjd||tHtjj|rlt |n|j dg|||gdt WdQXdS(s@Export the svn repository at the url to the destination locations!Exporting svn repository %s to %stexportR N( t get_url_revtget_rev_optionstremove_auth_from_urlRR RtostpathtexistsRRR(R R!R$trevt rev_options((s6/usr/lib/python2.7/site-packages/pip/vcs/subversion.pyR&;s  cC@s"|jdg|||gdS(Ntswitch(R(R tdestR$R.((s6/usr/lib/python2.7/site-packages/pip/vcs/subversion.pyR/JscC@s|jdg||gdS(Ntupdate(R(R R0R.((s6/usr/lib/python2.7/site-packages/pip/vcs/subversion.pyR1MscC@s|j\}}t||}|j|}|rCd|}nd}|j||||rtjd||t||jddg|||gndS(Ns (to revision %s)tsChecking out %s%s to %sR s-q(R'R(R)tcheck_destinationRR RR(R R0R$R-R.t rev_display((s6/usr/lib/python2.7/site-packages/pip/vcs/subversion.pytobtainPs  cC@sx|D]{}t|j}|s(qnd|krYdj|jdd j}n|}||jkr|jdddSqWdS(Nt-it#ii(Rt egg_fragmenttjointsplittlowertkeyR(R tdisttdependency_linksR$R8R<((s6/usr/lib/python2.7/site-packages/pip/vcs/subversion.pyt get_locationas  %c C@sd}xtj|D]\}}}|j|krAg|(qn|j|jtjj||jd}tjj|sqn|j|\}}||kr|d} n$| s|j|  rg|(qnt ||}qW|S(sR Return the maximum revision for all files under a given location itentriesR ( R*twalkRtremoveR+R9R,t_get_svn_url_revt startswithtmax( R R!trevisiontbasetdirstfilest entries_fntdirurltlocalrevtbase_url((s6/usr/lib/python2.7/site-packages/pip/vcs/subversion.pyt get_revisionos"  cC@sAtt|j\}}|jdr7d|}n||fS(Nsssh://ssvn+(tsuperRR'RD(R R$R-((s6/usr/lib/python2.7/site-packages/pip/vcs/subversion.pyR's cC@sw|}x]tjjtjj|dse|}tjj|}||kr tjd|dSq W|j|dS(Nssetup.pysGCould not find setup.py for directory %s (tried all parent directories)i( R*R+R,R9RRRRRC(R R!t orig_locationt last_location((s6/usr/lib/python2.7/site-packages/pip/vcs/subversion.pytget_urls$ c C@sIddlm}tjj||jd}tjj|rat|}|j}WdQXnd}|j ds|j ds|j drt t t j |jd}|dd=|dd }g|D]2}t|d kr|d rt|d ^qdg}n |j d rtj|} | sNtd |n| jd }gtj|D]} t| jd ^qmdg}nyk|jdd|gdt} tj| jd }gtj| D]} t| jd ^q}Wn|k r#dg}}nX|r9t|} nd} || fS(Ni(tInstallationErrorR@R2t8t9t10s ii s! I; 5 cC@s[|j|}|dkrdS|jjddd}|j|}d|||fS(NR6iissvn+%s@%s#egg=%s(RRRtegg_nameR:RN(R R=R!trepotegg_project_nameR-((s6/usr/lib/python2.7/site-packages/pip/vcs/subversion.pytget_src_requirements  cC@stS(s&Always assume the versions don't match(R(R R0R.((s6/usr/lib/python2.7/site-packages/pip/vcs/subversion.pyt check_versionscC@sYtj|}|jjdd}|j||j|j|jf}tj|}|S(Nt@i( t urllib_parseturlsplittnetlocR:tschemeR+tquerytfragmentt urlunsplit(R$tpurltstripped_netloct url_piecestsurl((s6/usr/lib/python2.7/site-packages/pip/vcs/subversion.pyR)s !(R ssvn+sshssvn+https svn+httpsssvn+svn(t__name__t __module__tnameRt repo_nametschemesR%R&R/R1R5R?RNR'RRRCRpRqt staticmethodR)(((s6/usr/lib/python2.7/site-packages/pip/vcs/subversion.pyRs"          , cC@s|rd|g}ng}tj|}t|drO|j|j}}nl|d}d|kr|jdd}d|kr|jdd\}}q|d}}n d \}}|r|d|g7}n|r|d|g7}n|S( Ns-rtusernameiRrit:s --usernames --password(NN(RsRtthasattrRtpasswordR:R(R$R-R.trRRRutauth((s6/usr/lib/python2.7/site-packages/pip/vcs/subversion.pyR(s$    (t __future__RtloggingR*tretpip._vendor.six.moves.urllibRRst pip.indexRt pip.utilsRRtpip.utils.loggingRtpip.vcsRRtcompileR`RbRRReRdt getLoggerR~RRR(tregister(((s6/usr/lib/python2.7/site-packages/pip/vcs/subversion.pyts$    bazaar.pyo000064400000011236151027772600006547 0ustar00 abc@@sddlmZddlZddlZddlZyddlmZWnek rgddl ZnXddl m Z m Z ddl mZmZddlmZejeZdefdYZejedS( i(tabsolute_importN(tparse(trmtreet display_path(tvcstVersionControl(t path_to_urltBazaarcB@s}eZdZdZdZdZdd Zd Zd Z d Z d Z dZ dZ dZdZdZRS(tbzrs.bzrtbranchsbzr+https bzr+httpssbzr+sshsbzr+sftpsbzr+ftpsbzr+lpcO@s[tt|j|||ttddrWtjjdgtjjdgndS(Nt uses_fragmenttlp( tsuperRt__init__tgetattrt urllib_parsetNoneR textendtnon_hierarchical(tselfturltargstkwargs((s2/usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyR scC@sstjdd}|j|tjj|r>t|nz#|jd|gd|dtWdt|XdS(sU Export the Bazaar repository at the url to the destination location s-exportspip-texporttcwdt show_stdoutN( ttempfiletmkdtemptunpacktostpathtexistsRt run_commandtFalse(Rtlocationttemp_dir((s2/usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyR&s   cC@s|jd|gd|dS(NtswitchR(R (RtdestRt rev_options((s2/usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyR$5scC@s!|jddg|d|dS(Ntpulls-qR(R (RR%R&((s2/usr/lib/python2.7/site-packages/pip/vcs/bazaar.pytupdate8scC@s|j\}}|r1d|g}d|}n g}d}|j||||rtjd||t||jddg|||gndS(Ns-rs (to revision %s)tsChecking out %s%s to %sR s-q(t get_url_revtcheck_destinationtloggertinfoRR (RR%RtrevR&t rev_display((s2/usr/lib/python2.7/site-packages/pip/vcs/bazaar.pytobtain;s   cC@sAtt|j\}}|jdr7d|}n||fS(Nsssh://sbzr+(R RR*t startswith(RRR.((s2/usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyR*Ls cC@s|jdgdtd|}xp|jD]b}|j}xMdD]E}|j|rD|j|d}|j|rt|S|SqDWq+WdS(NR-RRscheckout of branch: sparent branch: i(scheckout of branch: sparent branch: ( R R!t splitlineststripR1tsplitt_is_local_repositoryRR(RR"turlstlinetxtrepo((s2/usr/lib/python2.7/site-packages/pip/vcs/bazaar.pytget_urlSs    cC@s,|jdgdtd|}|jdS(NtrevnoRRi(R R!R2(RR"trevision((s2/usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyt get_revision`scC@sw|j|}|sdS|jjds;d|}n|jjddd}|j|}d|||fS(Nsbzr:sbzr+t-iis %s@%s#egg=%s(R:RtlowerR1tegg_nameR4R=(RtdistR"R9tegg_project_namet current_rev((s2/usr/lib/python2.7/site-packages/pip/vcs/bazaar.pytget_src_requirementes cC@stS(s&Always assume the versions don't match(R!(RR%R&((s2/usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyt check_versionos(Rsbzr+https bzr+httpssbzr+sshsbzr+sftpsbzr+ftpsbzr+lpN(t__name__t __module__tnametdirnamet repo_nametschemesRR RR$R(R0R*R:R=RDRE(((s2/usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyRs        (t __future__RtloggingRRturllibRRt ImportErrorturlparset pip.utilsRRtpip.vcsRRt pip.downloadRt getLoggerRFR,Rtregister(((s2/usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyts    ___init__.pyo000064400000031415151027772600007047 0ustar00 abc@@sdZddlmZddlZddlZddlZddlZddlZddlm Z ddl m Z ddl mZmZmZmZmZddgZejeZd efd YZeZd efd YZd ZdS(s)Handles all VCS (version control) supporti(tabsolute_importN(tparse(t BadCommand(t display_patht backup_dirtcall_subprocesstrmtreetask_path_existstvcstget_src_requirementt VcsSupportcB@seZiZddddddgZdZdZedZed Zed Z d Z ddd Z d Z dZdZRS(tsshtgitthgtbzrtsftptsvncC@sRtjj|jttddr;tjj|jntt|j dS(Nt uses_fragment( t urllib_parset uses_netloctextendtschemestgetattrtNoneRtsuperR t__init__(tself((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyRscC@s |jjS(N(t _registryt__iter__(R((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR$scC@st|jjS(N(tlistRtvalues(R((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pytbackends'scC@sg|jD]}|j^q S(N(Rtdirname(Rtbackend((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pytdirnames+scC@s.g}x!|jD]}|j|jqW|S(N(RRR(RRR!((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt all_schemes/scC@sbt|ds&tjd|jdS|j|jkr^||j|js  cC@sJxC|jjD]2}|j|rtjd||j|jSqWdS(s Return the name of the version control backend if found at given location, e.g. vcs.get_backend_name('/path/to/vcs/checkout') sDetermine that %s uses VCS: %sN(RRtcontrols_locationR&R)R$R(Rtlocationtvc_type((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pytget_backend_nameFs    cC@s*|j}||jkr&|j|SdS(N(tlowerR(RR$((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt get_backendRs cC@s&|j|}|r"|j|SdS(N(R0R2R(RR.R/((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pytget_backend_from_locationWs N(R(t __module__RRRRtpropertyRR"R#R+RR,R0R2R3(((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR s   tVersionControlcB@seZdZdZdZddZdZdZdZ dZ dZ dZ dZ d Zd Zd Zd Zd ZdZdZdZdZeddddddZedZRS(tcO@s&||_tt|j||dS(N(turlRR6R(RR8targstkwargs((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyRgs cC@s1tjj|\}}|jtjjp0|S(sy posix absolute paths start with os.path.sep, win32 ones start with drive (like c:\folder) (tostpatht splitdrivet startswithtsep(Rtrepotdrivettail((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt_is_local_repositorykscC@s|jddS(Nt/t_(treplace(Rtsurname((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyttranslate_egg_surnameuscC@s tdS(s Export the repository at the url to the destination location i.e. only download the files, without vcs informations N(tNotImplementedError(RR.((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pytexportysc C@sd}|jjddd}tj|\}}}}}d}d|krj|jdd\}}ntj||||df}||fS(sm Returns the correct repository URL and revision by parsing the given repository URL svSorry, '%s' is a malformed VCS url. The format is +://, e.g. svn+http://myrepo/svn/MyApp#egg=MyAppt+it@R7N(R8tsplitRturlsplitRtrsplitt urlunsplit( Rt error_messageR8tschemetnetlocR<tquerytfragtrev((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt get_url_revs cC@s|j||j|fS(sA Returns (url, revision), where both are strings (tget_urlt get_revision(RR.((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pytget_infoscC@stj|jdS(si Normalize a URL for comparison by unquoting it and removing any trailing slash. RD(Rtunquotetrstrip(RR8((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt normalize_urlscC@s|j||j|kS(sV Compare two repo URLs for identity, ignoring incidental differences. (R](Rturl1turl2((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt compare_urlsscC@s tdS(sx Called when installing or updating an editable package, takes the source path of the checkout. N(RI(Rtdest((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pytobtainscC@s tdS(sB Switch the repo at ``dest`` to point to ``URL``. N(RI(RRaR8t rev_options((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pytswitchscC@s tdS(sO Update an already-existing repo to the given ``rev_options``. N(RI(RRaRc((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pytupdatescC@s tdS(sp Return True if the version is identical to what exists and doesn't need to be updated. N(RI(RRaRc((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt check_versionsc C@smt}t}tjj|rAt}tjjtjj||jr|j|}|j||rt j d|j j t |||j||st jdt ||j ||j||qt jdq>t jd|j|j t ||ddf}qAt jd ||j|j d df}n|rit jd |j|td |d|d}|dkrt jd|j t ||||j|||qi|dkrqi|dkrt jdt |t|t}qi|d krJt|} t jdt || tj|| t}qi|dkritjdqin|S(s Prepare a location to receive a checkout/clone. Return True if the location is ready for (and requires) a checkout/clone, False otherwise. s)%s in %s exists, and has correct URL (%s)sUpdating %s %s%ss$Skipping because already up-to-date.s%s %s in %s exists with URL %ss%(s)witch, (i)gnore, (w)ipe, (b)ackup tstitwtbs0Directory %s already exists, and is not a %s %s.s(i)gnore, (w)ipe, (b)ackup s+The plan is to install the %s repository %ssWhat to do? %siisSwitching %s %s to %s%ss Deleting %ssBacking up %s to %stai(RgRhRiRj(RhRiRj(tTruetFalseR;R<texiststjoinR RXR`R&R)t repo_namettitleRRftinfoReR'R$RRdRRtshutiltmovetsystexit( RRaR8Rct rev_displaytcheckouttpromptt existing_urltresponsetdest_dir((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pytcheck_destinations$                  cC@s0tjj|rt|n|j|dS(sq Clean up current location and download the url repository (and vcs infos) into location N(R;R<RnRRb(RR.((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pytunpacks cC@s tdS(s Return a string representing the requirement needed to redownload the files currently present in location, something like: {repository_url}@{revision}#egg={project_name}-{version_identifier} N(RI(RtdistR.((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR scC@s tdS(s_ Return the url used at location Used in get_info or check_destination N(RI(RR.((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyRX)scC@s tdS(s_ Return the current revision of the files at location Used in get_info N(RI(RR.((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyRY0straisec C@su|jg|}y t|||||||SWn>tk rp}|jtjkrjtd|jqqnXdS(s Run a VCS subcommand This is simply a wrapper around call_subprocess that adds the VCS command name, and checks that the VCS is available sCannot find command %rN(R$RtOSErrorterrnotENOENTR( Rtcmdt show_stdouttcwdt on_returncodet command_desct extra_environtspinnerte((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyt run_command7s   cC@sDtjd||j|jtjj||j}tjj|S(s Check if a location is controlled by the vcs. It is meant to be overridden to implement smarter detection mechanisms for specific vcs. sChecking in %s for %s (%s)...(R&R)R R$R;R<RoRn(R*R.R<((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR-Ns (N(R(R4R$R RRRRCRHRJRWRZR]R`RbRdReRfR}R~R RXRYRlRt classmethodR-(((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR6as2            U  cC@sztj|}|r`y|j||SWq`tk r\tjd||j|jSXntjd||jS(NsPcannot determine version of editable source in %s (%s command not found in path)stcannot determine version of editable source in %s (is not SVN checkout, Git clone, Mercurial clone or Bazaar branch)(RR3R RR&R'R$tas_requirement(RR.tversion_control((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyR [s    (t__doc__t __future__RRtloggingR;RsRutpip._vendor.six.moves.urllibRRtpip.exceptionsRt pip.utilsRRRRRt__all__t getLoggerR(R&tobjectR RR6R (((s4/usr/lib/python2.7/site-packages/pip/vcs/__init__.pyts     ( G bazaar.pyc000064400000011236151027772600006533 0ustar00 abc@@sddlmZddlZddlZddlZyddlmZWnek rgddl ZnXddl m Z m Z ddl mZmZddlmZejeZdefdYZejedS( i(tabsolute_importN(tparse(trmtreet display_path(tvcstVersionControl(t path_to_urltBazaarcB@s}eZdZdZdZdZdd Zd Zd Z d Z d Z dZ dZ dZdZdZRS(tbzrs.bzrtbranchsbzr+https bzr+httpssbzr+sshsbzr+sftpsbzr+ftpsbzr+lpcO@s[tt|j|||ttddrWtjjdgtjjdgndS(Nt uses_fragmenttlp( tsuperRt__init__tgetattrt urllib_parsetNoneR textendtnon_hierarchical(tselfturltargstkwargs((s2/usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyR scC@sstjdd}|j|tjj|r>t|nz#|jd|gd|dtWdt|XdS(sU Export the Bazaar repository at the url to the destination location s-exportspip-texporttcwdt show_stdoutN( ttempfiletmkdtemptunpacktostpathtexistsRt run_commandtFalse(Rtlocationttemp_dir((s2/usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyR&s   cC@s|jd|gd|dS(NtswitchR(R (RtdestRt rev_options((s2/usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyR$5scC@s!|jddg|d|dS(Ntpulls-qR(R (RR%R&((s2/usr/lib/python2.7/site-packages/pip/vcs/bazaar.pytupdate8scC@s|j\}}|r1d|g}d|}n g}d}|j||||rtjd||t||jddg|||gndS(Ns-rs (to revision %s)tsChecking out %s%s to %sR s-q(t get_url_revtcheck_destinationtloggertinfoRR (RR%RtrevR&t rev_display((s2/usr/lib/python2.7/site-packages/pip/vcs/bazaar.pytobtain;s   cC@sAtt|j\}}|jdr7d|}n||fS(Nsssh://sbzr+(R RR*t startswith(RRR.((s2/usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyR*Ls cC@s|jdgdtd|}xp|jD]b}|j}xMdD]E}|j|rD|j|d}|j|rt|S|SqDWq+WdS(NR-RRscheckout of branch: sparent branch: i(scheckout of branch: sparent branch: ( R R!t splitlineststripR1tsplitt_is_local_repositoryRR(RR"turlstlinetxtrepo((s2/usr/lib/python2.7/site-packages/pip/vcs/bazaar.pytget_urlSs    cC@s,|jdgdtd|}|jdS(NtrevnoRRi(R R!R2(RR"trevision((s2/usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyt get_revision`scC@sw|j|}|sdS|jjds;d|}n|jjddd}|j|}d|||fS(Nsbzr:sbzr+t-iis %s@%s#egg=%s(R:RtlowerR1tegg_nameR4R=(RtdistR"R9tegg_project_namet current_rev((s2/usr/lib/python2.7/site-packages/pip/vcs/bazaar.pytget_src_requirementes cC@stS(s&Always assume the versions don't match(R!(RR%R&((s2/usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyt check_versionos(Rsbzr+https bzr+httpssbzr+sshsbzr+sftpsbzr+ftpsbzr+lpN(t__name__t __module__tnametdirnamet repo_nametschemesRR RR$R(R0R*R:R=RDRE(((s2/usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyRs        (t __future__RtloggingRRturllibRRt ImportErrorturlparset pip.utilsRRtpip.vcsRRt pip.downloadRt getLoggerRFR,Rtregister(((s2/usr/lib/python2.7/site-packages/pip/vcs/bazaar.pyts    ___init__.py000064400000030126151027772600006666 0ustar00"""Handles all VCS (version control) support""" from __future__ import absolute_import import errno import logging import os import shutil import sys from pip._vendor.six.moves.urllib import parse as urllib_parse from pip.exceptions import BadCommand from pip.utils import (display_path, backup_dir, call_subprocess, rmtree, ask_path_exists) __all__ = ['vcs', 'get_src_requirement'] logger = logging.getLogger(__name__) class VcsSupport(object): _registry = {} schemes = ['ssh', 'git', 'hg', 'bzr', 'sftp', 'svn'] def __init__(self): # Register more schemes with urlparse for various version control # systems urllib_parse.uses_netloc.extend(self.schemes) # Python >= 2.7.4, 3.3 doesn't have uses_fragment if getattr(urllib_parse, 'uses_fragment', None): urllib_parse.uses_fragment.extend(self.schemes) super(VcsSupport, self).__init__() def __iter__(self): return self._registry.__iter__() @property def backends(self): return list(self._registry.values()) @property def dirnames(self): return [backend.dirname for backend in self.backends] @property def all_schemes(self): schemes = [] for backend in self.backends: schemes.extend(backend.schemes) return schemes def register(self, cls): if not hasattr(cls, 'name'): logger.warning('Cannot register VCS %s', cls.__name__) return if cls.name not in self._registry: self._registry[cls.name] = cls logger.debug('Registered VCS backend: %s', cls.name) def unregister(self, cls=None, name=None): if name in self._registry: del self._registry[name] elif cls in self._registry.values(): del self._registry[cls.name] else: logger.warning('Cannot unregister because no class or name given') def get_backend_name(self, location): """ Return the name of the version control backend if found at given location, e.g. vcs.get_backend_name('/path/to/vcs/checkout') """ for vc_type in self._registry.values(): if vc_type.controls_location(location): logger.debug('Determine that %s uses VCS: %s', location, vc_type.name) return vc_type.name return None def get_backend(self, name): name = name.lower() if name in self._registry: return self._registry[name] def get_backend_from_location(self, location): vc_type = self.get_backend_name(location) if vc_type: return self.get_backend(vc_type) return None vcs = VcsSupport() class VersionControl(object): name = '' dirname = '' # List of supported schemes for this Version Control schemes = () def __init__(self, url=None, *args, **kwargs): self.url = url super(VersionControl, self).__init__(*args, **kwargs) def _is_local_repository(self, repo): """ posix absolute paths start with os.path.sep, win32 ones start with drive (like c:\\folder) """ drive, tail = os.path.splitdrive(repo) return repo.startswith(os.path.sep) or drive # See issue #1083 for why this method was introduced: # https://github.com/pypa/pip/issues/1083 def translate_egg_surname(self, surname): # For example, Django has branches of the form "stable/1.7.x". return surname.replace('/', '_') def export(self, location): """ Export the repository at the url to the destination location i.e. only download the files, without vcs informations """ raise NotImplementedError def get_url_rev(self): """ Returns the correct repository URL and revision by parsing the given repository URL """ error_message = ( "Sorry, '%s' is a malformed VCS url. " "The format is +://, " "e.g. svn+http://myrepo/svn/MyApp#egg=MyApp" ) assert '+' in self.url, error_message % self.url url = self.url.split('+', 1)[1] scheme, netloc, path, query, frag = urllib_parse.urlsplit(url) rev = None if '@' in path: path, rev = path.rsplit('@', 1) url = urllib_parse.urlunsplit((scheme, netloc, path, query, '')) return url, rev def get_info(self, location): """ Returns (url, revision), where both are strings """ assert not location.rstrip('/').endswith(self.dirname), \ 'Bad directory: %s' % location return self.get_url(location), self.get_revision(location) def normalize_url(self, url): """ Normalize a URL for comparison by unquoting it and removing any trailing slash. """ return urllib_parse.unquote(url).rstrip('/') def compare_urls(self, url1, url2): """ Compare two repo URLs for identity, ignoring incidental differences. """ return (self.normalize_url(url1) == self.normalize_url(url2)) def obtain(self, dest): """ Called when installing or updating an editable package, takes the source path of the checkout. """ raise NotImplementedError def switch(self, dest, url, rev_options): """ Switch the repo at ``dest`` to point to ``URL``. """ raise NotImplementedError def update(self, dest, rev_options): """ Update an already-existing repo to the given ``rev_options``. """ raise NotImplementedError def check_version(self, dest, rev_options): """ Return True if the version is identical to what exists and doesn't need to be updated. """ raise NotImplementedError def check_destination(self, dest, url, rev_options, rev_display): """ Prepare a location to receive a checkout/clone. Return True if the location is ready for (and requires) a checkout/clone, False otherwise. """ checkout = True prompt = False if os.path.exists(dest): checkout = False if os.path.exists(os.path.join(dest, self.dirname)): existing_url = self.get_url(dest) if self.compare_urls(existing_url, url): logger.debug( '%s in %s exists, and has correct URL (%s)', self.repo_name.title(), display_path(dest), url, ) if not self.check_version(dest, rev_options): logger.info( 'Updating %s %s%s', display_path(dest), self.repo_name, rev_display, ) self.update(dest, rev_options) else: logger.info( 'Skipping because already up-to-date.') else: logger.warning( '%s %s in %s exists with URL %s', self.name, self.repo_name, display_path(dest), existing_url, ) prompt = ('(s)witch, (i)gnore, (w)ipe, (b)ackup ', ('s', 'i', 'w', 'b')) else: logger.warning( 'Directory %s already exists, and is not a %s %s.', dest, self.name, self.repo_name, ) prompt = ('(i)gnore, (w)ipe, (b)ackup ', ('i', 'w', 'b')) if prompt: logger.warning( 'The plan is to install the %s repository %s', self.name, url, ) response = ask_path_exists('What to do? %s' % prompt[0], prompt[1]) if response == 's': logger.info( 'Switching %s %s to %s%s', self.repo_name, display_path(dest), url, rev_display, ) self.switch(dest, url, rev_options) elif response == 'i': # do nothing pass elif response == 'w': logger.warning('Deleting %s', display_path(dest)) rmtree(dest) checkout = True elif response == 'b': dest_dir = backup_dir(dest) logger.warning( 'Backing up %s to %s', display_path(dest), dest_dir, ) shutil.move(dest, dest_dir) checkout = True elif response == 'a': sys.exit(-1) return checkout def unpack(self, location): """ Clean up current location and download the url repository (and vcs infos) into location """ if os.path.exists(location): rmtree(location) self.obtain(location) def get_src_requirement(self, dist, location): """ Return a string representing the requirement needed to redownload the files currently present in location, something like: {repository_url}@{revision}#egg={project_name}-{version_identifier} """ raise NotImplementedError def get_url(self, location): """ Return the url used at location Used in get_info or check_destination """ raise NotImplementedError def get_revision(self, location): """ Return the current revision of the files at location Used in get_info """ raise NotImplementedError def run_command(self, cmd, show_stdout=True, cwd=None, on_returncode='raise', command_desc=None, extra_environ=None, spinner=None): """ Run a VCS subcommand This is simply a wrapper around call_subprocess that adds the VCS command name, and checks that the VCS is available """ cmd = [self.name] + cmd try: return call_subprocess(cmd, show_stdout, cwd, on_returncode, command_desc, extra_environ, spinner) except OSError as e: # errno.ENOENT = no such file or directory # In other words, the VCS executable isn't available if e.errno == errno.ENOENT: raise BadCommand('Cannot find command %r' % self.name) else: raise # re-raise exception if a different error occurred @classmethod def controls_location(cls, location): """ Check if a location is controlled by the vcs. It is meant to be overridden to implement smarter detection mechanisms for specific vcs. """ logger.debug('Checking in %s for %s (%s)...', location, cls.dirname, cls.name) path = os.path.join(location, cls.dirname) return os.path.exists(path) def get_src_requirement(dist, location): version_control = vcs.get_backend_from_location(location) if version_control: try: return version_control().get_src_requirement(dist, location) except BadCommand: logger.warning( 'cannot determine version of editable source in %s ' '(%s command not found in path)', location, version_control.name, ) return dist.as_requirement() logger.warning( 'cannot determine version of editable source in %s (is not SVN ' 'checkout, Git clone, Mercurial clone or Bazaar branch)', location, ) return dist.as_requirement()