@@ -356,15 +356,31 @@ Module contents
356356 This function used to be called unconditionally.
357357
358358
359+ .. function :: makepath(*paths)
360+
361+ Join *paths * with :func: `os.path.join `, attempt to make the result
362+ absolute with :func: `os.path.abspath `, and return a 2-tuple containing
363+ the absolute path and its case-normalized form as produced by
364+ :func: `os.path.normcase `. If :func: `os.path.abspath ` raises
365+ :exc: `OSError `, the joined path is used unchanged for the
366+ case-normalization step.
367+
368+ The second element of the returned tuple is the form used throughout the
369+ :mod: `!site ` module to compare paths on case-insensitive file systems, and
370+ is what populates the ``known_paths `` sets that prevent duplicate
371+ :data: `sys.path ` entries in various APIs within this module.
372+
373+
359374.. class :: StartupState(known_paths=None)
360375
361376 Instances of this class are used as an accumulator for interpreter startup
362377 configuration data, such as ``.pth `` and ``.start `` files, from one or more
363378 site directories. These are used to batch the processing of these startup
364379 files. The optional *known_paths * argument is a set of case-normalized
365- paths used to prevent duplicate :data: `sys.path ` entries. With ``None ``
366- (the default), this set is built from the current :data: `sys.path `.
367- :func: `main ` implicitly uses an instance of this class.
380+ paths (which can be produced by :func: `makepath `) used to prevent duplicate
381+ :data: `sys.path ` entries. With ``None `` (the default), this set is built
382+ from the current :data: `sys.path `. :func: `main ` implicitly uses an
383+ instance of this class.
368384
369385 .. versionadded :: 3.15
370386
@@ -375,6 +391,10 @@ Module contents
375391 and :file: `.pth ` file ``import `` lines (:ref: `deprecated
376392 <site-pth-files>`).
377393
394+ This method is not idempotent and must not be called more than once
395+ on the same instance. Doing so would apply the accumulated state
396+ more than once, re-running entry points and ``import `` lines.
397+
378398
379399.. function :: addsitedir(sitedir, known_paths=None, *, startup_state=None)
380400
0 commit comments