Rep@s_dgZddlZddlZddlZddlZddlZddlZddlZddl Zddl Z ddl m Z ddl mZmZmZddlmZddlmZddlmZmZmZddlmZdd lmZdd lmZdd lm Z dd l!m"Z"ddl#Z#d dl$m%Z%e&de&dddZ'ddZ(ddZ)e*e+fZ,ddZ-ddZ.ddZ/ddZ0dd Z1d!d"Z2d#d$Z3d%d&Z4d'd(Z5d)d*Z6d+d,Z7d-d.Z8e ej9j:Z;Gd/dde%e;Z:Gd0d1d1Z<dS)2 DistributionN) defaultdict)DistutilsOptionErrorDistutilsPlatformErrorDistutilsSetupError) rfc822_escape)six)mapfilter filterfalse) packaging)Require)windows_support) get_unpatched)parse_configuration)Distribution_parse_config_filesz)pkg_resources.extern.packaging.specifiersz&pkg_resources.extern.packaging.versioncCstjdtt|S)NzDo not call this function)warningswarnDeprecationWarningr)clsr/builddir/build/BUILDROOT/alt-python35-setuptools-36.3.0-4.el8.x86_64/opt/alt/python35/lib/python3.5/site-packages/setuptools/dist.py_get_unpatched!srcCsd}|js3|js3|js3|js3|jr9d}t|drNd}|jd||jd|j|jd|j|jd|j |jd |j |jd |j |jd |j |jd |j |jr|jd |jt|j}|jd|dj|j}|rl|jd||j|d|j|j|d|j|j|d|j|j|d|j|j|d|jt|dr |jd|jdS)z5Write the PKG-INFO format data to a file object. z1.0z1.1python_requiresz1.2zMetadata-Version: %s z Name: %s z Version: %s z Summary: %s zHome-page: %s z Author: %s zAuthor-email: %s z License: %s zDownload-URL: %s zDescription: %s ,z Keywords: %s Platform ClassifierRequiresProvides ObsoleteszRequires-Python: %s N)providesrequires obsoletes classifiers download_urlhasattrwriteget_name get_versionget_descriptionget_url get_contactget_contact_email get_licenserget_long_descriptionjoin get_keywords _write_list get_platformsget_classifiers get_requires get_provides get_obsoletesr)selffileversion long_desckeywordsrrrwrite_pkg_file's8 r=c Cs?ttjj|dddd}|j|WdQRXdS)z3Write the PKG-INFO file into the release tree. zPKG-INFOwencodingzUTF-8N)openospathr0r=)r8base_dirpkg_inforrrwrite_pkg_infoRs rEcCsey*tjjd|}|j s)tWn4ttttfk r`td||fYnXdS)Nzx=z4%r must be importable 'module:attrs' string (got %r)) pkg_resources EntryPointparseextrasAssertionError TypeError ValueErrorAttributeErrorr)distattrvalueeprrrcheck_importable]srRcCsZydj||kstWn4ttttfk rUtd||fYnXdS)z*Verify that value is a string list or Nonez%%r must be a list of strings (got %r)N)r0rJrKrLrMr)rNrOrPrrrassert_string_lisths rTcCs|}t|||xq|D]i}|j|sFtdd||jd\}}}|r||krtjjd||qWdS)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)rThas_contents_forr rpartition distutilslogr)rNrOrPZ ns_packagesnspparentsepchildrrr check_nsprs  r^c CsNy ttjt|jWn'tttfk rItdYnXdS)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_extraitemsrKrLrMr)rNrOrPrrr check_extrass  rdcCsT|jd\}}}|r=tj|r=td|ttj|dS)N:zInvalid environment marker: ) partitionrFinvalid_markerrr_parse_requirements)extrareqsnamer\markerrrrrbsrbcCs:t||kr6d}t|jd|d|dS)z)Verify that value is True, False, 0, or 1z0{attr!r} must be a boolean value (got {value!r})rOrPN)boolrformat)rNrOrPtmplrrr assert_boolsrpcCsmyttj|WnOttfk rh}z)d}t|jd|d|WYdd}~XnXdS)z9Verify that install_requires is a valid requirements listzm{attr!r} must be a string or list of strings containing valid project/version requirement specifiers; {error}rOerrorN)r_rFrhrKrLrrn)rNrOrPrqrorrrcheck_requirementss rrcCsjytjj|WnOtjjk re}z)d}t|jd|d|WYdd}~XnXdS)z.Verify that value is a valid version specifierzF{attr!r} must be a string containing valid version specifiers; {error}rOrqN)r specifiers SpecifierSetInvalidSpecifierrrn)rNrOrPrqrorrrcheck_specifiers rvcCsLytjj|Wn1tk rG}zt|WYdd}~XnXdS)z)Verify that entry_points map is parseableN)rFrG parse_maprLr)rNrOrPerrrcheck_entry_pointssrycCs"t|tjstddS)Nztest_suite must be a string) isinstancer string_typesr)rNrOrPrrrcheck_test_suitesr|c Csxt|trdxR|jD]@\}}t|ts8Pyt|Wqtk r[PYqXqWdSt|ddS)z@Verify that value is a dictionary of package names to glob listsNzI must be a dictionary mapping package names to lists of wildcard patterns)rzdictrcstriterrKr)rNrOrPkvrrrcheck_package_datas  rcCs:x3|D]+}tjd|stjjd|qWdS)Nz \w+(\.\w+)*z[WARNING: %r not a valid package name; please use only .-separated package names in setup.py)rematchrXrYr)rNrOrPpkgnamerrrcheck_packagess   rc@seZdZdZdZddZdddZddZd d Ze d d Z d dZ ddZ dddZ ddZddZddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Z d9d:Z!d;d<Z"d=d>Z#d?d@Z$dAdBZ%dCdDZ&dS)EraDistribution with support for features, 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. 'features' **deprecated** -- a dictionary mapping option names to 'setuptools.Feature' objects. Features are a portion of the distribution that can be included or excluded based on user options, inter-feature dependencies, and availability on the current system. Excluded features are omitted from all setup commands, including source and binary distributions, so you can create multiple distributions from the same source tree. Feature names should be valid Python identifiers, except that they may contain the '-' (minus) sign. Features can be included or excluded via the command line options '--with-X' and '--without-X', where 'X' is the name of the feature. Whether a feature is included by default, and whether you are allowed to control this from the command line, is determined by the Feature object. See the 'Feature' class for more information. '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. They are used by the feature subsystem to configure the distribution for the included and excluded features. NcCs| sd|ksd|kr#dStjt|dj}tjjj|}|dk r|jd rtjt|d|_ ||_ dS)Nrkr:zPKG-INFO) rF safe_namer~lower working_setby_keyget has_metadata safe_version_version _patched_dist)r8attrskeyrNrrrpatch_missing_pkg_info'sz#Distribution.patch_missing_pkg_infoc Cst|d}|si|_|p'i}d|ksBd|krLtjg|_i|_g|_|o||jdd|_|j ||dk r|jdg|_ t |d|j |rd|kr|j |dx0t jdD]}t|j|jdqWtj||t|jjtjrYt|jj|j_|jjdk ryctjj|jj}t|}|jj|krtjd|jj|f||j_Wn5tjjtfk rtjd |jjYnX|j dS) N package_datafeaturesrequire_featuressrc_rootdependency_linksZsetup_requireszdistutils.setup_keywordszNormalizing '%s' to '%s'zThe 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&rFeaturewarn_deprecatedrr dist_filespoprrrrTfetch_build_eggsrFiter_entry_pointsvars setdefaultrk _Distribution__init__rzmetadatar:numbersNumberr~r VersionrrInvalidVersionrK_finalize_requires)r8rZhave_package_dataZ _attrs_dictrQverZnormalized_versionrrrr4sH           zDistribution.__init__cCs9t|ddr!|j|j_|j|jdS)z Set `metadata.python_requires` and fix environment markers in `install_requires` and `extras_require`. rN)getattrrr_convert_extras_requirements"_move_install_requirements_markers)r8rrrrbs zDistribution._finalize_requirescCst|ddpi}tt|_xf|jD]X\}}|j|x>tj|D]-}|j|}|j||j|q[Wq4WdS)z Convert requirements in `extras_require` of the form `"extra": ["barbazquux; {marker}"]` to `"extra:{marker}": ["barbazquux"]`. extras_requireN) rrr__tmp_extras_requirercrFrh _suffix_forappend)r8Z spec_ext_reqssectionrrsuffixrrrrls z)Distribution._convert_extras_requirementscCs|jrdt|jSdS)ze For a requirement, return the 'extras_require' suffix for that requirement. rerS)rlr~)reqrrrr{szDistribution._suffix_forcsdd}tddp!f}ttj|}t||}t||}ttt|_x/|D]'}j dt|j j |qvWt fddj j D_dS)zv Move requirements in `install_requires` that are using environment markers `extras_require`. cSs|j S)N)rl)rrrr is_simple_reqszFDistribution._move_install_requirements_markers..is_simple_reqinstall_requiresNrec3s:|]0\}}|ddtj|DfVqdS)cSsg|]}t|qSr)r~).0rrrr s zMDistribution._move_install_requirements_markers...N)r _clean_req)rrr)r8rr szBDistribution._move_install_requirements_markers..)rr_rFrhr r r r~rrrlrr}rcr)r8rZspec_inst_reqsZ inst_reqsZ simple_reqsZ complex_reqsrr)r8rrs  %z/Distribution._move_install_requirements_markerscCs d|_|S)zP Given a Requirement, remove environment markers and return it. N)rl)r8rrrrrs zDistribution._clean_reqcCs1tj|d|t||j|jdS)zYParses configuration files from various levels and loads configuration. filenamesN)rparse_config_filesrcommand_optionsr)r8rrrrrszDistribution.parse_config_filescCs&tj|}|jr"|j|S)z3Process features after parsing command line options)rparse_command_liner_finalize_features)r8resultrrrrs  zDistribution.parse_command_linecCsd|jddS)z;Convert feature name to corresponding option attribute nameZwith_-_)replace)r8rkrrr_feature_attrnameszDistribution._feature_attrnamecCsUtjjtj|d|jdd}x$|D]}tjj|ddq1W|S)zResolve pre-setup requirements installerreplace_conflictingTr)rFrresolverhfetch_build_eggadd)r8r"Zresolved_distsrNrrrrs    zDistribution.fetch_build_eggscCstj||jr |jxdtjdD]S}t||jd}|dk r0|jd|j |j ||j|q0Wt|ddrdd|j D|_ n g|_ dS)Nzdistutils.setup_keywordsrconvert_2to3_doctestscSs"g|]}tjj|qSr)rArBabspath)rprrrrs z1Distribution.finalize_options..) rfinalize_optionsr_set_global_opts_from_featuresrFrrrkrequirerloadr)r8rQrPrrrrs     zDistribution.finalize_optionsc Cstjjtjd}tjj|stj|tj|tjj|d}t|d.}|j d|j d|j dWdQRX|S)Nz.eggsz README.txtr>zcThis 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. ) rArBr0curdirexistsmkdirrZ hide_filer@r')r8Z egg_cache_dirZreadme_txt_filenamefrrrget_egg_cache_dirs    zDistribution.get_egg_cache_dirc Csfy|j}g|j_Wn=tk rXddlm}|jddgi}|j|jd}d}x't |D]}||kr}||=q}W|j r|j d d }d|kr|dd j |}d |f|d<|j } ||d dgd| dddddd dddddddddd }|j ||_YnX|j|S)z Fetch an egg needed for buildingr) easy_install script_argsr find_links site_dirs index_urloptimize allow_hostsNrsetupargsx install_dirZexclude_scriptsTZ always_copyFZbuild_directoryeditableupgradeZ multi_versionZ no_reportuser)rrrrrr)Z _egg_fetcherZ package_indexZto_scanrMZsetuptools.command.easy_installr __class__rget_option_dictr_rsplitrensure_finalized) r8rcmdrrNoptsZkeeprlinksrrrrrs6         zDistribution.fetch_build_eggc Cs g}|jj}x|jjD]\}}|j|d|j||jr%|j}d}d}|js||}}d|dd||fd|dd||ff}|j |d||d|.cs2g|](}|kr|j r|qSr)r)rr)rrrrrs cs8g|].}|jkr|jj r|qSr)rkr)rr)rrrrrs N)packages py_modules ext_modules)r8rr)rrrexclude_packagezs  " " zDistribution.exclude_packagecCsD|d}x3|jD]%}||ks8|j|rdSqWdS)z.)rzsequencerrrMr)r8rkrPoldr)rPr _exclude_miscs zDistribution._exclude_miscc st|ts%td||fyt||Wn"tk r\td|YnXdkr|t|||nOttst|dn-fdd|D}t|||dS)zAHandle 'include()' for list/tuple attrs without a special handlerz%s: setting must be a list (%r)z %s: No such distribution settingNz4: this setting cannot be changed via include/excludecs"g|]}|kr|qSrr)rr )rrrrs z.Distribution._include_misc..)rzr rrrMr)r8rkrPrr)rrrs  zDistribution._include_misccKsZxS|jD]E\}}t|d|d}|rB||q |j||q WdS)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)rcrr)r8rrrexcluderrrrs  zDistribution.excludecCs<t|ts"td|ftt|j|dS)Nz.packages: setting must be a list or tuple (%r))rzr rr_r r )r8rrrr_exclude_packagesszDistribution._exclude_packagesc Cs|jj|_|jj|_|d}|jd}xY||kr||\}}||=ddl}|j|d|dd<|d}q:Wtj|||}|j|} t | ddrd|f|j|d<|dk rgS|S)NraliasesTrZcommand_consumes_argumentsz command liner) rrrrshlexrr_parse_command_optsrr) r8parserrrrsrcaliasrnargs cmd_classrrrrs"   z Distribution._parse_command_optsc Csi}x|jjD]\}}x|jD]\}\}}|dkrPq/|jdd}|dkr|j|}|jj}|jt|dixT|jD]%\} } | |kr| }d}PqWtdn|dkrd}||j |i|`_ and will be removed in a future version. A subset of the distribution that can be excluded if unneeded/wanted Features are created using these keyword arguments: 'description' -- a short, human readable description of the feature, to be used in error messages, and option help messages. 'standard' -- if true, the feature is included by default if it is available on the current system. Otherwise, the feature is only included if requested via a command line '--with-X' option, or if another included feature requires it. The default setting is 'False'. 'available' -- if true, the feature is available for installation on the current system. The default setting is 'True'. 'optional' -- if true, the feature's inclusion can be controlled from the command line, using the '--with-X' or '--without-X' options. If false, the feature's inclusion status is determined automatically, based on 'availabile', 'standard', and whether any other feature requires it. The default setting is 'True'. 'require_features' -- a string or sequence of strings naming features that should also be included if this feature is included. Defaults to empty list. May also contain 'Require' objects that should be added/removed from the distribution. 'remove' -- a string or list of strings naming packages to be removed from the distribution if this feature is *not* included. If the feature *is* included, this argument is ignored. This argument exists to support removing features that "crosscut" a distribution, such as defining a 'tests' feature that removes all the 'tests' subpackages provided by other features. The default for this argument is an empty list. (Note: the named package(s) or modules must exist in the base distribution when the 'setup()' function is initially called.) other keywords -- any other keyword arguments are saved, and passed to the distribution's 'include()' and 'exclude()' methods when the feature is included or excluded, respectively. So, for example, you could pass 'packages=["a","b"]' to cause packages 'a' and 'b' to be added or removed from the distribution as appropriate. A feature must include at least one 'requires', 'remove', or other keyword argument. Otherwise, it can't affect the distribution in any way. Note also that you can subclass 'Feature' to create your own specialized feature types that modify the distribution in other ways when included or excluded. See the docstrings for the various methods here for more detail. Aside from the methods, the only feature attributes that distributions look at are 'description' and 'optional'. cCs d}tj|tdddS)NzrFeatures are deprecated and will be removed in a future version. See https://github.com/pypa/setuptools/issues/65. stacklevel)rrr)msgrrrrszFeature.warn_deprecatedFTc Ks|j||_||_||_||_t|ttfrL|f}dd|D|_dd|D}|r||d.cSs%g|]}t|ts|qSr)rzr~)rrrrrrs rzgFeature %s: must define 'require_features', 'remove', or at least one of 'packages', 'py_modules', etc.) rrstandard availablerrzr~r rremoverIr) r8rrBrCrrrDrIZerrrrrs$          zFeature.__init__cCs|jo|jS)z+Should this feature be included by default?)rCrB)r8rrrrszFeature.include_by_defaultcCsQ|jst|jd|j|jx|jD]}|j|q6WdS)aEnsure feature and its requirements are included in distribution You may override this in a subclass to perform additional operations on the distribution. Note that this method may be called more than once per feature, and so should be idempotent. z3 is required, but is not available on this platformN)rCrrrrIrr)r8rNrrrrrs zFeature.include_incCs>|j|j|jr:x|jD]}|j|q#WdS)a2Ensure feature is excluded from distribution You may override this in a subclass to perform additional operations on the distribution. This method will be called at most once per feature, and only after all included features have been asked to include themselves. N)rrIrDr )r8rNr rrrrs  zFeature.exclude_fromcCsCx<|jD]1}|j|s td|j||fq WdS)aVerify that feature makes sense in context of distribution This method is called by the distribution just before it parses its command line. It checks to ensure that the 'remove' attribute, if any, contains only valid package/module names that are present in the base distribution when 'setup()' is called. You may override it in a subclass to perform any other required validation of the feature against a target distribution. zg%s wants to be able to remove %s, but the distribution doesn't contain any packages or modules under %sN)rDrVrr)r8rNr rrrrs zFeature.validateN) r:r;r<r=r>rrrrrrrrrrrYs 7    r)=__all__rrArrZ distutils.logrXdistutils.core distutils.cmddistutils.distr` collectionsrdistutils.errorsrrrdistutils.utilrZsetuptools.externrZsetuptools.extern.six.movesr r r Zpkg_resources.externr Zsetuptools.dependsr setuptoolsrZsetuptools.monkeyrZsetuptools.configrrFZ py36compatr __import__rr=rEr%r_r rRrTr^rdrbrprrrvryr|rrcorerrrrrrrsX               +         z