U l a+@sdgZddlZddlZddlZddlZddlZddlZddlZddl Zddl Zddl Zddl m Z ddlmZddlmZddlZddlmZddlmZddlmZmZdd l mZdd lmZdd lmZdd lmZdd lm Z ddl!m"Z"m#Z#m$Z$ddl%m&Z&ddl'Z'ddl'm(Z(ddl)m*Z*ddl+m,Z,ddl-Z-e.de.dddZ/ddZ0ddZ1ddZ2e3e4fZ5ddZ6d d!Z7d"d#Z8d$d%Z9d&d'Z:d(d)Z;d*d+Zd0d1Z?d2d3Z@d4d5ZAe*ejBjCZDGd6ddeDZCGd7d8d8e&ZEdS)9 DistributionN) strtobool)DEBUGtranslate_longopt) defaultdict)message_from_file)DistutilsOptionErrorDistutilsSetupError) rfc822_escape) StrictVersion)six) packaging) ordered_set)mapfilter filterfalse)SetuptoolsDeprecationWarning)windows_support) get_unpatched)parse_configurationz&setuptools.extern.packaging.specifiersz#setuptools.extern.packaging.versioncCstdtt|S)NzDo not call this function)warningswarnDistDeprecationWarningr)clsrPC:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-wx4infiz\setuptools\dist.py_get_unpatched+s rcCst|dd}|dkr|js |jr*td}nd|jdk sT|jdk sTt|dddk sT|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*      r0cs t|fdd}fdd}td|_|d|_|d|_|d|_|d |_d |_|d |_d |_ |d |_ |d |_ dkr|d|_ nd |_ |d|_ |d|_dkr|dd|_|d|_|d|_|jtdkr |d|_|d|_|d|_nd |_d |_d |_d S)z-Reads the metadata values from a file object.cs|}|dkrdS|S)NUNKNOWNr)namevaluemsgrr _read_fieldJsz"read_pkg_file.._read_fieldcs|d}|gkrdS|SN)get_all)r2valuesr4rr _read_listPs z!read_pkg_file.._read_listzmetadata-versionr2versionsummaryauthorNz author-emailz home-pagelicensez download-url descriptionkeywords,platform classifierr"r*r)r+)rr rr2r;r?r=r& author_emailr'urlr>r-long_descriptionsplitr@ platformsr,r*r)r+)r.filer6r:rr4r read_pkg_fileFs:                 rJc s}tjrfdd}n fdd}|dt||d|d|d|d|td kr|d  |d  n.d }|D]$\}}t |}|d k r|||q|d j r|dj jD]}|dd|qt} |d| d} | r:|d| |td krdD]} |d| qPndddddtdr|djjr|djjr jD]} |d| qd S)z5Write the PKG-INFO format data to a file object. csd||fdSNz%s: %s )writeZ _encode_fieldkeyr3rIr.rr write_fieldsz#write_pkg_file..write_fieldcsd||fdSrK)rLrM)rIrrrPszMetadata-VersionNameVersionZSummaryz Home-pager!Author Author-email))rSr=)rTrD)Z Maintainerr&)zMaintainer-emailr'NZLicensez Download-URLz Project-URLz%s, %s DescriptionrAZKeywordsPlatform ClassifierRequiresProvides Obsoletesr zRequires-PythonzDescription-Content-TypezProvides-Extra)r0r PY2strget_name get_versionget_descriptionget_urlr get_contactget_contact_emailr# get_licenser-r(itemsr get_long_descriptionjoin get_keywords get_platforms _write_listget_classifiers get_requires get_provides get_obsoleteshasattrr r$r%) r.rIr;rPZoptional_fieldsfieldattrZattr_val project_url long_descr@rBextrarrOrwrite_pkg_file|sZ             rtc CsPztjd|}|jrtWn,ttttfk rJtd||fYnXdS)Nzx=z4%r must be importable 'module:attrs' string (got %r)) pkg_resources EntryPointparseextrasAssertionError TypeError ValueErrorAttributeErrorr )distrpr3eprrrcheck_importablesrc CsZz(t|ttfstd||ks&tWn,ttttfk rTtd||fYnXdS)z"Verify that value is a string listz%%r must be a list of strings (got %r)N) isinstancelisttupleryrfrzr{r|r r}rpr3rrrassert_string_lists rcCsd|}t||||D]J}||s2tdd||d\}}}|r||krtjd||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)rhas_contents_forr rpartition distutilslogr)r}rpr3Z ns_packagesnspparentsepchildrrr check_nsps    rc Cs@zttt|Wn"tttfk r:tdYnXdS)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) r itertoolsstarmap _check_extrardrzr{r|r rrrr check_extrass rcCs<|d\}}}|r*t|r*td|tt|dS)N:zInvalid environment marker: ) partitionruinvalid_markerr rparse_requirements)rsreqsr2rmarkerrrrrs rcCs&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}))rpr3N)boolr format)r}rpr3tmplrrr assert_bool s rc Csjz(tt|t|ttfr&tdWn<ttfk rd}zd}t|j ||dW5d}~XYnXdS)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}rperrorN) rrurrdictsetrzr{r rr}rpr3rrrrrcheck_requirementss rc CsRztj|Wn<tjjk rL}zd}t|j||dW5d}~XYnXdS)z.Verify that value is a valid version specifierzF{attr!r} must be a string containing valid version specifiers; {error}rN)r specifiers SpecifierSetInvalidSpecifierr rrrrrcheck_specifiers rc Cs@ztj|Wn*tk r:}z t|W5d}~XYnXdS)z)Verify that entry_points map is parseableN)rurv parse_mapr{r )r}rpr3errrcheck_entry_points*srcCst|tjstddS)Nztest_suite must be a string)rr string_typesr rrrrcheck_test_suite2s rcCs\t|tstd||D]6\}}t|tjsDtd||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)rrr rrdr rr)r}rpr3kvrrrcheck_package_data7s  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)rematchrrr)r}rpr3pkgnamerrrcheck_packagesFs  rc@sFeZdZdZdeejejdZdZddZ dGddZ e dd Z e d d Z d d ZddZe ddZddZddZdHddZe ddZdIddZdJddZdd 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*dS)KraG 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|ksd|krdStt|d}tjj|}|dk rh|dshtt|d|_ ||_ dS)Nr2r;zPKG-INFO) ru safe_namer\lower working_setby_keyget has_metadata safe_version_version _patched_dist)r.attrsrNr}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]}||kr||}qq|r|nd}tj||qjjj_dS)N package_datasrc_rootdependency_linkssetup_requiresdistutils.setup_keywordscs i|]\}}|jkr||qSr)_DISTUTILS_UNSUPPORTED_METADATA.0rrr.rr s z)Distribution.__init__..)rnr dist_filespoprrrrruiter_entry_pointsvars setdefaultr2 _Distribution__init__rdrmetadata__dict__setattr_normalize_version_validate_versionr;_finalize_requires)r.rZhave_package_datar~optiondefaultsourcer3rrrrs2   zDistribution.__init__cCsPt|tjs|dkr|Sttj|}||krLd}t|j ft |S|S)Nz)Normalizing '{version}' to '{normalized}') r setuptoolssicr\rr;rRrrrlocals)r; normalizedrrrrrszDistribution._normalize_versionc Csft|tjrt|}|dk rbztj|Wn4tjjtfk r`t d|t |YSX|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.) rnumbersNumberr\rr;rRInvalidVersionrzrrrr)r;rrrrs 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`. r Nextras_requirerr) r#r rrkeysrGr%add_convert_extras_requirements"_move_install_requirements_markers)r.rsrrrrs   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) r#rr_tmp_extras_requirerdrur _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. rr)rr\reqrrrrszDistribution._suffix_forcsdd}tddpd}tt|}t||}t||}ttt|_|D]}j dt|j  |qNt fddj D_dS) zv Move requirements in `install_requires` that are using environment markers `extras_require`. cSs|j Sr7rrrrr is_simple_reqszFDistribution._move_install_requirements_markers..is_simple_reqinstall_requiresNrrc3s,|]$\}}|ddtj|DfVqdS)cSsg|] }t|qSr)r\)rrrrr szMDistribution._move_install_requirements_markers...N)r _clean_reqrrrr szBDistribution._move_install_requirements_markers..)r#rrurrrrr\rrrrrrdr)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}tjs>tjtjkr>ddddddd d d d d ddg }ng}t|}|dkrZ|}t rh| d|}|D]}t j |dd4}t r| dj fttjr|jn|j|W5QRX|D]\}||}||} |D]>} | dkr| |kr|||| } | dd} || f| | <qq|qrd|jkr|jdD]\} \} } |j| } zF| r|t|| t|  n(| dkrt|| t| n t|| | Wn,tk r}z t|W5d}~XYnXqHdS)z Adapted from distutils.dist.Distribution.parse_config_files, this method provides the same functionality in subtly-improved ways. r) ConfigParserz 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)Z(setuptools.extern.six.moves.configparserrr r[sysr base_prefix frozensetfind_config_filesrannounceioopenrrreadfp read_filesectionsoptionsget_option_dict_try_strrreplacercommand_optionsrd negative_optrrr{r )r. filenamesrignore_optionsparserfilenamereaderrr opt_dictoptvalsrcaliasr5rrr_parse_config_files)s`           z Distribution._parse_config_filescCs.tjs |Sz |WStk r(YnX|S)ab On Python 2, much of distutils relies on string values being of type 'str' (bytes) and not unicode text. If the value can be safely encoded to bytes using the default encoding, prefer that. Why the default encoding? Because that value can be implicitly decoded back to text if needed. Ref #1653 )r r[encodeUnicodeEncodeError)rrrrr gs  zDistribution._try_strc Cs^|}|dkr||}tr,|d||D]"\}\}}trZ|d|||fzdd|jD}Wntk rg}YnXz |j}Wntk ri}YnXz~t|t j } ||kr| rt |||t | nJ||kr| rt ||t |n,t ||rt |||ntd|||fWq4tk rV} z t| W5d} ~ XYq4Xq4dS)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')get_command_namer rrrdboolean_optionsr|rrr rrrrnr r{) r. command_obj option_dict command_namerrr3 bool_optsneg_opt is_stringr5rrr_set_command_options{sF           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.rr'rrrparse_config_filess  zDistribution.parse_config_filescCs8tjjt||jdd}|D]}tjj|ddq|S)zResolve pre-setup requirementsT) installerreplace_conflicting)r )rurresolverfetch_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|Sr7)load)rrrrz/Distribution.finalize_options..)rNN)rrursorted)r.groupr0epsr~rrrfinalize_optionss zDistribution.finalize_optionscCsJtdD]:}t||jd}|dk r |j|jd|||j|q dS)Nrr))rurr#r2requirer,r1)r.r~r3rrr_finalize_setup_keywordss z%Distribution._finalize_setup_keywordscCs*t|ddr dd|jD|_ng|_dS)Nconvert_2to3_doctestscSsg|]}tj|qSr)ospathabspathrprrrrsz8Distribution._finalize_2to3_doctests..)r#r;rrrr_finalize_2to3_doctestss   z$Distribution._finalize_2to3_doctestsc Csvtjtjd}tj|srt|t|tj|d}t|d$}| d| d| dW5QRX|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. ) r<r=rfcurdirexistsmkdirrZ hide_filerrL)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.rr,rrrr,s zDistribution.fetch_build_eggcCs\||jkr|j|Std|}|D]*}|j|jd||j|<}|St||S)z(Pluggable version of get_command_class()distutils.commandsr8N)cmdclassrurr9r,r1rget_command_class)r.commandr6r~rIrrrrJs   zDistribution.get_command_classcCs:tdD]$}|j|jkr |}||j|j<q t|SNrH)rurr2rIr+rprint_commandsr.r~rIrrrrMs  zDistribution.print_commandscCs:tdD]$}|j|jkr |}||j|j<q t|SrL)rurr2rIr+rget_command_listrNrrrrO 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)rdr# _include_misc)r.rrrincluderrrrQs  zDistribution.includecsfd|jr&fdd|jD|_|jrDfdd|jD|_|jrbfdd|jD|_dS)z9Remove packages, modules, and extensions in named packagercs"g|]}|kr|s|qSr startswithr?packagepfxrrr,s z0Distribution.exclude_package..cs"g|]}|kr|s|qSrrRr?rTrrr2s cs&g|]}|jkr|js|qSr)r2rSr?rTrrr8s N)packages py_modules ext_modules)r.rUrrTrexclude_package's   zDistribution.exclude_packagecCs2|d}|D]}||ks&||rdSqdS)z.rsequencer r#r|r)r.r2r3oldrr`r _exclude_miscFs    zDistribution._exclude_misccst|tstd||fzt||Wn tk rHtd|YnXdkr`t|||n:ttsxt|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|]}|kr|qSrrr^rcrrrmsz.Distribution._include_misc..ra)r.r2r3newrrerrPYs$    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)rdr#rd)r.rrrexcluderrrrgps  zDistribution.excludecCs,t|tstd|ftt|j|dS)Nz.packages: setting must be a list or tuple (%r))rrbr rrrZ)r.rWrrr_exclude_packagess  zDistribution._exclude_packagesc Cs|jj|_|jj|_|d}|d}||krf||\}}||=ddl}||d|dd<|d}q&t|||}||} t | ddrd|f||d<|dk rgS|S)NraliasesTrZcommand_consumes_arguments command lineargs) __class__global_optionsrr shlexrGr_parse_command_optsrJr#) r.rrkrKrirrrnnargs cmd_classrrrros"       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. rjrrrrNzShouldn't be able to get herer) rrdr get_command_objrcopyupdater#ryr) r.dcmdoptsrrrZcmdobjr$negposrrrget_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)rWrXrYrrr2endswith)r.pkgr{extr2Z buildinforrrr[s    z$Distribution.iter_distribution_namesc Csddl}tjs|jr t||St|jtj s:t||S|jj dkrVt||S|jj }|jj }|j dkrtdpvd}|jj}t |jd||||_zt||WSt |j|||||_XdS)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)rutf8win32 r)rr r[ help_commandsrhandle_display_optionsrstdoutr TextIOWrapperrrerrorsrBline_bufferingdetach)r. option_orderrrrnewlinerrrrrs6    z#Distribution.handle_display_options)N)N)N)NF)+r __module__ __qualname____doc__rrZ OrderedSetrrrr staticmethodrrrrrrrrr r&r(r-r7r:rArGr,rJrMrOrQrZrrdrPrgrhrorzr[rrrrrrRsX4 "    >  /     (c@seZdZdZdS)rzrClass for warning about deprecations in dist in setuptools. Not ignored by default, unlike DeprecationWarning.N)rrrrrrrrrsr)F__all__rrrr<rrZ distutils.logrdistutils.core distutils.cmddistutils.distdistutils.utilrdistutils.debugrdistutils.fancy_getoptrr collectionsremailrdistutils.errorsr r r Zdistutils.versionr Zsetuptools.externr rrZsetuptools.extern.six.movesrrrrrrrZsetuptools.monkeyrZsetuptools.configrru __import__rr0rJrtrrrbrrrrrrrrrrrrcorerrrrrrrsp              6L    8