From 5ca5d7da67bbb8eb617ae4d4c09c51ad76df8807 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Thu, 18 Apr 2024 20:47:27 -0400 Subject: [PATCH] Add test for avoiding irrelevant extras (#3107) ## Summary This PR adds a test that currently leads to an error, but should successfully resolve as of https://github.com/astral-sh/uv/pull/3100. The core idea is that if we have a pinned package, we shouldn't try to build other versions of that package if we have an unconstrained variant with an extra. --- crates/uv/tests/pip_compile.rs | 52 ++++++++++++++++++++++++++++++ scripts/links/extras-0.0.1.tar.gz | Bin 0 -> 690 bytes scripts/links/extras-0.0.2.tar.gz | Bin 0 -> 690 bytes 3 files changed, 52 insertions(+) create mode 100644 scripts/links/extras-0.0.1.tar.gz create mode 100644 scripts/links/extras-0.0.2.tar.gz diff --git a/crates/uv/tests/pip_compile.rs b/crates/uv/tests/pip_compile.rs index 82360443a..de40cc531 100644 --- a/crates/uv/tests/pip_compile.rs +++ b/crates/uv/tests/pip_compile.rs @@ -3901,6 +3901,58 @@ fn find_links_requirements_txt() -> Result<()> { Ok(()) } +/// `extras==0.0.2` fails to build (i.e., it always throws). Since `extras==0.0.1` is pinned, we +/// should never even attempt to build `extras==0.0.2`, despite an unpinned `extras[dev]` +/// requirement. +/// +/// This resolution should succeed, but currently fails. +#[test] +fn avoid_irrelevant_extras() -> Result<()> { + let context = TestContext::new("3.12"); + let requirements_in = context.temp_dir.child("requirements.in"); + requirements_in.write_str(indoc! {r" + extras==0.0.1 + extras[dev] + "})?; + + let filters = std::iter::once((r"exit code: 1", "exit status: 1")) + .chain(context.filters()) + .collect::>(); + + uv_snapshot!(filters, context.compile() + .arg("requirements.in") + .arg("--find-links") + .arg(context.workspace_root.join("scripts").join("links")), @r###" + success: false + exit_code: 2 + ----- stdout ----- + + ----- stderr ----- + error: Failed to download and build: extras==0.0.2 + Caused by: Failed to build: extras==0.0.2 + Caused by: Build backend failed to determine extra requires with `build_wheel()` with exit status: 1 + --- stdout: + + --- stderr: + Traceback (most recent call last): + File "", line 14, in + File "[CACHE_DIR]/[TMP]/build_meta.py", line 325, in get_requires_for_build_wheel + return self._get_build_requires(config_settings, requirements=['wheel']) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "[CACHE_DIR]/[TMP]/build_meta.py", line 295, in _get_build_requires + self.run_setup() + File "[CACHE_DIR]/[TMP]/build_meta.py", line 487, in run_setup + super().run_setup(setup_script=setup_script) + File "[CACHE_DIR]/[TMP]/build_meta.py", line 311, in run_setup + exec(code, locals()) + File "", line 3, in + ZeroDivisionError: division by zero + --- + "###); + + Ok(()) +} + /// Use an existing resolution for `black==23.10.1`, with stale versions of `click` and `pathspec`. /// Nothing should change. #[test] diff --git a/scripts/links/extras-0.0.1.tar.gz b/scripts/links/extras-0.0.1.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..4672622a8dae10a57a8a12760a6226387702ec6f GIT binary patch literal 690 zcmV;j0!{rNiwFSHI3Q*K1MQeyZ<{a_hI{Q_VR5xd3$u-}rAWD&x@nr$R;#+3C_*fl z%o>3VNYrZDf1mjXNfZJ~N{QC^xpA-!b~t{|IUMnr#%?k|CNlB+tCs;G#BCeqEh}0? zXwjBHOc_SVvN*9J!WJX=3feEUpBc(m-(|GR2$(Tg(+sUfeihqt9Wpf|F^Kx zKVz6_|KA5Y_D@8*T$qcej@M}O|Ag_4|F@a4zim;Z{eK_$aWsdy-P0%v5-8`3C{BwW z0P^MyfQnFsgppAk7vo*twJHL`$jDDm*(pQyrh>qU#qXtzMKT)a-5G`qd(4eqfP&aR{5XOJ<0S>Eu!_` z2V)iNoh;Z-KnEbEQKgL|=e|=DAe@8h4 znL18anP98`-`JlLn&tnT5S{<^LgV*eNA;lN>OWRye~xTz|31+5pUb9E|M#~K-#%R5 zo9ScvoHg3N|8W)nk*)Mk5amqkzYo?WAFv<$!J%-lH?Vb1_QpK15TPf+>5~)4@K;hh zXYd YajpM8(8||nG@8rg9{`nXH~=gF0AxF7@Bjb+ literal 0 HcmV?d00001 diff --git a/scripts/links/extras-0.0.2.tar.gz b/scripts/links/extras-0.0.2.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..38df28bce37ec01f1ad7074d772539922900848c GIT binary patch literal 690 zcmV;j0!{rNiwFSFI3Q*K1MQmekD4$P$M5I<6%9Xa$>iEnXky||%WYYf-CcIM{bCGZ zQav&R2GwYm{qHLUokoP{A!f6mAFR;E7GA&ay}rnoBK5K!GLcDcZ_Wckh}kw&ty8p! z(4sAYm^v6C%VNle2wM(8H_$%QdUlv+!b{~+#_7yUvzLS8@y>VAG>E33yE7Md0(Scb9kfq0blK(odl|l^y*T7bc%hdqFgb+lmKA`G1o8 zf5#z2`~NQ3v46(JJTa41%X2jOf5JBQr^Lb1{PJPyK^+@AJI+zXHi6Q{Zq@* z`tO3F4EAmw>_O$s)Tz;1>;L@wqoQsP5uk|v(G5KGqf2_~{-B4wJ zS2~11xNcjSV59%vvp*wP=YO40d;V*w9&}9o2RX|A3~Bp!g0BBuH?{hIdU*c&{_e>X zOYxdH8qfdo%)j>k$hIINh%&AJPFRL$JRdC>+^ZSBcDg(l^X`pkF0Xg zx=v8pDdNNp`GSY4_tG!yKciOv+h%#i9F6%Ov9{`ew$wi+*w*^*0#%IzU?`*b2&gKX zR@gOBtN$I(d-@#B=RdX;|5>hoi|Y8_31yCd>1AjxM6Ld-a<>!aXx9HG|0hfiM1(j@ Y|No;CwDL6?jpjP}1ILd{_W&#a0FwuA0{{R3 literal 0 HcmV?d00001