_dBddlmZddlmZddlmZddlZddlZddlZddl m Z ddl m Z ddl m Z ddl Z Gdd e je ZGd d Zy) ) convert_path)log)DistutilsOptionErrorN) easy_install)_path) namespacesceZdZdZdZej ddgzZejdgzZdZdZ dZ d Z e d Z d Zd Zd ZdZy)developzSet up package for developmentz%install package in 'development mode') uninstalluzUninstall this source package)z egg-path=Nz-Set the path to be used in the .egg-link filer Fc|jr(d|_|j|jn|j |j y)NT)r multi_versionuninstall_linkuninstall_namespacesinstall_for_developmentwarn_deprecated_optionsselfs >!%D     !  % % '  ( ( * $$&cfd|_d|_tj|d|_d|_y)N.)r egg_pathrinitialize_options setup_pathalways_copy_fromrs rrzdevelop.initialize_options%s- ''- #rc <ddl}|jd}|jg|_t j ||j |j|jjtjd|jdz}tjj|j||_|j |_|j".tjj%|j |_t'j(|j }t'j(tjj|j|j"}||k7rt+d|z|j-||j/|tjj%|j0|j|_|j5|j |j|j"|_y)Nregg_infoz*.eggz .egg-linkzA--egg-path must be a relative path from the install directory to  project_name) pkg_resourcesget_finalized_commandegg_nameargsrfinalize_optionsexpand_basedirs expand_dirs package_indexscanglobospathjoin install_diregg_linkegg_baserabspathrnormpathr Distribution PathMetadatardist_resolve_setup_pathr)rr"ei egg_link_fntargetrs rr&zdevelop.finalize_options,s  ' ' 3[[M %%d+    ' 23kkK/  T%5%5{C   == GGOOBKK8DM .>>"'',,t/?/?"OP v &!#)*  "..   & &vrwwr{{/K L/  22 MM    MM rc|jtjdjd}|tjk7rd|j ddzz}t jtjj|||}t jtj}||k7r td|||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,seprstripcurdircountrr3r-r.r)r1r/r path_to_setupresolvedrAs rr7zdevelop._resolve_setup_pathSs!((5<>"'',,{Hm"TU * v &*   rcl|jd|jdd|jdtjr*|j tjdt_|j t jd|j|j|jsJt|jd5}|j|jdz|jzddd|jd|j |j" y#1swY2xYw)Nr build_extr=)inplacezCreating %s (link to %s)w ) run_commandreinitialize_command setuptoolsbootstrap_install_fromrinstall_namespacesrinfor0r1dry_runopenwriterrprocess_distributionr6no_deps)rfs rrzdevelop.install_for_developmenths $ !!+q!9 %  , ,   j?? @04J - ! +T]]DMMJ||dmmS) @Q ,t>? @ !!$ t||3CD  @ @s ,D**D3ctjj|jrt j d|j|j t|j}|Dcgc]}|j}}|j||jg|j|jgfvrt jd|y|jstj|j|js|j|j |j"j$rt jdyycc}w)NzRemoving %s (link to %s)z$Link points to %s: uninstall abortedz5Note: you must uninstall or replace scripts manually!)r,r-existsr0rrOr1rQr@closerrwarnrPunlink update_pthr6 distributionscripts)r egg_link_filelinecontentss rrzdevelop.uninstall_link~s 77>>$-- ( HH/ N /M2?@$ @H@    !$--1QRR?J<< $--(|| OODII &    $ $ HHL M %As.Ec||jurtj||S|j||jj xsgD]}t jjt|}t jj|}tj|5}|j}ddd|j|||y#1swY xYwN)r6rinstall_egg_scriptsinstall_wrapper_scriptsr\r]r,r-r2rbasenameiorQreadinstall_script)rr6 script_name script_pathstrm script_texts rrczdevelop.install_egg_scriptss tyy 33D$? ? $$T* ,,44: MK''//,{*CDK''**;7K% *"iik  *   k; L  M * *s /CC( cDt|}tj||Srb)VersionlessRequirementrrdrr6s rrdzdevelop.install_wrapper_scriptss%d+33D$??rN)__name__ __module__ __qualname____doc__ descriptionr user_optionsboolean_optionscommand_consumes_argumentsrrr& staticmethodr7rrrcrdrrr r s{(9K,,;L0L #22k]BO!&'$% N(E,N"M$@rr c"eZdZdZdZdZdZy)rna 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' c||_yrb)_VersionlessRequirement__distros r__init__zVersionlessRequirement.__init__s  rc.t|j|Srb)getattrr|)rnames r __getattr__z"VersionlessRequirement.__getattr__st{{D))rc|jSrbr rs ras_requirementz%VersionlessRequirement.as_requirements   rN)rprqrrrsr}rrryrrrnrns *!rrn)distutils.utilr distutilsrdistutils.errorsrr,r+rfsetuptools.command.easy_installrrLrrDevelopInstallerr rnryrrrsF'1 8!U@j))<U@p!!r