pub struct Workspace { /* private fields */ }Expand description
A workspace, consisting of a root directory and members. See ProjectWorkspace.
Implementations§
Source§impl Workspace
impl Workspace
Sourcepub async fn discover(
path: &Path,
options: &DiscoveryOptions,
cache: &WorkspaceCache,
) -> Result<Self, WorkspaceError>
pub async fn discover( path: &Path, options: &DiscoveryOptions, cache: &WorkspaceCache, ) -> Result<Self, WorkspaceError>
Find the workspace containing the given path.
Unlike the ProjectWorkspace discovery, this does not require a current project. It also
always uses absolute path, i.e., this method only supports discovering the main workspace.
Steps of workspace discovery: Start by looking at the closest pyproject.toml:
- If it’s an explicit workspace root: Collect workspace from this root, we’re done.
- If it’s also not a project: Error, must be either a workspace root or a project.
- Otherwise, try to find an explicit workspace root above:
- If an explicit workspace root exists: Collect workspace from this root, we’re done.
- If there is no explicit workspace: We have a single project workspace, we’re done.
Note that there are two kinds of workspace roots: projects, and (legacy) non-project roots.
The non-project roots lack a [project] table, and so are not themselves projects, as in:
[tool.uv.workspace]
members = ["packages/*"]
[tool.uv]
dev-dependencies = ["ruff"]Sourcepub fn with_current_project(
self,
package_name: PackageName,
) -> Option<ProjectWorkspace>
pub fn with_current_project( self, package_name: PackageName, ) -> Option<ProjectWorkspace>
Set the current project to the given workspace member.
Returns None if the package is not part of the workspace.
Sourcepub fn with_pyproject_toml(
self,
package_name: &PackageName,
pyproject_toml: PyProjectToml,
) -> Result<Option<Self>, WorkspaceError>
pub fn with_pyproject_toml( self, package_name: &PackageName, pyproject_toml: PyProjectToml, ) -> Result<Option<Self>, WorkspaceError>
Set the ProjectWorkspace for a given workspace member.
Assumes that the project name is unchanged in the updated PyProjectToml.
Sourcepub fn is_non_project(&self) -> bool
pub fn is_non_project(&self) -> bool
Returns true if the workspace has a (legacy) non-project root.
Sourcepub fn members_requirements(&self) -> impl Iterator<Item = Requirement> + '_
pub fn members_requirements(&self) -> impl Iterator<Item = Requirement> + '_
Returns the set of all workspace members.
Sourcepub fn required_members(&self) -> &BTreeMap<PackageName, Editability>
pub fn required_members(&self) -> &BTreeMap<PackageName, Editability>
The workspace members that are required my another member of the workspace.
Sourcepub fn is_required_member(&self, name: &PackageName) -> bool
pub fn is_required_member(&self, name: &PackageName) -> bool
Whether a given workspace member is required by another member.
Sourcepub fn group_requirements(&self) -> impl Iterator<Item = Requirement> + '_
pub fn group_requirements(&self) -> impl Iterator<Item = Requirement> + '_
Returns the set of all workspace member dependency groups.
Sourcepub fn environments(&self) -> Option<&SupportedEnvironments>
pub fn environments(&self) -> Option<&SupportedEnvironments>
Returns the set of supported environments for the workspace.
Sourcepub fn required_environments(&self) -> Option<&SupportedEnvironments>
pub fn required_environments(&self) -> Option<&SupportedEnvironments>
Returns the set of required platforms for the workspace.
Sourcepub fn requires_python(
&self,
groups: &DependencyGroupsWithDefaults,
) -> Result<RequiresPythonSources, DependencyGroupError>
pub fn requires_python( &self, groups: &DependencyGroupsWithDefaults, ) -> Result<RequiresPythonSources, DependencyGroupError>
Returns an iterator over the requires-python values for each member of the workspace.
Sourcepub fn requirements(&self) -> Vec<Requirement<VerbatimParsedUrl>>
pub fn requirements(&self) -> Vec<Requirement<VerbatimParsedUrl>>
Returns any requirements that are exclusive to the workspace root, i.e., not included in any of the workspace members.
For now, there are no such requirements.
Sourcepub fn workspace_dependency_groups(
&self,
) -> Result<BTreeMap<GroupName, FlatDependencyGroup>, DependencyGroupError>
pub fn workspace_dependency_groups( &self, ) -> Result<BTreeMap<GroupName, FlatDependencyGroup>, DependencyGroupError>
Returns any dependency groups that are exclusive to the workspace root, i.e., not included in any of the workspace members.
For workspaces with non-[project] roots, returns the dependency groups defined in the
corresponding pyproject.toml.
Otherwise, returns an empty list.
Sourcepub fn overrides(&self) -> Vec<Requirement<VerbatimParsedUrl>>
pub fn overrides(&self) -> Vec<Requirement<VerbatimParsedUrl>>
Returns the set of overrides for the workspace.
Sourcepub fn exclude_dependencies(&self) -> Vec<PackageName>
pub fn exclude_dependencies(&self) -> Vec<PackageName>
Returns the set of dependency exclusions for the workspace.
Sourcepub fn constraints(&self) -> Vec<Requirement<VerbatimParsedUrl>>
pub fn constraints(&self) -> Vec<Requirement<VerbatimParsedUrl>>
Returns the set of constraints for the workspace.
Sourcepub fn build_constraints(&self) -> Vec<Requirement<VerbatimParsedUrl>>
pub fn build_constraints(&self) -> Vec<Requirement<VerbatimParsedUrl>>
Returns the set of build constraints for the workspace.
Sourcepub fn install_path(&self) -> &PathBuf
pub fn install_path(&self) -> &PathBuf
The path to the workspace root, the directory containing the top level pyproject.toml with
the uv.tool.workspace, or the pyproject.toml in an implicit single workspace project.
Sourcepub fn venv(&self, active: Option<bool>) -> PathBuf
pub fn venv(&self, active: Option<bool>) -> PathBuf
The path to the workspace virtual environment.
Uses .venv in the install path directory by default.
If UV_PROJECT_ENVIRONMENT is set, it will take precedence. If a relative path is provided,
it is resolved relative to the install path.
If active is true, the VIRTUAL_ENV variable will be preferred. If it is false, any
warnings about mismatch between the active environment and the project environment will be
silenced.
Sourcepub fn packages(&self) -> &BTreeMap<PackageName, WorkspaceMember>
pub fn packages(&self) -> &BTreeMap<PackageName, WorkspaceMember>
The members of the workspace.
Sourcepub fn sources(&self) -> &BTreeMap<PackageName, Sources>
pub fn sources(&self) -> &BTreeMap<PackageName, Sources>
The sources table from the workspace pyproject.toml.
Sourcepub fn pyproject_toml(&self) -> &PyProjectToml
pub fn pyproject_toml(&self) -> &PyProjectToml
The pyproject.toml of the workspace.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Workspace
impl RefUnwindSafe for Workspace
impl Send for Workspace
impl Sync for Workspace
impl Unpin for Workspace
impl UnwindSafe for Workspace
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)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> 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>
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>
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> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more