Your IP : 216.73.216.213


Current Path : /opt/alt/python34/lib64/python3.4/Tools/freeze/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/Tools/freeze/__pycache__/checkextensions_win32.cpython-34.pyc

�
e f8�@s�dZddlZddlZyddlZWnek
rHdZYnXGdd�d�Zdd�Zdd�Zd	d
�Zdd�Z	d
Z
dZdZdZ
dS)a�Extension management for Windows.

Under Windows it is unlikely the .obj files are of use, as special compiler options
are needed (primarily to toggle the behavior of "public" symbols.

I don't consider it worth parsing the MSVC makefiles for compiler options.  Even if
we get it just right, a specific freeze application may have specific compiler
options anyway (eg, to enable or disable specific functionality)

So my basic strategy is:

* Have some Windows INI files which "describe" one or more extension modules.
  (Freeze comes with a default one for all known modules - but you can specify
  your own).
* This description can include:
  - The MSVC .dsp file for the extension.  The .c source file names
    are extracted from there.
  - Specific compiler/linker options
  - Flag to indicate if Unicode compilation is expected.

At the moment the name and location of this INI file is hardcoded,
but an obvious enhancement would be to provide command line options.
�Nc@s^eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�
CExtensionz8An abstraction of an extension implemented in C/C++
    cCs(||_||_g|_g|_dS)N)�name�sourceFiles�compilerOptions�
linkerLibs)�selfrr�r�G/opt/alt/python34/lib64/python3.4/Tools/freeze/checkextensions_win32.py�__init__"s			zCExtension.__init__cCs|jS)N)r)rrrr	�GetSourceFiles,szCExtension.GetSourceFilescCs|jj|�dS)N)r�append)rZoptionrrr	�AddCompilerOption/szCExtension.AddCompilerOptioncCs|jS)N)r)rrrr	�GetCompilerOptions1szCExtension.GetCompilerOptionscCs|jj|�dS)N)rr)r�librrr	�AddLinkerLib4szCExtension.AddLinkerLibcCs|jS)N)r)rrrr	�
GetLinkerLibs6szCExtension.GetLinkerLibsN)
�__name__�
__module__�__qualname__�__doc__r
rr
rrrrrrr	rs
rcCs�tjjtjjtjd�dd�}tjj|�sUtjjd|�n
|j	|�g}xb|D]Z}xQ|D]5}t
|||�}|dk	r||j	|�Pq|q|Wtjjd|�qoW|S)Nrzextensions_win32.inizDWARNING: %s can not be found - standard extensions may not be found
z6No definition of module %s in any specified map file.
)�os�path�join�split�sys�argv�isfile�stderr�writer�get_extension_defn)�unknownZ
extra_inis�prefixZdefaultMapName�ret�modZiniZdefnrrr	�checkextensions9s,



r$cCs�tdkrdS|tjd<tj|dd|�}|dkrEdStj|�}tjj|�s�tjjtjj|�d|�}nt	|�}|dkr�dSt
||�}tjj|�dtjd<tjj|�dtjd<tj|dd|�}|r*|jtj|��ntj|dd|�}|j�}tj|d	d|�rv|jd
�ntj|dd|�j�}x$|D]}	|jtj|	��q�Wx0|D](}
|
|j
kr�|j
j|
�q�q�W|S)NZPYTHONPREFIX�dsp�r�dsp_pathZini_pathZcl�excludeZUnicodez/D UNICODE /D _UNICODE�libs)�win32apir�environZ
GetProfileValZExpandEnvironmentStringsr�isabsrr�	parse_dsprr
rr�remove)Z
moduleNameZmapFileNamer!r%r�moduleZ
cl_optionsr(r)r�excrrr	rRs:
(

rcCsg}tjj|�\}}yt|d�j�}WnCtk
r|}z#tjjd||f�dSWYdd}~XnXx�|D]�}|j	�jdd�}|ddkr�tjj
|d�dj�d
kr|jt
jtjj||d���qq�q�W|S)N�rz%s: %s
�=�rZSOURCE��.cpp�.c)r5r6)rrr�open�	readlines�IOErrorrrr�strip�splitext�lowerrr*ZGetFullPathNamer)r%r"r'Zdsp_name�lines�msg�lineZfieldsrrr	r-s
&3r-cCs�t|d�}z�|jt�x5|D]-}|jjd�d}|jd|�q&W|jt�x;|D]3}|jjd�d}|jd||f�qkW|jt�|jt�Wd|j�XdS)N�w�.r4zextern void init%s(void);
z	{"%s", init%s},
���rB)	r7r�ext_src_headerrr�ext_tab_header�ext_tab_footer�ext_src_footer�close)Zfname�modules�fpr/rrrr	�write_extension_table�s




rJz#include "Python.h"
z)
static struct _inittab extensions[] = {
z)        /* Sentinel */
        {0, 0}
};
z�extern DL_IMPORT(int) PyImport_ExtendInittab(struct _inittab *newtab);

int PyInitFrozenExtensions()
{
        return PyImport_ExtendInittab(extensions);
}

)rrrr*�ImportErrorrr$rr-rJrCrDrErFrrrr	�<module>s
-