mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 07:31:38 +00:00 
			
		
		
		
	GH-126985: Don't override venv detection with PYTHONHOME (#127968)
This commit is contained in:
		
							parent
							
								
									46006a1b35
								
							
						
					
					
						commit
						b74c8f58e8
					
				
					 2 changed files with 38 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -344,9 +344,10 @@ def search_up(prefix, *landmarks, test=isfile):
 | 
			
		|||
 | 
			
		||||
venv_prefix = None
 | 
			
		||||
 | 
			
		||||
# Calling Py_SetPythonHome(), Py_SetPath() or
 | 
			
		||||
# setting $PYTHONHOME will override venv detection.
 | 
			
		||||
if not home and not py_setpath:
 | 
			
		||||
# Calling Py_SetPath() will override venv detection.
 | 
			
		||||
# Calling Py_SetPythonHome() or setting $PYTHONHOME will override the 'home' key
 | 
			
		||||
# specified in pyvenv.cfg.
 | 
			
		||||
if not py_setpath:
 | 
			
		||||
    try:
 | 
			
		||||
        # prefix2 is just to avoid calculating dirname again later,
 | 
			
		||||
        # as the path in venv_prefix is the more common case.
 | 
			
		||||
| 
						 | 
				
			
			@ -370,6 +371,9 @@ def search_up(prefix, *landmarks, test=isfile):
 | 
			
		|||
    for line in pyvenvcfg:
 | 
			
		||||
        key, had_equ, value = line.partition('=')
 | 
			
		||||
        if had_equ and key.strip().lower() == 'home':
 | 
			
		||||
            # If PYTHONHOME was set, ignore 'home' from pyvenv.cfg.
 | 
			
		||||
            if home:
 | 
			
		||||
                break
 | 
			
		||||
            # Override executable_dir/real_executable_dir with the value from 'home'.
 | 
			
		||||
            # These values may be later used to calculate prefix/base_prefix, if a more
 | 
			
		||||
            # reliable source — like the runtime library (libpython) path — isn't available.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue