@@ -582,7 +582,7 @@ def search_up(prefix, *landmarks, test=isfile):
582
582
# Detect prefix by searching from our executable location for the stdlib_dir
583
583
if STDLIB_SUBDIR and STDLIB_LANDMARKS and executable_dir and not prefix :
584
584
prefix = search_up (executable_dir , * STDLIB_LANDMARKS )
585
- if prefix :
585
+ if prefix and not stdlib_dir :
586
586
stdlib_dir = joinpath (prefix , STDLIB_SUBDIR )
587
587
588
588
if PREFIX and not prefix :
@@ -631,20 +631,6 @@ def search_up(prefix, *landmarks, test=isfile):
631
631
warn ('Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]' )
632
632
633
633
634
- # If we haven't set [plat]stdlib_dir already, set them now
635
- if not stdlib_dir :
636
- if prefix :
637
- stdlib_dir = joinpath (prefix , STDLIB_SUBDIR )
638
- else :
639
- stdlib_dir = ''
640
-
641
- if not platstdlib_dir :
642
- if exec_prefix :
643
- platstdlib_dir = joinpath (exec_prefix , PLATSTDLIB_LANDMARK )
644
- else :
645
- platstdlib_dir = ''
646
-
647
-
648
634
# For a venv, update the main prefix/exec_prefix but leave the base ones unchanged
649
635
# XXX: We currently do not update prefix here, but it happens in site.py
650
636
#if venv_prefix:
@@ -706,8 +692,9 @@ def search_up(prefix, *landmarks, test=isfile):
706
692
pythonpath .extend (v .split (DELIM ))
707
693
i += 1
708
694
# Paths from the core key get appended last, but only
709
- # when home was not set and we aren't in a build dir
710
- if not home_was_set and not venv_prefix and not build_prefix :
695
+ # when home was not set and we haven't found our stdlib
696
+ # some other way.
697
+ if not home and not stdlib_dir :
711
698
v = winreg .QueryValue (key , None )
712
699
if isinstance (v , str ):
713
700
pythonpath .extend (v .split (DELIM ))
@@ -722,6 +709,11 @@ def search_up(prefix, *landmarks, test=isfile):
722
709
pythonpath .append (joinpath (prefix , p ))
723
710
724
711
# Then add stdlib_dir and platstdlib_dir
712
+ if not stdlib_dir and prefix :
713
+ stdlib_dir = joinpath (prefix , STDLIB_SUBDIR )
714
+ if not platstdlib_dir and exec_prefix :
715
+ platstdlib_dir = joinpath (exec_prefix , PLATSTDLIB_LANDMARK )
716
+
725
717
if os_name == 'nt' :
726
718
# QUIRK: Windows generates paths differently
727
719
if platstdlib_dir :
@@ -792,5 +784,6 @@ def search_up(prefix, *landmarks, test=isfile):
792
784
config ['base_exec_prefix' ] = base_exec_prefix or exec_prefix
793
785
794
786
config ['platlibdir' ] = platlibdir
795
- config ['stdlib_dir' ] = stdlib_dir
796
- config ['platstdlib_dir' ] = platstdlib_dir
787
+ # test_embed expects empty strings, not None
788
+ config ['stdlib_dir' ] = stdlib_dir or ''
789
+ config ['platstdlib_dir' ] = platstdlib_dir or ''
0 commit comments