3

Q'ícã@sRddlZddlmZddlZddlmZejjZGdd„dƒZ	Gdd„de	ƒZ
dS)éN)Úlog)Úmapc	@sTeZdZdZdd„Zdd„Zdd„ZdZdZdd„Z	dd„Z
dd„Zedd„ƒZ
dS)Ú	Installerz
-nspkg.pthc	Csˆ|jƒ}|sdStjj|jƒƒ\}}||j7}|jj|ƒtj	d|ƒt
|j|ƒ}|jrdt
|ƒdSt|dƒ}|j|ƒWdQRXdS)Nz
Installing %sÚwt)Ú_get_all_ns_packagesÚosÚpathÚsplitextÚ_get_targetÚ	nspkg_extÚoutputsÚappendrÚinforÚ_gen_nspkg_lineÚdry_runÚlistÚopenÚ
writelines)ÚselfÚnspÚfilenameÚextÚlinesÚf©rú;/tmp/pip-build-l_bcah40/setuptools/setuptools/namespaces.pyÚinstall_namespacess
zInstaller.install_namespacescCsHtjj|jƒƒ\}}||j7}tjj|ƒs.dStjd|ƒtj|ƒdS)NzRemoving %s)	rrr	r
rÚexistsrrÚremove)rrrrrrÚuninstall_namespaces!s
zInstaller.uninstall_namespacescCs|jS)N)Útarget)rrrrr
)szInstaller._get_targetúimport sys, types, osú#has_mfs = sys.version_info > (3, 5)ú$p = os.path.join(%(root)s, *%(pth)r)ú4importlib = has_mfs and __import__('importlib.util')ú-has_mfs and __import__('importlib.machinery')ú™m = has_mfs and sys.modules.setdefault(%(pkg)r, importlib.util.module_from_spec(importlib.machinery.PathFinder.find_spec(%(pkg)r, [os.path.dirname(p)])))úCm = m or sys.modules.setdefault(%(pkg)r, types.ModuleType(%(pkg)r))ú7mp = (m or []) and m.__dict__.setdefault('__path__',[])ú(p not in mp) and mp.append(p)ú4m and setattr(sys.modules[%(parent)r], %(child)r, m)cCsdS)Nz$sys._getframe(1).f_locals['sitedir']r)rrrrÚ	_get_rootCszInstaller._get_rootcCsVt|ƒ}t|jdƒƒ}|jƒ}|j}|jdƒ\}}}|rB||j7}dj|ƒtƒdS)NÚ.ú;Ú
)	ÚstrÚtupleÚsplitr+Ú_nspkg_tmplÚ
rpartitionÚ_nspkg_tmpl_multiÚjoinÚlocals)rÚpkgÚpthÚrootZ
tmpl_linesÚparentÚsepÚchildrrrrFs
zInstaller._gen_nspkg_linecCs |jjp
g}ttt|j|ƒƒƒS)z,Return sorted list of all package namespaces)ÚdistributionZnamespace_packagesÚsortedÚflattenrÚ
_pkg_names)rÚpkgsrrrrQszInstaller._get_all_ns_packagesccs,|jdƒ}x|r&dj|ƒV|jƒqWdS)zÏ
        Given a namespace package, yield the components of that
        package.

        >>> names = Installer._pkg_names('a.b.c')
        >>> set(names) == set(['a', 'a.b', 'a.b.c'])
        True
        r,N)r1r5Úpop)r7Úpartsrrrr@Vs

zInstaller._pkg_namesN)	r!r"r#r$r%r&r'r(r))r*)Ú__name__Ú
__module__Ú__qualname__rrrr
r2r4r+rrÚstaticmethodr@rrrrrs$rc@seZdZdd„Zdd„ZdS)ÚDevelopInstallercCstt|jƒƒS)N)Úreprr/Zegg_path)rrrrr+gszDevelopInstaller._get_rootcCs|jS)N)Úegg_link)rrrrr
jszDevelopInstaller._get_targetN)rDrErFr+r
rrrrrHfsrH)rÚ	distutilsrÚ	itertoolsZsetuptools.extern.six.movesrÚchainÚ
from_iterabler?rrHrrrrÚ<module>s[