
    G@d'                         d Z ddlZddlmZ ddlZddlmZmZm	Z	m
Z
mZmZmZmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ  G d de          ZdS )z&Main interpreter entry in Preferences.    N)QButtonGroup	QGroupBoxQInputDialogQLabel	QLineEditQMessageBoxQPushButtonQVBoxLayout)_)PluginConfigPage)to_text_string)programs)get_list_conda_envs_cache)get_python_executable)get_list_pyenv_envs_cachec                   F     e Zd Z fdZ fdZd Zd Zd Zd Zd Z	 xZ
S )MainInterpreterConfigPagec                    t                                          ||           | j        | _        d | _        d | _        d | _        t                      }t                      }i ||}| 	                    d          }|
                                D ]&}||         \  }}	||vr|                    |           '|                     d|           | 	                    d          }
| 	                    d          st          j        |
          st                      }
n+| 	                    d          s|                     dd           |                    |
           |                                  d S )Ncustom_interpreters_list
executabledefaultcustom_interpreter )super__init__perform_adjustmentsapply_callbackcus_exec_radiopyexec_editcus_exec_combor   r   
get_optionkeysappend
set_optionospisfiler   _add_to_custom_interpreters!validate_custom_interpreters_list)selfpluginparent	conda_env	pyenv_envenvsvalid_custom_listenvpathr   r   	__class__s              Glib/python3.11/site-packages/spyder/plugins/maininterpreter/confpage.pyr   z"MainInterpreterConfigPage.__init__   sp   ((("6""-//	-//	)))y) OO,FGG99;; 	/ 	/C3iGD!,,,!((...24EFFF __\22
 ??9%% 	7SZ
-C-C 	7.00JJ!566 	7OO0#666**:666..00000    c                 H    t                                                       d S )N)r   
initialize)r)   r2   s    r3   r6   z$MainInterpreterConfigPage.initialize<   s    r4   c           	         | j         }t          t          d                    }t          |          }t	          t          d                    }|                     t          d          d|          | _        |                     t          d          d|          | _        t          j	        dk    rt          d	          d
z   }nd }t                      }|                    |           |                    | j                   |                    | j                   |                                  |                     t          d          |                     d          d|ddt          j                  | _        | j        j                            | j        j                   | j        j                            | j        j                   |                    | j                   |                    |           | j        j                                        | _        t          t          d                    }t	          t          d                    }|                    d            |t          d          ddt          d                    }	 |t          d          dt          d                    }
t7          t          d                    }|j                            | j                   t                      }|                    |           |                    |	           |                    |
           |                    |           |                    |           t                      }|                    |           |                    |           |                    d           |                     |           d S )NzPython interpreterz5Select the Python interpreter for all Spyder consolesz#Default (i.e. the same as Spyder's)r   )button_groupz%Use the following Python interpreter:customntExecutablesz (*.exe)zRecent custom interpretersr   r   T)filtersdefault_line_editadjust_to_contentsvalidate_callbackzUser Module Reloader (UMR)zUMR forces Python to reload modules which were imported when executing a file in a Python or IPython console with the <i>runfile</i> function.z
Enable UMRzumr/enableday  This option will enable the User Module Reloader (UMR) in Python/IPython consoles. UMR forces Python to reload deeply modules during import when running a Python file using the Spyder's builtin function <b>runfile</b>.<br><br><b>1.</b> UMR may require to restart the console in which it will be called (otherwise only newly imported modules will be reloaded when executing files).<br><br><b>2.</b> If errors occur when re-running a PyQt-based program, please check that the Qt objects are properly destroyed (e.g. you may have to use the attribute <b>Qt.WA_DeleteOnClose</b> on your main window, using the <b>setAttribute</b> method))msg_if_enabledmsg_warningzShow reloaded modules listzumr/verbosezCPlease note that these changes will be applied only to new consoles)msg_infoz'Set UMR excluded (not reloaded) modules   )create_checkboxr   r   r   r   create_radiobuttondef_exec_radior   osnamer
   	addWidgetr(   create_file_comboboxr!   r   is_python_interpreterr    toggledconnectsetDisabled
setEnabled	setLayoutcomboboxlineEditr   setWordWrapr	   clickedset_umr_namelist
addStretch)r)   newcbpyexec_group	pyexec_bgpyexec_labelr<   pyexec_layout	umr_group	umr_labelumr_enabled_boxumr_verbose_boxumr_namelist_btn
umr_layoutvlayouts                 r3   
setup_pagez$MainInterpreterConfigPage.setup_page?   s   $ !#7!8!899 ..	a !+ , , - -"55344" 6 
 

 #55566" 6 
 
 7d??&&z1GGG#--- 3444 3444..000"77*++OO677 "#&< 8 
 
 	#++D,?,KLLL#++D,?,JKKK 3444}---.7@@BB a <==>>	1 ) * * + +	 	d###%lOO@ 	
 
 
