3

Q'ícnã@s¨ddlmZddlmZddlmZmZddlZddlZddl	Z	ddl
mZddlm
Z
mZmZddlmZddlmZddlZGd	d
„d
ejeƒZGdd„deƒZdS)
é)Úconvert_path)Úlog)ÚDistutilsErrorÚDistutilsOptionErrorN)Úsix)ÚDistributionÚPathMetadataÚnormalize_path)Úeasy_install)Ú
namespacesc@sveZdZdZdZejddgZejdgZd	Zd
d„Z	dd
„Z
dd„Zedd„ƒZ
dd„Zdd„Zdd„Zdd„ZdS)ÚdevelopzSet up package for developmentz%install package in 'development mode'Ú	uninstallÚuúUninstall this source packageú	egg-path=Nú-Set the path to be used in the .egg-link fileFcCs2|jrd|_|jƒ|jƒn|jƒ|jƒdS)NT)r
Z
multi_versionÚuninstall_linkZuninstall_namespacesÚinstall_for_developmentZwarn_deprecated_options)Úself©rú@/tmp/pip-build-l_bcah40/setuptools/setuptools/command/develop.pyÚruns
zdevelop.runcCs&d|_d|_tj|ƒd|_d|_dS)NÚ.)r
Úegg_pathr
Úinitialize_optionsÚ
setup_pathZalways_copy_from)rrrrr's

zdevelop.initialize_optionscCs|jdƒ}|jr,d}|j|jf}t||ƒ‚|jg|_tj|ƒ|jƒ|j	ƒ|j
jtjdƒƒ|jd}t
jj|j|ƒ|_|j|_|jdkr t
jj|jƒ|_t|jƒ}tt
jj|j|jƒƒ}||krÔtd|ƒ‚t|t|t
jj|jƒƒ|jd|_|j|j|j|jƒ|_dS)NÚegg_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_inforrÚegg_nameÚargsr
Úfinalize_optionsÚexpand_basedirsÚexpand_dirsZ
package_indexÚscanÚglobÚosÚpathÚjoinÚinstall_dirÚegg_linkÚegg_baserÚabspathr	rrrÚdistÚ_resolve_setup_pathr)rÚeiÚtemplater Zegg_link_fnÚtargetrrrrr!.s<






zdevelop.finalize_optionscCsh|jtjdƒjdƒ}|tjkr0d|jdƒd}ttjj|||ƒƒ}|ttjƒkrdt	d|ttjƒƒ‚|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&ÚsepÚrstripÚcurdirÚcountr	r'r(r)r+r)rZ
path_to_setupZresolvedrrrr.Xs
zdevelop._resolve_setup_pathcCsDtjršt|jddƒrš|jddd|jdƒ|jdƒ}t|jƒ}|jd|d|jdƒ|jddd|jdƒ|jdƒ}||_	||j
_t||j
ƒ|j
_n"|jdƒ|jdd	d|jdƒ|jƒtjrÜ|jtjƒdt_|jƒtjd
|j|jƒ|js,t|jdƒ}|j|j	d|jƒWdQRX|jd|j
|jƒdS)
NZuse_2to3FÚbuild_pyr)Zinplacer)r+Ú	build_extr3zCreating %s (link to %s)ÚwÚ
)rÚPY3ÚgetattrÚdistributionÚreinitialize_commandÚrun_commandrr	Ú	build_librr-ÚlocationrrÚ	_providerZinstall_site_pyÚ
setuptoolsZbootstrap_install_fromr
Zinstall_namespacesrÚinfor*r+Údry_runÚopenÚwriterZprocess_distributionÚno_deps)rZbpy_cmdZ
build_pathZei_cmdÚfrrrrks4







 zdevelop.install_for_developmentcCs¢tjj|jƒrztjd|j|jƒt|jƒ}dd„|Dƒ}|jƒ||j	g|j	|j
gfkrhtjd|ƒdS|jsztj
|jƒ|jsŒ|j|jƒ|jjržtjdƒdS)NzRemoving %s (link to %s)cSsg|]}|jƒ‘qSr)r6)Ú.0Úlinerrrú
<listcomp>žsz*develop.uninstall_link.<locals>.<listcomp>z$Link points to %s: uninstall abortedz5Note: you must uninstall or replace scripts manually!)r&r'Úexistsr*rrFr+rHÚcloserrÚwarnrGÚunlinkZ
update_pthr-r?Úscripts)rZ
egg_link_fileÚcontentsrrrršs
zdevelop.uninstall_linkc
Cs„||jk	rtj||ƒS|j|ƒx^|jjp,gD]N}tjjt	|ƒƒ}tjj
|ƒ}tj|ƒ}|j
ƒ}WdQRX|j||||ƒq.WdS)N)r-r
Úinstall_egg_scriptsÚinstall_wrapper_scriptsr?rSr&r'r,rÚbasenameÚiorHÚreadZinstall_script)rr-Úscript_nameZscript_pathÚstrmÚscript_textrrrrU¬s

zdevelop.install_egg_scriptscCst|ƒ}tj||ƒS)N)ÚVersionlessRequirementr
rV)rr-rrrrV¾szdevelop.install_wrapper_scripts)r
rr)rNr)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Údescriptionr
Úuser_optionsÚboolean_optionsZcommand_consumes_argumentsrrr!Ústaticmethodr.rrrUrVrrrrrs	*/rc@s(eZdZdZdd„Zdd„Zdd„ZdS)	r]az
    Adapt a pkg_resources.Distribution to simply return the project
    name as the 'requirement' so that scripts will work across
    multiple versions.

    >>> 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>rf)rÚnamerrrÚ__getattr__Ôsz"VersionlessRequirement.__getattr__cCs|jS)N)r)rrrrÚas_requirement×sz%VersionlessRequirement.as_requirementN)r^r_r`rargrirjrrrrr]Ãsr])Údistutils.utilrÚ	distutilsrZdistutils.errorsrrr&r%rXZsetuptools.externrÚ
pkg_resourcesrrr	Zsetuptools.command.easy_installr
rErZDevelopInstallerrÚobjectr]rrrrÚ<module>s4