Skip to content

Commit

Permalink
refactor: check for capitalization for specs argument
Browse files Browse the repository at this point in the history
  • Loading branch information
orhun committed Feb 22, 2024
1 parent 2f0fe4e commit 74a5707
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 59 deletions.
22 changes: 0 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

84 changes: 64 additions & 20 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,19 @@ readme = "README.md"

[features]
default = ["native-tls"]
native-tls = ["reqwest/native-tls", "rattler_repodata_gateway/native-tls", "rattler/native-tls", "rip/native-tls"]
rustls-tls = ["reqwest/rustls-tls", "reqwest/rustls-tls-native-roots", "rattler_repodata_gateway/rustls-tls", "rattler/rustls-tls", "rip/rustls-tls"]
native-tls = [
"reqwest/native-tls",
"rattler_repodata_gateway/native-tls",
"rattler/native-tls",
"rip/native-tls",
]
rustls-tls = [
"reqwest/rustls-tls",
"reqwest/rustls-tls-native-roots",
"rattler_repodata_gateway/rustls-tls",
"rattler/rustls-tls",
"rip/rustls-tls",
]
slow_integration_tests = []

[dependencies]
Expand All @@ -21,7 +32,15 @@ async-once-cell = "0.5.3"
async-recursion = "1.0.5"
async-scoped = { version = "0.8.0", features = ["use-tokio"] }
chrono = "0.4.33"
clap = { version = "4.5.0", default-features = false, features = ["derive", "usage", "wrap_help", "std", "color", "error-context", "env"] }
clap = { version = "4.5.0", default-features = false, features = [
"derive",
"usage",
"wrap_help",
"std",
"color",
"error-context",
"env",
] }
clap-verbosity-flag = "2.1.2"
clap_complete = "4.5.0"
console = { version = "0.15.8", features = ["windows-console-colors"] }
Expand All @@ -39,7 +58,14 @@ insta = { version = "1.34.0", features = ["yaml"] }
is_executable = "1.0.1"
itertools = "0.12.1"
lazy_static = "1.4.0"
miette = { version = "7.0.0", features = ["fancy", "supports-color", "supports-hyperlinks", "supports-unicode", "terminal_size", "textwrap"] }
miette = { version = "7.0.0", features = [
"fancy",
"supports-color",
"supports-hyperlinks",
"supports-unicode",
"terminal_size",
"textwrap",
] }
minijinja = { version = "1.0.12", features = ["builtins"] }
once_cell = "1.19.0"
pep440_rs = "0.4.0"
Expand All @@ -49,9 +75,15 @@ rattler_conda_types = { version = "0.18.0", default-features = false }
rattler_digest = { version = "0.18.0", default-features = false }
rattler_lock = { version = "0.18.0", default-features = false }
rattler_networking = { version = "0.18.0", default-features = false }
rattler_repodata_gateway = { version = "0.18.0", default-features = false, features = ["sparse"] }
rattler_shell = { version = "0.18.0", default-features = false, features = ["sysinfo"] }
rattler_solve = { version = "0.18.0", default-features = false, features = ["resolvo"] }
rattler_repodata_gateway = { version = "0.18.0", default-features = false, features = [
"sparse",
] }
rattler_shell = { version = "0.18.0", default-features = false, features = [
"sysinfo",
] }
rattler_solve = { version = "0.18.0", default-features = false, features = [
"resolvo",
] }
rattler_virtual_packages = { version = "0.18.0", default-features = false }
regex = "1.10.3"
reqwest = { version = "0.11.24", default-features = false }
Expand All @@ -71,16 +103,28 @@ tabwriter = { version = "1.4.0", features = ["ansi_formatting"] }
tar = "0.4.40"
tempfile = "3.10.0"
thiserror = "1.0.56"
tokio = { version = "1.36.0", features = ["macros", "rt-multi-thread", "signal"] }
tokio = { version = "1.36.0", features = [
"macros",
"rt-multi-thread",
"signal",
] }
tokio-util = "0.7.10"
toml_edit = { version = "0.21.1", features = ["serde"] }
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
url = "2.5.0"
zip = { version = "0.6.6", default-features = false, features = ["deflate", "time"] }
zip = { version = "0.6.6", default-features = false, features = [
"deflate",
"time",
] }