*  %*++ 9 : :
 
 
 '788: : (()>??? ]]
Y'''_---_----...J'''--,''')$$$1wr4   c                    t          j        |          sd S t          j        d         }	 ddg}t	          j        ||i           }t          |                                d                   }n# t          $ r |}Y nt          $ r Y dS w xY w||k    r@t          j        | t          d          t          d          ||fz  t          j                   dS )	Nr   z-cz&import sys; print(sys.version_info[0]))r0   FWarningaI  You selected a <b>Python %d</b> interpreter for the console but Spyder is running on <b>Python %d</b>!.<br><br>Although this is possible, we recommend you to install and run Spyder directly with your selected interpreter, to avoid seeing false warnings and errors due to the incompatible syntax between these two Python versions.T)r%   r&   sysversion_infor   run_programintcommunicateIOError
ValueErrorr   warningr   Ok)r)   pyexecspyder_versionargsprocconsole_versions         r3   warn_python_compatibilityz3MainInterpreterConfigPage.warn_python_compatibility   s   z&!! 	F)!,	BCD'"===D!$"2"2"4"4Q"788OO 	- 	- 	-,OOO 	 	 	55	 _,,) >   '78    ts   AA- -B;	BBc                 `   t          j        | t          d          t          d          t          j        d                    |                     d                              \  }}|rEt          |          }|r|                    dd          	                    d          }g }g }|D ]+}t          j        |          r|                    |           ,d                    t          |          t          |          z
  t          |          z
            }|r>t          j        | t          d          t          d          |z  t          j                   t          j        | t          d          t          d	          t          j                   ng }|                     d|           d
S d
S )z"Set UMR excluded modules name listUMRz=Set the list of excluded modules as this: <i>numpy, scipy</i>z, zumr/namelistr    ,z;The following modules are not installed on your machine:
%szKPlease note that these changes will be applied only to new IPython consolesN)r   getTextr   r   Normaljoinr!   r   replacesplitr   is_module_installedr#   setr   rm   rn   informationr$   )r)   	argumentsvalidnamelistfixed_namelistnon_ascii_namelistmodule_nameinvalids           r3   rU   z*MainInterpreterConfigPage.set_umr_namelist   s   '/eHH $ % %IIdoon5566
 
	5  	<&y11I $$,,S"55;;C@@!#%'"#+ ; ;K3K@@ ;&--k:::))CMM#n2E2E$E$'(:$;$;%< = = '% ; < <>EF#   'eHH @ A AN    "$OONN;;;;;=	< 	<r4   c                     |                      d          }g }|D ]+}t          j        |          r|                    |           ,|                     d|           dS )z8Check that the used custom interpreters are still valid.r   N)r!   r%   r&   r#   r$   )r)   custom_listr/   values       r3   r(   z;MainInterpreterConfigPage.validate_custom_interpreters_list   sl    oo&@AA  	0 	0Ez%   0!((///24EFFFFFr4   c                    | j                                         s| j                                        }t	          j        |          }|                    d          r|                    dd          }| j        j	        j
        }||vrC||gz   }| j        j	                                         | j        j	                            |           | j                            |           |                     |           dS dS )z@Perform some adjustments to the page after applying preferences.zpythonw.exez
python.exeN)rF   	isCheckedr   textr%   normpathendswithr|   r    rQ   choicesclearaddItemssetTextrt   )r)   r   r   s      r3   r   z-MainInterpreterConfigPage.perform_adjustments   s    ",,.. 	7)..00Jj11J""=11 M'//|LL
 -6>K,,)ZL8#,22444#,55kBBB$$Z000 **:66666!	7 	7r4   )__name__
__module____qualname__r   r6   rc   rt   rU   r(   r   __classcell__)r2   s   @r3   r   r      s        1 1 1 1 1<    ^  ^  ^ @  <(< (< (<TG G G7 7 7 7 7 7 7r4   r   )__doc__rG   os.pathr1   r%   rf   qtpy.QtWidgetsr   r   r   r   r   r   r	   r
   spyder.api.translationsr   spyder.api.preferencesr   spyder.py3compatr   spyder.utilsr   spyder.utils.condar   spyder.utils.miscr   spyder.utils.pyenvr   r    r4   r3   <module>r      sj   - , 
			       



N N N N N N N N N N N N N N N N N N N N & % % % % % 3 3 3 3 3 3 + + + + + + ! ! ! ! ! ! 8 8 8 8 8 8 3 3 3 3 3 3 8 8 8 8 8 8g7 g7 g7 g7 g7 0 g7 g7 g7 g7 g7r4   