o
    LK&h                     @   s:   d dl Z d dlZd dlmZ ddlmZ G dd dZdS )    N)paths_on_pythonpath   )
namespacesc                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
TestNamespacesc           	      C   s   t |d}t |d}|d }|d }||f}tjdddt|dt|g}t| t | tjdddt|dt|g}t| tjd	d
g}tt	t| t| W d   dS 1 saw   Y  dS )z
        Installing two packages sharing the same namespace, one installed
        to a site dir and the other installed just to a path on PYTHONPATH
        should leave the namespace in tact and both packages reachable by
        import.
        	myns.pkgA	myns.pkgBzsite-packageszpath-packages-mpip.__main__install-t-cz"import myns.pkgA; import myns.pkgBN)
r   build_namespace_packagesys
executablestr
subprocess
check_callmake_site_dirr   map)	selftmpdirpkg_Apkg_Bsite_packagespath_packagestargetsinstall_cmd
try_import r   S/var/www/html/venv/lib/python3.10/site-packages/setuptools/tests/test_namespaces.pytest_mixed_site_and_non_site
   s>   
	

	"z+TestNamespaces.test_mixed_site_and_non_sitec                 C   s   t |d}|d }|  tjddddt|t|g}tt|g t| W d   n1 s3w   Y  t 	| tjdd	g}tt|g t| W d   dS 1 s[w   Y  dS )
zc
        Ensure that a namespace package doesn't break on import
        of pkg_resources.
        r   packagesr   pipr
   r   Nr   zimport pkg_resources)
r   r   mkdirr   r   r   r   r   r   r   )r   r   pkgtargetr   r   r   r   r   test_pkg_resources_import4   s,   	
"z(TestNamespaces.test_pkg_resources_importc                 C   s   t |d}|d }tjdddt|dt|g}t| t | tjddg}tt|g tj|t|d	 W d
   d
S 1 sDw   Y  d
S )z
        Installing a namespace packages but also having it in the current
        working directory, only one version should take precedence.
        r   r!   r   r	   r
   r   r   z&import pkg_resources; import myns.pkgAcwdN	r   r   r   r   r   r   r   r   r   )r   r   r   r%   r   pkg_resources_impr   r   r   (test_namespace_package_installed_and_cwdP   s&   
	
"z7TestNamespaces.test_namespace_package_installed_and_cwdc                 C   s   t |d}t |d}|d }tjdddt|dt|g}t| t | tjdd	g}tt|g tj|t|d
 W d   dS 1 sJw   Y  dS )z
        Installing one namespace package and also have another in the same
        namespace in the current working directory, both of them must be
        importable.
        r   r   r!   r   r	   r
   r   r   z8import pkg_resources; import myns.pkgA; import myns.pkgBr'   Nr)   )r   r   r   r   r%   r   r*   r   r   r   5test_packages_in_the_same_namespace_installed_and_cwdm   s(   
	
"zDTestNamespaces.test_packages_in_the_same_namespace_installed_and_cwdN)__name__
__module____qualname__r    r&   r+   r,   r   r   r   r   r   	   s
    *r   )r   r   setuptools._pathr    r   r   r   r   r   r   <module>   s
    