/ lib / PyInstaller / compat.pyc
compat.pyc
  1  o

  2  �G�ch}�	@s<UdZddlmZddlZddlZddlZddlZddlZddl	Z	ddl
  3  Z
  4  ddlZddlZddl
mZddlmZej�dd�dkZejdkZd	ed
  5  <ejdkZejdkZejd
kZejdkZejdkZejdkZejdkZej�d�Z e o}e�!�ddkZ"dZ#ejdkZ$ejdkZ%ej�d�Z&ej�d�Z'ej�d�Z(ej�d�Z)ej�d�Z*ej�d�Z+e&p�e'p�e(p�e)p�e+p�e*Z,e&o�de
  6  �-dg�vZ.e%r�e/dd �e�0�d�1d!�D��ndZ2e3e2�o�e2dd"�d#kZ4e3e2�o�e2dd"�d$kZ5e4p�e5Z6ejdd"�Z7e �se$�rd%e7d&e7d'e7d(e7d)e7hZ8nee%�r&d*d+d,e7dd-e7d.e7hZ8nRe(�r8d/e7d0e7d1e7d2e7hZ8n@e)�rJd3e7d4e7d5e7d6e7hZ8n.e*�rVd7e7d8e7hZ8n"e+�r_d1e7hZ8ne,�rtd5e7d6e7d9e7d2e7d1e7hZ8ne9d:��ej:�;e<ed;e<ed<ej=���Z>d=ed<<e>ej:�;ej=�kZ?Z@ej:�Aej:�Be>d>��ZCej:�Aej:�Bej=d>��ZDe<ed?ejE�ZFe �o�ej:�GeF�dkZHeH�r�ej:�Be>ej:�IeF��ZFej:�JeF��s�e9d@��ejKjLZMejNjOZOejN�P�ZQe �rzddAlRmSZSddBlRmTZTWn(eU�yej�dC��s	e9dD��YneV�yejWjXd"k�re9dE���we%�r-ejdk�r*dFndGZYne�Y�dZYe$�r8dHne�Z�ZZee�[�e�Z��Z[d�dKdL�Z\e �rfzddl]Z^e\e^jK�_dM��Z#Wn
  7  eV�yeYnwd�d�dQdR�Z`d�dTdU�Zad�dVdW�ZbdddX�d�d_d`�Zcd�dbdc�Zdddd�d�dgdh�Zeddd�d�didj�Zfdkdl�Zgd�dndo�Zhd�dpdq�Zid�dsdt�Zjd�d�dwdx�Zke<e	dxek�Zkd�dzd{�Zlhd|�Zme�s�em�nd}�hd~�Zohd�Zpd�d�hZqeoepBeqBZrhd��ZseresBZtid�d��d�d��d�d��d�d��d�d��d�d��d�d��d�d��d�d��d�d��d�d��d�d��d�d��d�d��d�d��d�d��d�d��d�d�d���Zud�d��ZvdS)�zp
  8  Various classes and functions to provide some backwards-compatibility with previous versions of Python onward.
  9  �)�annotationsN)�_pyi_machine)�ExecCommandFailedZPYINSTALLER_STRICT_COLLECT_MODE�0l�bool�	is_64bits)��)r��r�)r�)r�	)r�
 10  )r��win�10F�cygwin�darwin�linux�sun�aix�freebsd�openbsdzhp-ux�musl�lddccs�|]}t|�VqdS�N)�int)�.0�x�r ��C:\Users\Jacks.GUTTSPC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\PyInstaller\compat.py�	<genexpr>Es�r"�.�)r�)rrzpython%d%d.dllzlibpython%d%d.dllzlibpython%d%dm.dllzlibpython%d.%d.dllzlibpython%d.%dm.dll�Pythonz.PythonzPython%dzlibpython%d.%d.dylibzlibpython%d.%dm.dylibzlibpython%d.%d.azlibpython%d.%dm.azlibpython%d.%d.sozlibpython%d.%dm.sozlibpython%d.%d.so.1zlibpython%d.%dm.so.1zlibpython%d.%d.so.1.0zlibpython%d.%dm.so.1.0zlibpython%d.%d.so.0.0zlibpython%d.%dm.so.0.0zlibpython%d.%dmu.so.1.0z[Your platform is not yet supported. Please define constant PYDYLIB_NAMES for your platform.�real_prefix�base_prefix�strz
 11  conda-meta�_base_executablez^PyInstaller cannot locate real python executable belonging to Python from Microsoft App Store!)�
 12  pywintypes)�win32apiZPYINSTALLER_NO_PYWIN32_FAILUREzoPyInstaller cannot check for assembly dependencies.
 13  Please install pywin32-ctypes.
 14  
 15  pip install pywin32-ctypes
 16  z�pycparser, a Windows only indirect dependency of PyInstaller, is incompatible with Python's "discard docstrings" (-OO) flag mode. For more information see:
 17      https://github.com/pyinstaller/pyinstaller/issues/6345�64bit�32bitZCygwin�filename�str | os.PathLikecCsvd}tdd�|D��}z%t|d��}|�d�|�|�}Wd�n1s&wY|�|�WSty:YdSw)z�
 18      Check if the given PE file is a Wine DLL (PE-converted built-in, or fake/placeholder one).
 19  
 20      Returns True if the given file is a Wine DLL, False if not (or if file cannot be analyzed or does not exist).
 21      )sWine builtin DLLsWine placeholder DLLcSsg|]}t|��qSr )�len)r�sigr r r!�
 22  <listcomp>�szis_wine_dll.<locals>.<listcomp>�rb�@NF)�max�open�seek�read�
 23  startswith�	Exception)r/Z_WINE_SIGNATURESZ_MAX_LEN�fp�	signaturer r r!�is_wine_dll�s
 24  ��r>�kernel32�name�default�
 25  str | NonecCstj�||�S)zQ
 26      Returns unicode string containing value of environment variable 'name'.
 27      )�os�environ�get)r@rAr r r!�getenv�rF�valuecCs|tj|<dS)zd
 28      Accepts unicode string and set it as environment variable 'name' containing value 'value'.
 29      N�rCrD)r@rHr r r!�setenv
