diff --git a/README.md b/README.md index 55774a08..70dfc0c6 100644 --- a/README.md +++ b/README.md @@ -216,12 +216,12 @@ requirements: host: - pip - poetry-core >=1.0.0 - - python 3.10 + - python 3.10.* run: # sync with normalized deps from poetry-generated setup.py - markdown-it-py >=2.2.0 - pygments >=2.13.0,<3.0.0 - - python 3.10 + - python 3.10.* - typing_extensions >=4.0.0,<5.0.0 tests: diff --git a/docs/index.md b/docs/index.md index daaf76eb..aa0f8764 100644 --- a/docs/index.md +++ b/docs/index.md @@ -238,12 +238,12 @@ requirements: host: - pip - poetry-core >=1.0.0 - - python 3.10 + - python 3.10.* run: # sync with normalized deps from poetry-generated setup.py - markdown-it-py >=2.2.0 - pygments >=2.13.0,<3.0.0 - - python 3.10 + - python 3.10.* - typing_extensions >=4.0.0,<5.0.0 tests: diff --git a/examples/rich/recipe.yaml b/examples/rich/recipe.yaml index 1832f046..533508d5 100644 --- a/examples/rich/recipe.yaml +++ b/examples/rich/recipe.yaml @@ -23,12 +23,12 @@ requirements: host: - pip - poetry-core >=1.0.0 - - python 3.10 + - python 3.10.* run: # sync with normalized deps from poetry-generated setup.py - markdown-it-py >=2.2.0 - pygments >=2.13.0,<3.0.0 - - python 3.10 + - python 3.10.* - typing_extensions >=4.0.0,<5.0.0 tests: diff --git a/src/build.rs b/src/build.rs index 66293a26..d28a3c8b 100644 --- a/src/build.rs +++ b/src/build.rs @@ -3,7 +3,7 @@ use std::{path::PathBuf, vec}; use miette::{Context, IntoDiagnostic}; -use rattler_conda_types::{Channel, MatchSpec, ParseStrictness}; +use rattler_conda_types::{Channel, MatchSpec}; use crate::{ metadata::{build_reindexed_channels, Output}, @@ -39,10 +39,8 @@ pub async fn skip_existing( let match_specs = outputs .iter() - .map(|o| { - MatchSpec::from_str(o.name().as_normalized(), ParseStrictness::Strict).into_diagnostic() - }) - .collect::, _>>()?; + .map(|o| o.name().clone().into()) + .collect::>(); let channels = if only_local { vec![ diff --git a/src/package_test/run_test.rs b/src/package_test/run_test.rs index e37df3e8..52a9ff49 100644 --- a/src/package_test/run_test.rs +++ b/src/package_test/run_test.rs @@ -510,9 +510,9 @@ impl PythonTest { // Add `pip` if pip_check is set to true if self.pip_check { - dependencies_map.iter_mut().for_each(|(_, v)| { - v.push(MatchSpec::from_str("pip", ParseStrictness::Strict).unwrap()) - }); + dependencies_map + .iter_mut() + .for_each(|(_, v)| v.push("pip".parse().unwrap())); } // Run tests for each python version @@ -613,10 +613,7 @@ impl PerlTest { ParseStrictness::Lenient, )?; - let dependencies = vec![ - MatchSpec::from_str("perl", ParseStrictness::Strict).unwrap(), - match_spec, - ]; + let dependencies = vec!["perl".parse().unwrap(), match_spec]; create_environment( "test", diff --git a/src/recipe/parser/requirements.rs b/src/recipe/parser/requirements.rs index 16e9cd8b..7e76131a 100644 --- a/src/recipe/parser/requirements.rs +++ b/src/recipe/parser/requirements.rs @@ -366,6 +366,32 @@ impl TryConvertNode for RenderedNode { impl TryConvertNode for RenderedScalarNode { fn try_convert(&self, _name: &str) -> Result> { + let string = self.as_str(); + + // if we have a matchspec that is only numbers, and ., we complain and ask the user to add a + // `.*` or `==` in front of it. + let split_string = string.split_whitespace().collect::>(); + if split_string.len() >= 2 { + if split_string[1].chars().all(|c| c.is_numeric() || c == '.') { + let name = split_string[0]; + let version = split_string[1]; + let rest = split_string[2..].join(" "); + let rest = if rest.is_empty() { + "".to_string() + } else { + format!(" {}", rest) + }; + + return Err(vec![_partialerror!( + *self.span(), + ErrorKind::Other, + label = format!( + "This match spec is ambiguous. Do you mean `{name} =={version}{rest}` or `{name} {version}.*{rest}`?" + ) + )]); + } + } + MatchSpec::from_str(self.as_str(), ParseStrictness::Strict).map_err(|err| { let str = self.as_str(); vec![_partialerror!( diff --git a/src/render/run_exports.rs b/src/render/run_exports.rs index 3ad05d9e..5910dec3 100644 --- a/src/render/run_exports.rs +++ b/src/render/run_exports.rs @@ -45,7 +45,8 @@ impl IgnoreRunExports { let to_specs = |strings: &Vec| -> Result, ParseMatchSpecError> { strings .iter() - .map(|s| MatchSpec::from_str(s, ParseStrictness::Strict)) + // We have to parse these as lenient as they come from packages + .map(|s| MatchSpec::from_str(s, ParseStrictness::Lenient)) .filter_map(|result| match result { Ok(spec) => { if spec diff --git a/test-data/recipes/package-content-tests/rich-recipe.yaml b/test-data/recipes/package-content-tests/rich-recipe.yaml index 97f26af8..1052396b 100644 --- a/test-data/recipes/package-content-tests/rich-recipe.yaml +++ b/test-data/recipes/package-content-tests/rich-recipe.yaml @@ -21,12 +21,12 @@ requirements: host: - pip - poetry-core >=1.0.0 - - python 3.10 + - python 3.10.* run: # sync with normalized deps from poetry-generated setup.py - markdown-it-py >=2.2.0 - pygments >=2.13.0,<3.0.0 - - python 3.10 + - python 3.10.* - typing_extensions >=4.0.0,<5.0.0 tests: diff --git a/test-data/recipes/race-condition/recipe-python-min.yaml b/test-data/recipes/race-condition/recipe-python-min.yaml index d959a763..e647b8f7 100644 --- a/test-data/recipes/race-condition/recipe-python-min.yaml +++ b/test-data/recipes/race-condition/recipe-python-min.yaml @@ -4,12 +4,10 @@ package: requirements: host: - - python ${{ python_min }} - python >=${{ python_min }} - python ${{ python_min }}.* - python ${{ python_min ~ ".*,<4.0a0" }} run: - - python ${{ python_min }} - python >=${{ python_min }} - python ${{ python_min }}.* - python ${{ python_min ~ ".*,<4.0a0" }} diff --git a/test-data/recipes/rich/recipe.yaml b/test-data/recipes/rich/recipe.yaml index 406e4958..4c494aa2 100644 --- a/test-data/recipes/rich/recipe.yaml +++ b/test-data/recipes/rich/recipe.yaml @@ -21,12 +21,12 @@ requirements: host: - pip - poetry-core >=1.0.0 - - python 3.10 + - python 3.10.* run: # sync with normalized deps from poetry-generated setup.py - markdown-it-py >=2.2.0 - pygments >=2.13.0,<3.0.0 - - python 3.10 + - python 3.10.* - typing_extensions >=4.0.0,<5.0.0 tests: diff --git a/test-data/recipes/toml/recipe.yaml b/test-data/recipes/toml/recipe.yaml index a54cd460..786b44e5 100644 --- a/test-data/recipes/toml/recipe.yaml +++ b/test-data/recipes/toml/recipe.yaml @@ -18,9 +18,9 @@ build: requirements: host: - - python 3.12.1 - - pip 23.3.2 - - setuptools 68 + - python 3.12.1.* + - pip 23.3.2.* + - setuptools 68.* run: - python diff --git a/test/end-to-end/__snapshots__/test_simple/test_python_min_render.json b/test/end-to-end/__snapshots__/test_simple/test_python_min_render.json index b334593a..207528c6 100644 --- a/test/end-to-end/__snapshots__/test_simple/test_python_min_render.json +++ b/test/end-to-end/__snapshots__/test_simple/test_python_min_render.json @@ -1,12 +1,10 @@ { "host": [ - "python ==3.8.0", "python >=3.8.0", "python 3.8.0.*", "python 3.8.0.*,<4.0a0" ], "run": [ - "python ==3.8.0", "python >=3.8.0", "python 3.8.0.*", "python 3.8.0.*,<4.0a0"