diff --git a/Cargo.lock b/Cargo.lock index 148e4dd..a1aec17 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -46,7 +46,7 @@ dependencies = [ [[package]] name = "anysnake2" -version = "1.9.2" +version = "1.10.0" dependencies = [ "anyhow", "base64", diff --git a/Cargo.toml b/Cargo.toml index c9b6681..89b84ee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "anysnake2" -version = "1.9.2" +version = "1.10.0" authors = ["Florian Finkernagel "] edition = "2021" diff --git a/examples/just_python/anysnake2.toml b/examples/just_python/anysnake2.toml index db4ca3a..c14572b 100644 --- a/examples/just_python/anysnake2.toml +++ b/examples/just_python/anysnake2.toml @@ -4,17 +4,21 @@ rev = "dev" [outside_nixpkgs] -rev = "21.05" # the nixpgks version or github hash +rev = "22.05" # the nixpgks version or github hash [nixpkgs] # the nixpkgs used inside the container -rev = "21.05" # the nixpgks version or github hash +rev = "22.05" # the nixpgks version or github hash packages = ["which"] [python] # python section is optional -version="3.8" # does not go down to 3.8.x. That's implicit in the nixpkgs (for now) -ecosystem_date="2022-02-16" # you get whatever packages the solver would have produced on that day +version="3.10" # does not go down to 3.8.x. That's implicit in the nixpkgs (for now) +ecosystem_date="2022-11-23" # you get whatever packages the solver would have produced on that day + +additional_mkpython_arguments = """ +providers. platformdirs="nixpkgs"; +""" # must be verbatim nix code [clones.code] # example-cli-python="git+https://github.com/ojixzzz/example-cli-python" @@ -23,9 +27,13 @@ example-cli-python="file://./example-cli-python/" [python.packages] # you can use standard python requirements.txt version specification syntax # i.e. version specifiers from https://www.python.org/dev/peps/pep-0440/#id53 -pandas="1.2" +pandas="1.5.1" # you can refer to the repos you cloned example-cli-python="editable/code" +black="" +tomli=">1.2" + + # and you can fetch from github, git and mercurial (any nix fetcher actually, see # https://nixos.org/manual/nixpkgs/stable/#chap-pkgs-fetchers) diff --git a/examples/no_anysnake2_toml/no anysnake test folder b/examples/no_anysnake2_toml/no anysnake test folder new file mode 100644 index 0000000..e69de29 diff --git a/src/config.rs b/src/config.rs index 340a7fd..564b675 100644 --- a/src/config.rs +++ b/src/config.rs @@ -235,6 +235,7 @@ pub struct Python { pub ecosystem_date: String, #[serde(deserialize_with = "de_python_package_definition")] pub packages: HashMap, + pub additional_mkpython_arguments: Option, } impl Python { diff --git a/src/flake_template.nix b/src/flake_template.nix index 0553d98..2bbfbf9 100644 --- a/src/flake_template.nix +++ b/src/flake_template.nix @@ -177,6 +177,7 @@ substituteInPlace 'requirements.txt' --replace 'pytest' "" ''; %PYTHON_BUILD_PACKAGES% + %PYTHON_ADDITIONAL_MKPYTHON_ARGUMENTS% }; }; in rec { diff --git a/src/flake_writer.rs b/src/flake_writer.rs index ddb7beb..dde12bf 100644 --- a/src/flake_writer.rs +++ b/src/flake_writer.rs @@ -144,6 +144,9 @@ pub fn write_flake( &mut flakes_used_for_python_packages, )?; + let out_additional_mkpython_arguments = + &python.additional_mkpython_arguments.as_deref().unwrap_or(""); + let ecosystem_date = python .parsed_ecosystem_date() .context("Failed to parse python.ecosystem-date")?; @@ -170,6 +173,10 @@ pub fn write_flake( //.replace("%PYTHON_MAJOR_MINOR%", &python_major_minor) .replace("%PYTHON_PACKAGES%", &out_python_packages) .replace("%PYTHON_BUILD_PACKAGES%", &out_python_build_packages) + .replace( + "%PYTHON_ADDITIONAL_MKPYTHON_ARGUMENTS%", + &&out_additional_mkpython_arguments, + ) .replace("%PYTHON_MAJOR_DOT_MINOR%", &python_major_dot_minor) .replace("%PYPI_DEPS_DB_REV%", &pypi_debs_db_rev) .replace( @@ -190,7 +197,8 @@ pub fn write_flake( None => flake_contents .replace("\"%MACHNIX%\"", "null") .replace("%DEVELOP_PYTHON_PATH%", "") - .replace("%PYTHON_BUILD_PACKAGES%", ""), + .replace("%PYTHON_BUILD_PACKAGES%", "") + .replace("%PYTHON_ADDITIONAL_MKPYTHON_ARGUMENTS%", ""), }; flake_contents = match &parsed_config.flakes { @@ -460,7 +468,6 @@ fn format_input_defs(inputs: &[InputFlake]) -> String { let mut iter = fl.url.rsplitn(2, "/"); iter.next(); // eat the branch iter.collect() - } else { fl.url.to_string() }; diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 9b1778f..42ceb05 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -21,9 +21,9 @@ fn run_test(cwd: &str, args: &[&str]) -> (i32, String, String) { let p = std::env::current_exe() .expect("No current exe?") .parent() - .unwrap() + .expect("no parent") .parent() - .unwrap() + .expect("no parent parent") .join("anysnake2"); println!("Current exe {:?}", p); let mut full_args = vec!["--no-version-switch"]; @@ -90,7 +90,7 @@ fn test_just_python() { "examples/just_python", &["run", "--", "python", "--version"], ); - assert!(stdout.contains("3.8.9")); + assert!(stdout.contains("3.10.4")); let td_path = td.path().to_string_lossy(); @@ -105,7 +105,7 @@ fn test_just_python() { ], ); - assert!(stdout.contains("1.2.0")); + assert!(stdout.contains("1.5.1")); let (_code, stdout, _stderr) = run_test(&td_path, &["run", "--", "hello"]); dbg!(&stdout); @@ -293,7 +293,7 @@ fn test_python_pip_reinstall_if_venv_changes() { run_test_tempdir("examples/just_python", &["run", "--", "cat"]); println!("first: {}", stdout); let first = - ex::fs::read_to_string(td.path().join(".anysnake2_flake/venv/3.8/bin/hello")).unwrap(); + ex::fs::read_to_string(td.path().join(".anysnake2_flake/venv/3.10/bin/hello")).unwrap(); let toml_path = td.path().join("anysnake2.toml"); let mut toml = ex::fs::read_to_string(&toml_path).unwrap(); @@ -305,7 +305,7 @@ fn test_python_pip_reinstall_if_venv_changes() { let (_code, stdout, _stderr) = run_test(&td_path, &["run", "--", "which", "hello"]); println!("second: {}", stdout); let second = - ex::fs::read_to_string(td.path().join(".anysnake2_flake/venv/3.8/bin/hello")).unwrap(); + ex::fs::read_to_string(td.path().join(".anysnake2_flake/venv/3.10/bin/hello")).unwrap(); let lines_first: Vec<_> = first.split("\n").collect(); let lines_second: Vec<_> = second.split("\n").collect();