3 (\@sddlmZddlmZddlmZmZddlZddlZddl Z ddl m Z ddl Z ddl mZddlmZddlZeZGdd d ejeZGd d d ZdS) ) convert_path)log)DistutilsErrorDistutilsOptionErrorN)six) easy_install) namespacesc@sveZdZdZdZejddgZejdgZd Zd d Z d d Z ddZ e ddZ ddZddZddZddZdS)developzSet up package for developmentz%install package in 'development mode' uninstalluUninstall this source package egg-path=N-Set the path to be used in the .egg-link fileFcCs2|jrd|_|j|jn|j|jdS)NT)r Z multi_versionuninstall_linkZuninstall_namespacesinstall_for_developmentZwarn_deprecated_options)selfrv/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-install-rm6ck8ia/setuptools/setuptools/command/develop.pyrun s  z develop.runcCs&d|_d|_tj|d|_d|_dS)N.)r egg_pathrinitialize_options setup_pathZalways_copy_from)rrrrr)s  zdevelop.initialize_optionscCs|jd}|jr,d}|j|jf}t|||jg|_tj||j|j |j j t j d|jd}t jj|j||_|j|_|jdkrt jj|j|_tj|j}tjt jj|j|j}||krtd|tj|tj|t jj|j|jd|_|j|j|j|j|_dS)Negg_infoz-Please rename %r to %r before using 'develop'z*.eggz .egg-linkzA--egg-path must be a relative path from the install directory to ) project_name)get_finalized_commandZbroken_egg_inforregg_nameargsrfinalize_optionsexpand_basedirs expand_dirsZ package_indexscanglobospathjoin install_diregg_linkegg_baserabspath pkg_resourcesnormalize_pathr Distribution PathMetadatadist_resolve_setup_pathr)reitemplaterZ egg_link_fntargetrrrrr0s<         zdevelop.finalize_optionscCsn|jtjdjd}|tjkr0d|jdd}tjtjj |||}|tjtjkrjt d|tjtj|S)z Generate a path from egg_base back to '.' where the setup script resides and ensure that path points to the setup path from $install_dir/$egg_path. /z../zGCan't get a consistent path to setup script from installation directory) replacer#seprstripcurdircountr*r+r$r%r)r(r&rZ path_to_setupZresolvedrrrr/Zs zdevelop._resolve_setup_pathc CsHtjrt|jddr|jddd|jd|jd}tj|j }|jd|d|jd|jddd|jd|jd}||_ ||j _ tj ||j|j _n"|jd|jdd d|jd|jtjr|jtjdt_|jtjd |j|j|js0t|jd }|j|j d |jWdQRX|jd|j |j dS) NZuse_2to3Fbuild_pyr)Zinplacer)r( build_extr4zCreating %s (link to %s)w )rPY3getattr distributionreinitialize_command run_commandrr*r+ build_librr.locationr-r _providerZinstall_site_py setuptoolsZbootstrap_install_fromrZinstall_namespacesrinfor'r(dry_runopenwriterZprocess_distributionno_deps)rZbpy_cmdZ build_pathZei_cmdfrrrrns6          zdevelop.install_for_developmentcCstjj|jrztjd|j|jt|j}dd|D}|j||j g|j |j gfkrhtj d|dS|j sztj |j|j s|j|j|jjrtj ddS)NzRemoving %s (link to %s)cSsg|] }|jqSr)r7).0linerrr sz*develop.uninstall_link..z$Link points to %s: uninstall abortedz5Note: you must uninstall or replace scripts manually!)r#r$existsr'rrGr(rIcloserrwarnrHunlinkZ update_pthr.r@scripts)rZ egg_link_filecontentsrrrrs    zdevelop.uninstall_linkc Cs||jk rtj||S|j|x^|jjp,gD]N}tjjt |}tjj |}t j |}|j }WdQRX|j||||q.WdS)N)r.rinstall_egg_scriptsinstall_wrapper_scriptsr@rTr#r$r)rbasenameiorIreadZinstall_script)rr. script_nameZ script_pathstrm script_textrrrrVs     zdevelop.install_egg_scriptscCst|}tj||S)N)VersionlessRequirementrrW)rr.rrrrWszdevelop.install_wrapper_scripts)r r r )r Nr)__name__ __module__ __qualname____doc__ descriptionr user_optionsboolean_optionsZcommand_consumes_argumentsrrr staticmethodr/rrrVrWrrrrr s  * 0r c@s(eZdZdZddZddZddZdS) r^a Adapt a pkg_resources.Distribution to simply return the project name as the 'requirement' so that scripts will work across multiple versions. >>> from pkg_resources import Distribution >>> dist = Distribution(project_name='foo', version='1.0') >>> str(dist.as_requirement()) 'foo==1.0' >>> adapted_dist = VersionlessRequirement(dist) >>> str(adapted_dist.as_requirement()) 'foo' cCs ||_dS)N)_VersionlessRequirement__dist)rr.rrr__init__szVersionlessRequirement.__init__cCs t|j|S)N)r?rg)rnamerrr __getattr__sz"VersionlessRequirement.__getattr__cCs|jS)N)r)rrrras_requirementsz%VersionlessRequirement.as_requirementN)r_r`rarbrhrjrkrrrrr^s r^)distutils.utilr distutilsrdistutils.errorsrrr#r"rYZsetuptools.externrr*Zsetuptools.command.easy_installrrFrtype __metaclass__ZDevelopInstallerr r^rrrrs     6