bgddlZddlmZddlmZmZddlZddlmZm Z ddl m Z ddl m Z ddlmZgd Zd ZeeefZd ed eefd Zded eefdZded eefdZd ed eefdZd ed eefdZdS)N)Path)ListUnion)CouldNotParseRequirementsRequirementsNotFound) from_setup_py)parse_constraint)DetectedRequirement)find_requirementsfrom_requirements_txtfrom_requirements_dirfrom_requirements_blobfrom_pyproject_tomlr rr)z-iz --index-urlz--extra-index-urlz --no-indexz-fz --find-linksz-rpathreturncg}t|trt|}|dz }|rJ|r6 t |}||S#t$rYnwxYw|dz }|r^|rJ t|}t|dkr||Sn#t$rYnwxYwdD]M}||z }|jr?|r+ |t|z }6#t$r }Yd}~Ed}~wwxYwN|dz }|r*| rt|}|||z }t|} | || z }tt|}t|dkr||St )a This method tries to determine the requirements of a particular project by inspecting the possible places that they could be defined. It will attempt, in order: 1) to parse setup.py in the root for an install_requires value 2) to read a requirements.txt file or a requirements.pip in the root 3) to read all .txt files in a folder called 'requirements' in the root 4) to read files matching "*requirements*.txt" and "*reqs*.txt" in the root, excluding any starting or ending with 'test' If one of these succeeds, then a list of pkg_resources.Requirement's will be returned. If none can be found, then a RequirementsNotFound will be raised zsetup.pyzpyproject.tomlr)zrequirements.txtzrequirements.pipN requirements) isinstancestrrexistsis_filer sortrrlenr is_dirrrlistsetr) rrsetup_py poetry_toml reqfile_namereqfileerequirements_dirfrom_dir from_blobs m/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/requirements_detector/detect.pyr r &si"L$Dzzj HX--// (22L       (    D ))K 3 3 5 5 .{;;L<  1$$!!#####%)    D A % > goo//   5g > >> ,    n,  %%5%<%<%>%>%()9::   H $L&t,,I ! L))**L <1 s6$A:: BB87C11 C>=C>&D99 E E  toml_filecg}t|trt|}tj|}|didi}|di}||di|D]\}}|dkrt|tr;d|vr |d}n.tj ||}|| |ntt|}d|vrd|vr d |vr d |vrd |}tj |||}|| ||S) Ntoolpoetry dependencieszdev-dependenciespythonversion,<>=z==)rrrtomlloadgetupdateitemslowerdictr parseappendr ) r'rparsedpoetry_sectionr+namespecreq parsed_specs r&rrisL)S!!$OO Yy ! !FZZ++//"==N!%%nb99L**+=rBBCCC"((**%% d ::<<8 # #  dD ! ! D  I)/4 9EE? '',,,*40011 k ! !c&<&<KAWAW\_gr\r\r,{,,K!'4(>(>(> JJ ?    $ $ $ requirements_filecg}t|trt|}|5}|D]}|dkr|drC|dtvrwtj ||}|| | dddn #1swxYwY|S)N#r) rrropen readlinesstrip startswithsplit _PIP_OPTIONSr r9r:)rBrfr?detecteds r&r r sBL#S))4 !233    ! !*Q;;== * *Cyy{{b  yy{{%%c** yy{{  ""1%55*06GHHH    ) ) ) ) **************** sB:DD Dcjg}t|trt|}|D]]}|s|jds|jdr|t|z }^tt|S)Nz.txtz.pip) rrriterdirrr=endswithr rr)rrentrys r&rrsL$Dzz99}}   :  v & & 9%**=*=f*E*E 9 1%88 8L L!! " ""rAcg}t|trt|}|D]}|st jd|j}|4|d ds(|d dr|t|z }|S)Nz ^(\w*)req(uirement)?s(\w*)\.txt$rtest) rrrrOrrematchr=grouprIrPr )rrrQms r&rrsL$Dzz55}}   H8%* E E 9  771::  ( ( AGGAJJ,?,?,G,G  -e444 rA)rUpathlibrtypingrrr2 exceptionsrr handle_setupr poetry_semverr requirementr __all__rKrPr rr rrrAr&rbs  GGGGGGGG''''''++++++,,,,,,     #t)@A@$':";@@@@F1.A)BBQ48K3L4 # #d+>&? # # # #t,?'@rA