@@ -229,9 +229,10 @@ def search_up(prefix, *landmarks, test=isfile):
229
229
230
230
pythonpath = config .get ('module_search_paths' )
231
231
pythonpath_was_set = config .get ('module_search_paths_set' )
232
+ stdlib_dir = config .get ('stdlib_dir' )
233
+ stdlib_dir_was_set_in_config = bool (stdlib_dir )
232
234
233
235
real_executable_dir = None
234
- stdlib_dir = None
235
236
platstdlib_dir = None
236
237
237
238
# ******************************************************************************
@@ -507,11 +508,12 @@ def search_up(prefix, *landmarks, test=isfile):
507
508
build_stdlib_prefix = build_prefix
508
509
else :
509
510
build_stdlib_prefix = search_up (build_prefix , * BUILDSTDLIB_LANDMARKS )
510
- # Always use the build prefix for stdlib
511
- if build_stdlib_prefix :
512
- stdlib_dir = joinpath (build_stdlib_prefix , 'Lib' )
513
- else :
514
- stdlib_dir = joinpath (build_prefix , 'Lib' )
511
+ # Use the build prefix for stdlib when not explicitly set
512
+ if not stdlib_dir_was_set_in_config :
513
+ if build_stdlib_prefix :
514
+ stdlib_dir = joinpath (build_stdlib_prefix , 'Lib' )
515
+ else :
516
+ stdlib_dir = joinpath (build_prefix , 'Lib' )
515
517
# Only use the build prefix for prefix if it hasn't already been set
516
518
if not prefix :
517
519
prefix = build_stdlib_prefix
@@ -543,8 +545,9 @@ def search_up(prefix, *landmarks, test=isfile):
543
545
prefix , had_delim , exec_prefix = home .partition (DELIM )
544
546
if not had_delim :
545
547
exec_prefix = prefix
546
- # Reset the standard library directory if it was already set
547
- stdlib_dir = None
548
+ # Reset the standard library directory if it was not explicitly set
549
+ if not stdlib_dir_was_set_in_config :
550
+ stdlib_dir = None
548
551
549
552
550
553
# First try to detect prefix by looking alongside our runtime library, if known
@@ -560,7 +563,8 @@ def search_up(prefix, *landmarks, test=isfile):
560
563
if STDLIB_SUBDIR and STDLIB_LANDMARKS and not prefix :
561
564
if any (isfile (joinpath (library_dir , f )) for f in STDLIB_LANDMARKS ):
562
565
prefix = library_dir
563
- stdlib_dir = joinpath (prefix , STDLIB_SUBDIR )
566
+ if not stdlib_dir_was_set_in_config :
567
+ stdlib_dir = joinpath (prefix , STDLIB_SUBDIR )
564
568
565
569
566
570
# Detect prefix by looking for zip file
@@ -571,7 +575,7 @@ def search_up(prefix, *landmarks, test=isfile):
571
575
prefix = executable_dir
572
576
else :
573
577
prefix = search_up (executable_dir , ZIP_LANDMARK )
574
- if prefix :
578
+ if prefix and not stdlib_dir_was_set_in_config :
575
579
stdlib_dir = joinpath (prefix , STDLIB_SUBDIR )
576
580
if not isdir (stdlib_dir ):
577
581
stdlib_dir = None
0 commit comments