a oeU@s.dgZddlZddlZddlZddlZddlZddlZddlmZddl m Z ddl m Z ddl mZmZmZddlZddlZddlZddlZddlZddlmZddlmZmZdd lmZdd lmZd d l m!Z!m"Z"d d l#m$Z$d dl%m&Z&m'Z'd dl(m)Z)m*Z*d dl+m,Z,d dl-m.Z.d dl-m/Z/d dl-m0Z0d dl-m1Z2d dl3m4Z4d dl5m6Z6m7Z7d dl8m9Z9d dl:m;Z;d dlZ>e?e@fZAddZBddZCddZDd d!ZEd"d#ZFd$d%ZGd&d'ZHd(d)ZId*d+ZJd,d-ZKd.d/ZLd0d1ZMd2d3ZNd4d5ZOe;ejPjQZRGd6ddeRZQGd7d8d8e>ZSdS)9 DistributionN)suppress)iglob)Path)ListOptionalSet)DEBUG)DistutilsOptionErrorDistutilsSetupErrortranslate_longopt) strtobool) partitionunique_everseen) OrderedSet) InvalidMarkerMarker)InvalidSpecifier SpecifierSet)Version) _entry_points)_normalization)_reqs)command)metadata)setupcfg pyprojecttoml)ConfigDiscovery) get_unpatched)InformationOnlySetuptoolsDeprecationWarningc Csbztj|ddd}|jrJWn>ttttfy\}ztd||f|WYd}~n d}~00dS)N)valuenamegroupz4%r must be importable 'module:attrs' string (got %r))rZ EntryPointextras TypeError ValueErrorAttributeErrorAssertionErrorr )distattrr#eper/0C:\Program Files\Certbot\pkgs\setuptools\dist.pycheck_importable-s r1c Cslz(t|ttfsJd||ks&JWn>ttttfyf}ztd||f|WYd}~n d}~00dS)z"Verify that value is a string listz%%r must be a list of strings (got %r)N) isinstancelisttuplejoinr'r(r)r*r r+r,r#r.r/r/r0assert_string_list7s r8cCst|}t||||D]Z}||s2tdd||d\}}}|r^||vr^tjd||tjddddqd S) 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.pyz/The namespace_packages parameter is deprecated.zr?)r+r,r#Zpkgnamer/r/r0check_packagess  rkcsxeZdZdZddeeddddeedZdZdd Z dSd d Z d d Z ddZ e ddZddZddZddZe ddZdTddZddZddZd d!ZdUd"d#Zd$d%ZdVd'd(Zd)d*Zd+d,Ze d-d.Zd/d0Zd1d2Zd3d4Zd5d6Z d7d8Z!d9d:Z"d;d<Z#d=d>Z$d?d@Z%dAdBZ&dCdDZ'dEdFZ(dGdHZ)dIdJZ*dKdLZ+dMdNZ,dOdPZ-fdQdRZ.Z/S)WraG 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. cCsdSrQr/r/r/r/r0zDistribution.cCsdSrQr/r/r/r/r0rlrmcCsdSrQr/r/r/r/r0rl rm)Zlong_description_content_typeZ project_urlsprovides_extras license_file license_filesinstall_requiresextras_requireNcCs|rd|vsd|vrdStt|d}ttjFt|}|durp|dspt t|d|_ ||_ Wdn1s0YdS)Nr$versionzPKG-INFO) rZ safe_namerdlowerrrPackageNotFoundError distribution read_textZ safe_versionZ_version _patched_dist)selfattrsr$r+r/r/r0patch_missing_pkg_infos  z#Distribution.patch_missing_pkg_infocst|d}|si|_|pi}g|_|dd|_|||dg|_|dg|_tj ddD]}t | |j dqbt |jddh8fd d |D}t||t |_t||_||||jj|j_|dS) N package_datasrc_rootdependency_linkssetup_requiresdistutils.setup_keywordsr%rqrrcsi|]\}}|vr||qSr/r/.0rfrgZ metadata_onlyr/r0 .rmz)Distribution.__init__..)hasattrr|Z dist_filespopr}r{r~rr entry_pointsvars setdefaultr$r]_DISTUTILS_UNSUPPORTED_METADATArH _Distribution__init__Z_referenced_filesr set_defaults_set_metadata_defaults_normalize_versionrs_finalize_requires)ryrzZhave_package_datar-Z dist_attrsr/rr0rs(       zDistribution.__init__cs@dh}fddtjD}||}|r?sz2Distribution._validate_metadata..z&Required package metadata is missing: )rrr )ryrequiredZprovidedmissingrPr/rr0_validate_metadata=s  zDistribution._validate_metadatacCs4|jD]$\}}t|j||||q dS)z Fill-in missing metadata fields not supported by distutils. Some fields may have been set by other tools (e.g. pbr). Those fields (vars(self.metadata)) take precedence to supplied attrs. N)rrHrrrget)ryrzoptiondefaultr/r/r0rJsz#Distribution._set_metadata_defaultscCslddlm}t|tjr"t|}nt||s4|dur8|Stt|}||krhtd|d|d|S|S)Nr)sicz Normalizing 'z' to '') r2rr3numbersNumberrdrr!r@)rsrZ normalizedr/r/r0rTs    zDistribution._normalize_versioncCslt|ddr|j|j_||j|j_|j|j_|jrh|jD]$}|dd}|rB|jj |qBdS)z Set `metadata.python_requires` and fix environment markers in `install_requires` and `extras_require`. python_requiresNrJr) rrr_normalize_requiresrqrrkeyssplitrnadd)ryrNr/r/r0rds    zDistribution._finalize_requirescCsNt|ddpg}t|ddpi}tttt||_dd|D|_dS)zAMake sure requirement-related attributes exist and are normalizedrqNrrc Ss*i|]"\}}|tttt|pgqSr/)r4maprdrrMrr/r/r0r|sz4Distribution._normalize_requires..) rr4rrdrrMrqrHrr)ryrqrrr/r/r0rws z Distribution._normalize_requirescCs`|jj}|r|ng}|jj}|r2||vr2|||durF|durFd}tt|||j_dS)z>> list(Distribution._expand_patterns(['LICENSE'])) ['LICENSE'] >>> list(Distribution._expand_patterns(['setup.cfg', 'LIC*'])) ['setup.cfg', 'LICENSE'] css:|]2}tt|D] }|dstj|r|VqqdS)~N)sortedrendswithospathisfile)rpatternrr/r/r0 sz0Distribution._expand_patterns..r/)rr/r/r0rszDistribution._expand_patternsc Csddlm}tjtjkrgngd}t|}|dur<|}trJ|d|}t |_ |D]}t |dd6}tr|dj fit ||Wdn1s0Y|D]d}||}||} |D]F} | d ks| |vrq||| } || |} || |} || f| | <qq|qZd |jvr8dS|jd D]\} \} } |j| } | rpt|  } n| d vrt| } zt|| p| | Wn0ty}zt||WYd}~n d}~00qFdS) 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-8encodingz reading {filename}__name__global)verbosedry_run)Z configparserrsysr base_prefix frozensetZfind_config_filesr announcerdZ optionxformopenrTlocalsZ read_fileZsectionsoptionsget_option_dictrwarn_dash_deprecationmake_option_lowercasercommand_optionsrH negative_optrsetattrr(r )ry filenamesrZignore_optionsparserfilenamereadersectionrZopt_dictoptvalsrcaliasr.r/r/r0_parse_config_filessP   (           z Distribution._parse_config_filescCsz|dvr |S|dd}tttjj|}|dsN|dkrN||vrN|Sd|vrvt j dd|d|d d d d |S) N)zoptions.extras_requirezoptions.data_files-_rrzInvalid dash-separated optionsz) Usage of dash-separated zZ will not be supported in future versions. Please use the underscore name z instead. !userguide/declarative_config.htmli r:Zdue_date) replacer4rEchainr=r__all___setuptools_commands startswithr"r@)ryrrZunderscore_optZcommandsr/r/r0rs8  z"Distribution.warn_dash_deprecationcCs.ztdjjWStjy(gYS0dS)NZ setuptools)rrvrnamesrurr/r/r0rsz!Distribution._setuptools_commandsc CsF|dks|r|S|}tjdd|d|d|dddd |S) NrzInvalid uppercase configurationz$ Usage of uppercase key z in zL will not be supported in future versions. Please use lowercase z instead. rrr)islowerrtr"r@)ryrrZ lowercase_optr/r/r0rs  z"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|qSr/r )ror/r/r0 Crmz5Distribution._set_command_options..z1error in %s: command '%s' has no such option '%s')Zget_command_namerr rrHZboolean_optionsr)rr3rdrrrr r() ryZ command_objZ option_dictZ command_namersourcer#Z bool_optsneg_optZ is_stringr.r/r/r0_set_command_options-s>           z!Distribution._set_command_optionscCs\g}t|jptjd}|durFtdd|}t|d}t|d}n|rT|g}||fS)z/Add default file and split between INI and TOMLzpyproject.tomlNcSst|jdkS)Nz.toml)rsuffix)fr/r/r0rl`rmz8Distribution._get_project_config_files..rr)rr}rcurdirrr4exists)ryr tomlfilesZstandard_project_metadatapartsr/r/r0_get_project_config_files[s z&Distribution._get_project_config_filesFcCsX||\}}|j|dtj||j|d|D]}t|||q0||dS)zXParses configuration files from various levels and loads configuration. )r)ignore_option_errorsN) rrrZparse_configurationrrZapply_configurationrr)ryrrZinifilesrrr/r/r0parse_config_filesgs zDistribution.parse_config_filescCsddlm}|||S)zResolve pre-setup requirementsr)_fetch_build_eggs) installerr)ryZrequiresrr/r/r0fetch_build_eggsxs zDistribution.fetch_build_eggscCsRd}dd}tj|d}t|j|}tdd|}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)hookr/r/r0by_ordersz/Distribution.finalize_options..by_orderrcSs|SrQ)ra)r.r/r/r0rlrmz/Distribution.finalize_options..)rN)rrrE filterfalse_removedrr)ryr%rZdefinedZfilteredZloadedr-r/r/r0finalize_options~s zDistribution.finalize_optionscCsdh}|j|vS)z When removing an entry point, if metadata is loaded from an older version of Setuptools, that removed entry point will attempt to be loaded and will fail. See #2765 for more details. Z 2to3_doctests)r$)r-Zremovedr/r/r0rs zDistribution._removedcCs>tjddD],}t||jd}|dur |||j|q dS)Nrr)rrrr$ra)ryr-r#r/r/r0_finalize_setup_keywordssz%Distribution._finalize_setup_keywordscCsddlm}tjtjd}tj|st|||tj|d}t |d.}| d| d| dWdn1s0Y|S) Nr)windows_supportz.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. ) r2rrrr6rrmkdirZ hide_filerwrite)ryrZ egg_cache_dirZreadme_txt_filenamerr/r/r0get_egg_cache_dirs     (zDistribution.get_egg_cache_dircCsddlm}|||S)z Fetch an egg needed for buildingr)fetch_build_egg)rr)ryZreqrr/r/r0rs zDistribution.fetch_build_eggcCsP||jvr|j|Stjd|d}|D]}||j|<}|St||S)z(Pluggable version of get_command_class()distutils.commands)r%r$N)cmdclassrrrarget_command_class)ryrZepsr-rr/r/r0rs  zDistribution.get_command_classcCs<tjddD]$}|j|jvr |}||j|j<q t|SNrr)rrr$rrarprint_commandsryr-rr/r/r0rs  zDistribution.print_commandscCs<tjddD]$}|j|jvr |}||j|j<q t|Sr)rrr$rrarget_command_listrr/r/r0rs  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)rHr _include_misc)ryrzrfrgincluder/r/r0r s  zDistribution.includecsfd|jr&fdd|jD|_|jrDfdd|jD|_|jrbfdd|jD|_dS)z9Remove packages, modules, and extensions in named packager9cs"g|]}|kr|s|qSr/rrppackagepfxr/r0rsz0Distribution.exclude_package..cs"g|]}|kr|s|qSr/r r r r/r0rscs&g|]}|jkr|js|qSr/)r$rr r r/r0rsN)packages py_modules ext_modules)ryrr/r r0exclude_packages   zDistribution.exclude_packagecCs2|d}|D]}||ks&||rdSqdS)z.r3sequencer rr)r)ryr$r#oldr.r/rr0 _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)rNrcsg|]}|vr|qSr/r/rrr/r0r.rmz.Distribution._include_misc..r)ryr$r#r.newr/rr0rs $ 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)rHrr)ryrzrfrgexcluder/r/r0r 1s  zDistribution.excludecCs,t|tstd|ftt|j|dS)Nz.packages: setting must be a list or tuple (%r))r3rr r4rr)ryrr/r/r0_exclude_packagesHs  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_optionsrrshlexrr_parse_command_optsrr) ryrr$rr"rrr&nargsZ cmd_classr/r/r0r'Os"       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) rrHrZget_command_objrcopyupdaterr*r) rydcmdZoptsrrrZcmdobjrnegposr/r/r0get_cmdline_optionsjs(     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 distributionr/moduleNi)rrrr3r5r$r)rypkgr0extr$Z buildinfor/r/r0rs    z$Distribution.iter_distribution_namesc Csddl}|jrt||St|jtjs4t||S|jj dvrPt||S|jj}|jj ddzt||W|jj |dS|jj |d0dS)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)rutf8rr) rZ help_commandsrhandle_display_optionsr3stdoutio TextIOWrapperrrt reconfigure)ryZ option_orderrrr/r/r0r4s    z#Distribution.handle_display_optionscs|t|dSrQ)rsuper run_command)ryrr%r/r0r:szDistribution.run_command)N)N)N)NF)0r __module__ __qualname____doc__r\rr4rrxr{rrr staticmethodrrrrrrrrrrrrrrrrrrrrrr rr;rrr r!r'r/rr4r: __classcell__r/r/r;r0rsd4        O" .    &c@seZdZdZdS)rWzrClass for warning about deprecations in dist in setuptools. Not ignored by default, unlike DeprecationWarning.N)rr<r=r>r/r/r/r0rWsrW)Trr6rErrrir contextlibrglobrpathlibrtypingrrrZ distutils.cmdr=Zdistutils.commandZdistutils.coreZdistutils.distZ distutils.logZdistutils.debugr Zdistutils.errorsr r Zdistutils.fancy_getoptr Zdistutils.utilrZextern.more_itertoolsrrZextern.ordered_setrZextern.packaging.markersrrZextern.packaging.specifiersrrZextern.packaging.versionrr2rrrrrZ _importlibrZconfigrrZ discoveryrZmonkeyr warningsr!r"r5r4rr1r8rDrIrGrLrVrYr_r`rcrerhrkZcorerrrWr/r/r/r0sp                    {