o ~ReT @sddlmZddlmZddlmmZddlZddlZddl Z ddl Z ddl Z ddl Z ddlZddlmZddZGdddejZd d ZdS) )glob) convert_pathN)unique_everseencCst|t|jtjBdSN)oschmodstatst_modeS_IWRITE)targetr /builddir/build/BUILDROOT/alt-python310-setuptools-58.3.0-2.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/setuptools/command/build_py.py make_writablesrc@seZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddZeddZd 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. cCs@tj||jj|_|jjpi|_d|jvr|jd=g|_dS)N data_files)origrfinalize_options distribution package_dataexclude_package_data__dict___build_py__updated_filesselfr r r rs    zbuild_py.finalize_optionscCsN|js|jsdS|jr||jr|||tjj|dddS)z?Build modules, packages, and copy data files to build directoryNr)Zinclude_bytecode) py_modulespackagesZ build_modulesZbuild_packagesbuild_package_data byte_compilerr get_outputsrr r r run$s z build_py.runcCs&|dkr ||_|jStj||S)zlazily compute data filesr)_get_data_filesrrr __getattr__)rattrr r r r!4s zbuild_py.__getattr__cCs.tj||||\}}|r|j|||fSr)rr build_modulerappend)rmoduleZ module_filepackageoutfilecopiedr r r r#;s zbuild_py.build_modulecCs|tt|j|jp dS)z?Generate list of '(package,src_dir,build_dir,filenames)' tuplesr )analyze_manifestlistmap_get_pkg_data_filesrrr r r r Aszbuild_py._get_data_filescsJ||tjj|jg|d}fdd||D}|||fS)N.csg|] }tj|qSr )rpathrelpath).0filesrc_dirr r Ns z0build_py._get_pkg_data_files..)get_package_dirrr.join build_libsplitfind_data_files)rr& build_dir filenamesr r2r r,Fs    zbuild_py._get_pkg_data_filescCsX||j||}tt|}tj|}ttj j |}t|j |g|}| |||S)z6Return filenames for package's data files in 'src_dir')_get_platform_patternsrr+r itertoolschain from_iterablefilterrr.isfilemanifest_filesgetexclude_data_files)rr&r3patternsZglobs_expandedZ globs_matchesZ glob_filesfilesr r r r9Ts   zbuild_py.find_data_filesc Cst|jD]4\}}}}|D]+}tj||}|tj|tj||}|||\}} t|tj|}q qdS)z$Copy data files into build directoryN) rrr.r6mkpathdirname copy_filerabspath) rr&r3r:r;filenamer srcfileoutfr(r r r reszbuild_py.build_package_datac Csi|_}|jjs dSi}|jpdD] }||t||<q|d|d}|jj D]N}t j t|\}}d}|} |ra||kra||vra|}t j |\}} t j | |}|ra||kra||vsF||vrz|dro|| kroq,|||g|q,dS)Nr egg_infoz.py)rBrZinclude_package_datarassert_relativer5 run_commandget_finalized_commandfilelistrFrr.r8r6endswith setdefaultr$) rZmfZsrc_dirsr&Zei_cmdr.dfprevZoldfZdfr r r r)ps.    zbuild_py.analyze_manifestcCsdSrr rr r r get_data_filesszbuild_py.get_data_filescCsz|j|WStyYnwtj|||}||j|<|r#|jjs%|S|jjD]}||ks6||dr8nq)|St |d }| }Wdn1sPwYd|vrbt j d|f|S)z8Check namespace packages' __init__ for declare_namespacer-rbNsdeclare_namespacezNamespace package problem: %s 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_checkedKeyErrorrr check_packagerZnamespace_packages startswithioopenread distutilserrorsDistutilsError)rr& package_dirZinit_pypkgrVcontentsr r r r\s0      zbuild_py.check_packagecCsi|_tj|dSr)rZrrinitialize_optionsrr r r rgszbuild_py.initialize_optionscCs0tj||}|jjdurtj|jj|S|Sr)rrr5rZsrc_rootrr.r6)rr&resr r r r5s zbuild_py.get_package_dircs\t||j||}fdd|D}tj|}t|fddD}tt|S)z6Filter filenames for package's data files in 'src_dir'c3s|] }t|VqdSr)fnmatchr@r0pattern)rFr r z.build_py.exclude_data_files..c3s|] }|vr|VqdSrr )r0fn)badr r rlrm)r*r<rr=r>r?setr)rr&r3rFrEZ match_groupsmatchesZkeepersr )rorFr rDs  zbuild_py.exclude_data_filescs.t|dg||g}fdd|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. c3s"|] }tjt|VqdSr)rr.r6rrjr2r r rls  z2build_py._get_platform_patterns..)r=r>rC)specr&r3Z raw_patternsr r2r r<s   zbuild_py._get_platform_patternsN)__name__ __module__ __qualname____doc__rrr!r#r r,r9rr)rXr\rgr5rD staticmethodr<r r r r rs$  rcCs6tj|s|Sddlm}td|}||)Nr)DistutilsSetupErrorz Error: setup script specifies an absolute path: %s setup() arguments must *always* be /-separated paths relative to the setup.py directory, *never* absolute paths. )rr.isabsdistutils.errorsrytextwrapdedentlstrip)r.rymsgr r r rOs    rO)rdistutils.utilrZdistutils.command.build_pycommandrrrrir|r^r{rar=rZ setuptools.extern.more_itertoolsrrrOr r r r s   E