Returns a list containing all global site-packages directories. For each directory present in ``prefixes`` (or the global ``PREFIXES``), this function will find its `site-packages` subdirectory depending on the system environment, and will return a list of full paths.
(prefixes=None)
| 380 | return known_paths |
| 381 | |
| 382 | def getsitepackages(prefixes=None): |
| 383 | """Returns a list containing all global site-packages directories. |
| 384 | |
| 385 | For each directory present in ``prefixes`` (or the global ``PREFIXES``), |
| 386 | this function will find its `site-packages` subdirectory depending on the |
| 387 | system environment, and will return a list of full paths. |
| 388 | """ |
| 389 | sitepackages = [] |
| 390 | seen = set() |
| 391 | |
| 392 | if prefixes is None: |
| 393 | prefixes = PREFIXES |
| 394 | |
| 395 | for prefix in prefixes: |
| 396 | if not prefix or prefix in seen: |
| 397 | continue |
| 398 | seen.add(prefix) |
| 399 | |
| 400 | implementation = _get_implementation().lower() |
| 401 | ver = sys.version_info |
| 402 | if hasattr(sys, 'abiflags') and 't' in sys.abiflags: |
| 403 | abi_thread = 't' |
| 404 | else: |
| 405 | abi_thread = '' |
| 406 | if os.sep == '/': |
| 407 | libdirs = [sys.platlibdir] |
| 408 | if sys.platlibdir != "lib": |
| 409 | libdirs.append("lib") |
| 410 | |
| 411 | for libdir in libdirs: |
| 412 | path = os.path.join(prefix, libdir, |
| 413 | f"{implementation}{ver[0]}.{ver[1]}{abi_thread}", |
| 414 | "site-packages") |
| 415 | sitepackages.append(path) |
| 416 | else: |
| 417 | sitepackages.append(prefix) |
| 418 | sitepackages.append(os.path.join(prefix, "Lib", "site-packages")) |
| 419 | return sitepackages |
| 420 | |
| 421 | def addsitepackages(known_paths, prefixes=None): |
| 422 | """Add site-packages to sys.path""" |
no test coverage detected
searching dependent graphs…