a [dg֜@sdgZddlZddlZddlZddlZddlZddlZddlZddl Zddl Zddl Zddl Zddl mZddlmZddlmZddlZddlmZddlmZddlmZmZdd l mZdd lmZdd lmZdd lm Z d dl!m"Z"ddl#Z#ddl$Z#ddl#m%Z%ddl&m'Z'ddl(m)Z)ddl*Z*e+de+dddZ,ddZ-ddZ.ddZ/ddZ0e1e2fZ3ddZ4d d!Z5d"d#Z6d$d%Z7d&d'Z8d(d)Z9d*d+Z:d,d-Z;d.d/Zd4d5Z?e'ej@jAZBGd6ddeBZAGd7d8d8e"ZCdS)9 DistributionN) strtobool)DEBUGtranslate_longopt) defaultdict)message_from_file)DistutilsOptionErrorDistutilsSetupError) rfc822_escape) StrictVersion) packaging) ordered_set)SetuptoolsDeprecationWarning)windows_support) get_unpatched)parse_configurationz&setuptools.extern.packaging.specifiersz#setuptools.extern.packaging.versioncCstdtt|S)NzDo not call this function)warningswarnDistDeprecationWarningr)clsr9/usr/local/lib/python3.9/site-packages/setuptools/dist.py_get_unpatched+s rcCst|dd}|dur|js |jr*td}nd|jdusT|jdusTt|dddusT|jr^td}n0|js||js||j s||j s||j rtd}ntd}||_ |S)Nmetadata_versionz2.1python_requires1.21.1z1.0) getattrlong_description_content_typeprovides_extrasr maintainermaintainer_email project_urlsprovidesrequires obsoletes classifiers download_urlr)selfmvrrrget_metadata_version0s*      r,cs t|fdd}fdd}td|_|d|_|d|_|d|_|d |_d |_|d |_d |_ |d |_ |d |_ dvr|d|_ nd |_ |d|_ |d|_dvr|dd|_|d|_|d|_|jtdkr |d|_|d|_|d|_nd |_d |_d |_d S)z-Reads the metadata values from a file object.cs|}|dkrdS|S)NZUNKNOWNr)namevaluemsgrr _read_fieldJsz"read_pkg_file.._read_fieldcs|d}|gkrdS|SN)Zget_all)r-valuesr/rr _read_listPs z!read_pkg_file.._read_listzmetadata-versionr-versionZsummaryauthorNz author-emailz home-pagelicensez download-url descriptionkeywords,platformZ classifierrr&r%r')rr rr-r5r8r6r" author_emailr#urlr7r)Zlong_descriptionsplitr9Z platformsr(r&r%r')r*filer1r4rr/r read_pkg_fileFs:                 r@cCs"d|vrtd|dd}|S)N z1newlines not allowed and will break in the future )rrreplace)valrrr single_line{s  rEc s|}fdd}|dt||d||d||dt||d||tdkr|d ||d | n.d }|D]$\}}t ||}|d ur|||q|d | |j r|d|j |j D]}|dd|qt|} |d| d|} | r(|d| |tdkrR|D]} |d| q>n|d||d||d||d||d|t|dr|d|j|jr|d|j|jr|jD]} |d| qd S)z5Write the PKG-INFO format data to a file object. csd||fdS)Nz%s: %s )write)keyr.r?rr write_fieldsz#write_pkg_file..write_fieldzMetadata-VersionNameVersionZSummaryz Home-pagerAuthor Author-email))rLr6)rMr<)Z Maintainerr")zMaintainer-emailr#NZLicensez Download-URLz Project-URLz%s, %sZ Descriptionr:ZKeywordsZPlatformZ ClassifierZRequiresZProvidesZ ObsoletesrzRequires-PythonzDescription-Content-TypezProvides-Extra)r,strget_nameZ get_versionrEZget_descriptionZget_urlr Z get_contactZget_contact_emailrZ get_licenser)r$itemsr Zget_long_descriptionjoinZ get_keywordsZ get_platformsZ _write_listZget_classifiersZ get_requiresZ get_providesZ get_obsoleteshasattrrr r!) r*r?r5rIZoptional_fieldsZfieldattrZattr_valZ project_urlZ long_descr9r;extrarrHrwrite_pkg_filesV             rUc CsXztjd|}Wn>ttttfyR}ztd||f|WYd}~n d}~00dS)Nzx=z4%r must be importable 'module:attrs' string (got %r)) pkg_resources EntryPointparse TypeError ValueErrorAttributeErrorAssertionErrorr )distrSr.eperrrcheck_importablesr`c CsHzWn>ttttfyB}ztd||f|WYd}~n d}~00dS)z"Verify that value is a string listz%%r must be a list of strings (got %r)N)rYrZr[r\r r]rSr.r_rrrassert_string_lists rbcCsd|}t||||D]J}||s2tdd||d\}}}|r||vrtjd||qdS)z(Verify that namespace packages are validz1Distribution contains no modules or packages for znamespace package %r.z^WARNING: %r is declared as a package namespace, but %r is not: please correct this in setup.pyN)rbhas_contents_forr rpartition distutilslogr)r]rSr.Z ns_packagesZnspparentsepchildrrr check_nsps   rkc CsRzttt|Wn4tttfyL}ztd|WYd}~n d}~00dS)z+Verify that extras_require mapping is validz'extras_require' must be a dictionary whose values are strings or lists of strings containing valid project/version requirement specifiers.N) list itertoolsstarmap _check_extrarPrYrZr[r rarrr check_extrassrpcCs<|d\}}}|r*t|r*td|tt|dS)N:zInvalid environment marker: ) partitionrVZinvalid_markerr rlparse_requirements)rTZreqsr-rimarkerrrrros rocCs&t||kr"d}t|j||ddS)z)Verify that value is True, False, 0, or 1z0{attr!r} must be a boolean value (got {value!r}))rSr.N)boolr format)r]rSr.tmplrrr assert_bools rxc Csnz(tt|t|ttfr&tdWn@ttfyh}z$d}t|j ||d|WYd}~n d}~00dS)z9Verify that install_requires is a valid requirements listzUnordered types are not allowedzm{attr!r} must be a string or list of strings containing valid project/version requirement specifiers; {error}rSerrorN) rlrVrs isinstancedictsetrYrZr rvr]rSr.rzrwrrrcheck_requirementss  rc CsZztj|WnDtjjtfyT}z$d}t|j||d|WYd}~n d}~00dS)z.Verify that value is a valid version specifierzF{attr!r} must be a string containing valid version specifiers; {error}ryN)r Z specifiersZ SpecifierSetZInvalidSpecifierr[r rvr~rrrcheck_specifier%s rc CsDztj|Wn.ty>}zt||WYd}~n d}~00dS)z)Verify that entry_points map is parseableN)rVrWZ parse_maprZr rarrrcheck_entry_points3srcCst|tstddS)Nztest_suite must be a string)r{rNr )r]rSr.rrrcheck_test_suite;s rcCsZt|tstd||D]4\}}t|tsBtd||t|d||q dS)z@Verify that value is a dictionary of package names to glob listszT{!r} must be a dictionary mapping package names to lists of string wildcard patternsz,keys of {!r} dict must be strings (got {!r})zvalues of {!r} dictN)r{r|r rvrPrNrb)r]rSr.kvrrrcheck_package_data@s  rcCs(|D]}td|stjd|qdS)Nz \w+(\.\w+)*z[WARNING: %r not a valid package name; please use only .-separated package names in setup.py)rematchrfrgr)r]rSr.Zpkgnamerrrcheck_packagesOs  rc@sJeZdZdZdeejejdZdZddZ dIddZ e dd Z e d d Z d d ZddZe ddZddZddZdJddZddZddZdKddZdLdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Z d3d4Z!d5d6Z"d7d8Z#d9d:Z$d;d<Z%d=d>Z&d?d@Z'dAdBZ(dCdDZ)dEdFZ*dGdHZ+dS)MraG Distribution with support for tests and package data This is an enhanced version of 'distutils.dist.Distribution' that effectively adds the following new optional keyword arguments to 'setup()': 'install_requires' -- a string or sequence of strings specifying project versions that the distribution requires when installed, in the format used by 'pkg_resources.require()'. They will be installed automatically when the package is installed. If you wish to use packages that are not available in PyPI, or want to give your users an alternate download location, you can add a 'find_links' option to the '[easy_install]' section of your project's 'setup.cfg' file, and then setuptools will scan the listed web pages for links that satisfy the requirements. 'extras_require' -- a dictionary mapping names of optional "extras" to the additional requirement(s) that using those extras incurs. For example, this:: extras_require = dict(reST = ["docutils>=0.3", "reSTedit"]) indicates that the distribution can optionally provide an extra capability called "reST", but it can only be used if docutils and reSTedit are installed. If the user installs your package using EasyInstall and requests one of your extras, the corresponding additional requirements will be installed if needed. 'test_suite' -- the name of a test suite to run for the 'test' command. If the user runs 'python setup.py test', the package will be installed, and the named test suite will be run. The format is the same as would be used on a 'unittest.py' command line. That is, it is the dotted name of an object to import and call to generate a test suite. 'package_data' -- a dictionary mapping package names to lists of filenames or globs to use to find data files contained in the named packages. If the dictionary has filenames or globs listed under '""' (the empty string), those names will be searched for in every package, in addition to any names for the specific package. Data files found using these names/globs will be installed along with the package, in the same location as the package. Note that globs are allowed to reference the contents of non-package subdirectories, as long as you use '/' as a path separator. (Globs are automatically converted to platform-specific paths at runtime.) In addition to these new keywords, this class also has several new methods for manipulating the distribution's contents. For example, the 'include()' and 'exclude()' methods can be thought of as in-place add and subtract commands that add or remove packages, modules, extensions, and so on from the distribution. N)r r$r!Z license_filescCsl|rd|vsd|vrdStt|d}tjj|}|durh|dshtt|d|_ ||_ dS)Nr-r5zPKG-INFO) rVZ safe_namerNlower working_setZby_keygetZ has_metadataZ safe_versionZ_version _patched_dist)r*attrsrGr]rrrpatch_missing_pkg_infosz#Distribution.patch_missing_pkg_infocstd}|si_|pi}g_|dd_||dg_|dg_t dD]}t  |j dq`t fdd|DjD]J\}}jj|fD]}||vr||}qq|r|nd}tj||qjjj_dS)N package_datasrc_rootdependency_linkssetup_requiresdistutils.setup_keywordscs i|]\}}|jvr||qSr)_DISTUTILS_UNSUPPORTED_METADATA.0rrr*rr s z)Distribution.__init__..)rRrZ dist_filespoprrrrrViter_entry_pointsvars setdefaultr- _Distribution__init__rPrmetadata__dict__setattr_normalize_version_validate_versionr5_finalize_requires)r*rZhave_package_datar^optiondefaultsourcer.rrrrs2   zDistribution.__init__cCsTt|tjs|dur|Sttj|}||krPd}t|j fit |S|S)Nz)Normalizing '{version}' to '{normalized}') r{ setuptoolssicrNr r5rKrrrvlocals)r5Z normalizedrwrrrrszDistribution._normalize_versionc Csdt|tjrt|}|dur`ztj|Wn2tjjtfy^t d|t |YS0|S)NzThe version specified (%r) is an invalid version, this may not work as expected with newer versions of setuptools, pip, and PyPI. Please see PEP 440 for more details.) r{numbersNumberrNr r5rKZInvalidVersionrYrrrr)r5rrrrs zDistribution._validate_versioncCsft|ddr|j|j_t|ddrR|jD]$}|dd}|r,|jj|q,|| dS)z Set `metadata.python_requires` and fix environment markers in `install_requires` and `extras_require`. rNextras_requirerqr) rrrrkeysr>r!add_convert_extras_requirements"_move_install_requirements_markers)r*rTrrrrs   zDistribution._finalize_requirescCsht|ddpi}tt|_|D]@\}}|j|t|D]"}||}|j|||q>q"dS)z Convert requirements in `extras_require` of the form `"extra": ["barbazquux; {marker}"]` to `"extra:{marker}": ["barbazquux"]`. rN) rrrl_tmp_extras_requirerPrVrs _suffix_forappend)r*Z spec_ext_reqssectionrrsuffixrrrrs   z)Distribution._convert_extras_requirementscCs|jrdt|jSdS)ze For a requirement, return the 'extras_require' suffix for that requirement. rq)rtrNreqrrrr szDistribution._suffix_forcsdd}tddpd}tt|}t||}t||}ttt|_ |D]}j dt|j  |qPt fddj D_dS) zv Move requirements in `install_requires` that are using environment markers `extras_require`. cSs|j Sr2rtrrrr is_simple_reqszFDistribution._move_install_requirements_markers..is_simple_reqinstall_requiresNrrqc3s,|]$\}}|ddtj|DfVqdS)cSsg|] }t|qSr)rN)rrrrr 'zMDistribution._move_install_requirements_markers...N)map _clean_reqrrrr &szBDistribution._move_install_requirements_markers..)rrlrVrsfilterrm filterfalserrNrrrtrr|rPr)r*rZspec_inst_reqsZ inst_reqsZ simple_reqsZ complex_reqsrrrrrs    z/Distribution._move_install_requirements_markerscCs d|_|S)zP Given a Requirement, remove environment markers and return it. Nr)r*rrrrr+szDistribution._clean_reqc Csddlm}tjtjkrgngd}t|}|dur<|}trJ|d|}t |_ |D]}t j |dd6}tr|dj fit||Wdn1s0Y|D]d}||}||} |D]F} | d ks| |vrq||| } || |} || |} || f| | <qq|qZd |jvr:dS|jd D]\} \} } |j| } | rrt|  } n| d vrt| } zt|| p| | Wn0ty}zt||WYd}~n d}~00qHdS) z Adapted from distutils.dist.Distribution.parse_config_files, this method provides the same functionality in subtly-improved ways. r) ConfigParser) z install-basezinstall-platbasez install-libzinstall-platlibzinstall-purelibzinstall-headerszinstall-scriptsz install-dataprefixz exec-prefixhomeuserrootNz"Distribution.parse_config_files():utf-8)encodingz reading {filename}__name__global)verbosedry_run) configparserrsysr base_prefix frozensetZfind_config_filesrannouncerNZ optionxformioopenrvrZ read_fileZsectionsoptionsget_option_dictrwarn_dash_deprecationmake_option_lowercasercommand_optionsrP negative_optrrrZr )r* filenamesrZignore_optionsparserfilenamereaderrrZopt_dictoptrDsrcaliasr_rrr_parse_config_files3sJ  (           z Distribution._parse_config_filescCsd|dvr |S|dd}tjjtjj}|dsF|dkrF||vrF|Sd|vr`td||f|S)N)zoptions.extras_requirezoptions.data_files-_rrzrUsage of dash-separated '%s' will not be supported in future versions. Please use the underscore name '%s' instead)rCrfcommand__all__r startswithrr)r*rrZunderscore_optcommandsrrrrus z"Distribution.warn_dash_deprecationcCs4|dks|r|S|}td|||f|S)NrzlUsage of uppercase key '%s' in '%s' will be deprecated in future versions. Please use lowercase '%s' instead)islowerrrr)r*rrZ lowercase_optrrrrsz"Distribution.make_option_lowercasec Cs\|}|dur||}tr,|d||D] \}\}}trZ|d|||fzdd|jD}Wntyg}Yn0z |j}Wntyi}Yn0z|t|t } ||vr| rt |||t | nJ||vr| rt ||t |n,t ||rt |||nt d|||fWq4tyT} zt | | WYd} ~ q4d} ~ 00q4dS)a Set the options for 'command_obj' from 'option_dict'. Basically this means copying elements of a dictionary ('option_dict') to attributes of an instance ('command'). 'command_obj' must be a Command instance. If 'option_dict' is not supplied, uses the standard option dictionary for this command (from 'self.command_options'). (Adopted from distutils.dist.Distribution._set_command_options) Nz# setting options for '%s' command:z %s = %s (from %s)cSsg|] }t|qSrr)rorrrrsz5Distribution._set_command_options..z1error in %s: command '%s' has no such option '%s')Zget_command_namerrrrPZboolean_optionsr[rr{rNrrrRr rZ) r*Z command_objZ option_dictZ command_namerrr.Z bool_optsneg_optZ is_stringr_rrr_set_command_optionssF             z!Distribution._set_command_optionsFcCs(|j|dt||j|d|dS)zYParses configuration files from various levels and loads configuration. )r)ignore_option_errorsN)rrrr)r*rrrrrparse_config_filess  zDistribution.parse_config_filescCs8tjjt||jdd}|D]}tjj|ddq|S)zResolve pre-setup requirementsT) installerZreplace_conflicting)rC)rVrresolversfetch_build_eggr)r*r&Zresolved_distsr]rrrfetch_build_eggsszDistribution.fetch_build_eggscCs>d}dd}tddt|}t||dD] }||q,dS)z Allow plugins to apply arbitrary operations to the distribution. Each hook may optionally define a 'order' to influence the order of execution. Smaller numbers go first and the default is 0. z(setuptools.finalize_distribution_optionscSs t|ddS)Norderr)r)hookrrrby_ordersz/Distribution.finalize_options..by_ordercSs|Sr2)load)r_rrrrz/Distribution.finalize_options..)rGN)rrVrsorted)r*grouprepsr^rrrfinalize_optionss zDistribution.finalize_optionscCsJtdD]:}t||jd}|dur |j|jd|||j|q dS)Nrr)rVrrr-requirerr)r*r^r.rrr_finalize_setup_keywordss z%Distribution._finalize_setup_keywordscCs*t|ddr dd|jD|_ng|_dS)Nconvert_2to3_doctestscSsg|]}tj|qSr)ospathabspathrprrrrsz8Distribution._finalize_2to3_doctests..)rrrrrr_finalize_2to3_doctestss   z$Distribution._finalize_2to3_doctestscCstjtjd}tj|st|t|tj|d}t|d.}| d| d| dWdn1s|0Y|S)Nz.eggsz README.txtwzcThis directory contains eggs that were downloaded by setuptools to build, test, and run plug-ins. zAThis directory caches those eggs to prevent repeated downloads. z/However, it is safe to delete this directory. ) rrrQcurdirexistsmkdirrZ hide_filerrF)r*Z egg_cache_dirZreadme_txt_filenamefrrrget_egg_cache_dirs      (zDistribution.get_egg_cache_dircCsddlm}|||S)z Fetch an egg needed for buildingr)r)Zsetuptools.installerr)r*rrrrrr s zDistribution.fetch_build_eggcCs\||jvr|j|Std|}|D]*}|j|jd||j|<}|St||S)z(Pluggable version of get_command_class()distutils.commandsrN)cmdclassrVrrrrrget_command_class)r*rrr^rrrrrs   zDistribution.get_command_classcCs:tdD]$}|j|jvr |}||j|j<q t|SNr)rVrr-rrrprint_commandsr*r^rrrrrs  zDistribution.print_commandscCs:tdD]$}|j|jvr |}||j|j<q t|Sr)rVrr-rrrget_command_listrrrrr#s  zDistribution.get_command_listcKs@|D]2\}}t|d|d}|r.||q|||qdS)aAdd items to distribution that are named in keyword arguments For example, 'dist.include(py_modules=["x"])' would add 'x' to the distribution's 'py_modules' attribute, if it was not already there. Currently, this method only supports inclusion for attributes that are lists or tuples. If you need to add support for adding to other attributes in this or a subclass, you can add an '_include_X' method, where 'X' is the name of the attribute. The method will be called with the value passed to 'include()'. So, 'dist.include(foo={"bar":"baz"})' will try to call 'dist._include_foo({"bar":"baz"})', which can then handle whatever special inclusion logic is needed. Z _include_N)rPr _include_misc)r*rrrincluderrrr+s  zDistribution.includecsfd|jr&fdd|jD|_|jrDfdd|jD|_|jrbfdd|jD|_dS)z9Remove packages, modules, and extensions in named packagerccs"g|]}|kr|s|qSrrrpackagepfxrrrFsz0Distribution.exclude_package..cs"g|]}|kr|s|qSrrrrrrrLscs&g|]}|jkr|js|qSr)r-rrrrrrRsN)packages py_modules ext_modules)r*rrrrexclude_packageAs   zDistribution.exclude_packagecCs2|d}|D]}||ks&||rdSqdS)z.r{sequencer rr[r)r*r-r.oldr_rr$r _exclude_misc`s$  zDistribution._exclude_miscc st|tstd||fzt||Wn2tyZ}ztd||WYd}~n d}~00durrt|||n:ttst|dn"fdd|D}t|||dS)zAHandle 'include()' for list/tuple attrs without a special handlerz%s: setting must be a list (%r)r Nr!csg|]}|vr|qSrrr"r'rrrrz.Distribution._include_misc..r%)r*r-r.r_newrr)rrss(   zDistribution._include_misccKs@|D]2\}}t|d|d}|r.||q|||qdS)aRemove items from distribution that are named in keyword arguments For example, 'dist.exclude(py_modules=["x"])' would remove 'x' from the distribution's 'py_modules' attribute. Excluding packages uses the 'exclude_package()' method, so all of the package's contained packages, modules, and extensions are also excluded. Currently, this method only supports exclusion from attributes that are lists or tuples. If you need to add support for excluding from other attributes in this or a subclass, you can add an '_exclude_X' method, where 'X' is the name of the attribute. The method will be called with the value passed to 'exclude()'. So, 'dist.exclude(foo={"bar":"baz"})' will try to call 'dist._exclude_foo({"bar":"baz"})', which can then handle whatever special exclusion logic is needed. Z _exclude_N)rPrr()r*rrrexcluderrrr+s  zDistribution.excludecCs,t|tstd|ftt|j|dS)Nz.packages: setting must be a list or tuple (%r))r{r&r rlrr)r*rrrr_exclude_packagess  zDistribution._exclude_packagesc Cs|jj|_|jj|_|d}|d}||vrf||\}}||=ddl}||d|dd<|d}q&t|||}||} t | ddrd|f||d<|durgS|S)NraliasesTrZcommand_consumes_arguments command lineargs) __class__Zglobal_optionsrrshlexr>r_parse_command_optsrr) r*rr/rr-rrr1nargsZ cmd_classrrrr2s"       z Distribution._parse_command_optsc Csi}|jD]\}}|D]\}\}}|dkr4q|dd}|dkr||}|j}|t|di|D]\} } | |krv| }d}qqvtdn |dkrd}|| |i|<qq|S) ahReturn a '{cmd: {opt:val}}' map of all command-line options Option names are all long, but do not include the leading '--', and contain dashes rather than underscores. If the option doesn't take an argument (e.g. '--quiet'), the 'val' is 'None'. Note that options provided by config files are intentionally excluded. r.rrrrNzShouldn't be able to get herer) rrPrCZget_command_objrcopyupdaterr\r) r*dcmdZoptsrrrDZcmdobjrnegposrrrget_cmdline_optionss(     z Distribution.get_cmdline_optionsccsv|jpdD] }|Vq |jpdD] }|Vq |jp4dD]:}t|trN|\}}n|j}|drj|dd}|Vq6dS)z@Yield all packages, modules, and extension names in distributionrmoduleNi)rrrr{tupler-endswith)r*Zpkgr;extr-Z buildinforrrrs    z$Distribution.iter_distribution_namesc Csddl}|jrt||St|jtjs4t||S|jj dvrPt||S|jj}|jj }|j dkrndppd}|jj }t|j d||||_z(t||Wt|j |||||_St|j |||||_0dS)zIf there were any non-global "display-only" options (--help-commands or the metadata display options) on the command line, display the requested info and return true; else return false. rN)rutf8win32rAr)rZ help_commandsrhandle_display_optionsr{stdoutr TextIOWrapperrrerrorsr;line_bufferingdetach)r*Z option_orderrrrDnewlinerErrrrAs2    z#Distribution.handle_display_options)N)N)N)NF),r __module__ __qualname____doc__r|rZ OrderedSetrrrr staticmethodrrrrrrrrrrrrrrrrr rrrrrrrdr(rr+r,r2r:rrArrrrr[sX4 "    B /     (c@seZdZdZdS)rzrClass for warning about deprecations in dist in setuptools. Not ignored by default, unlike DeprecationWarning.N)rrHrIrJrrrrrsr)DrrrrrrrZ distutils.logrfZdistutils.coreZ distutils.cmdZdistutils.distZdistutils.commandZdistutils.utilrZdistutils.debugrZdistutils.fancy_getoptrrm collectionsrZemailrZdistutils.errorsr r r Zdistutils.versionr Zsetuptools.externr rrrrZsetuptools.commandrZsetuptools.monkeyrZsetuptools.configrrV __import__rr,r@rErUr<rlr&r`rbrkrprorxrrrrrrZcorerrrrrrrsr             5 H   I