a oeQ@sdZddlmZddlmZddlmZmZddlmZmZm Z m Z ddl m Z m Z ddlmZddlmZdd lmZdd lZdd 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'dd l(m)Z)dd l*m+Z+ddl,m-Z-ddl.m/Z/ddl0m1Z1m2Z2m3Z3ddl,m4Z4m5Z5ddl6m7Z7m8Z8ddl9m:Z:ddl;mZ>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHdd l;Z;ddlImJZJddlKmLZLddlMmNZNejOde;jPdgdZQddZRddZSd d!ZTd"d#ZUGd$d%d%e)ZVd&d'ZWd(d)ZXd*d+ZYd,d-ZZd.d/Z[Gd0d1d1e@Z\Gd2d3d3e\Z]ej^_d4d5d6kre]Z\d7d8Z`d9d:Zad;d<Zbd=d>Zcdmd?d@ZddAdBZedCdDZfdEejgvrefZhndFdGZhdndIdJZidKdLZjdMdNZkdOdPZlzddQlmmZnWneoy>dRdSZnYn0dTdUZmGdVdWdWepZqeqrZsGdXdYdYeqZtGdZd[d[ZuGd\d]d]euZvGd^d_d_evZwd`daZxdbdcZyddeafdedfZzdgdhZ{didjZ|Gdkdldle7Z}d S)oa) 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.pypa.io/en/latest/deprecated/easy_install.html )glob) get_platform) convert_path subst_vars)DistutilsArgErrorDistutilsOptionErrorDistutilsErrorDistutilsPlatformError)logdir_util) first_line_re)find_executable)installN)get_path)Command) run_setup)setopt)unpack_archive) PackageIndexparse_requirement_arg URL_SCHEME) bdist_eggegg_info)SetuptoolsDeprecationWarningSetuptoolsWarning)Wheel) normalize_pathresource_stringget_distributionfind_distributions Environment Requirement Distribution PathMetadata EggMetadata WorkingSetDistributionNotFoundVersionConflict DEVELOP_DIST) py312compat)ensure_directory) yield_linesdefault)category) easy_installPthDistributionsextract_wininst_cfgget_exe_prefixescCstddkS)NP)structcalcsizer7r7@C:\Program Files\Certbot\pkgs\setuptools\command\easy_install.pyis_64bit]sr9cCs |dS)Nutf8)encodesr7r7r8 _to_bytesasr>cCs*z|dWdSty$YdS0dS)NasciiTF)r; UnicodeErrorr<r7r7r8isasciies   rAcCst|ddS)N z; )textwrapdedentstripreplace)textr7r7r8 _one_linermsrHc@seZdZdZdZdZdddddd d d d d ddddddddddddddejfgZgdZ ddiZ e Z dd Z d!d"Zd#d$Zed%d&Zd'd(Zed)d*Zed+d,Zd-d.Zd/d0Zd1d2Zd3d4Zdd5d6Zd7d8Zd9d:Zd;d<Zed=Z ed>Z!ed?Z"d@dAZ#dBdCZ$dDdEZ%dFdGZ&dHdIZ'dJdKZ(e)j*dLdMZ+ddOdPZ,ddQdRZ-dSdTZ.ddUdVZ/dWdXZ0dYdZZ1d[d\Z2dd]d^Z3ed_d`Z4ddcddZ5dedfZ6dgdhZ7didjZ8dkdlZ9dmdnZ:dodpZ;edqZedvZ?dwdxZ@dydzZAd{d|ZBd}d~ZCddZDddZEddZFddZGedHZIddZJeKeKddddZLeKdddZMddZNdS)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=r=zinstall 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') rIrKrPrMrRr[r]r`rbrcrXrIcCstd|_d|_|_d|_|_|_d|_d|_ d|_ d|_ d|_ |_ d|_|_|_d|_|_|_d|_|_|_d|_d|_d|_d|_d|_d|_d|_d|_d|_t j!|_"t j#|_$d|_%d|_&d|_'|_(d|_)i|_*d|_+|j,j-|_-|j,.||j,/ddS)Nrr/)0EasyInstallDeprecationWarningemitrczip_oklocal_snapshots_ok install_dir script_direxclude_scripts index_url find_linksbuild_directoryargsoptimizerecordrM always_copy multi_versionr[no_deps allow_hostsrootprefix no_reportrbinstall_purelibinstall_platlibinstall_headers install_libinstall_scripts install_data install_baseinstall_platbasesite USER_BASEinstall_userbase USER_SITEinstall_usersite no_find_links package_indexpth_filealways_copy_from site_dirsinstalled_projectsZ_dry_run distributionverboseZ_set_command_optionsget_option_dictselfr7r7r8initialize_optionssB     zeasy_install.initialize_optionscCs"dd|D}tt|j|dS)Ncss*|]"}tj|stj|r|VqdSN)ospathexistsislink).0filenamer7r7r8 sz/easy_install.delete_blockers..)listmap _delete_path)rblockersZextant_blockersr7r7r8delete_blockersszeasy_install.delete_blockerscCsJtd||jrdStj|o.tj| }|r8tntj}||dS)Nz Deleting %s) r infodry_runrrisdirr_rmtreeunlink)rrZis_treeZremoverr7r7r8rs  zeasy_install._delete_pathcCs8djtj}td}d}t|jfittdS)zT Render the Setuptools version and installation details, then exit. {}.{} setuptoolsz=setuptools {dist.version} from {dist.location} (Python {ver})N)formatsys version_inforprintlocals SystemExit)Zverdisttmplr7r7r8_render_versions  zeasy_install._render_versioncCsX|jo |tjd}tt|_|j|j |j |j |tj jdtj jtj jtj j|jd|jdttddttddd tt.|jttd Wdn1s0Y|jd ttd ddd|j|jd <|j|jd<|jr4tjs4td| |!|"|#dddd|j$durp|j%|_$|j&durd|_&|'dd|'dd|jr|j(r|j(|_%|j)|_$|'ddt*|_+|j+,|-|j.|j/s|0t12dd}|j3p||_3|j+dd|_4|j%t5|j$fD] }||j4vr,|j46d|q,|j7durrdd|j7dD}nd g}|j8dur|j9|j3|j4|d!|_8t:|j4tj;|_<|j=durt>|j=t?r|j=|_=ng|_=|j@r|j8A|j4tj;|j&s |j8B|j=|'dd"|C|jD|_D|j/r>|jEs>tFd#|jGsNtFd$g|_HdS)%Nr.rv exec_prefixabiflags platlibdirlib) Z dist_nameZ dist_versionZ dist_fullname py_versionZpy_version_shortZpy_version_nodotZ sys_prefixZsys_exec_prefixrr)Zimplementation_lowerimplementationZpy_version_nodot_platZwindiruserbaseZusersitez6WARNING: The user site-packages directory is disabled.rhrirmrFr{)rhrhr|rhrir)rprpZ__EASYINSTALL_INDEXzhttps://pypi.org/simple/cSsg|] }|qSr7)rErr=r7r7r8 Jz1easy_install.finalize_options..,*) search_pathhosts)roroz9Must specify a build directory (-b) when using --editablez:No urls, filenames, or requirements specified (see --help))Irbrrsplitdict sysconfigZget_config_vars config_varsupdaterZget_nameZ get_versionZ get_fullnamermajorminorgetattr contextlibsuppressAttributeErrorrZ_get_implementationlower setdefaultrFrrrcrENABLE_USER_SITEr warn_fix_install_dir_for_user_siteexpand_basedirs expand_dirs_expandrirhrZset_undefined_optionsrxr| get_site_dirs all_site_dirsextend_process_site_dirsrr[check_site_dirrgetenvrk shadow_pathrinsertrtr create_indexr r local_indexrl isinstancestrrgZscan_egg_linksadd_find_links_validate_optimizerormrrnoutputs)rrZ default_index path_itemrr7r7r8finalize_optionss    "              zeasy_install.finalize_optionsccsx|dur dStttj}dd|dD}|D]B}tj|sNtd|q0t||vrht |dq0t|Vq0dS)NcSsg|]}tj|qSr7)rr expanduserrErr7r7r8rrrz3easy_install._process_site_dirs..rz"%s (in --site-dirs) does not existz$ (in --site-dirs) is not on sys.path) rrrrrrrr rr)rnormpathrOr7r7r8rls   zeasy_install._process_site_dirsc CsPzt|}|tdvrtWn.tyJ}ztd|WYd}~n d}~00|S)Nz--optimize must be 0, 1, or 2)intrange ValueErrorr)valuer\r7r7r8r{s  zeasy_install._validate_optimizecCsP|js dS||jdur(d}t||j|_|_tjd}||dS)z; Fix the install_dir if "--user" was used. Nz$User base directory is not specified_user) rccreate_home_pathrr r~rrname select_scheme)rmsgZ scheme_namer7r7r8rs  z+easy_install._fix_install_dir_for_user_sitecCsX|D]N}t||}|durtjdks.tjdkr:tj|}t||j}t|||qdS)Nposixnt)rrrrrrrsetattr)rattrsattrvalr7r7r8 _expand_attrss   zeasy_install._expand_attrscCs|gddS)zNCalls `os.path.expanduser` on install_base, install_platbase and root.)r~rruNrrr7r7r8rszeasy_install.expand_basedirscCsgd}||dS)z+Calls `os.path.expanduser` on install dirs.)rxryr{rzr|r}Nr)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 |Wt|jjnt|jj0dS)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')Zannouncer ZWARNrr set_verbosityrnr/rsrprrulenr distutilsrexecuteZ write_filewarn_deprecated_options)rZshow_deprecationspecrZroot_lenZcounterrr7r7r8runs0     zeasy_install.runcCsBz t}Wn ty,tdtj}Yn0tj|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) rgetpid ExceptionrandomZrandintrmaxsizerjoinrh)rZpidr7r7r8pseudo_tempnames   zeasy_install.pseudo_tempnamecCsdSrr7rr7r7r8rsz$easy_install.warn_deprecated_optionscCsBt|j}tj|d}tj|sNzt|WntyL|Yn0||j v}|sl|j sl| }n^| d}tj|}z*|rt |t|dt |Wnty|Yn0|s|j stjdd}t|j|j||r|jdurt||j |_nd|_|j r8tj|s8d|_||_dS)z;Verify that self.install_dir is .pth-capable dir, if neededeasy-install.pthz .write-testw PYTHONPATHrN)rrhrrrrmakedirsOSErrorcant_write_to_targetrrrcheck_pth_processingrropencloseenvirongetr r_easy_install__no_default_msgrr0)rinstdirrZ is_site_dirZtestfileZ test_existsZ 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.pypa.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)NrB) _easy_install__cant_write_msgrexc_inforhrrr_easy_install__not_exists_id_easy_install__access_msgr)rrr7r7r8r 1s z!easy_install.cant_write_to_targetc Cs$|j}td||d}|d}tj|}tdd}z6|rNt|tj |}tj |ddt |d}Wnt y| Yn|0z6||jfit|d }tj}tjd krtj|\}} tj|d } | d kotj| } | r| }d dlm} | |dddgd tj|rtd|W|rV|tj|rnt|tj|rt|dSW|r|tj|rt|tj|r t|n@|r|tj|rt|tj|r t|0|js td|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() rBT)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)rhr rrrrrrHrdirnamer r r r writerrrr executablerrrrdistutils.spawnrrrr) rrrZok_fileZ ok_existsrrrUr basenameZaltZuse_altrr7r7r8r =sr                 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)rjZmetadata_isdirZmetadata_listdirinstall_scriptZ get_metadatainstall_wrapper_scripts)rr script_namer7r7r8install_egg_scriptswsz easy_install.install_egg_scriptscCsTtj|rDt|D]*\}}}|D]}|jtj||q$qn |j|dSr)rrrwalkrappendr)rrbaserfilesrr7r7r8 add_outputs  zeasy_install.add_outputcCs|jrtd|fdS)NzjInvalid argument %r: you can't use filenames or URLs with --editable (except via the --find-links option).)r[rrrr7r7r8 not_editables zeasy_install.not_editablecCs<|js dStjtj|j|jr8td|j|jfdS)Nz2%r already exists in %s; can't do a checkout there)r[rrrrrmkeyrr-r7r7r8check_editables zeasy_install.check_editablec csJtjdd}z"t|VWtj|o,t|ntj|oBt|0dS)Nz easy_install-)rv)tempfilemkdtemprrrrr)rtmpdirr7r7r8_tmpdirs  zeasy_install._tmpdirFc CsX|8}t|tst|rV|||j||}|d|||dWdStj |r|||d|||dWdSt |}| ||j |||j|j|j |j}|durd|}|jr|d7}t|nN|jtkr||||d|WdS|||j||WdSWdn1sJ0YdS)NTz+Could not find suitable distribution for %rz2 (--always-copy skips system and development eggs)Using)r4rr!rr.rdownload install_itemrrrrr0Zfetch_distributionrMr[rqrrZ precedencer(process_distributionlocation)rrdepsr3dlrrr7r7r8r/s8          zeasy_install.easy_installcCs |p|j}|ptj||k}|p,|d }|pT|jduoTtjt|t|jk}|r|s|j|jD]}|j |krjqqjd}t dtj ||r| |||}|D]}||||qn ||g}|||d|d|dur|D]}||vr|SqdS)N.eggTz Processing %srr5)rqrrrendswithrrr project_namer9r rr" install_eggsr8egg_distribution)rrr6r3r:Zinstall_neededrZdistsr7r7r8r7s2     zeasy_install.install_itemc Cs>zt||Wn(ty8tj||ddYn0dS)NrZunix)rZ_select_schemerrrF)rrr7r7r8rs zeasy_install.select_schemec Gs|||j|||j|jvr2|j||j|||||j|j<t |j ||g|R| dr|j s|j |d|s|jsdS|dur|j|jkrtd|dS|dus||vr|}tt|}t d|ztg|g|j|j}WnftyB}ztt||WYd}~n)rrr& script_textdev_pathrZ is_scriptbodyr7r7r8r$Fs   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)rFrdecode)r[rZ raw_bytesr7r7r8rXPs   zeasy_install._load_templatetr7csfdd|Dtd|jtjj|}|jrLdSt }t |tj |rpt |t |d|}||Wdn1s0Yt|d|dS)z1Write an executable file to the scripts directorycsg|]}tjj|qSr7)rrrrirrQrr7r8rbrz-easy_install.write_script..zInstalling %s script to %sNri)rr rrirrrr,r current_umaskr+rrr rchmod)rr&rQmodertargetmaskrUr7rr8rV_s   (zeasy_install.write_scriptc CsR|j|j|jd}z||dd}Wnty<Yn0|||gS|}tj|rt|dstt |||j ntj |rtj |}| |r|jr|dur||||}tj|d}tj|s$ttj|dd}|stdtj |t|dkrtdtj ||d }|jrBt|||gS|||SdS) N)r<.exez.whl.pyzsetup.pyrz"Couldn't find a setup script in %srzMultiple setup scripts in %sr) install_egg install_exe install_wheelrKeyErrorrrisfiler=runpack_progressrabspath startswithrmrRrrrrrr[r rreport_editablebuild_and_install) rrrNr3Z installer_mapZ install_distrO setup_scriptZsetupsr7r7r8r?ssN     zeasy_install.install_eggscCs>tj|r"t|tj|d}ntt|}tj ||dS)NEGG-INFO)metadata) rrrr#rr$ zipimport zipimporterr"Z from_filename)regg_pathrur7r7r8r@s zeasy_install.egg_distributionc Cstj|jtj|}tj|}|js2t|||}tj |rXtj ||stj |rtj |st j||jdn"tj |r|tj|fd|zd}tj |r||rtjd}}n tjd}}nN||r|||jd}}n*d}||rtjd}}n tjd}}||||f|dtj|tj|ft||d Wn"tyt|dd Yn0||||S) Nr Removing FZMovingZCopyingZ ExtractingTz %s to %sfix_zipimporter_caches)rrrrhr"rorr+r@rsamefilerrr remove_treerrrprLrMcopytreerJZmkpathunpack_and_compilecopy2rupdate_dist_cachesrr,)rrxr3 destinationrZnew_dist_is_zippedrUrLr7r7r8risb               zeasy_install.install_eggc sPt|}|durtd|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 .exerurrb)r>rbplatformr<z.tmprtPKG-INFOrzMetadata-Version: 1.0 target_versionz%s: %s _-r#csg|]}tj|dqS)r)rrr)rrnrir7r8rrz,easy_install.install_exe..)rr)r1rr"rrrrregg_namer9r+r#Z _provider exe_to_eggrr ritemsrFtitlerrrSrUrZ make_zipfilerrri) rrNr3cfgrrxegg_tmpZ _egg_infoZpkg_infrUkvr7rr8rjsJ       zeasy_install.install_exec s8t|ggifdd}t||g}D]n}|dr<|d}|d}t|dd|d<tjj g|R} || |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}tjjg|R}|}|dsl|drt |d|d<dtj |dd< |n4|dr|dkrdtj |dd< ||Sq |d st d |dS) N/.pyd.dllrrrhSCRIPTS/rzWARNING: can't process %s)rrprrrrrr=r strip_modulesplitextr)r r)srcrPr=oldnewpartsr;r native_libsprefixes to_compile top_levelr7r8processs$        z(easy_install.exe_to_egg..processrrrrhrt)rrz.txtrrBN)r2rrr=rrrrrrr)Z write_stub byte_compileZwrite_safety_flagZ analyze_eggrrr rr) rrNrrZstubsresrresourceZpyfilerZtxtrUr7rr8rs6        zeasy_install.exe_to_eggc Cst|}|sJtj|j|}tj|}|jsBt |tj |rltj |slt j ||jdn"tj|r|tj|fd|z:||j|fdtj|tj|fWt|ddnt|dd0||||S)NryrzzInstalling %s to %sFr{)rZ is_compatiblerrrrhrrorr+rrr r~rrrZinstall_as_eggr"rrr,r@)rZ wheel_pathr3Zwheelrr7r7r8rkJs2    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}|jtttjvr>|d|j7}|j }|j }|j }d}|t S)z9Helpful installation message for display to package usersz %(what)s %(eggloc)s%(extras)srBr) rrrw_easy_install__mv_warningrhrrrr_easy_install__id_warningr9r>rbr) rZreqrZwhatrZegglocrrbextrasr7r7r8rDzs 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)NrB)rrrrr _easy_install__editable_msgr)rrrsrpythonr7r7r8rqs zeasy_install.report_editablec Cstjdttjdtt|}|jdkrNd|jd}|dd|n|jdkrd|dd|jrv|dd t d |t |ddd |zt ||Wn:ty}z"td |jdf|WYd}~n d}~00dS) Nzdistutils.command.bdist_eggzdistutils.command.egg_infor)rrrrz-qz-nz Running %s %s zSetup script exited with %s)rmodulesrrrrrrrr rrrrrrrn)rrsrOrnrr7r7r8rs    $zeasy_install.run_setupc Csddg}tjdtj|d}z|tj|||||||t|g}g}|D]&}||D]}|| |j |qhq\|s|j st d||Wt|t |jSt|t |j0dS)Nrz --dist-dirz egg-dist-tmp-)rvdirz+No eggs found in %s (setup script problem?))r1r2rrr_set_fetcher_optionsr)rr rir9rr rrrr) rrsrOrnZdist_dirZall_eggsZeggsr/rr7r7r8rrs.       zeasy_install.build_and_installc Csh|jd}d}i}|D]\}}||vr2q |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/)rlrrkrortr)r/z setup.cfgN) rrcopyrrrrrrZ edit_config) rr*Zei_optsZfetch_directivesZ fetch_optionsr/rZsettingsZ cfg_filenamer7r7r8rs  z!easy_install._set_fetcher_optionscCsL|jdurdS|j|jD]J}|js2|j|jkr2qtd||j||j|jvr|j|jq|js|j|jjvrtd|n2td||j ||j|jvr|j |j|j rdS|j |jdkrdSt j|jd}t j|rt |t|d(}||j|jdWdn1s>0YdS)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.pthwtrB)rr/rrr9r rrCrpathsrBr)rsaverrrrhrrr r make_relative)rrrOrrUr7r7r8rAs:           zeasy_install.update_pthcCstd|||S)NzUnpacking %s to %s)r debug)rrrPr7r7r8rnszeasy_install.unpack_progresscsdggfdd}t|||js`D]&}t|tjdBd@}t||q8dS)NcsZ|dr |ds |n|ds4|dr>|||j rV|pXdS)Nrh EGG-INFO/rz.so)r=rpr)rnr)rrPrZto_chmodrr7r8pfs    z+easy_install.unpack_and_compile..pfimi)rrrrstatST_MODErb)rrxrrrUrcr7rr8r s  zeasy_install.unpack_and_compilec Csvtjr dSddlm}zLt|jd||dd|jd|jrT|||jd|jdWt|jnt|j0dS)Nr)rr)roforcer) rdont_write_bytecodedistutils.utilrr rrrro)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.pypa.io/en/latest/deprecated/easy_install.html#custom-installation-locations Please make the appropriate changes for your system and try again. cCsb|js dSttjd}t|jD]4}||r(tj |s(| d|t |dq(dS)zCreate directories under ~.N~zos.makedirs('%s', 0o700)i) rcrrrr only_strsrvaluesrprZ debug_printr )rhomerr7r7r8rVszeasy_install.create_home_pathz/$base/lib/python$py_version_short/site-packagesz $base/binrrz$base/Lib/site-packagesz $base/ScriptscGs|dj}|jrdt|}|j|d<|jtj|j}| D]$\}}t ||ddur>t |||q>ddl m }|D]B}t ||}|durt|||}tjdkrtj|}t |||qtdS)Nrr*r)rr)Zget_finalized_commandrrvrINSTALL_SCHEMESrrrDEFAULT_SCHEMErrrrrrr)rrrschemerrrr7r7r8rls        zeasy_install._expand)T)F)F)T)N)r_r7)r)O__name__ __module__ __qualname____doc__ descriptionZcommand_consumes_argumentsrrZ user_optionsZboolean_optionsZ negative_optrrrrr staticmethodrrrrrrrrrrrrrCrDlstriprrrr r r'r,r.r0rcontextmanagerr4r/r7rr8rJrRr%r$rXrVr?r@rirjrrkrrrDrrqrrrrrArnrrrErrrrrrr7r7r7r8r/qs! -  {     - :    % # ,    3615   )" r/cCs tjddtj}td|S)Nrr)rrrrpathsepfilter)rr7r7r8 _pythonpathsrc sgttjg}tjtjkr0|tj|D]}|s>q4tjdvr`tj |ddnVtj dkrtj |ddj tj dtj |ddgn|tj |ddgtjdkrq4d |vrq4tj d }|sq4tj |d d d j tj d}|q4tdtdf}fdd|DtjrBtjtttWdn1sr0YtttS)z& Return a list of 'site' dirs )Zos2emxZriscosZLibz site-packagesrrz python{}.{}z site-pythondarwinzPython.frameworkHOMELibraryPythonrZpurelibZplatlibc3s|]}|vr|VqdSrr7rsitedirsr7r8rrz get_site_dirs..N)rrrrvrr)rrrrseprrrrrrrrrrrgetsitepackagesrrr)rrvrZhome_spZ lib_pathsr7rr8rsb             .rccsi}|D]}t|}||vrqd||<tj|s4qt|}||fV|D]}|ds\qL|dvrfqLttj||}tt |}| |D]L}| drqt| }||vrqd||<tj|sq|t|fVqqLqdS)zBYield sys.path directories that might contain "old-style" packagesrr)rrimportN) rrrrrKr=r rrr,rrprstrip)Zinputsseenrr+rrUlinesliner7r7r8 expand_pathss8        rc Cs`t|d}zDt|}|dur.W|dS|d|d|d}|dkr\W|dS||dtd|d\}}}|dvrW|dS||d|d d d }t |}z<||} | d d d } | t } |t| Wn"tjyYW|dS0|dr6|dsDW|dS|W|S|0dS)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-packagesrrrr)rrz .egg-inforNrrz -nspkg.pth)ZPURELIBZPLATLIB\rz%s/%s/rcSsg|]\}}||fqSr7)r)rrQyr7r7r8rHrz$get_exe_prefixes..)rZipFileinfolistrrrr=rrupperrr^r,rErFrpr)rsortreverse)Z exe_filenamerrJrrrrQZpthr7r7r8r2)s2       r2csfeZdZdZdfdd ZddZddZd d Zed d Z fd dZ fddZ ddZ Z S)r0z)A .pth file with Distribution paths in itr7cs||_ttt||_ttj|j|_| \|_ |_ |j dd|_ t gddt|j D]}tt|jt|dqddS)NT)rrrrrrrrbasedir_loadrdirty _init_pathssuper__init__r,rBr)rrrr __class__r7r8rQszPthDistributions.__init__c Csg}d}}t|j}t|jd}|D]}|}|||drNd}q(|}|r(|drfq(t t j |j |} | |vst j | std|d}|q(d|| <q(||r|ds|d}q||p|o|fS) NFZrt)import from T#z!cleaned up dirty or duplicated %rrr)rfromkeysrr rrr)rprErrrrrrr rpopr) rrrZ saw_importrrUrr stripped_pathnormalized_pathr7r7r8 _load_raw\s2      zPthDistributions._load_rawcCstj|jr|SgdfS)NF)rrrmrrrr7r7r8r{szPthDistributions._loadc Cs|\}}|ddD]6}||jvrD|j|td|d}q||q|jddD]N}||vr^|ds^tj |j |}tj |s^|j|td|d}q^|j |p|j|j kO_ |j sdStt|j|j}|rftd|j||}d |d}tj|jr,t|jt|jd}||Wdn1sZ0Yn*tj |jrtd |jt|jd |_ |jdd|j dd<dS) z$Write changed .pth file back to diskNzdetected new path %rT)rrrz!removing now non-existent path %rz Saving %srBrzDeleting empty %sF)rrr)r rrCrprrrrrrrrrrrr _wrap_linesrrr r) rZ last_pathsZ last_dirtyrZ absolute_pathZ rel_pathsrdatarUr7r7r8rsB           , zPthDistributions.savecCs|Srr7)rr7r7r8r szPthDistributions._wrap_linescsN|j|jvo$|j|jvp$|jtk}|r>|j|jd|_t|dS)z"Add `dist` to the distribution mapTN) r9rrrgetcwdr)rrrB)rrnew_pathrr7r8rBs   zPthDistributions.addcs2|j|jvr"|j|jd|_qt|dS)z'Remove `dist` from the distribution mapTN)r9rrCrrrIrr7r8rCs zPthDistributions.removecCstjt|\}}t|j}|g}tjdkr2dp6tj}t||kr||jkrl|tj | | |Stj|\}}||q8|S)Nr) rrrrrraltseprr)curdirrr)rrZnpathZlastZbaselenrrr7r7r8rs      zPthDistributions.make_relative)r7)rrrrrrrrrr rBrCr __classcell__r7r7rr8r0Ns .  r0c@s(eZdZeddZedZedZdS)RewritePthDistributionsccs$|jV|D] }|Vq |jVdSr)preludepostlude)clsrrr7r7r8r sz#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 classmethodr rHrrr7r7r7r8rs rZSETUPTOOLS_SYS_PATH_TECHNIQUErawZrewritecCs ttjtrtSttjS)z_ Return a regular expression based on first_line_re suitable for matching strings. )rr patternrrecompiler^r7r7r7r8_first_line_res rcCs\|tjtjfvr.tjdkr.t|tj||St\}}}|d|dd||ffdS)Nrrrz %s %s) rrrCrrbrS_IWRITErr)funcargexcetZevrr7r7r8 auto_chmods  rcCs.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)Z dist_pathr|rr7r7r8r s <  rcCsPg}t|}|D]:}t|}||r|||dtjdfvr||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)rrrprrr))rcacheresult prefix_lenpZnpr7r7r8"_collect_zipimporter_cache_entries[s  r(cCs@t||D]0}||}||=|o(|||}|dur |||<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()rr$updaterr' old_entryZ new_entryr7r7r8_update_zipimporter_cacheqs  r+cCst||dSr)r+)rr$r7r7r8r sr cCsdd}t|tj|ddS)NcSs |dSr)clearrr*r7r7r82clear_and_remove_cached_zip_archive_directory_dataszf_remove_and_clear_zip_directory_cache_data..clear_and_remove_cached_zip_archive_directory_datar)r+rv_zip_directory_cache)rr.r7r7r8r#s r#Z__pypy__cCsdd}t|tj|ddS)NcSs&|t||tj||Sr)r,rvrwrr1r-r7r7r8)replace_cached_zip_archive_directory_datas zT_replace_zip_directory_cache_data..replace_cached_zip_archive_directory_datar/r0)rr2r7r7r8r"s  r"c Cs2zt||dWnttfy(YdS0dSdS)z%Is this string a valid Python script?execFTN)r SyntaxError TypeError)rGrr7r7r8 is_pythons r7cCsZz:t|dd}|d}Wdn1s.0YWntyP|YS0|dkS)zCDetermine if the specified executable is a .sh (contains a #! line)zlatin-1)encodingr)N#!)r rr )r fpmagicr7r7r8is_shs ,  r<cCs t|gS)z@Quote a command line argument according to Windows parsing rules subprocess list2cmdline)rr7r7r8 nt_quote_argsr@cCsH|ds|drdSt||r&dS|drDd|dvSdS)zHIs this text, as a whole, a Python script? (as opposed to shell/bat/etc.rh.pywTr9rrF)r=r7rp splitlinesr)rZrr7r7r8rWs  rW)rbcGsdSrr7)rnr7r7r8_chmodsrCc CsTtd||zt||Wn2tjyN}ztd|WYd}~n d}~00dS)Nzchanging mode of %s to %ozchmod failed: %s)r rrCrerror)rrcr\r7r7r8rbs rbc@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. r7rr7r7r8rTszCommandSpec.bestcCstjtj}tjd|S)N__PYVENV_LAUNCHER__)rrrrr rr)rZ_defaultr7r7r8_sys_executableszCommandSpec._sys_executablecCs:t||r|St|tr ||S|dur0|S||S)zg Construct a CommandSpec from a parameter to build_scripts, which may be None. N)rrfrom_environment from_string)rZparamr7r7r8 from_param s  zCommandSpec.from_paramcCs||gSr)rHrFr7r7r8rIszCommandSpec.from_environmentcCstj|fi|j}||S)z} Construct a command spec from a simple string representing a command line parseable by shlex.split. )shlexr split_args)rstringrr7r7r8rJszCommandSpec.from_stringcCs8t|||_t|}t|s4dg|jdd<dS)Nz-xr)rLr_extract_optionsoptionsr>r?rA)rrZcmdliner7r7r8install_options(s zCommandSpec.install_optionscCs:|dd}t|}|r.|dp0dnd}|S)zH Extract any options from the first line of the script. rBrrr)rBrmatchgrouprE)Z orig_scriptfirstrSrPr7r7r8rO.s zCommandSpec._extract_optionscCs||t|jSr)_renderrrPrr7r7r8 as_header8szCommandSpec.as_headercCs6d}|D](}||r||r|ddSq|S)Nz"'rr)rpr=)itemZ_QUOTESqr7r7r8 _strip_quotes;s zCommandSpec._strip_quotescCs tdd|D}d|dS)Ncss|]}t|VqdSr)rErZrE)rrXr7r7r8rEsz&CommandSpec._render..r9rBr=)rrQr7r7r8rVCs zCommandSpec._renderN)rrrrrPrrMrrTrHrKrIrJrRrrOrWrZrVr7r7r7r8rEs*       rEc@seZdZeddZdS)WindowsCommandSpecFrN)rrrrrMr7r7r7r8r[Osr[c@sbeZdZdZedZeZ e dddZ e ddZ e dd Ze d d Ze dd dZdS)rSz` 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)()) Nc cs|dur|}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. NZconsoleguiZ_scripts) rYrrFZ get_entry_mapr_ensure_safe_nametemplater_get_script_args) rrheaderrtype_rTrZeprZrnrr7r7r8rUs   zScriptWriter.get_argscCstd|}|rtddS)z? Prevent paths in *_scripts entry point names. z[\\/]z+Path separators not allowed in script namesN)rsearchr)rZ has_path_sepr7r7r8r^s zScriptWriter._ensure_safe_namecCs.tjdkstjdkr&tjdkr&tS|SdS)zD Select the best ScriptWriter for this environment. win32javarN)rrrr_nameWindowsScriptWriterrTrFr7r7r8rTszScriptWriter.bestccs|||fVdSrr7)rrbrrarZr7r7r8r`szScriptWriter._get_script_argsrcCs"|j|}|||S)z;Create a #! line, getting options (if any) from script_text)command_spec_classrTrKrRrW)rrZr cmdr7r7r8rYs zScriptWriter.get_header)N)rN)rrrrrCrDrr_rErhrrUrr^rTr`rYr7r7r7r8rSSs%    rSc@s@eZdZeZeddZeddZeddZe ddZ d S) rgcCs"tt|d}tjdd}||S)zC Select the best ScriptWriter suitable for Windows )r ZnaturalZSETUPTOOLS_LAUNCHERr )rWindowsExecutableLauncherWriterrrr)rZ writer_lookupZlauncherr7r7r8rTs zWindowsScriptWriter.bestc #stddd|}|tjddvrDdjfit}t|gd}| || ||}fdd |D}|||d |fVd S) z For Windows, add a .py extension.pyarAr\PATHEXT;zK{ext} not listed in PATHEXT; scripts will not be recognized as executables.)rkrh -script.py.pyc.pyorArfcsg|] }|qSr7r7r`rr7r8rrz8WindowsScriptWriter._get_script_args..r_N) rrrrrrrrrerC_adjust_header) rrbrrarZextrrrr7rqr8r`s   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). rrr])rNrepl)rrescape IGNORECASEsub _use_header)rrbZ orig_headerrrtZ pattern_ob new_headerr7r7r8rrs 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. r)r"rd)rErrr )ryZ clean_headerr7r7r8rxs zWindowsScriptWriter._use_headerN) rrrr[rhrrTr`rrrrxr7r7r7r8rgs   rgc@seZdZeddZdS)rjc #s|dkrd}d}dg}nd}d}gd}|||}fdd|D} |||d | fVd t|d fVtsd } | td fVd S)zG For Windows, add a .py extension and an .exe launcher r]z -script.pywrAZclirn)rhrorpcsg|] }|qSr7r7r`rqr7r8rrzDWindowsExecutableLauncherWriter._get_script_args..r_rfrVz .exe.manifestN)rrget_win_launcherr9load_launcher_manifest) rrbrrarZZ launcher_typersrZhdrrZm_namer7rqr8r`s" z0WindowsExecutableLauncherWriter._get_script_argsN)rrrrr`r7r7r7r8rjsrjcCsJd|}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-arm64rz-arm64.z-64.z-32.r)r9rrFr)typeZ launcher_fnr7r7r8r{ s  r{cCsttd}|dtS)Nzlauncher manifest.xmlr]) pkg_resourcesrrr^vars)rZmanifestr7r7r8r| s r|FcCst|||Sr)r*Z shutil_rmtree)r ignore_errorsZonexcr7r7r8r% srcCstd}t||S)N)rumask)tmpr7r7r8ra) s  racCstdd|S)z, Exclude non-str values. Ref #3063. cSs t|tSr)rr)rr7r7r83 rzonly_strs..)r)rr7r7r8r/ src@seZdZdZdZdZdS)rdz#easy_install command is deprecated.z Please avoid running ``setup.py`` and ``easy_install``. Instead, use pypa/build, pypa/installer or other standards-based tools. z-https://github.com/pypa/setuptools/issues/917N)rrrZ_SUMMARYZ_DETAILSZ_SEE_URLr7r7r7r8rd6 srd)N)r3)~rrrrrrZdistutils.errorsrrrr rr r Zdistutils.command.build_scriptsr r!r Zdistutils.commandrrrrvrLr1rrrrrCwarningsrr5rr>rLrrrrrrZsetuptools.sandboxrZsetuptools.commandrZsetuptools.archive_utilrZsetuptools.package_indexrrrrrZsetuptools.warningsrrZsetuptools.wheelrr~rrrrr r!r"r#r$r%r&r'r(rr*_pathr+Zextern.jaraco.textr,filterwarningsZ PEP440Warning__all__r9r>rArHr/rrrr1r2r0rrrrrrr(r+r r#builtin_module_namesr"r7r<r@rWrbrC ImportErrorrrErHZsys_executabler[rSrgrjr{r|rrarrdr7r7r7r8s           <   J.)%   R     U_;