[target.'cfg(unix)'.dependencies]
nix = { version = "0.27.1", default-features = false, features = ["fs", "signal", "term", "poll"] }
nix = { version = "0.27.1", default-features = false, features = [
"fs",
"signal",
"term",
"poll",
] }
libc = { version = "0.2.153", default-features = false }
signal-hook = "0.3.17"

Expand All @@ -106,13 +150,13 @@ toml = "0.8.10"
#resolvo = { git = "https://github.com/mamba-org/resolvo.git", branch = "main" }
#deno_task_shell = { path = "../deno_task_shell" }

#rattler = { path = "../rattler/crates/rattler" }
#rattler_conda_types = { path = "../rattler/crates/rattler_conda_types" }
#rattler_digest = { path = "../rattler/crates/rattler_digest" }
#rattler_networking = { path = "../rattler/crates/rattler_networking" }
#rattler_repodata_gateway = { path = "../rattler/crates/rattler_repodata_gateway" }
#rattler_shell = { path = "../rattler/crates/rattler_shell" }
#rattler_solve = { path = "../rattler/crates/rattler_solve" }
#rattler_virtual_packages = { path = "../rattler/crates/rattler_virtual_packages" }
#rattler_lock = { path = "../rattler/crates/rattler_lock" }
#rip = { package = "rattler_installs_packages", path = "../rip" }
rattler = { path = "../rattler/crates/rattler" }
rattler_conda_types = { path = "../rattler/crates/rattler_conda_types" }
rattler_digest = { path = "../rattler/crates/rattler_digest" }
rattler_networking = { path = "../rattler/crates/rattler_networking" }
rattler_repodata_gateway = { path = "../rattler/crates/rattler_repodata_gateway" }
rattler_shell = { path = "../rattler/crates/rattler_shell" }
rattler_solve = { path = "../rattler/crates/rattler_solve" }
rattler_virtual_packages = { path = "../rattler/crates/rattler_virtual_packages" }
rattler_lock = { path = "../rattler/crates/rattler_lock" }
# rip = { package = "rattler_installs_packages", path = "../rip" }
17 changes: 16 additions & 1 deletion src/cli/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub struct Args {
/// - `pixi add --pypi boto3`
/// - `pixi add --pypi "boto3==version"
///
#[arg(required = true)]
#[arg(required = true, value_parser = Args::parse_specs)]
pub specs: Vec<String>,

/// The path to 'pixi.toml'
Expand Down Expand Up @@ -88,6 +88,21 @@ pub struct Args {
pub platform: Vec<Platform>,
}

impl Args {
/// Custom string parser for the dependencies.
///
/// Disallows strings with non-lowercase characters.
fn parse_specs(specs: &str) -> Result<String, String> {
if specs.chars().any(|v| !v.is_lowercase()) {
Err(String::from(
"please avoid using capitalized dependency names",
))
} else {
Ok(specs.to_string())
}
}
}

impl DependencyType {
pub fn from_args(args: &Args) -> Self {
if args.pypi {
Expand Down
16 changes: 0 additions & 16 deletions src/project/manifest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,14 +355,6 @@ impl Manifest {
miette::bail!("pixi does not support wildcard dependencies")
};

// Check for duplicates.
if dependency_table.contains_key(name.as_source()) {
return Err(miette::miette!(
"{} is already added.",
console::style(name.as_normalized()).bold(),
));
}

// Store (or replace) in the document
dependency_table.insert(name.as_source(), Item::Value(spec.to_string().into()));

Expand Down Expand Up @@ -392,14 +384,6 @@ impl Manifest {
consts::PYPI_DEPENDENCIES,
)?;

// Check for duplicates.
if dependency_table.contains_key(name.as_str()) {
return Err(miette::miette!(
"{} is already added.",
console::style(name.as_source_str()).bold(),
));
}

// Add the pypi dependency to the table
dependency_table.insert(name.as_str(), (*requirement).clone().into());

Expand Down

0 comments on commit 74a5707

Please sign in to comment.