_d:ddlmZddlmZddlmZddlmcmZddl Z ddl Z ddl Z ddl Z ddl ZddlZddlZddlmZddlmZmZmZmZmZmZddlmZdd lmZd ZGd d ejZd ZGddZ y))partial)glob) convert_pathN)Path)DictIterableIteratorListOptionalTuple)unique_everseen)SetuptoolsDeprecationWarningctj|tj|jtjzyN)oschmodstatst_modeS_IWRITE)targets =/usr/lib/python3/dist-packages/setuptools/command/build_py.py make_writablers'HHVRWWV_,,t}}<=c:eZdZUdZdZeed<dZee ed<dZ dfd Z dZ d Z d Zd Zd Zd ZdZd dee ffd Zdee e ffdZdeee e ffdZdeee e ffdZdZdZdee de dee fdZdZdZ dZ!dZ"dZ#e$dZ%xZ&S)!build_pyaXEnhanced 'build_py' command that includes data files with packages The data files are specified via a 'package_data' argument to 'setup()'. See 'setuptools.dist.Distribution' for more details. Also, this version of the 'build_py' command allows you to specify both 'py_modules' and 'packages' in the same setup operation. F editable_modeNexisting_egg_info_dirctjj||jj|_|jj xsi|_d|j vr |j d=g|_y)N data_files)origrfinalize_options distribution package_dataexclude_package_data__dict___build_py__updated_filesselfs rr"zbuild_py.finalize_options$sa &&t, --::$($5$5$J$J$Pb! 4== ( l+!rc|rDtt|j}tt|j}t|||||||Sr)strrresolvesuper copy_file)r)infileoutfile preserve_modepreserve_timeslinklevel __class__s rr.zbuild_py.copy_file,sU f--/0F$w-//12Gw G]ND%  rc>|js |jr |jry|jr|j|jr |j |j |j tjj|dy)z?Build modules, packages, and copy data files to build directoryNr)include_bytecode) py_modulespackagesr build_modulesbuild_packagesbuild_package_data byte_compiler!r get_outputsr(s rrunz build_py.run7sp4==T5G5G  ??    ==    !  # # % $--33D13MNrc|dk(r!|j|_|jStjj ||S)zlazily compute data filesr )_get_data_filesr r!r __getattr__)r)attrs rrBzbuild_py.__getattr__Gs; < "224DO?? "}}((t44rctjj||||\}}|r|jj |||fSr)r!r build_moduler'append)r)module module_filepackager0copieds rrEzbuild_py.build_moduleNsB--44T6;PWX   ' ' 0rc||jtt|j|jxsdS)z?Generate list of '(package,src_dir,build_dir,filenames)' tuples)analyze_manifestlistmap_get_pkg_data_filesr9r(s rrAzbuild_py._get_data_filesTs/ C00$--2E2FGGrc|jjditt|j|j xsdS)z Generate list of ``(package,src_dir,build_dir,filenames)`` tuples, but without triggering any attempt to analyze or build the manifest. manifest_filesrL)r& setdefaultrNrOrPr9r(s rget_data_files_without_manifestz(build_py.get_data_files_without_manifestYs:   !126C00$--2E2FGGrc&|j|}tjj|jg|j dz}|j ||Dcgc]"}tjj||$}}||||fScc}wN.)get_package_dirrpathjoin build_libsplitfind_data_filesrelpath)r)rIsrc_dir build_dirfile filenamess rrPzbuild_py._get_pkg_data_filescs&&w/GGLLDNN#3gmmC6H#HJ ,,Wg>  GGOOD' *  I55  s'Bc~|j|j||}tttd|}t j j|}ttjj|}t j |jj|g|}|j|||S)z6Return filenames for package's data files in 'src_dir'T) recursive)_get_platform_patternsr$rOrr itertoolschain from_iterablefilterrrYisfilerRgetexclude_data_files)r)rIr_patternsglobs_expanded globs_matches glob_filesfiless rr]zbuild_py.find_data_filesqs..       WTT:HE!55nE BGGNNM:     # #GR 0  &&w??rreturnc|jr't|jjSt||S)1See :class:`setuptools.commands.build.SubCommand`)rrNget_output_mappingkeysr-r>)r)r7r5s rr>zbuild_py.get_outputss:   //16689 9w"#344rctj|j|j}t t |dS)rtc |dS)NrrL)xs rz-build_py.get_output_mapping..s !A$r)key)rfrg _get_package_data_output_mapping_get_module_mappingdictsorted)r)mappings rruzbuild_py.get_output_mappings<//  1 1 3  $ $ & F7788rc#K|jD]:\}}}|jd}|j|j||}||f<yw)z5Iterate over all modules producing (dest, src) pairs.rWN)find_all_modulesr\get_module_outfiler[)r)rIrGrHfilenames rr}zbuild_py._get_module_mappingsV,0,A,A,C * (GV[mmC(G..t~~wOH[) ) *sAAc#K|jD]T\}}}}|D]H}tjj||}tjj||}||fJVyw)z6Iterate over package data producing (dest, src) pairs.N)r rrYrZ)r)rIr_r`rbrrsrcfiles rr|z)build_py._get_package_data_output_mappingsd6:oo ( 2GWi% (i:'',,w9w'' ( (sA%A'c|jD]S\}}|jtjj ||j ||\}}t |Uy)z$Copy data files into build directoryN)r|mkpathrrYdirnamer.r)r)rr_outf_copieds rr<zbuild_py.build_package_datasS#DDF "OFG KK/ 0!^^GVz/build_py._filter_build_files..s-TQay.@-TsN) rr[ build_temp build_baserrYnormpathisabsall) r)rqrr build_dirsp norm_dirsrars @rrzbuild_py._filter_build_filess**730@0@%BRBRS 2<BQRWW%%a(B B D((.I77==&#-T)-T*T  Cs:C C!C&AC  C cyrrLr(s rget_data_fileszbuild_py.get_data_filess rc |j|S#t$rYnwxYwtjj |||}||j|<|r|j j s|S|j j D]}||k(s|j|dzsn|Stj|d5}|j}dddn #1swYnxYwdvr#tjjd|d|S)z8Check namespace packages' __init__ for declare_namespacerWrbNsdeclare_namespacezNamespace package problem: z is a namespace package, but its __init__.py does not call declare_namespace()! Please fix it. (See the setuptools manual under "Namespace Packages" for details.) ")packages_checkedKeyErrorr!r check_packager#namespace_packages startswithioopenread distutilserrorsDistutilsError)r)rI package_dirinit_pypkgrcontentss rrzbuild_py.check_packages  ((1 1   ----dG[I)0g&d//BBN$$77 Cg~# !> N WWWd # qvvxH   x /""11.sO7ug6Os #c3,K|] }|vs| ywrrL)rfnbads rrz.build_py.exclude_data_files..s7"327s )rNrer%rfrgrhsetr) r)rIr_rqrm match_groupsmatcheskeepersrs ` @rrlzbuild_py.exclude_data_filessoU ..  % %    PhO //// ='l77OG,--rctj|jdg|j|g}fd|DS)z yield platform-specific path patterns (suitable for glob or fn_match) from a glob-based spec (such as self.package_data or self.exclude_package_data) matching package in src_dir. c3pK|]-}tjjt|/ywr)rrYrZr)rrr_s rrz2build_py._get_platform_patterns..+s/  GGLL,w"7 8 s36)rfrgrk)specrIr_ raw_patternss ` rrezbuild_py._get_platform_patternssC! HHR  HHWb !  (  r)rNr)r)'__name__ __module__ __qualname____doc__rbool__annotations__rr r+r"r.r?rBrErArTrPr]r r>rrur r r}r|r<rMrrrrrrXrl staticmethodre __classcell__)r5s@rrrs  M4+/8C=/"TU  O 5 H H 6@"5c5 9DcN9*XeCHo%>*((5c?2K("'eZdZdZGddeZdZdZdZdZ y) rz>Inform users that package or module is included as 'data file'ceZdZdZdZy)!_IncludePackageDataAbuse._WarningzU Package {importable!r} is absent from the `packages` configuration. a| ############################ # Package would be ignored # ############################ Python recognizes {importable!r} as an importable package[^1], but it is absent from setuptools' `packages` configuration. This leads to an ambiguous overall configuration. If you want to distribute this package, please make sure that {importable!r} is explicitly added to the `packages` configuration field. Alternatively, you can also rely on setuptools' discovery methods (for example by using `find_namespace_packages(...)`/`find_namespace:` instead of `find_packages(...)`/`find:`). You can read more about "package discovery" on setuptools documentation page: - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html If you don't want {importable!r} to be distributed and are already explicitly excluding {importable!r} via `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`, you can try to use `exclude_package_data`, or `include-package-data=False` in combination with a more fine grained `package-data` configuration. You can read more about "package data files" on setuptools documentation page: - https://setuptools.pypa.io/en/latest/userguide/datafiles.html [^1]: For Python, any directory (with suitable naming) can be imported, even if it does not contain any `.py` files. On the other hand, currently there is no concept of package data directory, all directories are treated like packages. N)rrr_SUMMARY_DETAILSrLrr_WarningrJs " rrc"t|_yr)r_already_warnedr(s r__init__z!_IncludePackageDataAbuse.__init__us "urcb|jdxr|dtd jS)Nz.py)endswithlen isidentifier)r)ras rrz"_IncludePackageDataAbuse.is_modulexs,}}U#J]E {(;(H(H(JJrct|j}ttjt j |j}|rdj|g|SyrV) rparentrNrf takewhiler+rpartsrZ)r)rrarrs rrz._IncludePackageDataAbuse.importable_subpackage{sO4jY(()9)9399EF 88V,e,- -rc||jvr8|jj||jj|yy)N)r)rremitadd)r)rs rrz_IncludePackageDataAbuse.warns> T11 1 MM  *  5  $ $Z 0 2rN) rrrrrrrrrrrLrrrrGs(H' /' V%K1rr)! functoolsrrdistutils.utilrdistutils.command.build_pycommandrr!rrrrrrrfrpathlibrtypingrrr r r r extern.more_itertoolsrwarningsrrrrrLrrr s_'))   BB33>X t}}X v#*>1>1r