pub struct SearchPath(/* private fields */);Expand description
Unification of the various kinds of search paths that can be used to locate Python modules.
The different kinds of search paths are:
- “Extra” search paths: these go at the start of the module resolution order
- First-party search paths: the user code that we are directly invoked on.
- Standard-library search paths: these come in three different forms:
- Custom standard-library search paths: paths provided by the user pointing to a custom typeshed directory on disk
- Vendored standard-library search paths: paths pointing to a directory in the vendored zip archive.
- Real standard-library search paths: path pointing to a directory of the real python stdlib for the environment.
- Site-packages search paths: search paths that point to the
site-packagesdirectory, in which packages are installed fromPyPI. - Editable search paths: Additional search paths added to the end of the module
resolution order. We discover these by iterating through
.pthfiles in thesite-packagesdirectory and searching for lines in those.pthfiles that point to existing directories on disk. Such lines indicate editable installations, which will be appended tosys.pathat runtime, and thus should also be considered valid search paths for our purposes.
For some of the above categories, there may be an arbitrary number in any given list of search paths: for example, the “Extra” category or the “Editable” category. For the “First-party”, “Site-packages” and “Standard-library” categories, however, there will always be exactly one search path from that category in any given list of search paths.
Implementations§
Source§impl SearchPath
impl SearchPath
Sourcepub fn is_standard_library(&self) -> bool
pub fn is_standard_library(&self) -> bool
Does this search path point to the standard library?
Sourcepub fn is_first_party(&self) -> bool
pub fn is_first_party(&self) -> bool
Is this search path in “first party” code? i.e., The end user’s project code.
Sourcepub fn is_site_packages(&self) -> bool
pub fn is_site_packages(&self) -> bool
Is the module in a site-packages directory?
Sourcepub fn describe_kind(&self) -> &'static str
pub fn describe_kind(&self) -> &'static str
Returns a string suitable for describing what kind of search path this is in user-facing diagnostics.
Trait Implementations§
Source§impl Clone for SearchPath
impl Clone for SearchPath
Source§fn clone(&self) -> SearchPath
fn clone(&self) -> SearchPath
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SearchPath
impl Debug for SearchPath
Source§impl Display for SearchPath
impl Display for SearchPath
impl Eq for SearchPath
Source§impl GetSize for SearchPath
impl GetSize for SearchPath
Source§fn get_heap_size(&self) -> usize
fn get_heap_size(&self) -> usize
Determines how many bytes this object occupies inside the heap. Read more
Source§fn get_heap_size_with_tracker<TRACKER: GetSizeTracker>(
&self,
tracker: TRACKER,
) -> (usize, TRACKER)
fn get_heap_size_with_tracker<TRACKER: GetSizeTracker>( &self, tracker: TRACKER, ) -> (usize, TRACKER)
Determines how many bytes this object occupies inside the heap while using a
tracker. Read moreSource§fn get_stack_size() -> usize
fn get_stack_size() -> usize
Determines how may bytes this object occupies inside the stack. Read more
Source§fn get_size_with_tracker<T>(&self, tracker: T) -> (usize, T)where
T: GetSizeTracker,
fn get_size_with_tracker<T>(&self, tracker: T) -> (usize, T)where
T: GetSizeTracker,
Determines the total size of the object while using a
tracker. Read moreSource§impl Hash for SearchPath
impl Hash for SearchPath
Source§impl PartialEq for SearchPath
impl PartialEq for SearchPath
Source§impl PartialEq<SearchPath> for SystemPath
impl PartialEq<SearchPath> for SystemPath
Source§impl PartialEq<SearchPath> for SystemPathBuf
impl PartialEq<SearchPath> for SystemPathBuf
Source§impl PartialEq<SearchPath> for VendoredPath
impl PartialEq<SearchPath> for VendoredPath
Source§impl PartialEq<SearchPath> for VendoredPathBuf
impl PartialEq<SearchPath> for VendoredPathBuf
Source§impl PartialEq<SystemPath> for SearchPath
impl PartialEq<SystemPath> for SearchPath
Source§impl PartialEq<SystemPathBuf> for SearchPath
impl PartialEq<SystemPathBuf> for SearchPath
Source§impl PartialEq<VendoredPath> for SearchPath
impl PartialEq<VendoredPath> for SearchPath
Source§impl PartialEq<VendoredPathBuf> for SearchPath
impl PartialEq<VendoredPathBuf> for SearchPath
impl StructuralPartialEq for SearchPath
Auto Trait Implementations§
impl Freeze for SearchPath
impl RefUnwindSafe for SearchPath
impl Send for SearchPath
impl Sync for SearchPath
impl Unpin for SearchPath
impl UnsafeUnpin for SearchPath
impl UnwindSafe for SearchPath
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> HashEqLike<&T> for T
impl<T> HashEqLike<&T> for T
Source§impl<T> HashEqLike<Cow<'_, T>> for T
impl<T> HashEqLike<Cow<'_, T>> for T
Source§impl<T> HashEqLike<T> for T
impl<T> HashEqLike<T> for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoDiagnosticMessage for Twhere
T: Display,
impl<T> IntoDiagnosticMessage for Twhere
T: Display,
fn into_diagnostic_message(self) -> DiagnosticMessage
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> ToCharString for Twhere
T: Display,
impl<T> ToCharString for Twhere
T: Display,
Source§fn try_to_char_string(&self) -> Result<CharString, ToCharStringError>
fn try_to_char_string(&self) -> Result<CharString, ToCharStringError>
Attempts to convert the value to a
CharString. Read moreSource§fn to_char_string(&self) -> CharString
fn to_char_string(&self) -> CharString
Converts the value to a
CharString. Read moreSource§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
Fallible version of
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a
CompactString. Read more