rGrJcCsdtj|<tj|=dS)z1
 30      Delete the environment variable 'name'.
 31      �NrI)r@r r r!�unsetenvs
 32  rL)�encoding�raise_enoent�cmdargsrMrN�bool | None�kwargs�int | bool | list | Nonec
 33  Os8tj|fdtji|��}z
 34  |jdd�d}WnGtyQ}z/|r'|jtjkr'�tdtj	d�tdd�
 35  |�tj	d�t|tj	d�tdtj	d�td	�|�d
 36  }~wtjy]|�
��wz|ri|�|�}W|St�|�}W|Sty�}ztdtj	d�tt|�tj	d�tdtj	d�tdtj	d��d
 37  }~ww)a�
 38  
 39      Run the command specified by the passed positional arguments, optionally configured by the passed keyword arguments.
 40  
 41      .. DANGER::
 42         **Ignore this function's return value** -- unless this command's standard output contains _only_ pathnames, in
 43         which case this function returns the correct filesystem-encoded string expected by PyInstaller. In all other
 44         cases, this function's return value is _not_ safely usable. Consider calling the general-purpose
 45         `exec_command_stdout()` function instead.
 46  
 47         For backward compatibility, this function's return value non-portably depends on the current Python version and
 48         passed keyword arguments:
 49  
 50         * Under Python 2.7, this value is an **encoded `str` string** rather than a decoded `unicode` string. This value
 51           _cannot_ be safely used for any purpose (e.g., string manipulation or parsing), except to be passed directly to
 52           another non-Python command.
 53         * Under Python 3.x, this value is a **decoded `str` string**. However, even this value is _not_ necessarily
 54           safely usable:
 55           * If the `encoding` parameter is passed, this value is guaranteed to be safely usable.
 56           * Else, this value _cannot_ be safely used for any purpose (e.g., string manipulation or parsing), except to be
 57             passed directly to another non-Python command. Why? Because this value has been decoded with the encoding
 58             specified by `sys.getfilesystemencoding()`, the encoding used by `os.fsencode()` and `os.fsdecode()` to
 59             convert from platform-agnostic to platform-specific pathnames. This is _not_ necessarily the encoding with
 60             which this command's standard output was encoded. Cue edge-case decoding exceptions.
 61  
 62      Parameters
 63      ----------
 64      cmdargs :
 65          Variadic list whose:
 66          1. Mandatory first element is the absolute path, relative path, or basename in the current `${PATH}` of the
 67             command to run.
 68          2. Optional remaining elements are arguments to pass to this command.
 69      encoding : str, optional
 70          Optional keyword argument specifying the encoding with which to decode this command's standard output under
 71          Python 3. As this function's return value should be ignored, this argument should _never_ be passed.
 72      raise_enoent : boolean, optional
 73          Optional keyword argument to simply raise the exception if the executing the command fails since to the command
 74          is not found. This is useful to checking id a command exists.
 75  
 76      All remaining keyword arguments are passed as is to the `subprocess.Popen()` constructor.
 77  
 78      Returns
 79      ----------
 80      str
 81          Ignore this value. See discussion above.
 82      �stdout�<��timeoutr�(----------------------------------------��filezError running '%s':� z Error: Executing command failed!N�.These are the bytes around the offending byte:)�
 83  subprocess�Popen�PIPE�communicate�OSError�errno�ENOENT�print�sys�stderr�joinr�TimeoutExpired�kill�decoderC�fsdecode�UnicodeDecodeErrorr))rMrNrOrQ�proc�out�er r r!�exec_command!s<1
 84  ������ro�float | bool | list | NonecOs$d|vr	|�d�tj|fi|��S)a�
 85      Return the exit code of the command specified by the passed positional arguments, optionally configured by the
 86      passed keyword arguments.
 87  
 88      Parameters
 89      ----------
 90      cmdargs : list
 91          Variadic list whose:
 92          1. Mandatory first element is the absolute path, relative path, or basename in the current `${PATH}` of the
 93             command to run.
 94          2. Optional remaining elements are arguments to pass to this command.
 95  
 96      All keyword arguments are passed as is to the `subprocess.call()` function.
 97  
 98      Returns
 99      ----------
