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

Launch the manifest-specified Julia version #1059

Closed
wants to merge 7 commits into from
Closed
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
11 changes: 11 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ is-terminal = "0.4"
path-absolutize = "3.1.0"
human-sort = "0.2.2"
regex = "1.10"
toml = "0.8.19"

[target.'cfg(windows)'.dependencies]
windows = { version = "0.58.0", features = ["Win32_Foundation", "Win32_UI_Shell", "Win32_Security", "Win32_System_JobObjects", "Win32_System_Console", "Win32_System_Threading", "Services_Store", "Foundation", "Foundation_Collections", "Web_Http", "Web_Http_Headers", "Storage_Streams", "Management_Deployment"] }
Expand Down
387 changes: 282 additions & 105 deletions src/bin/julialauncher.rs

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/bin/juliaup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use clap::Parser;
use juliaup::cli::{ConfigSubCmd, Juliaup, OverrideSubCmd, SelfSubCmd};
use juliaup::command_api::run_command_api;
use juliaup::command_completions::run_command_completions;
use juliaup::command_config_featuremanifestsupport::run_command_config_featuremanifestsupport;
#[cfg(not(windows))]
use juliaup::command_config_symlinks::run_command_config_symlinks;
use juliaup::command_config_versionsdbupdate::run_command_config_versionsdbupdate;
Expand Down Expand Up @@ -123,6 +124,9 @@ fn main() -> Result<()> {
ConfigSubCmd::VersionsDbUpdateInterval { value } => {
run_command_config_versionsdbupdate(value, false, &paths)
}
ConfigSubCmd::FeatureManifestSupport { value } => {
run_command_config_featuremanifestsupport(value, false, &paths)
}
},
Juliaup::Api { command } => run_command_api(&command, &paths),
Juliaup::InitialSetupFromLauncher {} => run_command_initial_setup_from_launcher(&paths),
Expand Down
6 changes: 6 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,10 @@ pub enum ConfigSubCmd {
/// New value
value: Option<i64>,
},
/// Enable Julia version selection from manifests
#[clap(name = "featuremanifestsupport")]
FeatureManifestSupport {
/// New value
value: Option<bool>,
},
}
50 changes: 50 additions & 0 deletions src/command_config_featuremanifestsupport.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
use crate::config_file::{load_config_db, load_mut_config_db, save_config_db};
use anyhow::{Context, Result};

pub fn run_command_config_featuremanifestsupport(
value: Option<bool>,
quiet: bool,
paths: &crate::global_paths::GlobalPaths,
) -> Result<()> {
match value {
Some(value) => {
let mut config_file = load_mut_config_db(paths)
.with_context(|| "`config` command failed to load configuration data.")?;

let mut value_changed = false;

if value != config_file.data.settings.feature_manifest_support {
config_file.data.settings.feature_manifest_support = value;

value_changed = true;
}

save_config_db(&mut config_file)
.with_context(|| "Failed to save configuration file from `config` command.")?;

if !quiet {
if value_changed {
eprintln!("Property 'featuremanifestsupport' set to '{}'", value);
} else {
eprintln!(
"Property 'featuremanifestsupport' is already set to '{}'",
value
);
}
}
}
None => {
let config_file = load_config_db(paths, None)
.with_context(|| "`config` command failed to load configuration data.")?;

if !quiet {
eprintln!(
"Property 'featuremanifestsupport' set to '{}'",
config_file.data.settings.feature_manifest_support
);
}
}
};

Ok(())
}
9 changes: 9 additions & 0 deletions src/config_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,20 @@ pub struct JuliaupConfigSettings {
skip_serializing_if = "is_default_versionsdb_update_interval"
)]
pub versionsdb_update_interval: i64,
#[serde(
rename = "FeatureManifestSupport",
default,
skip_serializing_if = "is_default"
)]
pub feature_manifest_support: bool,
}

impl Default for JuliaupConfigSettings {
fn default() -> Self {
JuliaupConfigSettings {
create_channel_symlinks: false,
versionsdb_update_interval: default_versionsdb_update_interval(),
feature_manifest_support: false,
}
}
}
Expand Down Expand Up @@ -203,6 +210,7 @@ pub fn load_config_db(
settings: JuliaupConfigSettings {
create_channel_symlinks: false,
versionsdb_update_interval: default_versionsdb_update_interval(),
feature_manifest_support: false,
},
last_version_db_update: None,
},
Expand Down Expand Up @@ -301,6 +309,7 @@ pub fn load_mut_config_db(paths: &GlobalPaths) -> Result<JuliaupConfigFile> {
settings: JuliaupConfigSettings {
create_channel_symlinks: false,
versionsdb_update_interval: default_versionsdb_update_interval(),
feature_manifest_support: false,
},
last_version_db_update: None,
};
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub mod command_add;
pub mod command_api;
pub mod command_completions;
pub mod command_config_backgroundselfupdate;
pub mod command_config_featuremanifestsupport;
pub mod command_config_modifypath;
pub mod command_config_startupselfupdate;
pub mod command_config_symlinks;
Expand Down
201 changes: 201 additions & 0 deletions tests/channel_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,204 @@ fn channel_selection() {
.failure()
.stderr("ERROR: `pr1` is not installed. Please run `juliaup add pr1` to install pull request channel if available.\n");
}

