U +aZ>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJdd l;Z;ejKde;jLddddddgZMddZNddZOdd ZPd!d"ZQd#d$ZRGd%dde,ZSd&d'ZTd(d)ZUd*d+ZVd,dZWd-dZXGd.ddeBZYGd/d0d0eYZZej[\d1d2d3kreZZYd4d5Z]d6d7Z^d8d9Z_d:d;Z`dhdd?Zbd@dAZcdBejdkrecZendCdDZedidFdGZfdHdIZgdJdKZhdLdMZizddNlmjZkWnelk r.dOdPZkYnXdQdRZjGdSdTdTemZnenoZpGdUdVdVenZqGdWdXdXZrGdYdZdZerZsGd[d\d\esZterjuZuerjvZvd]d^Zwd_d`Zxdae^fdbdcZydddeZzGdfdgdge+Z{d S)ja% Easy Install ------------ A tool for doing automatic download/extract/build of distutils-based Python packages. For detailed documentation, see the accompanying EasyInstall.txt file, or visit the `EasyInstall home page`__. __ https://setuptools.readthedocs.io/en/latest/easy_install.html )glob) get_platform) convert_path subst_vars)DistutilsArgErrorDistutilsOptionErrorDistutilsErrorDistutilsPlatformError)INSTALL_SCHEMES SCHEME_KEYS)logdir_util) first_line_re)find_executableN)get_config_varsget_path)SetuptoolsDeprecationWarning)Command) run_setup)setopt)unpack_archive) PackageIndexparse_requirement_arg URL_SCHEME) bdist_eggegg_info)Wheel) yield_linesnormalize_pathresource_stringensure_directoryget_distributionfind_distributions Environment Requirement Distribution PathMetadata EggMetadata WorkingSetDistributionNotFoundVersionConflict DEVELOP_DISTdefault)categorysamefile easy_installPthDistributionsextract_wininst_cfgget_exe_prefixescCstddkS)NP)structcalcsizer7r7G/tmp/pip-install-1bd_1mtk/setuptools/setuptools/command/easy_install.pyis_64bitJsr9cCsjtj|otj|}ttjdo&|}|r:tj||Stjtj|}tjtj|}||kS)z Determine if two paths reference the same file. Augments os.path.samefile to work on Windows and suppresses errors if the path doesn't exist. r.)ospathexistshasattrr.normpathnormcase)p1p2Z both_existZ use_samefileZnorm_p1Znorm_p2r7r7r8r.NscCs |dS)Nutf8)encodesr7r7r8 _to_bytes^srFcCs,z|dWdStk r&YdSXdS)NasciiTF)rC UnicodeErrorrDr7r7r8isasciibs  rIcCst|ddS)N z; )textwrapdedentstripreplace)textr7r7r8 _one_linerjsrPc@seZdZdZdZdZdddddd d d d d ddddddddddddddejfgZddddd d!d"d#d$dg Z d%diZ e Z d&d'Z d(d)Zd*d+Zed,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Zdd8d9Zd:d;Zdd?Zed@ZedAZedBZ dCdDZ!dEdFZ"dGdHZ#dIdJZ$dKdLZ%dMdNZ&e'j(dOdPZ)ddRdSZ*ddTdUZ+dVdWZ,ddXdYZ-dZd[Z.d\d]Z/d^d_Z0dd`daZ1edbdcZ2ddfdgZ3dhdiZ4djdkZ5dldmZ6dndoZ7dpdqZ8drdsZ9edtZ:eduZ;ddwdxZd|d}Z?d~dZ@ddZAddZBddZCddZDddZEedFZGddZHeIeIddddZJeIdddZKddZLdS)r/z'Manage a download/build/install processz Find/get/install Python packagesT)zprefix=Nzinstallation prefix)zip-okzzinstall package as a zipfile) multi-versionmz%make apps have to require() a version)upgradeUz1force upgrade (searches PyPI for latest versions))z install-dir=dzinstall package to DIR)z script-dir=rEzinstall scripts to DIR)exclude-scriptsxzDon't install scripts) always-copyaz'Copy all needed packages to install dir)z index-url=iz base URL of Python Package Index)z find-links=fz(additional URL(s) to search for packages)zbuild-directory=bz/download/extract/build in DIR; keep the results)z optimize=Ozlalso compile with optimization: -O1 for "python -O", -O2 for "python -OO", and -O0 to disable [default: -O0])zrecord=Nz3filename in which to record list of installed files) always-unzipZz*don't install as a zipfile, no matter what)z site-dirs=Sz)list of directories where .pth files work)editableez+Install specified packages in editable form)no-depsNzdon't install dependencies)z allow-hosts=Hz$pattern(s) that hostnames must match)local-snapshots-oklz(allow building eggs from local checkouts)versionNz"print version information and exit)z no-find-linksNz9Don't load find-links defined in packages being installeduserNz!install in user site-package '%s'rQrSrXrUrZrcrerhrjr`cCs&d|_d|_|_d|_|_|_d|_d|_d|_d|_ d|_ |_ d|_ |_ |_d|_|_|_d|_|_|_d|_d|_d|_d|_d|_d|_d|_d|_d|_tjrtj |_!tj"|_#n d|_!d|_#d|_$d|_%d|_&|_'d|_(i|_)d|_*|j+j,|_,|j+-||j+.ddS)Nrr/)/rkzip_oklocal_snapshots_ok install_dir script_direxclude_scripts index_url find_linksbuild_directoryargsoptimizerecordrU always_copy multi_versionrcno_deps allow_hostsrootprefix no_reportrjinstall_purelibinstall_platlibinstall_headers install_libinstall_scripts install_data install_baseinstall_platbasesiteENABLE_USER_SITE USER_BASEinstall_userbase USER_SITEinstall_usersite no_find_links package_indexpth_filealways_copy_from site_dirsinstalled_projects_dry_run distributionverbose_set_command_optionsget_option_dictselfr7r7r8initialize_optionssH      zeasy_install.initialize_optionscCs"dd|D}tt|j|dS)Ncss*|]"}tj|stj|r|VqdSN)r:r;r<islink).0filenamer7r7r8 s z/easy_install.delete_blockers..)listmap _delete_path)rblockersZextant_blockersr7r7r8delete_blockersszeasy_install.delete_blockerscCsJtd||jrdStj|o.tj| }|r8tntj}||dS)Nz Deleting %s) r infodry_runr:r;isdirrrmtreeunlink)rr;Zis_treeZremoverr7r7r8rs  zeasy_install._delete_pathcCs4djtj}td}d}t|jfttdS)zT Render the Setuptools version and installation details, then exit. {}.{} setuptoolsz=setuptools {dist.version} from {dist.location} (Python {ver})N)formatsys version_infor!printlocals SystemExit)verdisttmplr7r7r8_render_versions  zeasy_install._render_versionc Cs|jo |tjd}tdd\}}|j|j|j||dd|d|d||||t tddd |_ t j r|j |j d <|j|j d <n|jrtd ||||d d dd|jdkr|j|_|jdkrd|_|dd|dd|jr(|jr(|j|_|j|_|ddtttj}t|_ |j!dk rdd|j!dD}|D]N}t"j#|std|n,t||krt$|dn|j %t|qn|j&s|'|j(pd|_(|j dd|_)|jt|jfD] }||j)kr|j)*d|q|j+dk rBdd|j+dD}ndg}|j,dkrj|j-|j(|j)|d|_,t.|j)tj|_/|j0dk rt1|j0t2r|j0|_0ng|_0|j3r|j,4|j)tj|js|j,5|j0|dd t1|j6t7sVz0t7|j6|_6d|j6krdks$nt8Wn.t8k rT} zt$d!| W5d} ~ XYnX|j&rn|j9snt:d"|j;s~t:d#g|_'sz1easy_install.finalize_options..,z"%s (in --site-dirs) does not existz$ (in --site-dirs) is not on sys.pathzhttps://pypi.org/simple/cSsg|] }|qSr7)rMrr7r7r8r=s*) search_pathhosts)ruruz--optimize must be 0, 1, or 2z9Must specify a build directory (-b) when using --editablez:No urls, filenames, or requirements specified (see --help))=rjrrsplitrrget_name get_version get_fullnamegetattr config_varsrrrrrkr warn_fix_install_dir_for_user_siteexpand_basedirs expand_dirs_expandrornrset_undefined_optionsr~rrrr; get_site_dirs all_site_dirsrr:rrappendrccheck_site_dirrq shadow_pathinsertrzr create_indexr# local_indexrr isinstancestrrmZscan_egg_linksadd_find_linksruint ValueErrorrsrrtoutputs) rrr|rr>rrW path_itemrrdr7r7r8finalize_optionss                zeasy_install.finalize_optionscCs\|jr tjsdS||jdkr.d}t||j|_|_tj ddd}| |dS)z; Fix the install_dir if "--user" was used. Nz$User base directory is not specifiedposixunix_user) rkrrcreate_home_pathrr rrr:namerN select_scheme)rmsgZ scheme_namer7r7r8rds  z+easy_install._fix_install_dir_for_user_sitecCsX|D]N}t||}|dk rtjdks.tjdkr:tj|}t||j}t|||qdS)Nrnt)rr:rr;rrrsetattr)rattrsattrvalr7r7r8 _expand_attrsss   zeasy_install._expand_attrscCs|dddgdS)zNCalls `os.path.expanduser` on install_base, install_platbase and root.rrr{Nrrr7r7r8r|szeasy_install.expand_basedirscCsddddddg}||dS)z+Calls `os.path.expanduser` on install dirs.r~rrrrrNr)rdirsr7r7r8rszeasy_install.expand_dirsc Cs|r|dtj|j|jjkr,t|jz|jD]}|||j q4|j r|j }|j rt |j }t t |D]}|||d||<qrddlm}||j|j |fd|j |W5t|jjXdS)NzXWARNING: The easy_install command is deprecated and will be removed in a future version.r) file_utilz'writing list of installed files to '%s')announcer WARNrr set_verbosityrtr/ryrvrr{lenrange distutilsrexecute write_filewarn_deprecated_options)rZshow_deprecationspecrroot_lencounterrr7r7r8runs4     zeasy_install.runcCsDz t}Wn"tk r.tdtj}YnXtj|j d|S)zReturn a pseudo-tempname base in the install directory. This code is intentionally naive; if a malicious party can write to the target directory you're already in deep doodoo. rztest-easy-install-%s) r:getpid Exceptionrandomrandintrmaxsizer;joinrn)rpidr7r7r8pseudo_tempnames  zeasy_install.pseudo_tempnamecCsdSrr7rr7r7r8rsz$easy_install.warn_deprecated_optionsc CsRt|j}tj|d}tj|sTzt|Wn ttfk rR| YnX||j k}|sr|j sr| }nd| d}tj|}z*|rt|t|dt|Wn ttfk r| YnX|s|j stjdd}t|j|j||r&|jdkr,t||j |_nd|_|j rHtj|sHd|_||_dS)z;Verify that self.install_dir is .pth-capable dir, if neededeasy-install.pthz .write-testw PYTHONPATHrN)rrnr:r;r r<makedirsOSErrorIOErrorcant_write_to_targetrrxcheck_pth_processingr ropencloseenvirongetr r_easy_install__no_default_msgrr0)rinstdirrZ is_site_dirZtestfileZ test_exists pythonpathr7r7r8rs:         zeasy_install.check_site_diraS can't create or remove files in install directory The following error occurred while trying to add or remove files in the installation directory: %s The installation directory you specified (via --install-dir, --prefix, or the distutils default setting) was: %s z This directory does not currently exist. Please create it and try again, or choose a different installation directory (using the -d or --install-dir option). a Perhaps your account does not have write access to this directory? If the installation directory is a system-owned directory, you may need to sign in as the administrator or "root" account. If you do not have administrative access to this machine, you may wish to choose a different installation directory, preferably one that is listed in your PYTHONPATH environment variable. For information on other options, you may wish to consult the documentation at: https://setuptools.readthedocs.io/en/latest/easy_install.html Please make the appropriate changes for your system and try again. cCsP|jtd|jf}tj|js6|d|j7}n|d|j7}t |dS)NrJ) _easy_install__cant_write_msgrexc_infornr:r;r<_easy_install__not_exists_id_easy_install__access_msgr)rrr7r7r8r s z!easy_install.cant_write_to_targetc Cs|j}td||d}|d}tj|}tdd}z6|rNt|tj |}tj |ddt |d}Wn t t fk r|YnXz||jft|d }tj}tjd kr tj|\}} tj|d } | d kotj| } | r | }d dlm} | |dddgd tj|rJtd|WdSW5|r\|tj|rtt|tj|rt|X|jstd|dS)z@Empirically verify whether .pth files are supported in inst. dirz Checking .pth file support in %s.pthz.okzz import os f = open({ok_file!r}, 'w') f.write('OK') f.close() rJT)exist_okrNr pythonw.exe python.exer)spawnz-Ez-cpassz-TEST PASSED: %s appears to support .pth filesz+TEST FAILED: %s does NOT support .pth filesF)rnr rr r:r;r<rPrdirnamerrrrrrwriterrr executablerrr lowerdistutils.spawnr&rxr) rrrZok_fileZ ok_existsrr(r]r*basenameZaltZuse_altr&r7r7r8rs\             z!easy_install.check_pth_processingc CsV|jsH|drH|dD],}|d|r.q||||d|q||dS)z=Write all the scripts for `dist`, unless scripts are excludedscriptszscripts/N)rpmetadata_isdirmetadata_listdirinstall_script get_metadatainstall_wrapper_scripts)rr script_namer7r7r8install_egg_scriptsMs z easy_install.install_egg_scriptscCsTtj|rDt|D]*\}}}|D]}|jtj||q$qn |j|dSr)r:r;rwalkrrr )rr;baserfilesrr7r7r8 add_output[s  zeasy_install.add_outputcCs|jrtd|fdS)NzjInvalid argument %r: you can't use filenames or URLs with --editable (except via the --find-links option).)rcrrrr7r7r8 not_editablecs zeasy_install.not_editablecCs<|js dStjtj|j|jr8td|j|jfdS)Nz2%r already exists in %s; can't do a checkout there)rcr:r;r<r rskeyrr:r7r7r8check_editableks zeasy_install.check_editablec cs6tjdd}zt|VW5tj|o.t|XdS)Nz easy_install-)r|)tempfilemkdtempr:r;r<rr)rtmpdirr7r7r8_tmpdirus zeasy_install._tmpdirFc Cs:|&}t|tst|rT|||j||}|d|||dW5QRStj |r|||d|||dW5QRSt |}| ||j |||j|j|j |j}|dkrd|}|jr|d7}t|nJ|jtkr||||d|W5QRS|||j||W5QRSW5QRXdS)NTz+Could not find suitable distribution for %rz2 (--always-copy skips system and development eggs)Using)rArr$rr;rdownload install_itemr:r;r<rr=Zfetch_distributionrUrcrwrr precedencer+process_distributionlocation)rrdepsr@dlrrr7r7r8r/~s8        zeasy_install.easy_installcCs |p|j}|ptj||k}|p,|d }|pT|jdk oTtjt|t|jk}|r|s|j|jD]}|j |krjqqjd}t dtj ||r| |||}|D]}||||qn ||g}|||d|d|dk r|D]}||kr|SqdS)N.eggTz Processing %srrB)rwr:r;r(endswithrrr project_namerGr rr- install_eggsrFegg_distribution)rrrCr@rHZinstall_neededrdistsr7r7r8rDs2     zeasy_install.install_itemcCs<t|}tD]*}d|}t||dkr t||||q dS)z=Sets the install directories by applying the install schemes.install_N)r r rr)rrschemer<attrnamer7r7r8rs zeasy_install.select_schemec Gs|||j|||j|jkr2|j||j|||||j|j<t |j ||f|| dr|j s|j |d|s|jsdS|dk r|j|jkrtd|dS|dks||kr|}tt|}t d|ztg|g|j|j}Wnbtk r>}ztt||W5d}~XYn2tk rn}zt||W5d}~XYnX|js|jr|D]"}|j|jkr||qt d|dS)Nzdependency_links.txtzSkipping dependencies for %szProcessing dependencies for %sz'Finished processing dependencies for %s) update_pthraddrr<remover5rr rinstallation_report has_metadatarrget_metadata_linesrwras_requirementr$rr(resolver/r)rr*reportr)r requirementrrHrZdistreqZdistrosrdr7r7r8rFsL            z!easy_install.process_distributioncCs2|jdk r|j S|dr dS|ds.dSdS)Nz not-zip-safeTzzip-safeF)rlrWrrr7r7r8 should_unzips   zeasy_install.should_unzipcCstj|j|j}tj|r:d}t||j|j||Stj|rL|}nRtj ||krft |t |}t |dkrtj||d}tj|r|}t |t|||S)Nz<%r already exists in %s; build directory %s will not be keptrr)r:r;r rsr<r<r rrr(rlistdirrr shutilmove)rr dist_filename setup_basedstrcontentsr7r7r8 maybe_moves$       zeasy_install.maybe_movecCs,|jr dSt|D]}|j|qdSr)rp ScriptWriterbestget_args write_script)rrrtr7r7r8r3sz$easy_install.install_wrapper_scriptscCsNt|}t||}|r8||t}t||}||t|ddS)z/Generate a legacy script wrapper and install itr^N) rrYis_python_script_load_templaterrg get_headerrjrF)rrr4 script_textdev_pathrZ is_scriptbodyr7r7r8r1s   zeasy_install.install_scriptcCs(d}|r|dd}td|}|dS)z There are a couple of template scripts in the package. This function loads one of them and prepares it for use. z script.tmplz.tmplz (dev).tmplrutf-8)rNrdecode)rorZ raw_bytesr7r7r8rl&s   zeasy_install._load_templatetr7c sfdd|Dtd|jtjj|}|jrLdSt }t |tj |rpt |t |d|}||W5QRXt|d|dS)z1Write an executable file to the scripts directorycsg|]}tjj|qSr7)r:r;r rorrYrr7r8r8sz-easy_install.write_script..zInstalling %s script to %sNri)rr rror:r;r r9r current_umaskr r<rrr)chmod)rr4remodertargetmaskr]r7rr8rj5s   zeasy_install.write_scriptc CsT|j|j|jd}z||dd}Wntk r>YnX|||gS|}tj|rv|dsvt |||j ntj |rtj |}| |r|jr|dk r||||}tj|d}tj|s&ttj|dd}|stdtj |t|dkrtdtj ||d }|jrDt|||gS|||SdS) N)rJ.exez.whl.pyzsetup.pyrz"Couldn't find a setup script in %srzMultiple setup scripts in %sr) install_egg install_exe install_wheelr+KeyErrorr:r;isfilerKrunpack_progressrabspath startswithrsrfr r<rrrrcr rreport_editablebuild_and_install) rrrbr@Z installer_mapZ install_distrc setup_scriptZsetupsr7r7r8rMIsT      zeasy_install.install_eggscCs>tj|r"t|tj|d}ntt|}tj ||dS)NEGG-INFO)metadata) r:r;rr&r r' zipimport zipimporterr% from_filename)regg_pathrr7r7r8rN|s   zeasy_install.egg_distributionc Cstj|jtj|}tj|}|js2t|||}t ||sztj |rrtj |srt j ||jdn"tj|r|tj|fd|zd}tj |r||rtjd}}n tjd}}nL||r|||jd}}n*d}||r tjd}}n tjd}}||||f|dtj|tj|ft||d Wn$tk rxt|dd YnX||||S) Nr Removing FZMovingZCopyingZ ExtractingTz %s to %sfix_zipimporter_caches)r:r;r rnr-rrr rNr.rrr remove_treer<rrrr`racopytreer^mkpathunpack_and_compilecopy2r(update_dist_cachesrr9)rrr@ destinationrZnew_dist_is_zippedr]rTr7r7r8r}s^                zeasy_install.install_eggc sPt|}|dkrtd|td|dd|ddtd}tj||d}||_ |d}tj|d}tj|d }t |t |||_ | ||tj|st|d } | d |dD].\} } | d kr| d | dd| fq| tj|d|fddt|Dtj|||j|jd|||S)Nz(%s is not a valid distutils Windows .exerrrj)rLrjplatformrJz.tmprPKG-INFOrzMetadata-Version: 1.0 target_versionz%s: %s _-r.csg|]}tj|dqS)r)r:r;r )rrtror7r8rsz,easy_install.install_exe..)rr)r1rr%rrr:r;r egg_namerGr r& _provider exe_to_eggr<rr)itemsrNtitlerrrgrir make_zipfilerrr}) rrbr@cfgrregg_tmpZ _egg_infoZpkg_infr]kvr7rr8r~sJ       zeasy_install.install_exec s6t|ggifdd}t||g}D]l}|dr<|d}|d}t|dd|d<tjj f|} || |t ||q<| t tj dt|dD]Z} t| rtj d| d } tj| st| d } | d t| d | qd S) z;Extract a bdist_wininst to the directories an egg would usecs|}D]\}}||r ||t|d}|d}tjjf|}|}|dsj|drt |d|d<dtj |dd< |n4|dr|dkrdtj |dd< ||Sq |d st d |dS) N/.pyd.dllrrr|SCRIPTS/r"zWARNING: can't process %s)r+rrrr:r;r rKr strip_modulesplitextrr r)srcrdrEoldnewpartsrIr native_libsprefixes to_compile top_levelr7r8processs$        z(easy_install.exe_to_egg..processrrrr|r)rrz.txtrrJN)r2rr+rKrrrr:r;r rZ write_stub byte_compileZwrite_safety_flagZ analyze_eggrr<rr)r) rrbrrZstubsresrresourceZpyfilertxtr]r7rr8rs8          zeasy_install.exe_to_eggc Cst|}|sttj|j|}tj|}|j sBt |tj |rltj |slt j||j dn"tj|r|tj|fd|z.||j|fdtj|tj|fW5t|ddX||||S)NrrFrzInstalling %s to %s)r is_compatibleAssertionErrorr:r;r rnrrrr rrr rr<rrrZinstall_as_eggr-r(r9rN)r wheel_pathr@wheelrr7r7r8rs4       zeasy_install.install_wheela( Because this distribution was installed --multi-version, before you can import modules from this package in an application, you will need to 'import pkg_resources' and then use a 'require()' call similar to one of these examples, in order to select the desired version: pkg_resources.require("%(name)s") # latest installed version pkg_resources.require("%(name)s==%(version)s") # this exact version pkg_resources.require("%(name)s>=%(version)s") # this version or higher z Note also that the installation directory must be on sys.path at runtime for this to work. (e.g. by being the application's script directory, by being on PYTHONPATH, or by being added to sys.path by your code.) Installedc Cs^d}|jr>|js>|d|j7}|jtttjkr>|d|j7}|j }|j }|j }d}|t S)z9Helpful installation message for display to package usersz %(what)s %(eggloc)s%(extras)srJr) rxr}_easy_install__mv_warningrnrrrr;_easy_install__id_warningrGrLrjr) rreqrwhatrZegglocrrjextrasr7r7r8rVLs z easy_install.installation_reportaR Extracted editable version of %(spec)s to %(dirname)s If it uses setuptools in its setup script, you can activate it in "development" mode by going to that directory and running:: %(python)s setup.py develop See the setuptools documentation for the "develop" command for more info. cCs"tj|}tj}d|jtS)NrJ)r:r;r(rr*_easy_install__editable_msgr)rrrr(pythonr7r7r8res zeasy_install.report_editablec Cstjdttjdtt|}|jdkrNd|jd}|dd|n|jdkrd|dd|jrv|dd t d |t |ddd |zt ||Wn8tk r}ztd |jdf|W5d}~XYnXdS) Nzdistutils.command.bdist_eggzdistutils.command.egg_inforrrrrz-qz-nz Running %s %s zSetup script exited with %s)rmodules setdefaultrrrrrrr rrr rrrrt)rrrcrtrr7r7r8rjs.    zeasy_install.run_setupc Csddg}tjdtj|d}z| tj|| || |||t |g}g}|D]&}||D]}| | |j|qhq\|s|jstd||WSt|t|jXdS)Nrz --dist-dirz egg-dist-tmp-)r|dirz+No eggs found in %s (setup script problem?))r>r?r:r;r(rr rr_set_fetcher_optionsrrr#r}rGrr) rrrcrtdist_dirZall_eggseggsr<rr7r7r8rs*     zeasy_install.build_and_installc Csh|jd}d}i}|D]\}}||kr2q |d||<q t|d}tj|d}t ||dS)a When easy_install is about to run bdist_egg on a source dist, that source dist might have 'setup_requires' directives, requiring additional fetching. Ensure the fetcher options given to easy_install are available to that command as well. r/)rrrrqrurzr)r/z setup.cfgN) rrcopyrdictr:r;r rZ edit_config) rr7Zei_optsZfetch_directivesZ fetch_optionsr<rsettingsZ cfg_filenamer7r7r8rs  z!easy_install._set_fetcher_optionsc Cs6|jdkrdS|j|jD]J}|js2|j|jkr2qtd||j||j|jkr|j|jq|js|j|jjkrtd|n2td||j ||j|jkr|j |j|j rdS|j |jdkrdSt j|jd}t j|rt |t|d}||j|jdW5QRXdS)Nz&Removing %s from easy-install.pth filez4%s is already the active version in easy-install.pthz"Adding %s to easy-install.pth filersetuptools.pthwtrJ)rr<rxrGr rrUrpathsrTrrsaver:r;r rnrrrr) make_relative)rrrWrr]r7r7r8rSs:           zeasy_install.update_pthcCstd|||S)NzUnpacking %s to %s)r debug)rrrdr7r7r8rszeasy_install.unpack_progresscsdggfdd}t|||js`D]&}t|tjdBd@}t||q8dS)NcsZ|dr |ds |n|ds4|dr>|||j rV|pXdS)Nr| EGG-INFO/rz.so)rKrrrr)rrdrZto_chmodrr7r8pfs    z+easy_install.unpack_and_compile..pfimi)rrrr:statST_MODErv)rrrrr]rwr7rr8rs  zeasy_install.unpack_and_compilec Csjtjr dSddlm}z@t|jd||dd|jd|jrT|||jd|jdW5t|jXdS)Nr)rr)ruforcer) rdont_write_bytecodedistutils.utilrr rrrru)rrrr7r7r8rs  zeasy_install.byte_compilea bad install directory or PYTHONPATH You are attempting to install a package to a directory that is not on PYTHONPATH and which Python does not read ".pth" files from. The installation directory you specified (via --install-dir, --prefix, or the distutils default setting) was: %s and your PYTHONPATH environment variable currently contains: %r Here are some of your options for correcting the problem: * You can choose a different installation directory, i.e., one that is on PYTHONPATH or supports .pth files * You can add the installation directory to the PYTHONPATH environment variable. (It must then also be on PYTHONPATH whenever you run Python and want to use the package(s) you are installing.) * You can set up the installation directory to support ".pth" files by using one of the approaches described here: https://setuptools.readthedocs.io/en/latest/easy_install.html#custom-installation-locations Please make the appropriate changes for your system and try again. cCsb|js dSttjd}|jD]8\}}||r$tj|s$| d|t |dq$dS)zCreate directories under ~.N~zos.makedirs('%s', 0o700)i) rkrr:r;rrrrr debug_printr)rhomerr;r7r7r8r#szeasy_install.create_home_pathz/$base/lib/python$py_version_short/site-packagesz $base/binrrz$base/Lib/site-packagesz $base/ScriptscGs|dj}|jrd|}|j|d<|jtj|j}| D]$\}}t ||ddkr>t |||q>ddl m }|D]B}t ||}|dk rt|||}tjdkrtj|}t |||qtdS)Nrr7r)rr)get_finalized_commandrr|rr rr:rDEFAULT_SCHEMErrrrrr;r)rrrrQrrrr7r7r8r9s        zeasy_install._expand)T)F)F)T)N)rsr7)r)M__name__ __module__ __qualname____doc__ descriptionZcommand_consumes_argumentsrr user_optionsboolean_options negative_optrrrrr staticmethodrrrrrrrr rrrKrLlstriprr r!rrr5r9r;r= contextlibcontextmanagerrAr/rDrrFr^rfr3r1rlrjrMrNr}r~rrrrrVrrrrrrSrrrrMrrrr rrr7r7r7r8r/ns/     - ;   ! $ )    3 6.5   )  cCs tjddtj}td|S)Nrr)r:rrrpathsepfilter)rr7r7r8 _pythonpathPsrc sxgttjg}tjtjkr0|tj|D]}|s>q4tjdkr`tj |ddnVtj dkrtj |ddj tj dtj |ddgn|tj |ddgtjdkrq4d |krq4tj d }|sq4tj |d d d j tj d}|q4tdtdf}fdd|DtjrBtjtttW5QRXtttS)z& Return a list of 'site' dirs )Zos2emxZriscosLibz site-packagesrlibz python{}.{}z site-pythondarwinzPython.frameworkHOMELibraryPythonrpurelibplatlibc3s|]}|kr|VqdSrr7rsitedirsr7r8rsz get_site_dirs..)extendrrr|rrrr:r;r seprrrrrrrrrsuppressAttributeErrorgetsitepackagesrrr)rr|rZhome_spZ lib_pathsr7rr8rUs^             rccsi}|D]}t|}||krqd||<tj|s4qt|}||fV|D]}|ds\qL|dkrfqLttj||}tt |}| |D]L}| drqt| }||krqd||<tj|sq|t|fVqqLqdS)zBYield sys.path directories that might contain "old-style" packagesrr")rrimportN) rr:r;rr_rKrr rrrrrstrip)inputsseenr(r8rr]linesliner7r7r8 expand_pathss8        r c Cs@t|d}z$t|}|dkr*W dS|d|d|d}|dkrRWdS||dtd|d\}}}|dkrWdS||d|d d d }t |}z<||} | d d d } | t } |t| Wntjk rYW.dSX|dr"|ds*W dS|WS|XdS)znExtract configuration data from a bdist_wininst .exe Returns a configparser.RawConfigParser, or None rbN  zegg path translations for a given .exe file)zPURELIB/r)zPLATLIB/pywin32_system32r)zPLATLIB/r)rzEGG-INFO/scripts/)zDATA/lib/site-packagesrrrrrrz .egg-inforNrr"z -nspkg.pth)ZPURELIBZPLATLIB\rz%s/%s/rcSsg|]\}}||fqSr7)r+)rrYyr7r7r8rsz$get_exe_prefixes..)rZipFilerinfolistrrrrKrr upperrrrrrMrNrrsortreverse)Z exe_filenamerrRrrrrepthr7r7r8r2s<      " c@sReZdZdZdZdddZddZdd Zed d Z d d Z ddZ ddZ dS)r0z)A .pth file with Distribution paths in itFr7cCsl||_ttt||_ttj|j|_| t |gddt |j D]}tt|jt|dqLdS)NT)rrrrrr:r;r(basedir_loadr#__init__rrrTr")rrrr;r7r7r8r0szPthDistributions.__init__cCsg|_d}t|j}tj|jrt|jd}|D]}| drHd}q4| }|j || r4| drtq4t tj|j|}|jd<tj|r||kr|jd|_q4d||<q4||jr|sd|_|jr|jd s|jqdS)NFrtrT#rr)rrfromkeysrr:r;rrrrrrrMrr r.r<popdirtyr)rZ saw_importr r]r r;r7r7r8r/%s4       zPthDistributions._loadc Cs|js dStt|j|j}|rtd|j||}d |d}t j |jr`t |jt|jd}||W5QRXn(t j |jrtd|jt |jd|_dS)z$Write changed .pth file back to diskNz Saving %srJrzDeleting empty %sF)r5rrrrr rr _wrap_linesr r:r;rrrr)r<)rZ rel_pathsr datar]r7r7r8rDs   zPthDistributions.savecCs|Srr7)r r7r7r8r6ZszPthDistributions._wrap_linescCsN|j|jko$|j|jkp$|jtk}|r>|j|jd|_t||dS)z"Add `dist` to the distribution mapTN) rGrrr:getcwdrr5r#rT)rrnew_pathr7r7r8rT^s   zPthDistributions.addcCs2|j|jkr"|j|jd|_qt||dS)z'Remove `dist` from the distribution mapTN)rGrrUr5r#r]r7r7r8rUls zPthDistributions.removecCstjt|\}}t|j}|g}tjdkr2dp6tj}t||kr||jkrl|tj | | |Stj|\}}||q8|S)Nr) r:r;rrrr.altseprrcurdirr,r )rr;npathlastZbaselenrrr7r7r8rss      zPthDistributions.make_relativeN)r7) rrrrr5r0r/rrr6rTrUrr7r7r7r8r0s  c@s(eZdZeddZedZedZdS)RewritePthDistributionsccs$|jV|D] }|Vq |jVdSr)preludepostlude)clsr r r7r7r8r6sz#RewritePthDistributions._wrap_linesz? import sys sys.__plen = len(sys.path) z import sys new = sys.path[sys.__plen:] del sys.path[sys.__plen:] p = getattr(sys, '__egginsert', 0) sys.path[p:p] = new sys.__egginsert = p + len(new) N)rrr classmethodr6rPr?r@r7r7r7r8r>s r>ZSETUPTOOLS_SYS_PATH_TECHNIQUErawZrewritecCs ttjtrtSttjS)z_ Return a regular expression based on first_line_re suitable for matching strings. )rrpatternrrecompilerrr7r7r7r8_first_line_res rGcCs\|tjtjfkr.tjdkr.t|tj||St\}}}|d|dd||ffdS)Nrrrz %s %s) r:rrUrrvrS_IWRITErr)funcargexcetZevrr7r7r8 auto_chmods  rMcCs.t|}t|tj|r"t|nt|dS)aa Fix any globally cached `dist_path` related data `dist_path` should be a path of a newly installed egg distribution (zipped or unzipped). sys.path_importer_cache contains finder objects that have been cached when importing data from the original distribution. Any such finders need to be cleared since the replacement distribution might be packaged differently, e.g. a zipped egg distribution might get replaced with an unzipped egg folder or vice versa. Having the old finders cached may then cause Python to attempt loading modules from the replacement distribution using an incorrect loader. zipimport.zipimporter objects are Python loaders charged with importing data packaged inside zip archives. If stale loaders referencing the original distribution, are left behind, they can fail to load modules from the replacement distribution. E.g. if an old zipimport.zipimporter instance is used to load data from a new zipped egg archive, it may cause the operation to attempt to locate the requested data in the wrong location - one indicated by the original distribution's zip archive directory information. Such an operation may then fail outright, e.g. report having read a 'bad local file header', or even worse, it may fail silently & return invalid data. zipimport._zip_directory_cache contains cached zip archive directory information for all existing zipimport.zipimporter instances and all such instances connected to the same archive share the same cached directory information. If asked, and the underlying Python implementation allows it, we can fix all existing zipimport.zipimporter instances instead of having to track them down and remove them one by one, by updating their shared cached zip archive directory information. This, of course, assumes that the replacement distribution is packaged as a zipped egg. If not asked to fix existing zipimport.zipimporter instances, we still do our best to clear any remaining zipimport.zipimporter related cached data that might somehow later get used when attempting to load data from the new distribution and thus cause such load operations to fail. Note that when tracking down such remaining stale data, we can not catch every conceivable usage from here, and we clear only those that we know of and have found to cause problems if left alive. Any remaining caches should be updated by whomever is in charge of maintaining them, i.e. they should be ready to handle us replacing their zip archives with new distributions at runtime. N)r_uncacherpath_importer_cache!_replace_zip_directory_cache_data*_remove_and_clear_zip_directory_cache_data) dist_pathrnormalized_pathr7r7r8rs <  rcCsPg}t|}|D]:}t|}||r|||dtjdfkr||q|S)ap Return zipimporter cache entry keys related to a given normalized path. Alternative path spellings (e.g. those using different character case or those using alternative path separators) related to the same path are included. Any sub-path entries are included as well, i.e. those corresponding to zip archives embedded in other zip archives. rr)rrrr:rr)rScacheresult prefix_lenpnpr7r7r8"_collect_zipimporter_cache_entriess   rYcCs@t||D]0}||}||=|o(|||}|dk r |||<q dS)a Update zipimporter cache data for a given normalized path. Any sub-path entries are processed as well, i.e. those corresponding to zip archives embedded in other zip archives. Given updater is a callable taking a cache entry key and the original entry (after already removing the entry from the cache), and expected to update the entry and possibly return a new one to be inserted in its place. Returning None indicates that the entry should not be replaced with a new one. If no updater is given, the cache entries are simply removed without any additional processing, the same as if the updater simply returned None. N)rY)rSrTupdaterrW old_entryZ new_entryr7r7r8_update_zipimporter_caches  r\cCst||dSr)r\)rSrTr7r7r8rN8srNcCsdd}t|tj|ddS)NcSs |dSr)clearr;r[r7r7r82clear_and_remove_cached_zip_archive_directory_data=szf_remove_and_clear_zip_directory_cache_data..clear_and_remove_cached_zip_archive_directory_datarZr\r_zip_directory_cache)rSr_r7r7r8rQ<s rQZ__pypy__cCsdd}t|tj|ddS)NcSs&|t||tj||Sr)r]rrupdaterbr^r7r7r8)replace_cached_zip_archive_directory_dataSs zT_replace_zip_directory_cache_data..replace_cached_zip_archive_directory_datar`ra)rSrdr7r7r8rPRs  rPc Cs4zt||dWnttfk r*YdSXdSdS)z%Is this string a valid Python script?execFTN)rF SyntaxError TypeError)rOrr7r7r8 is_pythones ric CsNz(tj|dd}|d}W5QRXWnttfk rD|YSX|dkS)zCDetermine if the specified executable is a .sh (contains a #! line)zlatin-1)encodingr#!)rrrrr)r*fpmagicr7r7r8is_shos  rncCs t|gS)z@Quote a command line argument according to Windows parsing rules subprocess list2cmdline)rJr7r7r8 nt_quote_argysrrcCsH|ds|drdSt||r&dS|drDd|dkSdS)zMIs this text, as a whole, a Python script? (as opposed to shell/bat/etc. r|.pywTrkrrF)rKrir splitlinesr+)rnrr7r7r8rk~s  rk)rvcGsdSrr7)rtr7r7r8_chmodsruc CsRtd||zt||Wn0tjk rL}ztd|W5d}~XYnXdS)Nzchanging mode of %s to %ozchmod failed: %s)r rrur:error)r;rwrdr7r7r8rvs rvc@seZdZdZgZeZeddZeddZ eddZ edd Z ed d Z d d Z eddZddZeddZeddZdS) CommandSpeczm A command spec for a #! header, specified as a list of arguments akin to those passed to Popen. cCs|S)zV Choose the best CommandSpec class based on environmental conditions. r7rAr7r7r8rhszCommandSpec.bestcCstjtj}tjd|S)N__PYVENV_LAUNCHER__)r:r;r>rr*rr)rA_defaultr7r7r8_sys_executableszCommandSpec._sys_executablecCs:t||r|St|tr ||S|dkr0|S||S)zg Construct a CommandSpec from a parameter to build_scripts, which may be None. N)rrfrom_environment from_string)rAparamr7r7r8 from_params  zCommandSpec.from_paramcCs||gSr)r{rxr7r7r8r|szCommandSpec.from_environmentcCstj|f|j}||S)z} Construct a command spec from a simple string representing a command line parseable by shlex.split. )shlexr split_args)rAstringrr7r7r8r}szCommandSpec.from_stringcCs8t|||_t|}t|s4dg|jdd<dS)Nz-xr)rr_extract_optionsoptionsrprqrI)rrncmdliner7r7r8install_optionss zCommandSpec.install_optionscCs:|dd}t|}|r.|dp0dnd}|S)zH Extract any options from the first line of the script. rJrrr)rtrGmatchgrouprM)Z orig_scriptfirstrrr7r7r8rs zCommandSpec._extract_optionscCs||t|jSr)_renderrrrr7r7r8 as_headerszCommandSpec.as_headercCs6d}|D](}||r||r|ddSq|S)Nz"'rr)rrK)itemZ_QUOTESqr7r7r8 _strip_quotess zCommandSpec._strip_quotescCs tdd|D}d|dS)Ncss|]}t|VqdSr)rwrrM)rrr7r7r8rsz&CommandSpec._render..rkrJro)rrr7r7r8rs zCommandSpec._renderN)rrrrrrrrBrhr{rr|r}rrrrrrr7r7r7r8rws*       rwc@seZdZeddZdS)WindowsCommandSpecFrN)rrrrrr7r7r7r8rsrc@seZdZdZedZeZ e dddZ e dddZ e dd d Z ed d Ze d dZe ddZe ddZe dddZdS)rgz` Encapsulates behavior around writing entry point scripts for console and gui apps. aJ # EASY-INSTALL-ENTRY-SCRIPT: %(spec)r,%(group)r,%(name)r import re import sys # for compatibility with easy_install; see #2198 __requires__ = %(spec)r try: from importlib.metadata import distribution except ImportError: try: from importlib_metadata import distribution except ImportError: from pkg_resources import load_entry_point def importlib_load_entry_point(spec, group, name): dist_name, _, _ = spec.partition('==') matches = ( entry_point for entry_point in distribution(dist_name).entry_points if entry_point.group == group and entry_point.name == name ) return next(matches).load() globals().setdefault('load_entry_point', importlib_load_entry_point) if __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) sys.exit(load_entry_point(%(spec)r, %(group)r, %(name)r)()) NFcCs6tdt|rtnt}|d||}|||S)Nz Use get_argsr)warningsrEasyInstallDeprecationWarningWindowsScriptWriterrgrhget_script_headerri)rArr*wininstwriterheaderr7r7r8get_script_args"s zScriptWriter.get_script_argscCs$tjdtdd|rd}|||S)NzUse get_headerr) stacklevelr%)rrrrm)rArnr*rr7r7r8r*szScriptWriter.get_script_headerc cs|dkr|}t|}dD]Z}|d}||D]>\}}|||jt}|||||} | D] } | Vqlq:q dS)z Yield write_script() argument tuples for a distribution's console_scripts and gui_scripts entry points. NconsoleguiZ_scripts) rmrrY get_entry_mapr_ensure_safe_nametemplater_get_script_args) rArrrtype_rreprnrtrr7r7r8ri3s   zScriptWriter.get_argscCstd|}|rtddS)z? Prevent paths in *_scripts entry point names. z[\\/]z+Path separators not allowed in script namesN)rEsearchr)rZ has_path_sepr7r7r8rEs zScriptWriter._ensure_safe_namecCs tdt|rtS|SNzUse best)rrrrrh)rAZ force_windowsr7r7r8 get_writerNs zScriptWriter.get_writercCs.tjdkstjdkr&tjdkr&tS|SdS)zD Select the best ScriptWriter for this environment. win32javarN)rrr:r_namerrhrxr7r7r8rhTszScriptWriter.bestccs|||fVdSrr7)rArrrrnr7r7r8r^szScriptWriter._get_script_argsrcCs"|j|}|||S)z;Create a #! line, getting options (if any) from script_text)command_spec_classrhrrr)rArnr*cmdr7r7r8rmcs zScriptWriter.get_header)NF)NF)N)rN)rrrrrKrLrrrwrrBrrrirrrrhrrmr7r7r7r8rgs&#       rgc@sLeZdZeZeddZeddZeddZeddZ e d d Z d S) rcCstdt|Sr)rrrrhrxr7r7r8rns zWindowsScriptWriter.get_writercCs"tt|d}tjdd}||S)zC Select the best ScriptWriter suitable for Windows )r*ZnaturalZSETUPTOOLS_LAUNCHERr*)rWindowsExecutableLauncherWriterr:rr)rAZ writer_lookuplauncherr7r7r8rhts zWindowsScriptWriter.bestc #stddd|}|tjddkrBdjft}t|t dddd d dd g}| || ||}fd d |D}|||d|fVdS)z For Windows, add a .py extensionz.pyarsrPATHEXT;zK{ext} not listed in PATHEXT; scripts will not be recognized as executables.r| -script.py.pyc.pyorzcsg|] }|qSr7r7rtrr7r8rsz8WindowsScriptWriter._get_script_args..rsN) rr:rr+rrrrr UserWarningrU_adjust_header) rArrrrnextrrrr7rr8rs   z$WindowsScriptWriter._get_script_argscCsNd}d}|dkr||}}tt|tj}|j||d}||rJ|S|S)z Make sure 'pythonw' is used for gui and 'python' is used for console (regardless of what sys.executable is). r$r%r)rrepl)rErFescape IGNORECASEsub _use_header)rArZ orig_headerrDrZ pattern_ob new_headerr7r7r8rs z"WindowsScriptWriter._adjust_headercCs$|ddd}tjdkp"t|S)z Should _adjust_header use the replaced header? On non-windows systems, always use. On Windows systems, only use the replaced header if it resolves to an executable on the system. rr"r)rMrrr)rZ clean_headerr7r7r8rs zWindowsScriptWriter._use_headerN) rrrrrrBrrhrrrrr7r7r7r8rks    rc@seZdZeddZdS)rc #s|dkrd}d}dg}nd}d}dddg}|||}fd d |D} |||d | fVd t|d fVtsd} | td fVdS)zG For Windows, add a .py extension and an .exe launcher rz -script.pywrsclirr|rrcsg|] }|qSr7r7rtrr7r8rszDWindowsExecutableLauncherWriter._get_script_args..rsrzr^z .exe.manifestN)rget_win_launcherr9load_launcher_manifest) rArrrrnZ launcher_typerrhdrrZm_namer7rr8rs"  z0WindowsExecutableLauncherWriter._get_script_argsN)rrrrBrr7r7r7r8rsrcCs2d|}tr|dd}n |dd}td|S)z Load the Windows launcher (executable) suitable for launching a script. `type` should be either 'cli' or 'gui' Returns the executable as a byte string. z%s.exe.z-64.z-32.r)r9rNr)typeZ launcher_fnr7r7r8rs  rcCsttd}|dtS)Nzlauncher manifest.xmlrq) pkg_resourcesrrrrvars)rmanifestr7r7r8rs rFcCst|||Sr)r`r)r; ignore_errorsonerrorr7r7r8rsrcCstd}t||S)N)r:umask)tmpr7r7r8rus  ruc@seZdZdZdS)rzF Warning for EasyInstall deprecations, bypassing suppression. N)rrrrr7r7r7r8rsr)N)re)|rrrrrrdistutils.errorsrrrr distutils.command.installr r rr r Zdistutils.command.build_scriptsrr,rrr:rr`r>rrErrrKrrr5rrprrr sysconfigrrrrrZsetuptools.sandboxrZsetuptools.commandrZsetuptools.archive_utilrZsetuptools.package_indexrrrrrZsetuptools.wheelrrrrrr r!r"r#r$r%r&r'r(r)r*r+filterwarnings PEP440Warning__all__r9r.rFrIrPr/rrr r1r2r0r>rrrGrMrrYr\rNrQbuiltin_module_namesrPrirnrrrkrvru ImportErrorrrwr{Zsys_executablerrgrrrrrrrrurr7r7r7r8s          DkF.)%l  R    TtA