Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
keewenaw
GitHub Repository: keewenaw/ethereum-wallet-cracker
Path: blob/main/test/lib/python3.9/site-packages/pip/_internal/locations/base.py
5170 views
1
import functools
2
import os
3
import site
4
import sys
5
import sysconfig
6
import typing
7
8
from pip._internal.utils import appdirs
9
from pip._internal.utils.virtualenv import running_under_virtualenv
10
11
# Application Directories
12
USER_CACHE_DIR = appdirs.user_cache_dir("pip")
13
14
# FIXME doesn't account for venv linked to global site-packages
15
site_packages: typing.Optional[str] = sysconfig.get_path("purelib")
16
17
18
def get_major_minor_version() -> str:
19
"""
20
Return the major-minor version of the current Python as a string, e.g.
21
"3.7" or "3.10".
22
"""
23
return "{}.{}".format(*sys.version_info)
24
25
26
def get_src_prefix() -> str:
27
if running_under_virtualenv():
28
src_prefix = os.path.join(sys.prefix, "src")
29
else:
30
# FIXME: keep src in cwd for now (it is not a temporary folder)
31
try:
32
src_prefix = os.path.join(os.getcwd(), "src")
33
except OSError:
34
# In case the current working directory has been renamed or deleted
35
sys.exit("The folder you are executing pip from can no longer be found.")
36
37
# under macOS + virtualenv sys.prefix is not properly resolved
38
# it is something like /path/to/python/bin/..
39
return os.path.abspath(src_prefix)
40
41
42
try:
43
# Use getusersitepackages if this is present, as it ensures that the
44
# value is initialised properly.
45
user_site: typing.Optional[str] = site.getusersitepackages()
46
except AttributeError:
47
user_site = site.USER_SITE
48
49
50
@functools.lru_cache(maxsize=None)
51
def is_osx_framework() -> bool:
52
return bool(sysconfig.get_config_var("PYTHONFRAMEWORK"))
53
54