-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
279 additions
and
11 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
use std::path::PathBuf; | ||
|
||
use crate::{Config, HuakResult}; | ||
|
||
pub fn add_to_toolchain(tool: String, channel: Option<String>, config: &Config) -> HuakResult<()> { | ||
todo!() | ||
} | ||
|
||
pub fn display_toolchain_info(channel: Option<String>, config: &Config) -> HuakResult<()> { | ||
todo!() | ||
} | ||
|
||
pub fn install_toolchain( | ||
channel: Option<String>, | ||
target: Option<PathBuf>, | ||
config: &Config, | ||
) -> HuakResult<()> { | ||
todo!() | ||
} | ||
|
||
pub fn list_toolchains(config: &Config) -> HuakResult<()> { | ||
todo!() | ||
} | ||
|
||
pub fn remove_from_toolchain( | ||
tool: String, | ||
channel: Option<String>, | ||
config: &Config, | ||
) -> HuakResult<()> { | ||
todo!() | ||
} | ||
|
||
pub fn run_from_toolchain( | ||
tool: String, | ||
channel: Option<String>, | ||
config: &Config, | ||
) -> HuakResult<()> { | ||
todo!() | ||
} | ||
|
||
pub fn uninstall_toolchain(channel: Option<String>, config: &Config) -> HuakResult<()> { | ||
todo!() | ||
} | ||
|
||
pub fn update_toolchain( | ||
tool: Option<String>, | ||
channel: Option<String>, | ||
config: &Config, | ||
) -> HuakResult<()> { | ||
todo!() | ||
} | ||
|
||
pub fn use_toolchain(channel: String, config: &Config) -> HuakResult<()> { | ||
todo!() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[package] | ||
name = "huak-toolchain" | ||
version = "0.0.0" | ||
edition.workspace = true | ||
rust-version.workspace = true | ||
authors.workspace = true | ||
license.workspace = true | ||
|
||
[dependencies] | ||
huak-python-manager = { path = "../huak-python-manager" } | ||
|
||
[lints] | ||
workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Toolchain | ||
|
||
The toolchain implementation for Huak. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
//! # The toolchain implementation for Huak. | ||
//! | ||
//! ## Toolchain | ||
//! | ||
//! - Channel | ||
//! - Path | ||
//! - Tools | ||
//! | ||
//! ## Channels | ||
//! | ||
//! Channels are used to identify toolchains. | ||
//! | ||
//! - major.minor of a Python interpreter | ||
//! - major.minor.patch of a Python interpreter | ||
//! - Complete Python interpreter identifying chains (for example, 'cpython-3.12.0-apple-aarch64-pgo+lto') | ||
//! - Etc. | ||
//! | ||
//! ## Path | ||
//! | ||
//! A unique toolchain is identifiable by the path it's installed to. A directory contains the entire toolchain. | ||
//! | ||
//! ## Tools | ||
//! | ||
//! Toolchains are composed of installed tools. The default tools installed are: | ||
//! | ||
//! - python (and Python installation management system) | ||
//! - ruff | ||
//! - mypy (TODO(cnpryer): May be replaced) | ||
//! - pytest (TODO(cnpryer): May be replaced) | ||
//! | ||
//! ## Other | ||
//! | ||
//! Tools are centralized around a common Python inerpreter installed to the toolchain. The toolchain utilizes | ||
//! a virtual environment shared by the tools in the toolchain. A bin directory contains the symlinked tools. | ||
//! If a platform doesn't support symlinks hardlinks are used. | ||
//! | ||
//! ## `huak-toolchain` | ||
//! | ||
//! This crate implements Huak's toolchain via `Channel`, `Toolchain`, and `Tool`. | ||
use std::path::PathBuf; | ||
|
||
const DEFAULT_TOOLS: [&str; 4] = ["python", "ruff", "mypy", "pytest"]; | ||
|
||
pub struct Toolchain { | ||
inner: ToolchainInner, | ||
} | ||
|
||
impl Toolchain { | ||
pub fn new(channel: Channel, path: PathBuf) -> Self { | ||
Toolchain { | ||
inner: ToolchainInner { | ||
channel, | ||
path, | ||
tools: Tools::new(), | ||
}, | ||
} | ||
} | ||
|
||
pub fn channel(&self) -> &Channel { | ||
&self.inner.channel | ||
} | ||
|
||
pub fn path(&self) -> &PathBuf { | ||
&self.inner.path | ||
} | ||
} | ||
|
||
impl From<PathBuf> for Toolchain { | ||
fn from(value: PathBuf) -> Self { | ||
todo!() | ||
} | ||
} | ||
|
||
struct ToolchainInner { | ||
channel: Channel, | ||
path: PathBuf, | ||
tools: Tools, | ||
} | ||
|
||
pub enum Channel { | ||
Latest, // TODO(cnpryer) | ||
Version(Version), | ||
IdentifierChain(String), // TODO(cnpryer): `Parts` or similar | ||
} | ||
|
||
struct Tools { | ||
tools: Vec<Tool>, | ||
} | ||
|
||
impl Tools { | ||
fn new() -> Self { | ||
Tools { | ||
tools: Vec::with_capacity(DEFAULT_TOOLS.len()), | ||
} | ||
} | ||
|
||
fn add(&mut self, tool: Tool) { | ||
todo!() | ||
} | ||
|
||
fn remove(&mut self, tool: Tool) { | ||
todo!() | ||
} | ||
} | ||
|
||
pub struct Tool { | ||
name: String, | ||
version: Version, // TODO(cnpryer): Use PEP440-compatible struct. | ||
} | ||
|
||
pub struct Version { | ||
major: Option<u8>, | ||
minor: Option<u8>, | ||
patch: Option<u8>, | ||
} |