U e^eN@sdZddlmZddlmZddlmZmZddlmZmZm Z m Z ddl m Z m Z ddlmZmZddlmZdd lmZdd lZdd lZdd lZdd lZdd lZdd lZdd lZdd lZdd lZdd lZdd lZdd l Z dd l!Z!dd l"Z"dd l#Z#dd l$Z$dd l%Z%dd l&Z&dd l'm(Z(m)Z)dd l*m+Z+dd l*m,Z,ddl-m.Z.ddl/m0Z0ddl1m2Z2ddl3m4Z4m5Z5m6Z6ddl/m7Z7m8Z8ddl9m:Z:ddl;mZ>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)ja0 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/deprecated/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-kjbsd5ow/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`cCs2tdtd|_d|_|_d|_|_|_d|_ d|_ d|_ d|_ d|_ |_d|_|_|_d|_|_|_d|_|_|_d|_d|_d|_d|_d|_d|_d|_d|_d|_ t!j"rt!j#|_$t!j%|_&n d|_$d|_&d|_'d|_(d|_)|_*d|_+i|_,d|_-|j.j/|_/|j.0||j.1ddS)NzVeasy_install command is deprecated. Use build and pip and other standards-based tools.rr/)2warningswarnEasyInstallDeprecationWarningrkzip_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_optionssP      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)rMrr7r7r8rCs*) search_pathhosts)rxrxz--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 rm_fix_install_dir_for_user_siteexpand_basedirs expand_dirs_expandrrrqrset_undefined_optionsrrrrr; get_site_dirs all_site_dirsrr:rrappendrccheck_site_dirrt shadow_pathinsertr}r create_indexr# local_indexru isinstancestrrpZscan_egg_linksadd_find_linksrxint ValueErrorrvrrwoutputs) rrrrr>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_namer7r7r8rjs  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_attrsys   zeasy_install._expand_attrscCs|dddgdS)zNCalls `os.path.expanduser` on install_base, install_platbase and root.rrr~Nrrr7r7r8rszeasy_install.expand_basedirscCsddddddg}||dS)z+Calls `os.path.expanduser` on install dirs.rrrrrrNr)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_verbosityrwr/r|ryrr~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;joinrq)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)rrqr:r;r r<makedirsOSErrorIOErrorcant_write_to_targetrr{check_pth_processingrropencloseenvirongetr rm_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/deprecated/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_inforqr:r;r<_easy_install__not_exists_id_easy_install__access_msgr)rrr7r7r8rs 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)rqr rrr:r;r<rPrdirnamerrrrrrwriterrr executablerrr lowerdistutils.spawnr(r{rm) 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)rsmetadata_isdirmetadata_listdirinstall_script get_metadatainstall_wrapper_scripts)rr script_namer7r7r8install_egg_scriptsSs z easy_install.install_egg_scriptscCsTtj|rDt|D]*\}}}|D]}|jtj||q$qn |j|dSr)r:r;rwalkrrr )rr;baserfilesrr7r7r8 add_outputas  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_editableis 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 rvkeyrr<r7r7r8check_editableqs zeasy_install.check_editablec cs6tjdd}zt|VW5tj|o.t|XdS)Nz easy_install-)r)tempfilemkdtempr:r;r<rr)rtmpdirr7r7r8_tmpdir{s 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)rCrr$rr=rdownload install_itemr:r;r<rr?Zfetch_distributionrUrcrzrr precedencer+process_distributionlocation)rrdepsrBdlrrr7r7r8r/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 %srrD)rzr:r;r*endswithrrr project_namerIr rr/ install_eggsrHegg_distribution)rrrErBrJZinstall_neededrdistsr7r7r8rFs2     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>remover7rr rinstallation_report has_metadatarrget_metadata_linesrzrmas_requirementr$rr(resolver/r)rr*reportr)r requirementrrJrZdistreqZdistrosrdr7r7r8rHsL            z!easy_install.process_distributioncCs2|jdk r|j S|dr dS|ds.dSdS)Nz not-zip-safeTzzip-safeF)rorYrrr7r7r8 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 rvr>r<r rmrr*rlistdirrr shutilmove)rr dist_filename setup_basedstrcontentsr7r7r8 maybe_moves$       zeasy_install.maybe_movecCs,|jr dSt|D]}|j|qdSr)rs ScriptWriterbestget_args write_script)rrrwr7r7r8r5sz$easy_install.install_wrapper_scriptscCsNt|}t||}|r8||t}t||}||t|ddS)z/Generate a legacy script wrapper and install itr^N) rr[is_python_script_load_templaterri get_headerrlrF)rrr6 script_textdev_pathrZ is_scriptbodyr7r7r8r3"s   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)rqrZ raw_bytesr7r7r8rn,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 rrrrYrr7r8r>sz-easy_install.write_script..zInstalling %s script to %sNri)rr rrrr:r;r r;r current_umaskr r<rrr+chmod)rr6rgmodertargetmaskr]r7rr8rl;s   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)rL.exez.whl.pyzsetup.pyrz"Couldn't find a setup script in %srzMultiple setup scripts in %sr) install_egg install_exe install_wheelr-KeyErrorr:r;isfilerMrunpack_progressrabspath startswithrvrhr r<rrrrcr rreport_editablebuild_and_install) rrrdrBZ installer_mapZ install_distre setup_scriptZsetupsr7r7r8rOOsT      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_pathrr7r7r8rPs   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 rqr/rrr rPr.rrr remove_treer<rrrrbrccopytreer`mkpathunpack_and_compilecopy2r*update_dist_cachesr r;)rrrB destinationrZnew_dist_is_zippedr]rTr7r7r8rs^                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)rNrjplatformrLz.tmprPKG-INFOrzMetadata-Version: 1.0 target_versionz%s: %s _-r0csg|]}tj|dqS)r)r:r;r )rrwrrr7r8rsz,easy_install.install_exe..)rr)r1rr%rrr:r;r egg_namerIr r& _provider exe_to_eggr<rr+itemsrNtitlerrrirkr make_zipfilerrr) rrdrBcfgrregg_tmpZ _egg_infoZpkg_infr]kvr7rr8rsJ       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 rMr strip_modulesplitextrr rm)srcrfrEoldnewpartsrKr native_libsprefixes to_compile top_levelr7r8processs$        z(easy_install.exe_to_egg..processrrrr~r)rrz.txtrrJN)r2rr-rMrrrr:r;r rZ write_stub byte_compileZwrite_safety_flagZ analyze_eggrr<rr+r) rrdrrZstubsresrresourceZpyfilertxtr]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 rqrrrr rrr rr<rrrZinstall_as_eggr/r*r;rP)r wheel_pathrBwheelrr7r7r8r$s4       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) r{r_easy_install__mv_warningrqrrrr;_easy_install__id_warningrIrNrjr) rreqrwhatrZegglocrrjextrasr7r7r8rXRs 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*pythonr7r7r8rks 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 rrrrw)rrrerwrr7r7r8rps.    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-)rdirz+No eggs found in %s (setup script problem?))r@rAr:r;r*rr rr_set_fetcher_optionsrrr#rrIrrm) rrrerwdist_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/)rurrtrxr}r)r/z setup.cfgN) rrcopyrdictr:r;r rZ edit_config) rr9Zei_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>r{rIr rrWrpathsrVrrsaver:r;r rqrrrr+ make_relative)rrrWrr]r7r7r8rUs:           zeasy_install.update_pthcCstd|||S)NzUnpacking %s to %s)r debug)rrrfr7r7r8rszeasy_install.unpack_progresscsdggfdd}t|||js`D]&}t|tjdBd@}t||q8dS)NcsZ|dr |ds |n|ds4|dr>|||j rV|pXdS)Nr~ EGG-INFO/rz.so)rMrrrr)rrfrZto_chmodrr7r8pfs    z+easy_install.unpack_and_compile..pfimi)rrrr:statST_MODErx)rrrrr]ryr7rr8rs  zeasy_install.unpack_and_compilec Csjtjr dSddlm}z@t|jd||dd|jd|jrT|||jd|jdW5t|jXdS)Nr)rr)rxforcer) rdont_write_bytecodedistutils.utilrr rrrrx)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/deprecated/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)Nrr9r)rr)get_finalized_commandrrrr rr:rDEFAULT_SCHEMErrrrrr;r)rrrrSrrrr7r7r8r?s        zeasy_install._expand)T)F)F)T)N)rur7)r)M__name__ __module__ __qualname____doc__ descriptionZcommand_consumes_argumentsrr user_optionsboolean_options negative_optrrrrr staticmethodrrrrrrrrrrrKrLlstripr r"r#rrr7r;r=r? contextlibcontextmanagerrCr/rFrrHr`rhr5r3rnrlrOrPrrrrrrrXrrrrrrUrrrrMrrrr rrr7r7r7r8r/ns5     - ;   ! $ )    3 6.5   )  cCs tjddtj}td|S)Nrr)r:rrrpathsepfilter)rr7r7r8 _pythonpathVsrc 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..)extendrrrrrrr:r;r seprrrrrrrrrsuppressAttributeErrorgetsitepackagesrrr)rrrZhome_spZ lib_pathsr7rr8r[s^             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;rrarMrr rrrrrstrip)inputsseenr*r:rr]linesliner7r7r8 expand_pathss8        rc 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..)rZipFilerinfolistrrrrMrr upperrrtrrMrNrrsortreverse)Z exe_filenamerrRrrrrgpthr7r7r8r2s<      " 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__rrrVr")rrrr;r7r7r8r2"szPthDistributions.__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;rrrrr rrMrr r0r<popdirtyr)rZ saw_importr r]r r;r7r7r8r1+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)r7rrrrr rr _wrap_linesr r:r;rrrr+r<)rZ rel_pathsr datar]r7r7r8rJs   zPthDistributions.savecCs|Srr7)r r7r7r8r8`szPthDistributions._wrap_linescCsN|j|jko$|j|jkp$|jtk}|r>|j|jd|_t||dS)z"Add `dist` to the distribution mapTN) rIrrr:getcwdrr7r#rV)rrnew_pathr7r7r8rVds   zPthDistributions.addcCs2|j|jkr"|j|jd|_qt||dS)z'Remove `dist` from the distribution mapTN)rIrrWr7r#r_r7r7r8rWrs zPthDistributions.removecCstjt|\}}t|j}|g}tjdkr2dp6tj}t||kr||jkrl|tj | | |Stj|\}}||q8|S)Nr) r:r;rrrr0altseprrcurdirr.r )rr;npathlastZbaselenrrr7r7r8rys      zPthDistributions.make_relativeN)r7) rrrrr7r2r1rrr8rVrWrr7r7r7r8r0s  c@s(eZdZeddZedZedZdS)RewritePthDistributionsccs$|jV|D] }|Vq |jVdSr)preludepostlude)clsr r r7r7r8r8sz#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 classmethodr8rPrArBr7r7r7r8r@s r@ZSETUPTOOLS_SYS_PATH_TECHNIQUErawZrewritecCs ttjtrtSttjS)z_ Return a regular expression based on first_line_re suitable for matching strings. )rrpatternrrecompilertr7r7r7r8_first_line_res rIcCs\|tjtjfkr.tjdkr.t|tj||St\}}}|d|dd||ffdS)Nrrrz %s %s) r:rrWrrxrS_IWRITErr!)funcargexcetZevrr7r7r8 auto_chmods  rOcCs.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)rUcacheresult prefix_lenpnpr7r7r8"_collect_zipimporter_cache_entries s   r[cCs@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)r[)rUrVupdaterrY old_entryZ new_entryr7r7r8_update_zipimporter_caches  r^cCst||dSr)r^)rUrVr7r7r8rP>srPcCsdd}t|tj|ddS)NcSs |dSr)clearr;r]r7r7r82clear_and_remove_cached_zip_archive_directory_dataCszf_remove_and_clear_zip_directory_cache_data..clear_and_remove_cached_zip_archive_directory_datar\r^r_zip_directory_cache)rUrar7r7r8rSBs rSZ__pypy__cCsdd}t|tj|ddS)NcSs&|t||tj||Sr)r_rrupdaterdr`r7r7r8)replace_cached_zip_archive_directory_dataYs zT_replace_zip_directory_cache_data..replace_cached_zip_archive_directory_datarbrc)rUrfr7r7r8rRXs  rRc Cs4zt||dWnttfk r*YdSXdSdS)z%Is this string a valid Python script?execFTN)rH SyntaxError TypeError)rOrr7r7r8 is_pythonks rkc 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_shus  rpcCs t|gS)z@Quote a command line argument according to Windows parsing rules subprocess list2cmdline)rLr7r7r8 nt_quote_argsrtcCsH|ds|drdSt||r&dS|drDd|dkSdS)zMIs this text, as a whole, a Python script? (as opposed to shell/bat/etc. r~.pywTrmrrF)rMrkr splitlinesr-)rprr7r7r8rms  rm)rxcGsdSrr7)rwr7r7r8_chmodsrwc CsRtd||zt||Wn0tjk rL}ztd|W5d}~XYnXdS)Nzchanging mode of %s to %ozchmod failed: %s)r rrwr:error)r;ryrdr7r7r8rxs rxc@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. r7rCr7r7r8rjszCommandSpec.bestcCstjtj}tjd|S)N__PYVENV_LAUNCHER__)r:r;r>rr,rr)rC_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)rCparamr7r7r8 from_params  zCommandSpec.from_paramcCs||gSr)r}rzr7r7r8r~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)rCstringrr7r7r8rszCommandSpec.from_stringcCs8t|||_t|}t|s4dg|jdd<dS)Nz-xr)rr_extract_optionsoptionsrrrsrI)rrpcmdliner7r7r8install_optionss zCommandSpec.install_optionscCs:|dd}t|}|r.|dp0dnd}|S)zH Extract any options from the first line of the script. rJrrr)rvrImatchgrouprM)Z orig_scriptfirstrrr7r7r8rs zCommandSpec._extract_optionscCs||t|jSr)_renderrrrr7r7r8 as_headerszCommandSpec.as_headercCs6d}|D](}||r||r|ddSq|S)Nz"'rr)rrM)itemZ_QUOTESqr7r7r8 _strip_quotess zCommandSpec._strip_quotescCs tdd|D}d|dS)Ncss|]}t|VqdSr)ryrrM)rrr7r7r8rsz&CommandSpec._render..rmrJrq)rrr7r7r8rs zCommandSpec._renderN)rrrrrrrrDrjr}rr~rrrrrrrr7r7r7r8rys*       ryc@seZdZeddZdS)WindowsCommandSpecFrN)rrrrrr7r7r7r8rsrc@seZdZdZedZeZ e dddZ e dddZ e dd d Z ed d Ze d dZe ddZe ddZe dddZdS)riz` 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)rlrmrnWindowsScriptWriterrirjget_script_headerrk)rCrr,wininstwriterheaderr7r7r8get_script_args(s zScriptWriter.get_script_argscCs$tjdtdd|rd}|||S)NzUse get_headerr) stacklevelr')rlrmrnro)rCrpr,rr7r7r8r0szScriptWriter.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) rorr[ get_entry_mapr_ensure_safe_nametemplater_get_script_args) rCrrrtype_rreprprwrr7r7r8rk9s   zScriptWriter.get_argscCstd|}|rtddS)z? Prevent paths in *_scripts entry point names. z[\\/]z+Path separators not allowed in script namesN)rGsearchr)rZ has_path_sepr7r7r8rKs zScriptWriter._ensure_safe_namecCs tdt|rtS|SNzUse best)rlrmrnrrj)rCZ force_windowsr7r7r8 get_writerTs zScriptWriter.get_writercCs.tjdkstjdkr&tjdkr&tS|SdS)zD Select the best ScriptWriter for this environment. win32javarN)rrr:r_namerrjrzr7r7r8rjZszScriptWriter.bestccs|||fVdSrr7)rCrrrrpr7r7r8rdszScriptWriter._get_script_argsrcCs"|j|}|||S)z;Create a #! line, getting options (if any) from script_text)command_spec_classrjrrr)rCrpr,cmdr7r7r8rois zScriptWriter.get_header)NF)NF)N)rN)rrrrrKrLrrryrrDrrrkrrrrjrror7r7r7r8ris&#       ric@sLeZdZeZeddZeddZeddZeddZ e d d Z d S) rcCstdt|Sr)rlrmrnrjrzr7r7r8rts zWindowsScriptWriter.get_writercCs"tt|d}tjdd}||S)zC Select the best ScriptWriter suitable for Windows )r,ZnaturalZSETUPTOOLS_LAUNCHERr,)rWindowsExecutableLauncherWriterr:rr)rCZ writer_lookuplauncherr7r7r8rjzs zWindowsScriptWriter.bestc #stddd|}|tjddkrBdjft}t|t dddd d dd g}| || ||}fd d |D}|||d|fVdS)z For Windows, add a .py extensionz.pyarurPATHEXT;zK{ext} not listed in PATHEXT; scripts will not be recognized as executables.r~ -script.py.pyc.pyor|csg|] }|qSr7r7rvrr7r8rsz8WindowsScriptWriter._get_script_args..ruN) rr:rr-rrrrlrm UserWarningrW_adjust_header) rCrrrrpextrrrr7rr8rs   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)rGrHescape IGNORECASEsub _use_header)rCrZ orig_headerrFrZ 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) rrrrrrDrrjrrrrr7r7r7r8rqs    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.pywruclirr~rrcsg|] }|qSr7r7rvrr7r8rszDWindowsExecutableLauncherWriter._get_script_args..rur|r^z .exe.manifestN)rget_win_launcherr9load_launcher_manifest) rCrrrrpZ launcher_typerrhdrrZm_namer7rr8rs"  z0WindowsExecutableLauncherWriter._get_script_argsN)rrrrDrr7r7r7r8rsrcCsJd|}tr4tdkr&|dd}q@|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.exez win-arm64.z-arm64.z-64.z-32.r)r9rrNr)typeZ launcher_fnr7r7r8rs  rcCsttd}|dtS)Nzlauncher manifest.xmlrs) pkg_resourcesrrrtvars)rmanifestr7r7r8rs rFcCst|||Sr)rbr)r; ignore_errorsonerrorr7r7r8rsrcCstd}t||S)N)r:umask)tmpr7r7r8rws  rwc@seZdZdZdS)rnzF Warning for EasyInstall deprecations, bypassing suppression. N)rrrrr7r7r7r8rnsrn)N)rg)|rrrrrrdistutils.errorsrrrr distutils.command.installr r rr r Zdistutils.command.build_scriptsrr.rrr:rrbr@rrGrr rKrlrr5rrrrrr sysconfigrrrrrZsetuptools.sandboxrZsetuptools.commandrZsetuptools.archive_utilrZsetuptools.package_indexrrrrrZsetuptools.wheelrrrrrr r!r"r#r$r%r&r'r(r)r*r+filterwarnings PEP440Warning__all__r9r.rFrIrPr/rrrr1r2r0r@rrrIrOrr[r^rPrSbuiltin_module_namesrRrkrprtrmrxrw ImportErrorrryr}Zsys_executablerrirrrrrrrrwrnr7r7r7r8s          DqF.)%l  R    TtA