ó +¢µRc@€soddlmZddlZddlZddlZddlmZmZmZddl m Z ddl m Z m Z ddlmZmZmZddlmZejeƒZejdƒZejd ejƒZejd ejƒZd „Zed d dd„ƒZdd„Zd„Z d„Z!d„Z"d„Z#ejdƒZ$ejdƒZ%d„Z&d„Z'dS(iÿÿÿÿ(twith_statementN(texiststisdirtjoin(t maketrans(tPIPEtPopen(tvreprtgetvertget_requested_versions(tmemoizes/.*?/usr/lib/python(\d.\d+)/(site|dist)-packagessÏ (?P[A-Za-z][A-Za-z0-9_.\-]*) # Python distribution name \s* (?P(?:-?\d\.\d+(?:-(?:\d\.\d+)?)?)?) # version range \s* (?P(?:[a-z][^;]*)?) # Debian dependency (?: # optional upstream version -> Debian version translator ;\s* (?PPEP386)? # PEP-386 mode \s* (?P(?:s|tr|y).*)? # translator rules )? s (?P[A-Za-z][A-Za-z0-9_.]*) # Python distribution name \s* (?P(?:\[[^\]]*\])?) # ignored for now \s* (?: # optional minimum/maximum version (?P<=?|>=?|==|!=) \s* (?P(\w|[-.])+) )? c C€s‹t|ƒy}xo|D]g}|jdƒ}|jdƒs| rGqntj|ƒstjd|jddƒd|ƒtSqWWdQXt S(s Check if pydist file looks good.s t#s"invalid pydist data in file %s: %st/iiÿÿÿÿN( topentstript startswitht PYDIST_REtmatchtlogterrortrsplittFalsetTrue(tfpathtfptline((s%/usr/share/python/debpython/pydist.pytvalidate=s  s/usr/share/python/dist/sdebian/pydist-overridess/usr/share/python/dist_fallbackc €s”t|ƒr|g}ng}tˆƒrS|j‡fd†tjˆƒDƒƒnt|ƒro|j|ƒni}x|D]}t|ƒü}xò|D]ê}|jdƒ}|jdƒs˜| rÉq˜nt j |ƒ}|s÷t d||fƒ‚n|j ƒ}t |dƒ} t|dƒ|d<|djƒ|d<|d r_|d jd ƒ|d Tss R sinvalid pydist line: %s (in %s)tnametvrangetversionst dependencytrulest;N(RRtextendtostlistdirtappendR RRRtsearcht Exceptiont groupdictt safe_nameR tsplitt setdefault( Rtfnametfbnametto_checktresultRRRtdistR((Rs%/usr/share/python/debpython/pydist.pytloadKs4   )      'c C€stjd||rt|ƒndƒt|tƒrCt|ƒ}ntjdƒj |ƒj ƒ\}}t |ƒ|}t ƒ}t j |ƒ}|sµtjdƒtd|ƒ‚n|jƒ}|d}|j|jƒƒ}|r´xË|D]À}|r||jd|ƒkrqín|ds%dS|djdƒr@|dS|d r¥|d s^|d r¥|d dkr¥t|d |d |d ƒ}d|d|d |fS|dSqíWndtt |ƒƒ} |réd| t|ƒf} n d| } tjd| ƒtd| dtdtdtƒ} | jƒ\} } | jdkrÇtƒ} xC| jdƒD]2}|jƒswq_n| j|jdƒdƒq_Wt| ƒdkrºtj d|ƒqÚ| j!ƒSntjd|| ƒt"|ƒ}tjd||t |ƒƒ|S(Ns-trying to guess dependency for %s (python=%s)s([^><= \[]+)(.*)s[please ask dh_python2 author to fix REQUIRES_RE or your upstream author to fix requires.txtsrequirement is not valid: %sRR R!t)tversiontstandardR"toperators==s %s (%s %s)s'*/%s-?*\.egg-info's"%s | grep '/python%s/\|/pyshared/'s$%s | grep '/python2\../\|/pyshared/'sinvoking dpkg -S %ss/usr/bin/dpkg -S %stshelltstdouttstderris t:is,more than one package name found for %s dists'dpkg -S did not find package for %s: %ss³Cannot find installed package that provides %s. Using %s as package name. Please add "%s correct_package_name" line to debian/pydist-overrides to override it if this is incorrect.(Ns==(#RtdebugRtNonet isinstancet basestringRtretcompileRtgroupsR+R3t REQUIRES_REtinfoR)R*tgettlowertendswitht _translatet ci_regexpRRRt communicatet returncodetsetR,RtaddtlenRtpoptsensible_pname(treqR5Rtresttdatatreq_dtdetailstitemtvtquerytprocessR9R:R1Rtpname((s%/usr/share/python/debpython/pydist.pytguess_dependencynsd $             c C€stj|ƒ}|r'|jdƒ}nd}g}t}}g}t|dƒñ}g|jƒD]}|jƒ^qb} xÂ| D]º} | s| jdƒr°|j | ƒqn| jdƒrÈt }n|rá|j | ƒqnt | |ƒ} | r.|j | ƒd| j ƒkrt }q;|j | ƒq|j | ƒqWWdQX|r}t|dƒ}|j d„|DƒƒWdQXn|S(NitrR t[t setuptoolstwcs€s|]}|dVqdS(s N((RR((s%/usr/share/python/debpython/pydist.pys Øs(t PUBLIC_DIR_RERtgroupR=RR t readlinesRRR'RR[RFt writelines( R.t public_dirtverR1tmodifiedtoptional_sectiont processedRRtlinesRR!((s%/usr/share/python/debpython/pydist.pyt parse_pydep¶s: %       cC€stjdƒjd|ƒjƒS(sEmulate distribute's safe_name.s[^A-Za-z0-9.]+t_(R@RAtsubRF(R((s%/usr/share/python/debpython/pydist.pyR+ÜscC€sBt|ƒjddƒ}|jdƒr4|d}nd|jƒS(s(Guess Debian package name from Egg name.Rkt-spython-is python-%s(R+treplaceRRF(tegg_name((s%/usr/share/python/debpython/pydist.pyRPás cC€sdjd„|jƒDƒƒS(s'Return case insensitive dpkg -S regexp.tcs€s7|]-}|jƒr+d|jƒ|fn|VqdS(s[%s%s]N(tisalphatupper(RR((s%/usr/share/python/debpython/pydist.pys ës(RRF(R((s%/usr/share/python/debpython/pydist.pyRIéss[-.]?(alpha|beta|rc|dev|a|b|c)s\$(\d+)cC€stjd|ƒS(scConvert Perl RE patterns used in uscan to Python's >>> print _pl2py('foo$3') foo\g<3> s\\g<\1>(tGROUP_RERl(tpattern((s%/usr/share/python/debpython/pydist.pyt_pl2pyòsc C€scx;|D]3}|jd ƒru|jdƒr1dnd}||dj||ƒ}|jt|d|dƒƒ}q|jdƒr*|dj|dƒ}tj|dƒ}d}|dr|d}d|krÝd}nd|krtj|dtjƒ}qn|jt|dƒ||ƒ}qt j d |ƒqW|d kr_t jd |ƒ}n|S( s>Translate Python version into Debian one. >>> _translate('1.C2betac', ['s/c//gi'], None) '1.2beta' >>> _translate('5-fooa1.2beta3-fooD', ... ['s/^/1:/', 's/-foo//g', 's:([A-Z]):+$1:'], 'PEP386') '1:5~a1.2~beta3+D' >>> _translate('x.y.x.z', ['tr/xy/ab/', 'y,z,Z,'], None) 'a.b.a.Z' ttrtyiiitstgRsunknown rule ignored: %stPEP386s~\g<1>(strRw( RR,t translateRR@RAtIRlRuRtwarnt PRE_VER_RE( R5R"R6truletposttmpRttcounttflags((s%/usr/share/python/debpython/pydist.pyRHûs( #     " ((t __future__RtloggingR%R@tos.pathRRRtstringRt subprocessRRtdebpython.versionRRR tdebpython.toolsR t getLoggert__name__RRAR`tVERBOSERRCRR3R=R[RjR+RPRIR~RsRuRH(((s%/usr/share/python/debpython/pydist.pyts6      ! H &