Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
pip._internal.self_outdated_check Namespace Reference

Data Structures

class  SelfCheckState
 
class  UpgradePrompt
 

Functions

str _get_statefile_name (str key)
 
bool was_installed_by_pip (str pkg)
 
Optional[str] _get_current_remote_pip_version (PipSession session, optparse.Values options)
 
Optional[UpgradePrompt_self_version_check_logic (*SelfCheckState state, datetime.datetime current_time, DistributionVersion local_version, Callable[[], Optional[str]] get_remote_version)
 
None pip_self_version_check (PipSession session, optparse.Values options)
 

Variables

str _DATE_FMT = "%Y-%m-%dT%H:%M:%SZ"
 
 logger = logging.getLogger(__name__)
 

Function Documentation

◆ _get_current_remote_pip_version()

Optional[str] _get_current_remote_pip_version ( PipSession  session,
optparse.Values   options 
)
protected

Definition at line 156 of file self_outdated_check.py.

158) -> Optional[str]:
159 # Lets use PackageFinder to see what the latest pip version is
160 link_collector = LinkCollector.create(
161 session,
162 options=options,
163 suppress_no_index=True,
164 )
165
166 # Pass allow_yanked=False so we don't suggest upgrading to a
167 # yanked version.
168 selection_prefs = SelectionPreferences(
169 allow_yanked=False,
170 allow_all_prereleases=False, # Explicitly set to False
171 )
172
173 finder = PackageFinder.create(
174 link_collector=link_collector,
175 selection_prefs=selection_prefs,
176 )
177 best_candidate = finder.find_best_candidate("pip").best_candidate
178 if best_candidate is None:
179 return None
180
181 return str(best_candidate.version)
182
183
for i

References i.

◆ _get_statefile_name()

str _get_statefile_name ( str  key)
protected

Definition at line 37 of file self_outdated_check.py.

37def _get_statefile_name(key: str) -> str:
38 key_bytes = key.encode()
39 name = hashlib.sha224(key_bytes).hexdigest()
40 return name
41
42

References i.

◆ _self_version_check_logic()

Optional[UpgradePrompt] _self_version_check_logic ( *SelfCheckState  state,
datetime.datetime  current_time,
DistributionVersion  local_version,
Callable[[], Optional[str]]  get_remote_version 
)
protected

Definition at line 184 of file self_outdated_check.py.

190) -> Optional[UpgradePrompt]:
191 remote_version_str = state.get(current_time)
192 if remote_version_str is None:
193 remote_version_str = get_remote_version()
194 if remote_version_str is None:
195 logger.debug("No remote pip version found")
196 return None
197 state.set(remote_version_str, current_time)
198
199 remote_version = parse_version(remote_version_str)
200 logger.debug("Remote version of pip: %s", remote_version)
201 logger.debug("Local version of pip: %s", local_version)
202
203 pip_installed_by_pip = was_installed_by_pip("pip")
204 logger.debug("Was pip installed by pip? %s", pip_installed_by_pip)
205 if not pip_installed_by_pip:
206 return None # Only suggest upgrade if pip is installed by pip.
207
208 local_version_is_older = (
209 local_version < remote_version
211 )
212 if local_version_is_older:
213 return UpgradePrompt(old=str(local_version), new=remote_version_str)
214
215 return None
216
217

References i, and pip._internal.self_outdated_check.was_installed_by_pip().

Referenced by pip._internal.self_outdated_check.pip_self_version_check().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pip_self_version_check()

None pip_self_version_check ( PipSession  session,
optparse.Values  options 
)
Check for an update for pip.

Limit the frequency of checks to once per week. State is stored either in
the active virtualenv or in the user's USER_CACHE_DIR keyed off the prefix
of the pip script path.

Definition at line 218 of file self_outdated_check.py.

218def pip_self_version_check(session: PipSession, options: optparse.Values) -> None:
219 """Check for an update for pip.
220
221 Limit the frequency of checks to once per week. State is stored either in
222 the active virtualenv or in the user's USER_CACHE_DIR keyed off the prefix
223 of the pip script path.
224 """
225 installed_dist = get_default_environment().get_distribution("pip")
226 if not installed_dist:
227 return
228
229 try:
230 upgrade_prompt = _self_version_check_logic(
231 state=SelfCheckState(cache_dir=options.cache_dir),
232 current_time=datetime.datetime.utcnow(),
233 local_version=installed_dist.version,
234 get_remote_version=functools.partial(
235 _get_current_remote_pip_version, session, options
236 ),
237 )
238 if upgrade_prompt is not None:
239 logger.warning("[present-rich] %s", upgrade_prompt)
240 except Exception:
241 logger.warning("There was an error checking the latest version of pip.")
242 logger.debug("See below for error", exc_info=True)

References pip._internal.self_outdated_check._self_version_check_logic(), and i.

Here is the call graph for this function:

◆ was_installed_by_pip()

bool was_installed_by_pip ( str  pkg)
Checks whether pkg was installed by pip

This is used not to display the upgrade message when pip is in fact
installed by system package manager, such as dnf on Fedora.

Definition at line 146 of file self_outdated_check.py.

146def was_installed_by_pip(pkg: str) -> bool:
147 """Checks whether pkg was installed by pip
148
149 This is used not to display the upgrade message when pip is in fact
150 installed by system package manager, such as dnf on Fedora.
151 """
152 dist = get_default_environment().get_distribution(pkg)
153 return dist is not None and "pip" == dist.installer
154
155

References i.

Referenced by pip._internal.self_outdated_check._self_version_check_logic().

Here is the caller graph for this function:

Variable Documentation

◆ _DATE_FMT

str _DATE_FMT = "%Y-%m-%dT%H:%M:%SZ"
protected

Definition at line 31 of file self_outdated_check.py.

◆ logger

logger = logging.getLogger(__name__)

Definition at line 34 of file self_outdated_check.py.