diff --git a/crates/uv/tests/pip_compile.rs b/crates/uv/tests/pip_compile.rs index b78004d14bb6a..2d32b7df5bf76 100644 --- a/crates/uv/tests/pip_compile.rs +++ b/crates/uv/tests/pip_compile.rs @@ -12035,3 +12035,253 @@ fn compile_requires_txt() -> Result<()> { Ok(()) } + +/// Regression test for: https://github.com/astral-sh/uv/issues/6269 +#[test] +fn astroid_not_repeated() -> Result<()> { + let context = TestContext::new("3.12"); + + let requirements_in = context.temp_dir.child("requirements.in"); + requirements_in.write_str( + "\ +alembic==1.8.1 +ipython>=8.4.0 +pylint>=2.14.5 + ", + )?; + + let constraints_txt = context.temp_dir.child("constraints.txt"); + constraints_txt.write_str( + "\ +dill==0.3.1.1 +exceptiongroup==1.0.0rc8 + ", + )?; + + uv_snapshot!(context + .pip_compile() + .arg("requirements.in") + .arg("-c").arg("constraints.txt") + .arg("--universal") + .arg("-p").arg("3.10"), @r###" + success: true + exit_code: 0 + ----- stdout ----- + # This file was autogenerated by uv via the following command: + # uv pip compile --cache-dir [CACHE_DIR] requirements.in -c constraints.txt --universal -p 3.10 + alembic==1.8.1 + # via -r requirements.in + astroid==2.13.5 + # via pylint + astroid==3.1.0 ; python_full_version < '3.11' + # via pylint + asttokens==2.4.1 + # via stack-data + colorama==0.4.6 ; sys_platform == 'win32' + # via + # ipython + # pylint + decorator==5.1.1 + # via ipython + dill==0.3.1.1 + # via + # -c constraints.txt + # pylint + exceptiongroup==1.0.0rc8 ; python_full_version < '3.11' + # via + # -c constraints.txt + # ipython + executing==2.0.1 + # via stack-data + greenlet==3.0.3 ; platform_machine == 'AMD64' or platform_machine == 'WIN32' or platform_machine == 'aarch64' or platform_machine == 'amd64' or platform_machine == 'ppc64le' or platform_machine == 'win32' or platform_machine == 'x86_64' + # via sqlalchemy + ipython==8.22.2 + # via -r requirements.in + isort==5.13.2 + # via pylint + jedi==0.19.1 + # via ipython + lazy-object-proxy==1.10.0 + # via astroid + mako==1.3.2 + # via alembic + markupsafe==2.1.5 + # via mako + matplotlib-inline==0.1.6 + # via ipython + mccabe==0.7.0 + # via pylint + parso==0.8.3 + # via jedi + pexpect==4.9.0 ; sys_platform != 'emscripten' and sys_platform != 'win32' + # via ipython + platformdirs==4.2.0 + # via pylint + prompt-toolkit==3.0.43 + # via ipython + ptyprocess==0.7.0 ; sys_platform != 'emscripten' and sys_platform != 'win32' + # via pexpect + pure-eval==0.2.2 + # via stack-data + pygments==2.17.2 + # via ipython + pylint==2.15.8 + # via -r requirements.in + pylint==3.1.0 ; python_full_version < '3.11' + # via -r requirements.in + six==1.16.0 + # via asttokens + sqlalchemy==2.0.29 + # via alembic + stack-data==0.6.3 + # via ipython + tomli==2.0.1 ; python_full_version < '3.11' + # via pylint + tomlkit==0.12.4 + # via pylint + traitlets==5.14.2 + # via + # ipython + # matplotlib-inline + typing-extensions==4.10.0 + # via + # astroid + # sqlalchemy + wcwidth==0.2.13 + # via prompt-toolkit + wrapt==1.16.0 + # via astroid + + ----- stderr ----- + warning: The requested Python version 3.10 is not available; 3.12.1 will be used to build dependencies instead. + Resolved 36 packages in [TIME] + "###); + + Ok(()) +} + +/// Regression test for: https://github.com/astral-sh/uv/issues/6412 +#[test] +fn tomli_less_than_python311() -> Result<()> { + let context = TestContext::new("3.12"); + + let requirements_in = context.temp_dir.child("requirements.in"); + requirements_in.write_str( + "\ +coverage[toml] +pandas +matplotlib + ", + )?; + + uv_snapshot!(context + .pip_compile() + .arg("requirements.in").arg("--universal").arg("-p").arg("3.8"), @r###" + success: true + exit_code: 0 + ----- stdout ----- + # This file was autogenerated by uv via the following command: + # uv pip compile --cache-dir [CACHE_DIR] requirements.in --universal -p 3.8 + contourpy==1.1.1 + # via matplotlib + coverage==7.4.4 + # via -r requirements.in + cycler==0.12.1 + # via matplotlib + fonttools==4.50.0 + # via matplotlib + importlib-resources==6.4.0 ; python_full_version < '3.10' + # via matplotlib + kiwisolver==1.4.5 + # via matplotlib + matplotlib==3.7.5 + # via -r requirements.in + numpy==1.24.4 ; python_full_version < '3.12' + # via + # contourpy + # matplotlib + # pandas + numpy==1.26.4 ; python_full_version >= '3.12' + # via + # contourpy + # matplotlib + # pandas + packaging==24.0 + # via matplotlib + pandas==2.0.3 + # via -r requirements.in + pillow==10.2.0 + # via matplotlib + pyparsing==3.1.2 + # via matplotlib + python-dateutil==2.9.0.post0 + # via + # matplotlib + # pandas + pytz==2024.1 + # via pandas + six==1.16.0 + # via python-dateutil + tomli==2.0.1 ; python_full_version == '3.11' + # via coverage + tzdata==2024.1 + # via pandas + zipp==3.18.1 ; python_full_version < '3.10' + # via importlib-resources + + ----- stderr ----- + warning: The requested Python version 3.8 is not available; 3.12.1 will be used to build dependencies instead. + Resolved 19 packages in [TIME] + "###); + + Ok(()) +} + +/// Regression test for: https://github.com/astral-sh/uv/issues/6836 +#[test] +fn importlib_metadata_not_repeated() -> Result<()> { + let context = TestContext::new("3.12"); + + let uv_toml = context.temp_dir.child("uv.toml"); + uv_toml.write_str(r#"environments = ["python_version >= '3.10'", "python_version >= '3.8' and python_version < '3.10'", "python_version < '3.8'"]"#)?; + let requirements_in = context.temp_dir.child("requirements.in"); + requirements_in.write_str("build")?; + + uv_snapshot!(context + .pip_compile() + .arg("requirements.in").arg("--universal").arg("-p").arg("3.7"), @r###" + success: true + exit_code: 0 + ----- stdout ----- + # This file was autogenerated by uv via the following command: + # uv pip compile --cache-dir [CACHE_DIR] requirements.in --universal -p 3.7 + build==1.1.1 + # via -r requirements.in + colorama==0.4.6 ; os_name == 'nt' + # via build + importlib-metadata==6.7.0 ; python_full_version < '3.10' + # via build + importlib-metadata==7.1.0 ; python_full_version < '3.10.2' + # via build + packaging==24.0 + # via build + pyproject-hooks==1.0.0 + # via build + tomli==2.0.1 ; python_full_version < '3.11' + # via + # build + # pyproject-hooks + typing-extensions==4.7.1 ; python_full_version < '3.8' + # via importlib-metadata + zipp==3.15.0 ; python_full_version < '3.10' + # via importlib-metadata + zipp==3.18.1 ; python_full_version < '3.10.2' + # via importlib-metadata + + ----- stderr ----- + warning: The requested Python version 3.7 is not available; 3.12.1 will be used to build dependencies instead. + Resolved 10 packages in [TIME] + "###); + + Ok(()) +}