o
    $¼"b�  ã                   @   s¸   d dl mZmZ d dlZd dlZd dlZd dlmZ d dlm	Z	m
Z
 d dlmZ d dlmZ ddlmZ d	d
lmZ eejƒG dd„ deeƒƒZG dd„ dee	ƒZG dd„ dee
ƒZdS )é    )Úabsolute_importÚunicode_literalsN)Úadd_metaclass)ÚPosixSupportsÚWindowsSupports)ÚPathRefToDest)ÚPathé   )ÚPython2é   )ÚPyPyc                       sˆ   e Zd ZdZedd„ ƒZe‡ fdd„ƒZedd„ ƒZedd	„ ƒZe	d
d„ ƒZ
e‡ fdd„ƒZe	dd„ ƒZ‡ fdd„Ze	dd„ ƒZ‡  ZS )ÚPyPy2ú c                 C   ó   dS )NÚpypy© ©Úclsr   r   úU/usr/lib/python3/dist-packages/virtualenv/create/via_global_ref/builtin/pypy/pypy2.pyÚexe_stem   ó   zPyPy2.exe_stemc                 #   sL   � t t| ƒ |¡D ]}|V  q	|  |¡}| ¡ r$t|jdd„ d�V  d S d S )Nc                 S   ó   | j S ©N)Úinclude©ÚselfÚ_r   r   r   Ú<lambda>    ó    zPyPy2.sources.<locals>.<lambda>©Údest)Úsuperr   ÚsourcesÚhost_include_markerÚexistsr   Úparent)r   ÚinterpreterÚsrcr#   ©Ú	__class__r   r   r"      s   €
ÿzPyPy2.sourcesc                 C   r   )NTr   r   r   r   r   Úneeds_stdlib_py_module"   r   zPyPy2.needs_stdlib_py_modulec                 C   s   t |jƒd S )NzPyPy.h)r   Úsystem_include)r   r&   r   r   r   r#   &   s   zPyPy2.host_include_markerc                 C   s   | j | j d¡ S )NÚheaders)r    r&   Úinstall_path©r   r   r   r   r   *   s   zPyPy2.includec                    s   t t| ƒ ¡ g d¢ S )N)ÚosÚcopy_regÚgenericpathÚ	linecacheÚstatÚUserDictÚwarnings)r!   r   Úmodulesr   r(   r   r   r6   .   s   zPyPy2.modulesc                 C   ó
   | j d S )NÚlib_pypyr   r.   r   r   r   r8   ;   ó   
zPyPy2.lib_pypyc                    sP   t t| ƒ ¡ }| | j¡ |  | j¡}| ¡ r | | jj	¡ |S t
 d|¡ |S )Nz2no include folders as can't find include marker %s)r!   r   Úensure_directoriesÚaddr8   r#   r&   r$   r   r%   ÚloggingÚdebug)r   Údirsr#   r(   r   r   r:   ?   s   ÿzPyPy2.ensure_directoriesc                 C   s   d  tj¡S )z¦
        PyPy2 built-in imports are handled by this path entry, don't overwrite to not disable it
        see: https://github.com/pypa/virtualenv/issues/1652
        zKor path.endswith("lib_pypy{}__extensions__") # PyPy2 built-in import marker)Úformatr/   Úsepr.   r   r   r   Úskip_rewriteI   s   zPyPy2.skip_rewrite)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úclassmethodr   r"   r*   r#   Úpropertyr   r6   r8   r:   rA   Ú__classcell__r   r   r(   r   r      s&    





r   c                       sL   e Zd ZdZe‡ fdd„ƒZedd„ ƒZedd„ ƒZe‡ fdd	„ƒZ	‡  Z
S )
Ú
PyPy2PosixzPyPy 2 on POSIXc                    ó   t t| ƒ ¡ dg S )NÚ	posixpath)r!   rI   r6   r   r(   r   r   r6   U   ó   zPyPy2Posix.modulesc                 C   s
   |  d¡S )Nz
libpypy*.*)Úglob)r   Ú
python_dirr   r   r   Ú_shared_libsY   r9   zPyPy2Posix._shared_libsc                 C   r7   )NÚlibr   r.   r   r   r   rP   ]   r9   zPyPy2Posix.libc                 #   sN   � t t| ƒ |¡D ]}|V  q	t|jƒd }| ¡ r%t|dd„ d�V  d S d S )NrP   c                 S   r   r   )rP   r   r   r   r   r   g   r   z$PyPy2Posix.sources.<locals>.<lambda>r   )r!   rI   r"   r   Úsystem_prefixr$   r   )r   r&   r'   Úhost_libr(   r   r   r"   a   s   €ÿzPyPy2Posix.sources)rB   rC   rD   rE   rF   r6   rO   rG   rP   r"   rH   r   r   r(   r   rI   R   s    

rI   c                       s@   e Zd ZdZe‡ fdd„ƒZedd„ ƒZe‡ fdd„ƒZ‡  ZS )ÚPypy2WindowszPyPy 2 on Windowsc                    rJ   )NÚntpath)r!   rS   r6   r   r(   r   r   r6   m   rL   zPypy2Windows.modulesc                 c   s&   � dD ]}|| }|  ¡ r|V  qd S )N)zlibpypy-c.dllzlibffi-7.dllzlibffi-8.dll)r$   )r   rN   Ú	candidateÚdllr   r   r   rO   q   s   €€ýzPypy2Windows._shared_libsc                 #   s>   � t t| ƒ |¡D ]}|V  q	tt|jƒd dd„ d�V  d S )NÚlibsc                 S   s   | j |j S r   )r    Úname)r   Úsr   r   r   r   }   s    z&Pypy2Windows.sources.<locals>.<lambda>r   )r!   rS   r"   r   r   rQ   )r   r&   r'   r(   r   r   r"   y   s   € zPypy2Windows.sources)	rB   rC   rD   rE   rF   r6   rO   r"   rH   r   r   r(   r   rS   j   s    
rS   )Ú
__future__r   r   Úabcr<   r/   Úsixr   Úvirtualenv.create.describer   r   Ú,virtualenv.create.via_global_ref.builtin.refr   Úvirtualenv.util.pathr   Úpython2.python2r
   Úcommonr   ÚABCMetar   rI   rS   r   r   r   r   Ú<module>   s    @