Lines Matching +full:- +full:- +full:directory +full:- +full:prefix
18 # abspath(path) -- make relative paths absolute against CWD
19 # basename(path) -- the filename of path
20 # dirname(path) -- the directory name of path
21 # hassuffix(path, suffix) -- returns True if path has suffix
22 # isabs(path) -- path is absolute or not
23 # isdir(path) -- path exists and is a directory
24 # isfile(path) -- path exists and is a file
25 # isxfile(path) -- path exists and is an executable file
26 # joinpath(*paths) -- combine the paths
27 # readlines(path) -- a list of each line of text in the UTF-8 encoded file
28 # realpath(path) -- resolves symlinks in path
29 # warn(message) -- print a warning (if enabled)
32 # os_name -- [in] one of 'nt', 'posix', 'darwin'
33 # PREFIX -- [in] sysconfig.get_config_var(...)
34 # EXEC_PREFIX -- [in] sysconfig.get_config_var(...)
35 # PYTHONPATH -- [in] sysconfig.get_config_var(...)
36 # WITH_NEXT_FRAMEWORK -- [in] sysconfig.get_config_var(...)
37 # VPATH -- [in] sysconfig.get_config_var(...)
38 # PLATLIBDIR -- [in] sysconfig.get_config_var(...)
39 # PYDEBUGEXT -- [in, opt] '_d' on Windows for debug builds
40 # EXE_SUFFIX -- [in, opt] '.exe' on Windows/Cygwin/similar
41 # VERSION_MAJOR -- [in] sys.version_info.major
42 # VERSION_MINOR -- [in] sys.version_info.minor
43 # ABI_THREAD -- [in] either 't' for free-threaded builds or ''
44 # PYWINVER -- [in] the Windows platform-specific version (e.g. 3.8-32)
51 # ENV_PATH -- [in] getenv(...)
52 # ENV_PYTHONHOME -- [in] getenv(...)
53 # ENV_PYTHONEXECUTABLE -- [in] getenv(...)
54 # ENV___PYVENV_LAUNCHER__ -- [in] getenv(...)
57 # config -- [in/out] dict of the PyConfig structure
58 # real_executable -- [in, optional] resolved path to main process
61 # executable_dir -- [in, optional] real directory containing binary
63 # py_setpath -- [in] argument provided to Py_SetPath
64 # If None, 'prefix' and 'exec_prefix' may be updated in config
65 # library -- [in, optional] path of dylib/DLL/so
67 # winreg -- [in, optional] the winreg module (only on Windows)
70 # HIGH-LEVEL ALGORITHM
80 # Two directories must be found, the platform independent directory
81 # (prefix), containing the common .py and .pyc files, and the platform
82 # dependent directory (exec_prefix), containing the shared library
83 # modules. Note that prefix and exec_prefix can be the same directory,
86 # This script carries out separate searches for prefix and exec_prefix.
88 # file or directory is found. If no prefix or exec_prefix is found, a
89 # warning message is issued and the preprocessor defined PREFIX and
96 # we use the config-specified program name or default to argv[0].
98 # the current working directory. If it only contains a name, it must
111 # link. If so, the link is realpath-ed and the directory of the link
113 # performed for prefix and for exec_prefix, but with different landmarks.
117 # property to override the executable dir used later for prefix searches.
118 # We do not activate the venv here - that is performed later by site.py.
125 # specified by Py_SetHome(), the directory containing the ._pth file is
128 # Step 3. Are we running python out of the build directory? This is
132 # directory containing pybuilddir.txt. If it is not found, the
134 # prefix is then found by searching up for a file that should only
135 # exist in the source tree, and the stdlib dir is set to prefix/Lib.
138 # a pyvenv.cfg file, ._pth file, or by detecting a build directory, it
139 # is assumed to point to prefix and exec_prefix. $PYTHONHOME can be a
140 # single directory, which is used for both, or the prefix and exec_prefix
143 # Step 5. Try to find prefix and exec_prefix relative to executable_dir,
145 # step to succeed. Note that if prefix and exec_prefix are different,
147 # subdirectory of prefix, both will be found.
150 # PREFIX and EXEC_PREFIX. These are supplied by the Makefile but can be
155 # Well, almost. Once we have determined prefix and exec_prefix, the
157 # relative path on PYTHONPATH is prefixed with prefix. Then the directory
160 # in a build directory, both prefix and exec_prefix are reset to the
161 # corresponding preprocessor variables (so sys.prefix will reflect the
163 # directory). This seems to make more sense given that currently the only
164 # known use of sys.prefix and sys.exec_prefix is for the ILU installation
184 …PLATSTDLIB_LANDMARK = f'{platlibdir}/python{VERSION_MAJOR}.{VERSION_MINOR}{ABI_THREAD}/lib-dynload'
210 def search_up(prefix, *landmarks, test=isfile): argument
211 while prefix:
212 if any(test(joinpath(prefix, f)) for f in landmarks):
213 return prefix
214 prefix = dirname(prefix)
225 prefix = config.get('prefix') variable
268 # Resolve partial path program_name against current directory
296 # look in the current working directory. Here, we emulate that
300 # build directory with an invalid argv0 (i.e. test_sys.test_executable)
306 # use the argv0 path for prefix calculation
359 # Try the same directory as executable
383 # "python" is not available in the "home" directory as the standard
434 # If we do not have the executable's directory, we can calculate it.
435 # This is the directory used to find prefix/exec_prefix if necessary.
439 # If we do not have the real executable's directory, we calculate it.
440 # This is the directory used to detect build layouts.
450 # no-site (unless explicitly requested)
455 # but environment variables and command-line options cannot.
483 # CHECK FOR BUILD DIRECTORY
490 # Detect a build marker and use it to infer prefix, exec_prefix,
517 # Use the build prefix for stdlib when not explicitly set
523 # Only use the build prefix for prefix if it hasn't already been set
524 if not prefix:
525 prefix = build_stdlib_prefix variable
526 # Do not warn, because 'prefix' never equals 'build_prefix' on POSIX
527 #elif not venv_prefix and prefix != build_prefix:
528 # warn('Detected development environment but prefix is already set')
538 # CALCULATE prefix AND exec_prefix
542 # As documented, calling Py_SetPath will force both prefix
544 prefix = exec_prefix = '' variable
547 # Read prefix and exec_prefix from explicitly set home
550 # split into prefix:exec_prefix
551 prefix, had_delim, exec_prefix = home.partition(DELIM) variable
553 exec_prefix = prefix
554 # Reset the standard library directory if it was not explicitly set
559 # First try to detect prefix by looking alongside our runtime library, if known
560 if library and not prefix:
566 prefix = library_dir variable
568 prefix = search_up(library_dir, ZIP_LANDMARK) variable
569 if STDLIB_SUBDIR and STDLIB_LANDMARKS and not prefix:
571 prefix = library_dir variable
573 stdlib_dir = joinpath(prefix, STDLIB_SUBDIR)
576 # Detect prefix by looking for zip file
577 if ZIP_LANDMARK and executable_dir and not prefix:
581 prefix = executable_dir variable
583 prefix = search_up(executable_dir, ZIP_LANDMARK) variable
584 if prefix and not stdlib_dir_was_set_in_config:
585 stdlib_dir = joinpath(prefix, STDLIB_SUBDIR)
590 # Detect prefix by searching from our executable location for the stdlib_dir
591 if STDLIB_SUBDIR and STDLIB_LANDMARKS and executable_dir and not prefix:
592 prefix = search_up(executable_dir, *STDLIB_LANDMARKS) variable
593 if prefix and not stdlib_dir:
594 stdlib_dir = joinpath(prefix, STDLIB_SUBDIR)
596 if PREFIX and not prefix:
597 prefix = PREFIX variable
598 if not any(isfile(joinpath(prefix, f)) for f in STDLIB_LANDMARKS):
599 warn('Could not find platform independent libraries <prefix>')
601 if not prefix:
602 prefix = abspath('') variable
603 warn('Could not find platform independent libraries <prefix>')
610 # gh-100320: Our PYDs are assumed to be relative to the Lib directory
611 # (that is, prefix) rather than the executable (that is, executable_dir)
612 exec_prefix = prefix
622 # gh-98790: We set platstdlib_dir here to avoid adding "DLLs" into
633 # Fallback: assume exec_prefix == prefix
635 exec_prefix = prefix
638 if not prefix or not exec_prefix:
639 warn('Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]')
642 # For a venv, update the main prefix/exec_prefix but leave the base ones unchanged
643 # XXX: We currently do not update prefix here, but it happens in site.py
645 # base_prefix = prefix
647 # prefix = exec_prefix = venv_prefix
672 # QUIRK: Windows uses the library directory rather than the prefix
679 # QUIRK: POSIX uses the default prefix when in the build directory
680 pythonpath.append(joinpath(PREFIX, ZIP_LANDMARK))
682 pythonpath.append(joinpath(prefix, ZIP_LANDMARK))
688 # where winver is sys.winver (typically '3.x' or '3.x-32')
717 pythonpath.append(joinpath(prefix, p))
720 if not stdlib_dir and prefix:
721 stdlib_dir = joinpath(prefix, STDLIB_SUBDIR)
732 # QUIRK: the executable directory is on sys.path
748 # POSIX prefix/exec_prefix QUIRKS
751 # QUIRK: Non-Windows replaces prefix/exec_prefix with defaults when running
752 # in build directory. This happens after pythonpath calculation.
754 prefix = config.get('prefix') or PREFIX variable
755 exec_prefix = config.get('exec_prefix') or EXEC_PREFIX or prefix
789 config['prefix'] = prefix
791 config['base_prefix'] = base_prefix or prefix