#[test]
fn manifest_version_selection() {
let depot_dir = assert_fs::TempDir::new().unwrap();

Command::cargo_bin("juliaup")
.unwrap()
.arg("add")
.arg("1.6.2")
.env("JULIA_DEPOT_PATH", depot_dir.path())
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
.assert()
.success()
.stdout("");

Command::cargo_bin("juliaup")
.unwrap()
.arg("add")
.arg("1.10.1")
.env("JULIA_DEPOT_PATH", depot_dir.path())
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
.assert()
.success()
.stdout("");

Command::cargo_bin("juliaup")
.unwrap()
.arg("add")
.arg("1.11.1")
.env("JULIA_DEPOT_PATH", depot_dir.path())
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
.assert()
.success()
.stdout("");

Command::cargo_bin("juliaup")
.unwrap()
.arg("default")
.arg("1.11.1")
.env("JULIA_DEPOT_PATH", depot_dir.path())
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
.assert()
.success()
.stdout("");

Command::cargo_bin("julia")
.unwrap()
.arg("-e")
.arg("print(VERSION)")
.env("JULIA_DEPOT_PATH", depot_dir.path())
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
.assert()
.success()
.stdout("1.11.1");

let proj1_dir = assert_fs::TempDir::new().unwrap();

// We are adding and then removing a package here to force generation of an actual Project.toml
Command::cargo_bin("julia")
.unwrap()
.arg("+1.10.1")
.arg("-e")
.arg("using Pkg; Pkg.activate(\".\"); Pkg.add(\"StringBuilders\"); Pkg.rm(\"StringBuilders\"); print(VERSION)")
.env("JULIA_DEPOT_PATH", depot_dir.path())
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
.current_dir(&proj1_dir)
.assert()
.success()
.stdout("1.10.1");

// First we try this with the feature disabled
Command::cargo_bin("julia")
.unwrap()
.arg("--project=.")
.arg("-e")
.arg("print(VERSION)")
.env("JULIA_DEPOT_PATH", depot_dir.path())
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
.current_dir(&proj1_dir)
.assert()
.success()
.stdout("1.11.1");

// Now we enable the feature
Command::cargo_bin("juliaup")
.unwrap()
.arg("config")
.arg("featuremanifestsupport")
.arg("true")
.env("JULIA_DEPOT_PATH", depot_dir.path())
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
.assert()
.success()
.stdout("");

Command::cargo_bin("julia")
.unwrap()
.arg("--project=.")
.arg("-e")
.arg("print(VERSION)")
.env("JULIA_DEPOT_PATH", depot_dir.path())
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
.current_dir(&proj1_dir)
.assert()
.success()
.stdout("1.10.1");

// TODO This currently fails, but it shouldn't
Command::cargo_bin("julia")
.unwrap()
.arg("--project")
.arg("-e")
.arg("print(VERSION)")
.env("JULIA_DEPOT_PATH", depot_dir.path())
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
.current_dir(&proj1_dir)
.assert()
.success()
.stdout("1.10.1");

Command::cargo_bin("julia")
.unwrap()
.arg("--project=@.")
.arg("-e")
.arg("print(VERSION)")
.env("JULIA_DEPOT_PATH", depot_dir.path())
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
.current_dir(&proj1_dir)
.assert()
.success()
.stdout("1.10.1");

let sub_dir1 = &proj1_dir.path().join("subdir1");
std::fs::create_dir(&sub_dir1).unwrap();

Command::cargo_bin("julia")
.unwrap()
.arg("--project=.")
.arg("-e")
.arg("print(VERSION)")
.env("JULIA_DEPOT_PATH", depot_dir.path())
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
.current_dir(&sub_dir1)
.assert()
.success()
.stdout("1.11.1");

// TODO This currently fails, but it shouldn't
Command::cargo_bin("julia")
.unwrap()
.arg("--project")
.arg("-e")
.arg("print(VERSION)")
.env("JULIA_DEPOT_PATH", depot_dir.path())
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
.current_dir(&sub_dir1)
.assert()
.success()
.stdout("1.10.1");

Command::cargo_bin("julia")
.unwrap()
.arg("--project=@.")
.arg("-e")
.arg("print(VERSION)")
.env("JULIA_DEPOT_PATH", depot_dir.path())
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
.current_dir(&sub_dir1)
.assert()
.success()
.stdout("1.10.1");

// Now we try with a Julia version that generates schema v1 manifests
let proj2_dir = assert_fs::TempDir::new().unwrap();

// We are adding and then removing a package here to force generation of an actual Project.toml
Command::cargo_bin("julia")
.unwrap()
.arg("+1.6.2")
.arg("-e")
.arg("using Pkg; Pkg.activate(\".\"); Pkg.add(\"StringBuilders\"); Pkg.rm(\"StringBuilders\"); print(VERSION)")
.env("JULIA_DEPOT_PATH", depot_dir.path())
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
.current_dir(&proj2_dir)
.assert()
.success()
.stdout("1.6.2");

// It shouldn't pick up the version from the manifest, as it isn't stored in the manifest
Command::cargo_bin("julia")
.unwrap()
.arg("--project=.")
.arg("-e")
.arg("print(VERSION)")
.env("JULIA_DEPOT_PATH", depot_dir.path())
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
.current_dir(&proj2_dir)
.assert()
.success()
.stdout("1.11.1");
}
Loading