K i!ddlmZddlmZddlZddlZddlZddlZddlm Z dZ Gdde Z Gdd e Zdd Zd Zdd Z dd ZeddZeddZddZddZdZdZddZdZdZy)) namedtuple)sha256N)XFAILctjjdk(stjdk(r t |S|S)Ndarwinnt)sysplatformlowerosnamer)funcs g/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/utilities/_compilation/util.py may_xfailr s2 ||x'277d?T{ c eZdZy)CompilerNotFoundErrorN)__name__ __module__ __qualname__rrrrsrrceZdZdZy) CompileErrorz2Failure to compile one or more C/C++ source files.N)rrr__doc__rrrrrs>$  uww}}T"""rc |xsd}t||}t||}tjj|sytjj |dz tjj |k\ryy)ao Investigate if path is non-existent or older than provided reference path. Parameters ========== path: string path to path which might be missing or too old other_path: string reference path cwd: string working directory (root of relative paths) Returns ======= True if path is older or missing. .r Tgư>F)r!r rr'getmtime)r other_pathr s rmissing_or_other_newerr1Bsi$ *C t %DZS1J 77>>$  ww #d*bgg.>.>t.DD rc|r~tjj|s tjj||}tjj|s tjj||}tjj |st dj ||r|ddk(sF|dz}n@tjj |r!tjj|rd}|rB|}tjj|}tjj||}ntjj|}tjj |s|r t|n t d|r t||sytjj|r>tjjtjj||}tj |||rtj"|||S)a Variation of ``shutil.copy`` with extra options. Parameters ========== src : str Path to source file. dst : str Path to destination. only_update : bool Only copy if source is newer than destination (returns None if it was newer), default: ``False``. copystat : bool See ``shutil.copystat``. default: ``True``. cwd : str Path to working directory (root of relative paths). dest_is_dir : bool Ensures that dst is treated as a directory. default: ``False`` create_dest_dirs : bool Creates directories if needed. Returns ======= Path to the copied file. zSource: `{}` does not existr#r$Tz You must create directory first.Nr.)r rrrr'FileNotFoundErrorformatr*basenamer%r(r1islinkrrealpathshutilcopycopystat) srcdst only_updater:r dest_is_dircreate_dest_dirsdest_dir dest_fnames rr9r9^s: ww}}S!'',,sC(Cww}}S!'',,sC(C 77>>#  = D DS IJJ2w#~c'C 77>># 277==#5KWW%%c* ggll8Z077??3' 77>>( #  h #$FG G%c3/  ww~~cggoobgg..s3o= KKSS! JrGlobpathnameArbitraryDepthGlobfilenamec|d}g}tj|D]S\}}}|D]H}tj||s|jtjj ||JU|S)Nr-)r walkfnmatchappendrr) filename_globr globbedrootdirs filenamesfns r glob_at_depthrPsn G!#7dI 7Br=1rww||D"56 77 Nrctt|d5tfddD]}j| dddS#1swYSxYw)ab Computes the SHA256 hash of a file. Parameters ========== path : string Path to file to compute hash of. nblocks : int Number of blocks to read per iteration. Returns ======= hashlib sha256 hash object. Use ``.digest()`` or ``.hexdigest()`` on returned object to get binary or hex encoded string. rbc@jjzSN)read block_size)fnblocksshsrz sha256_of_file..s!&&)>"?rrN)ropeniterupdate)rrXchunkrWrYs ` @@rsha256_of_filer_sY" B dD Q?E E IIe   I Is (A  Ac<t}|j||S)z' Computes the SHA256 hash of a string. )rr])stringrYs rsha256_of_stringrbs BIIf Irct|5}|D]}|jdsd|vs|jd}t|dk7r:|\}}|j jdj dk(sr|j jdj dk(sdddy  dddy #1swYy xYw) z Inspect a Cython source file (.pyx) and look for comment line like: # distutils: language = c++ Returns True if such a file is present in the file, else False. #=r#languagerzc++NTF)r[ startswithsplitr&stripr )rfhlinesplittedlhsrhss r pyx_is_cplusrps d (r (Ds#t ::c?x=A%#S99;$$&r*002j@yy{((*1-335>#' ( ( ( (  ( s(C C AC 2C 4C >C  Cctjj|\}}tjj|\}}|jdd}tj ddk(rddlm}m}|||g\}}}|ra|D]\} tjj|tjj| ksCtdj| ||||||} | Sddl } | jj||} | td|z| jj| } | j j#| | S)a$ Imports Python extension (from shared object file) Provide a list of paths in `only_if_newer_than` to check timestamps of dependencies. import_ raises an ImportError if any is newer. Word of warning: The OS may cache shared objects which makes reimporting same path of an shared object file very problematic. It will not detect the new time stamp, nor new checksum, but will instead silently use old module. Use unique names for this reason. Parameters ========== filename : str Path to shared object. only_if_newer_than : iterable of strings Paths to dependencies of the shared object. Raises ====== ``ImportError`` if any of the files specified in ``only_if_newer_than`` are newer than the file given by filename. r-rrf) find_module load_modulez{} is newer than {}NzFailed to import: '%s')r rrisplitextr version_infoimprrrsr/ ImportErrorr4importlib.utilutilspec_from_file_locationmodule_from_specloader exec_module) rEonly_if_newer_thanrr extrrrsfobjdatadepmod importlibspecs rimport_module_from_filers76x(JD$  &ID# ::c?1 D a0*4$8h ) S77##H-0@0@0EE%&;&B&B3&QRR S$h5 J ~~55dHE <6AB Bnn--d3 $ Jrcvddlm}|D]}||}|s|s||fcStdj|)a< Finds binary first matching name among candidates. Calls ``which`` from shutils for provided candidates and returns first hit. Parameters ========== candidates : iterable of str Names of candidate commands Raises ====== CompilerNotFoundError if no candidates match. r)whichz$No binary located for candidates: {})r8rrr4) candidatesrc binary_paths rfind_binary_of_commandrsG" "Ah k> !" F M Mj Y ZZrcDg}|D]}||vs|j||S)z) Uniquify a list (skip duplicate items). )rI)lresultxs r unique_listr2s0 F  F? MM!  Mr)r-rT)FTNFF)) collectionsrhashlibrr r8r rHsympy.testing.pytestrrr3r Exceptionrr!r(r1r9rBrDrPr_rbrprrrrrrrs" & - =I= *# 8:>-2GR&*% 4jA 0(-`[4r