100      int
101          This command's exit code as an unsigned byte in the range `[0, 255]`, where 0 signifies success and all other
102          values signal a failure.
103      rM)�popr\�call)rOrQr r r!�exec_command_rcrs
104  rs)rM�command_args�(float | str | bytes | bool | list | NonecOs4|du|d<tj|fi|��}|dur|S|�|�S)ap
105      Capture and return the standard output of the command specified by the passed positional arguments, optionally
106      configured by the passed keyword arguments.
107  
108      Unlike the legacy `exec_command()` and `exec_command_all()` functions, this modern function is explicitly designed
109      for cross-platform portability. The return value may be safely used for any purpose, including string manipulation
110      and parsing.
111  
112      .. NOTE::
113         If this command's standard output contains _only_ pathnames, this function does _not_ return the correct
114         filesystem-encoded string expected by PyInstaller. If this is the case, consider calling the filesystem-specific
115         `exec_command()` function instead.
116  
117      Parameters
118      ----------
119      command_args : List[str]
120          Variadic list whose:
121          1. Mandatory first element is the absolute path, relative path, or basename in the current `${PATH}` of the
122             command to run.
123          2. Optional remaining elements are arguments to pass to this command.
124      encoding : str, optional
125          Optional name of the encoding with which to decode this command's standard output (e.g., `utf8`), passed as a
126          keyword argument. If unpassed , this output will be decoded in a portable manner specific to to the current
127          platform, shell environment, and system settings with Python's built-in `universal_newlines` functionality.
128  
129      All remaining keyword arguments are passed as is to the `subprocess.check_output()` function.
130  
131      Returns
132      ----------
133      str
134          Unicode string of this command's standard output decoded according to the "encoding" keyword argument.
135      N�universal_newlines)r\�check_outputri)rMrtrQrSr r r!�exec_command_stdout�s&rxc
136  Os�tj|fdtjtjd�|��}z
137  |jdd�\}}Wn
tjy&|���wz|r5|�|�}|�|�}n
138  t�|�}t�|�}Wn+t	yk}zt
139  dtjd�t
140  t
|�tjd�t
141  dtjd�t
142  dtjd��d}~ww|j||fS)	a|
143      Run the command specified by the passed positional arguments, optionally configured by the passed keyword arguments.
144  
145      .. DANGER::
146         **Ignore this function's return value.** If this command's standard output consists solely of pathnames, consider
147         calling `exec_command()`; otherwise, consider calling `exec_command_stdout()`.
148  
149      Parameters
150      ----------
151      cmdargs : str
152          Variadic list whose:
153          1. Mandatory first element is the absolute path, relative path, or basename in the current `${PATH}` of the
154             command to run.
155          2. Optional remaining elements are arguments to pass to this command.
156      encoding : str, optional
157          Optional keyword argument specifying the encoding with which to decode this command's standard output. As this
158          function's return value should be ignored, this argument should _never_ be passed.
159  
160      All remaining keyword arguments are passed as is to the `subprocess.Popen()` constructor.
161  
162      Returns
163      ----------
164      (int, str, str)
165          Ignore this 3-element tuple `(exit_code, stdout, stderr)`. See the `exec_command()` function for discussion.
166      �����)�bufsizerSrerTrUrWrXr[N)r\r]r^r_rgrhrirCrjrkrcrdrer)�
167  returncode)rMrOrQrlrm�errrnr r r!�exec_command_all�s>����
168  
169  
170  ���r}cCs�tjg}tr;tdkrt��dkrddg}nddg}ntdkr#ddg}ng}dtjvr7tjd}|d	d
171  |g7}||}	|�	|�|�
172  d
�}|durRtditj��}d|d<d|d<||fS)Nr-�arm64�archz-arm64z-x86_64r.z-i386�DYLD_LIBRARY_PATHz-ezDYLD_LIBRARY_PATH=%sFz-O�envzUTF-8ZPYTHONIOENCODINGrMr )rd�
173  executable�	is_darwin�architecture�platform�machinerCrD�append�extendrE�dict)�argsrQrOZ	py_prefix�pathr�r r r!�
__wrap_python�s*
174  
175  
176  
177  
178  
179  
180  r�r�cO�t||�\}}t|i|��S)z`
181      Wrap running python script in a subprocess.
182  
183      Return stdout of the invoked command.
184      )r�ro�r�rQrOr r r!�exec_python!�r�cOr�)zc
185      Wrap running python script in a subprocess.
186  
187      Return exit code of the invoked command.
188      )r�rsr�r r r!�exec_python_rc+r�r�r�cCstj�tj�|��S)z�
189      Replace initial tilde '~' in path with user's home directory, and also expand environment variables
190      (i.e., ${VARNAME} on Unix, %VARNAME% on Windows).
191      )rCr��
192  expandvars�
193  expanduser)r�r r r!�expand_path8sr��prefixes�list | NonecCs�g}t�}|durtjtjg}|D]7}|r||vrq|�|�tjdkr8|�tj�	|ddtj
194  dd�d��q|�|�|�tj�	|dd��q|S)a
195      Returns a list containing all global site-packages directories.
196  
197      For each directory present in ``prefixes`` (or the global ``PREFIXES``), this function finds its `site-packages`
198      subdirectory depending on the system environment, and returns a list of full paths.
199      N�/�libzpython%d.%dr$z
site-packages)�setrd�prefix�exec_prefix�addrC�sepr�r�rf�version_info)r��sitepackages�seenr�r r r!�getsitepackagesAs
200  
201  (
202  r��pathnamecCstj�||�}|��Sr)�	importlib�	machinery�SourceFileLoader�load_module)r@r�Z
203  mod_loaderr r r!�importlib_load_sourceasr�>"�fnmatch�io�token�urllib�locale�sre_compile�keyword�abc�pathlib�operator�
sre_constants�	posixpath�ntpath�reprlib�collections�_collections_abc�	traceback�enum�	sre_parse�warnings�types�re�copyreg�heapq�codecs�_weakrefsetrC�tokenize�	functools�	encodings�genericpath�stat�weakref�	linecacheZ_bootlocale>�
ArchiveModule�NamespacePackage�CompiledModule�SourceModule�Package�FlatPackage>�Script�
BuiltinModule�RuntimePackage�	AliasNode�
RuntimeModule�	Extension�ExtensionPackage>�
MissingModuler��	BadModule�InvalidSourceModule�InvalidCompiledModule�ExcludedModuler�r�ZPYMODULEr�ZPYSOURCEr�r�r�r�r��	EXTENSIONr��BUILTINr�r��badr��excludedr��invalidr�r��missingr��runtime�BINARY)r�zdoes not occurc	Cs�tjdkr	td��trddlm}m}nddlm}m}dD]/}z||�}Wn	|y/Yqwtr4dndtj	�d|��}t
204  d	|�d
205  |�d��d|�d
���tr[t
�d�dur]t
206  d��dSdS)zp
207      Verify that all requirements to run PyInstaller are met.
208  
209      Fail hard if any requirement is not met.
210      rz,PyInstaller requires at Python 3.7 or newer.r)�distribution�PackageNotFoundError)Zenum34�typingr�zconda remove�"z" -m pip uninstall zThe 'z�' package is an obsolete backport of a standard library package and is incompatible with PyInstaller. Please remove this package (located in rKz) using
211      z
212  then try again.�objdumpNz�On Linux, objdump is required. It is typically provided by the 'binutils' package installable via your Linux distribution's package manager.)rdr��EnvironmentError�is_py38�importlib.metadatar�r��importlib_metadata�is_condar��
213  SystemExit�locate_file�is_linux�shutil�which)r�r�r@�dist�remover r r!�check_requirements�s0
214  ������r�)r/r0r)r@r)rArB)r@r)rHr))r@r))rOr)rMrBrNrPrQrR)rOr)rQrp)rtr)rMrBrQru)rOr)rMrBrQrR)r�r)rQrB)r�r0)r�r�)r@r)r�r))w�__doc__�
215  __future__rra�importlib.machineryr��importlib.utilrCr��siter\rdr��PyInstaller._shared_with_wafr�PyInstaller.exceptionsrrDrE�strict_collect_mode�maxsizer�__annotations__r��is_py35�is_py36�is_py37r��is_py39�is_py310�is_py311r:�is_win�	win32_ver�	is_win_10�is_win_wine�	is_cygwinr�r��is_solar�is_aix�
216  is_freebsd�
217  is_openbsd�is_hpux�is_unix�	getoutput�is_musl�tuple�mac_ver�split�
218  _macos_verr�is_macos_11_compat�is_macos_11_native�is_macos_11�_pyver�
PYDYLIB_NAMESr�r��abspath�getattrr�r(�is_venv�
is_virtualenv�isdirrfr��
is_pure_condar��python_executable�getsize�is_ms_app_store�basename�exists�util�MAGIC_NUMBER�BYTECODE_MAGICr��EXTENSION_SUFFIXES�all_suffixes�ALL_SUFFIXES�win32ctypes.pywin32r+r,�ImportErrorr;�flags�optimizer��systemr�r>�ctypes.util�ctypes�find_libraryrFrJrLrorsrxr}r�r�r�r�r�r��PY3_BASE_MODULESr��PURE_PYTHON_MODULE_TYPES�SPECIAL_MODULE_TYPES�BINARY_MODULE_TYPES�VALID_MODULE_TYPES�BAD_MODULE_TYPES�ALL_MODULE_TYPES�MODULE_TYPES_TO_TOC_DICTr�r r r r!�<module>sx
219  
220  
221  
222  
223  
224  
225  
226  
227  
228  (�
229  ����&�
230  ����
231  �
232  
233  
234  �
235  Q�0;
236  (
237  
238  
239  
	
240  %
241  �
�������
242  ��
���������