Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: make it possible to deserialize virtual packages #198

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ Cargo.lock
*.pdb

**/.DS_Store

# rattler
.prefix
2 changes: 1 addition & 1 deletion crates/rattler_conda_types/src/version/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ mod parse;
/// this problem by appending an underscore to plain version numbers:
///
/// 1.0.1_ < 1.0.1a => True # ensure correct ordering for openssl
#[derive(Clone, Debug, Eq)]
#[derive(Clone, Debug, Eq, Deserialize)]
pub struct Version {
/// A normed copy of the original version string trimmed and converted to lower case.
/// Also dashes are replaced with underscores if the version string does not contain
Expand Down
1 change: 1 addition & 0 deletions crates/rattler_virtual_packages/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ once_cell = "1.17.0"
rattler_conda_types = { version = "0.2.0", path = "../rattler_conda_types" }
thiserror = "1.0.38"
tracing = "0.1.37"
serde = { version = "1.0.130", features = ["derive"] }

[target.'cfg(target_os="macos")'.dependencies]
plist = "1"
15 changes: 10 additions & 5 deletions crates/rattler_virtual_packages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ use std::str::FromStr;
use crate::osx::ParseOsxVersionError;
use libc::DetectLibCError;
use linux::ParseLinuxVersionError;
use serde::Deserialize;

/// An enum that represents all virtual package types provided by this library.
#[derive(Clone, Eq, PartialEq, Hash, Debug)]
Expand Down Expand Up @@ -153,9 +154,10 @@ fn try_detect_virtual_packages() -> Result<Vec<VirtualPackage>, DetectVirtualPac
}

/// Linux virtual package description
#[derive(Clone, Eq, PartialEq, Hash, Debug)]
#[derive(Clone, Eq, PartialEq, Hash, Debug, Deserialize)]
pub struct Linux {
/// The version of linux
/// #[serde(deserialize_with = "from_str")]
pub version: Version,
}

Expand Down Expand Up @@ -186,12 +188,13 @@ impl From<Linux> for VirtualPackage {
}

/// LibC virtual package description
#[derive(Clone, Eq, PartialEq, Hash, Debug)]
#[derive(Clone, Eq, PartialEq, Hash, Debug, Deserialize)]
pub struct LibC {
/// The family of LibC. This could be glibc for instance.
pub family: String,

/// The version of the libc distribution.
/// #[serde(deserialize_with = "from_str")]
pub version: Version,
}

Expand Down Expand Up @@ -222,9 +225,10 @@ impl From<LibC> for VirtualPackage {
}

/// Cuda virtual package description
#[derive(Clone, Eq, PartialEq, Hash, Debug)]
#[derive(Clone, Eq, PartialEq, Hash, Debug, Deserialize)]
pub struct Cuda {
/// The maximum supported Cuda version.
/// #[serde(deserialize_with = "from_str")]
pub version: Version,
}

Expand Down Expand Up @@ -252,7 +256,7 @@ impl From<Cuda> for VirtualPackage {
}

/// Archspec describes the CPU architecture
#[derive(Clone, Eq, PartialEq, Hash, Debug)]
#[derive(Clone, Eq, PartialEq, Hash, Debug, Deserialize)]
pub struct Archspec {
/// A specification of the architecture family. This could be `x86_64` but it could also include
/// the full CPU family.
Expand Down Expand Up @@ -306,9 +310,10 @@ impl From<Archspec> for VirtualPackage {
}

/// OSX virtual package description
#[derive(Clone, Eq, PartialEq, Hash, Debug)]
#[derive(Clone, Eq, PartialEq, Hash, Debug, Deserialize)]
pub struct Osx {
/// The OSX version
/// #[serde(deserialize_with = "from_str")]
pub version: Version,
}

Expand Down