diff options
Diffstat (limited to 'venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/locations.py')
-rw-r--r-- | venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/locations.py | 194 |
1 files changed, 0 insertions, 194 deletions
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/locations.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/locations.py deleted file mode 100644 index ce8f7e9..0000000 --- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/locations.py +++ /dev/null | |||
@@ -1,194 +0,0 @@ | |||
1 | """Locations where we look for configs, install stuff, etc""" | ||
2 | from __future__ import absolute_import | ||
3 | |||
4 | import os | ||
5 | import os.path | ||
6 | import platform | ||
7 | import site | ||
8 | import sys | ||
9 | import sysconfig | ||
10 | from distutils import sysconfig as distutils_sysconfig | ||
11 | from distutils.command.install import SCHEME_KEYS, install # type: ignore | ||
12 | |||
13 | from pip._internal.compat import WINDOWS, expanduser | ||
14 | from pip._internal.utils import appdirs | ||
15 | |||
16 | # Application Directories | ||
17 | USER_CACHE_DIR = appdirs.user_cache_dir("pip") | ||
18 | |||
19 | |||
20 | DELETE_MARKER_MESSAGE = '''\ | ||
21 | This file is placed here by pip to indicate the source was put | ||
22 | here by pip. | ||
23 | |||
24 | Once this package is successfully installed this source code will be | ||
25 | deleted (unless you remove this file). | ||
26 | ''' | ||
27 | PIP_DELETE_MARKER_FILENAME = 'pip-delete-this-directory.txt' | ||
28 | |||
29 | |||
30 | def write_delete_marker_file(directory): | ||
31 | """ | ||
32 | Write the pip delete marker file into this directory. | ||
33 | """ | ||
34 | filepath = os.path.join(directory, PIP_DELETE_MARKER_FILENAME) | ||
35 | with open(filepath, 'w') as marker_fp: | ||
36 | marker_fp.write(DELETE_MARKER_MESSAGE) | ||
37 | |||
38 | |||
39 | def running_under_virtualenv(): | ||
40 | """ | ||
41 | Return True if we're running inside a virtualenv, False otherwise. | ||
42 | |||
43 | """ | ||
44 | if hasattr(sys, 'real_prefix'): | ||
45 | return True | ||
46 | elif sys.prefix != getattr(sys, "base_prefix", sys.prefix): | ||
47 | return True | ||
48 | |||
49 | return False | ||
50 | |||
51 | |||
52 | def virtualenv_no_global(): | ||
53 | """ | ||
54 | Return True if in a venv and no system site packages. | ||
55 | """ | ||
56 | # this mirrors the logic in virtualenv.py for locating the | ||
57 | # no-global-site-packages.txt file | ||
58 | site_mod_dir = os.path.dirname(os.path.abspath(site.__file__)) | ||
59 | no_global_file = os.path.join(site_mod_dir, 'no-global-site-packages.txt') | ||
60 | if running_under_virtualenv() and os.path.isfile(no_global_file): | ||
61 | return True | ||
62 | |||
63 | |||
64 | if running_under_virtualenv(): | ||
65 | src_prefix = os.path.join(sys.prefix, 'src') | ||
66 | else: | ||
67 | # FIXME: keep src in cwd for now (it is not a temporary folder) | ||
68 | try: | ||
69 | src_prefix = os.path.join(os.getcwd(), 'src') | ||
70 | except OSError: | ||
71 | # In case the current working directory has been renamed or deleted | ||
72 | sys.exit( | ||
73 | "The folder you are executing pip from can no longer be found." | ||
74 | ) | ||
75 | |||
76 | # under macOS + virtualenv sys.prefix is not properly resolved | ||
77 | # it is something like /path/to/python/bin/.. | ||
78 | # Note: using realpath due to tmp dirs on OSX being symlinks | ||
79 | src_prefix = os.path.abspath(src_prefix) | ||
80 | |||
81 | # FIXME doesn't account for venv linked to global site-packages | ||
82 | |||
83 | site_packages = sysconfig.get_path("purelib") | ||
84 | # This is because of a bug in PyPy's sysconfig module, see | ||
85 | # https://bitbucket.org/pypy/pypy/issues/2506/sysconfig-returns-incorrect-paths | ||
86 | # for more information. | ||
87 | if platform.python_implementation().lower() == "pypy": | ||
88 | site_packages = distutils_sysconfig.get_python_lib() | ||
89 | try: | ||
90 | # Use getusersitepackages if this is present, as it ensures that the | ||
91 | # value is initialised properly. | ||
92 | user_site = site.getusersitepackages() | ||
93 | except AttributeError: | ||
94 | user_site = site.USER_SITE | ||
95 | user_dir = expanduser('~') | ||
96 | if WINDOWS: | ||
97 | bin_py = os.path.join(sys.prefix, 'Scripts') | ||
98 | bin_user = os.path.join(user_site, 'Scripts') | ||
99 | # buildout uses 'bin' on Windows too? | ||
100 | if not os.path.exists(bin_py): | ||
101 | bin_py = os.path.join(sys.prefix, 'bin') | ||
102 | bin_user = os.path.join(user_site, 'bin') | ||
103 | |||
104 | config_basename = 'pip.ini' | ||
105 | |||
106 | legacy_storage_dir = os.path.join(user_dir, 'pip') | ||
107 | legacy_config_file = os.path.join( | ||
108 | legacy_storage_dir, | ||
109 | config_basename, | ||
110 | ) | ||
111 | else: | ||
112 | bin_py = os.path.join(sys.prefix, 'bin') | ||
113 | bin_user = os.path.join(user_site, 'bin') | ||
114 | |||
115 | config_basename = 'pip.conf' | ||
116 | |||
117 | legacy_storage_dir = os.path.join(user_dir, '.pip') | ||
118 | legacy_config_file = os.path.join( | ||
119 | legacy_storage_dir, | ||
120 | config_basename, | ||
121 | ) | ||
122 | # Forcing to use /usr/local/bin for standard macOS framework installs | ||
123 | # Also log to ~/Library/Logs/ for use with the Console.app log viewer | ||
124 | if sys.platform[:6] == 'darwin' and sys.prefix[:16] == '/System/Library/': | ||
125 | bin_py = '/usr/local/bin' | ||
126 | |||
127 | site_config_files = [ | ||
128 | os.path.join(path, config_basename) | ||
129 | for path in appdirs.site_config_dirs('pip') | ||
130 | ] | ||
131 | |||
132 | venv_config_file = os.path.join(sys.prefix, config_basename) | ||
133 | new_config_file = os.path.join(appdirs.user_config_dir("pip"), config_basename) | ||
134 | |||
135 | |||
136 | def distutils_scheme(dist_name, user=False, home=None, root=None, | ||
137 | isolated=False, prefix=None): | ||
138 | """ | ||
139 | Return a distutils install scheme | ||
140 | """ | ||
141 | from distutils.dist import Distribution | ||
142 | |||
143 | scheme = {} | ||
144 | |||
145 | if isolated: | ||
146 | extra_dist_args = {"script_args": ["--no-user-cfg"]} | ||
147 | else: | ||
148 | extra_dist_args = {} | ||
149 | dist_args = {'name': dist_name} | ||
150 | dist_args.update(extra_dist_args) | ||
151 | |||
152 | d = Distribution(dist_args) | ||
153 | d.parse_config_files() | ||
154 | i = d.get_command_obj('install', create=True) | ||
155 | # NOTE: setting user or home has the side-effect of creating the home dir | ||
156 | # or user base for installations during finalize_options() | ||
157 | # ideally, we'd prefer a scheme class that has no side-effects. | ||
158 | assert not (user and prefix), "user={} prefix={}".format(user, prefix) | ||
159 | i.user = user or i.user | ||
160 | if user: | ||
161 | i.prefix = "" | ||
162 | i.prefix = prefix or i.prefix | ||
163 | i.home = home or i.home | ||
164 | i.root = root or i.root | ||
165 | i.finalize_options() | ||
166 | for key in SCHEME_KEYS: | ||
167 | scheme[key] = getattr(i, 'install_' + key) | ||
168 | |||
169 | # install_lib specified in setup.cfg should install *everything* | ||
170 | # into there (i.e. it takes precedence over both purelib and | ||
171 | # platlib). Note, i.install_lib is *always* set after | ||
172 | # finalize_options(); we only want to override here if the user | ||
173 | # has explicitly requested it hence going back to the config | ||
174 | if 'install_lib' in d.get_option_dict('install'): | ||
175 | scheme.update(dict(purelib=i.install_lib, platlib=i.install_lib)) | ||
176 | |||
177 | if running_under_virtualenv(): | ||
178 | scheme['headers'] = os.path.join( | ||
179 | sys.prefix, | ||
180 | 'include', | ||
181 | 'site', | ||
182 | 'python' + sys.version[:3], | ||
183 | dist_name, | ||
184 | ) | ||
185 | |||
186 | if root is not None: | ||
187 | path_no_drive = os.path.splitdrive( | ||
188 | os.path.abspath(scheme["headers"]))[1] | ||
189 | scheme["headers"] = os.path.join( | ||
190 | root, | ||
191 | path_no_drive[1:], | ||
192 | ) | ||
193 | |||
194 | return scheme | ||