*g4SSKrSSKrSSKrSSKJrJr SSKJr SSKJ r \R"S\R5r \R"S\R5r \R"\5r"SS5rg) N)joinsplit)execute)Versionz (?:\#!\s*){0,1} # shebang prefix (?P .*?/bin/.*?)? (?P python|pypy) (?P \d[\.\d]*)? (?P -dbg)? (?P.*) a- (?P.*?) (?:\. (?Pabi\d+) |(?:\. (?P (?Pcpython|pypy) - (?P\d{2}) (?P[a-z]*?) ) (?: -(?P[^/]*?) )? ))? (?P_d)? \.so$c\rSrSrSrSrSrSrSrSr 0r SSjr Sr S r S rS r\S 5rSS jrSSjrSSjrSSjrSSjrSSjrSSjrSSjrSSjrSSjrSSjrSrg) Interpreter<NpythonFcpythonc[5nUS US [U[5(a,UR5Hn XbM [ X5X'M OuU(anUR SS5R 5(aU(d[U5US'O3URU5R5HupXbM XU 'M UR5Hup[X U 5 M g)Nselfvalue.version) locals isinstancerkeysgetattrreplaceisdigitrparseitemssetattr) rrpathnamerdebugimploptionsparamskeyvals +/usr/share/python3/debpython/interpreter.py__init__Interpreter.__init__Es 6N 7O e[ ) ){{};&")%"5FK%}}S"%--//$+ENy! $ 5 1 7 7 9HC{*&)s !: HC Ds #'crUS:XahU(aaURS5(aSURS'O%URS5(aSURS'SU;aSURS'OUS :XaUb [U5nUS ;a!Uc[[U5URU'gX RU'g) Nrr r rpypyz-dbgTrr)rrrr ) startswith__dict__rrr)rrrs r$ __setattr__Interpreter.__setattr__Zs 6>e))(1 f%!!&))(. f%)- g& Y 5#4ENE 7 7EM")+t">> sorted(Interpreter.parse('pypy').items()) [('debug', None), ('name', 'pypy'), ('options', ()), ('path', None), ('version', None)] >>> sorted(Interpreter.parse('/usr/bin/python3.3-dbg').items()) [('debug', '-dbg'), ('name', 'python'), ('options', ()), ('path', '/usr/bin/'), ('version', '3.3')] >>> sorted(Interpreter.parse('#! /usr/bin/pypy --foo').items()) [('debug', None), ('name', 'pypy'), ('options', ('--foo',)), ('path', '/usr/bin/'), ('version', None)] >>> sorted(Interpreter.parse('#! /usr/bin/python3.2').items()) [('debug', None), ('name', 'python'), ('options', ()), ('path', '/usr/bin/'), ('version', '3.2')] >>> sorted(Interpreter.parse('/usr/bin/python3.2-dbg --foo --bar').items()) [('debug', '-dbg'), ('name', 'python'), ('options', ('--foo', '--bar')), ('path', '/usr/bin/'), ('version', '3.2')] r ) SHEBANG_REsearch groupdicttupler)shebangr1s r$rInterpreter.parse~sT ""7+I!!#   %fY&7&=&=&? @F9  r'c[U=(d UR5nURS:XaSnO4U[S5-(aSU-nOU[S5-(aSU-nOSnU(aSU-nU(a S U<U<3nU$) agReturn path to site-packages directory. Note that returned path is not the final location of .py files >>> i = Interpreter('python') >>> i.sitedir(version='3.1') '/usr/lib/python3/dist-packages/' >>> i.sitedir(version='2.5') '/usr/lib/python2.5/site-packages/' >>> i.sitedir(version=Version('2.7')) '/usr/lib/python2.7/dist-packages/' >>> i.sitedir(version='3.1', gdb=True, package='python3-foo') 'debian/python3-foo/usr/lib/debug/usr/lib/python3/dist-packages/' >>> i.sitedir(version=Version('3.2')) '/usr/lib/python3/dist-packages/' >>> Interpreter('pypy').sitedir(version='2.0') '/usr/lib/pypy/dist-packages/' r)z/usr/lib/pypy/dist-packages/2.6z /usr/lib/python%s/site-packages/z3.0z /usr/lib/python%s/dist-packages/z/usr/lib/python3/dist-packages/z/usr/lib/debug%szdebian/)rrr)rgdbpackagerrs r$sitedirInterpreter.sitedirsz&'1T\\2 99 1D  &5?D  &5?D4D %,D $+T2D r'c 0[U=(d UR5nSUR;aSOSnU[S5::aX-$[U5upEUR S5(dUS- n[ USUSS<S UR U5<SU<35$) a^Given path to a .py file, return path to its .pyc/.pyo file. This function is inspired by Python 3.2's imp.cache_from_source. :param fpath: path to file name :param version: Python version >>> i = Interpreter('python') >>> i.cache_file('foo.py', Version('3.1')) 'foo.pyc' >>> i.cache_file('bar/foo.py', '3.2') 'bar/__pycache__/foo.cpython-32.pyc' z-Ooc3.1z.py __pycache__Nr)rrr rendswithr magic_tag)rfpathr last_charfdirfnames r$ cache_fileInterpreter.cache_files'1T\\24<</CS gen $$ $El ~~e$$ UNED-3BZ!8)*EF Fr'c[U=(d UR5nURU5up4URSS5SnU(a/USR U5- nU(aUSR U5- nUR (a(UR S:XaU[S5-(aUS- nS R U5$) z5Return extension name with soname and multiarch tags.rrz.{}z-{}r 3_dz{}.so)rr _get_configrr:rr)rrrsoabi multiarchr1s r$ext_fileInterpreter.ext_files'1T\\2++G4C#A&  ell5) )F%,,y11 ::$))y0ws|+ dNF~~f%%r'c[U=(d UR5nURS:XaU[S5-(agURSU5n[ U5$)zReturn magic number.r rZrz9import importlib.util; print(importlib.util.MAGIC_NUMBER))rrr_executeeval)rrr1s r$ magic_numberInterpreter.magic_numbersK'1T\\2 99 !g&=Z\cdF|r'c[U=(d UR5nURS:XaU[S5-(agURSU5$)zReturn Python magic tag (used in __pycache__ dir to tag files). >>> i = Interpreter('python') >>> i.magic_tag(version='3.2') 'cpython-32' r 3.2rz/import sys; print(sys.implementation.cache_tag))rrrrbr;s r$rQInterpreter.magic_tagsD'1T\\2 99 !g&?}}NPWXXr'c[U=(d UR5nURU5up#U$![a [R SSS9 gf=f)zReturn multiarch tag.zcannot get multiarchTexc_inforrrr\ Exceptionlogrrrr]r^s r$r^Interpreter.multiarchsZ'1T\\2 #//8 E    II,tI < 5AAc[U=(d UR5nURS:Xa/U[S5- (aSRUR5$gg)Nr rgzabi{})rrrr:majorr;s r$ stableabiInterpreter.stableabisH'1T\\2 99 !g&?>>'--0 0'@ !r'c[U=(d UR5nURU5up#U$![a [R SSS9 gf=f)z{Return SOABI flag (used to in .so files). >>> i = Interpreter('python') >>> i.soabi(version=Version('3.3')) 'cpython-33m' zcannot get soabiTrjrrlros r$r]Interpreter.soabi s['1T\\2 #//8 E    II(4I 8 rqc[U=(d UR5nSU;aURSS5up1OSn[R U5nU(dgUR 5nUS(ag[ XS9nUS(a#SRUSS USS5UlUR(d#US (dS US =(d S;aS UlUR5upgUSnURS:Xa/URS- (aURS5(aUSSnUS(dU(aKSRXS=(d U5nUS(dU(aSRXS=(d U5nUS- nX:Xag[X85$![a [RSS S9 gf=f)aPReturn extension file name if file can be renamed. >>> i = Interpreter('python') >>> i.check_extname('foo.so', version='3.3') # doctest: +ELLIPSIS 'foo.cpython-33m-....so' >>> i.check_extname('foo.abi3.so', version='3.3') >>> i.check_extname('foo/bar/bazmodule.so', version='3.3') # doctest: +ELLIPSIS 'foo/bar/baz.cpython-33m-....so' /rYrNrt)rverz{}.{}rrdflagsTzcannot get soabi/multiarchrjrr rgmoduleir]r^z{}-{}z.so)rrrsplit EXTFILE_REr?r@rr:rr\rmrnrrPr) rrUrrTinfoir]r^r1s r$ check_extnameInterpreter.check_extnames'1T\\2 %<,,sA.KD%D  ' ~~     . ;tE{1~tE{1~FAIwwDMST']5Hb-IAG  }} Ef 66Y 199#5&//(:S:SCR[F =E^^FM,BUCFK I [0A0NYO% ? D!!  II2TI B  sF''GGcn[U=(d UR5nURS:Xd4URS:Xa'US- (a US-(dUS- (dUS:XaSnOSnUS- nURX!5R S 5n[ R S US 'U$![a U$f=f) Nr)r rErZrMzimport sysconfig as s;z%from distutils import sysconfig as s;zOprint("__SEP__".join(i or "" for i in s.get_config_vars("SOABI", "MULTIARCH")))__SEP__DEB_HOST_MULTIARCHrY)rrrrbrosenvironKeyError)rrcmd conf_varss r$r\Interpreter._get_configKs'1T\\2 99 $))y"85 W^e#w#~*C9C D DMM#/55i@  ::&:;IaL   sB&& B43B4c[U=(d UR5nURU5SU4nU(a2XRR;aURRU$[ U5nUSS:wa5[ RUS5 [SRXS55eUSR5n[U5S:XaUSnU(aXPRRU'U$)Nz-c returncoderstderrz{} failed with status code {}stdoutrY) rrr0 __class___cacherrnrrmr: splitlineslen)rcommandrcacheoutputr1s r$rbInterpreter._execute^s'1T\\2::g&g6 W 5 55>>((1 1! , 1 $ IIfX& ';BB7S_L`ab b!,,. v;! AYF -3NN ! !' * r')NNNNNNN)FNNr5)NT)__name__ __module__ __qualname____firstlineno__rrrrrr rr%r,r2r6r0 staticmethodrrHrVr_rdrQr^rtr]rr\rb__static_attributes__r r'r$rr<s D DG E DG FAE04$*( (0$LF2 & Y 1 "/"b&r'r)loggingrreos.pathrr debpythonrdebpython.versionrcompileVERBOSEr>r getLoggerrrnrr r'r$rsq* % ZZ    ZZ jj! "!uur'