@@ -3544,6 +3544,133 @@ fn no_install_project_no_build() -> Result<()> {
3544
3544
Ok ( ( ) )
3545
3545
}
3546
3546
3547
+ #[ test]
3548
+ fn virtual_no_build ( ) -> Result < ( ) > {
3549
+ let context = TestContext :: new ( "3.12" ) ;
3550
+
3551
+ let pyproject_toml = context. temp_dir . child ( "pyproject.toml" ) ;
3552
+ pyproject_toml. write_str (
3553
+ r#"
3554
+ [project]
3555
+ name = "project"
3556
+ version = "0.1.0"
3557
+ requires-python = ">=3.12"
3558
+ dependencies = ["anyio==3.7.0"]
3559
+ "# ,
3560
+ ) ?;
3561
+
3562
+ // Generate a lockfile.
3563
+ context. lock ( ) . assert ( ) . success ( ) ;
3564
+
3565
+ // Clear the cache.
3566
+ fs_err:: remove_dir_all ( & context. cache_dir ) ?;
3567
+
3568
+ // `--no-build` should not raise an error, since we don't install virtual projects.
3569
+ uv_snapshot ! ( context. filters( ) , context. sync( ) . arg( "--no-build" ) , @r"
3570
+ success: true
3571
+ exit_code: 0
3572
+ ----- stdout -----
3573
+
3574
+ ----- stderr -----
3575
+ Resolved 4 packages in [TIME]
3576
+ Prepared 3 packages in [TIME]
3577
+ Installed 3 packages in [TIME]
3578
+ + anyio==3.7.0
3579
+ + idna==3.6
3580
+ + sniffio==1.3.1
3581
+ " ) ;
3582
+
3583
+ Ok ( ( ) )
3584
+ }
3585
+
3586
+ #[ test]
3587
+ fn virtual_no_build_dynamic_cached ( ) -> Result < ( ) > {
3588
+ let context = TestContext :: new ( "3.12" ) ;
3589
+
3590
+ let pyproject_toml = context. temp_dir . child ( "pyproject.toml" ) ;
3591
+ pyproject_toml. write_str (
3592
+ r#"
3593
+ [project]
3594
+ name = "project"
3595
+ version = "0.1.0"
3596
+ requires-python = ">=3.12"
3597
+ dynamic = ["dependencies"]
3598
+
3599
+ [tool.setuptools.dynamic]
3600
+ dependencies = {file = ["requirements.txt"]}
3601
+ "# ,
3602
+ ) ?;
3603
+
3604
+ context
3605
+ . temp_dir
3606
+ . child ( "requirements.txt" )
3607
+ . write_str ( "anyio==3.7.0" ) ?;
3608
+
3609
+ // Generate a lockfile.
3610
+ context. lock ( ) . assert ( ) . success ( ) ;
3611
+
3612
+ // `--no-build` should not raise an error, since we don't build or install the project (given
3613
+ // that it's virtual and the metadata is cached).
3614
+ uv_snapshot ! ( context. filters( ) , context. sync( ) . arg( "--no-build" ) , @r"
3615
+ success: true
3616
+ exit_code: 0
3617
+ ----- stdout -----
3618
+
3619
+ ----- stderr -----
3620
+ Resolved 4 packages in [TIME]
3621
+ Prepared 3 packages in [TIME]
3622
+ Installed 3 packages in [TIME]
3623
+ + anyio==3.7.0
3624
+ + idna==3.6
3625
+ + sniffio==1.3.1
3626
+ " ) ;
3627
+
3628
+ Ok ( ( ) )
3629
+ }
3630
+
3631
+ #[ test]
3632
+ fn virtual_no_build_dynamic_no_cache ( ) -> Result < ( ) > {
3633
+ let context = TestContext :: new ( "3.12" ) ;
3634
+
3635
+ let pyproject_toml = context. temp_dir . child ( "pyproject.toml" ) ;
3636
+ pyproject_toml. write_str (
3637
+ r#"
3638
+ [project]
3639
+ name = "project"
3640
+ version = "0.1.0"
3641
+ requires-python = ">=3.12"
3642
+ dynamic = ["dependencies"]
3643
+
3644
+ [tool.setuptools.dynamic]
3645
+ dependencies = {file = ["requirements.txt"]}
3646
+ "# ,
3647
+ ) ?;
3648
+
3649
+ context
3650
+ . temp_dir
3651
+ . child ( "requirements.txt" )
3652
+ . write_str ( "anyio==3.7.0" ) ?;
3653
+
3654
+ // Generate a lockfile.
3655
+ context. lock ( ) . assert ( ) . success ( ) ;
3656
+
3657
+ // Clear the cache.
3658
+ fs_err:: remove_dir_all ( & context. cache_dir ) ?;
3659
+
3660
+ // `--no-build` should raise an error, since we need to build the project.
3661
+ uv_snapshot ! ( context. filters( ) , context. sync( ) . arg( "--no-build" ) , @r"
3662
+ success: false
3663
+ exit_code: 2
3664
+ ----- stdout -----
3665
+
3666
+ ----- stderr -----
3667
+ error: Failed to generate package metadata for `project==0.1.0 @ virtual+.`
3668
+ Caused by: Building source distributions for `project` is disabled
3669
+ " ) ;
3670
+
3671
+ Ok ( ( ) )
3672
+ }
3673
+
3547
3674
/// Convert from a package to a virtual project.
3548
3675
#[ test]
3549
3676
fn convert_to_virtual ( ) -> Result < ( ) > {
@@ -4815,25 +4942,25 @@ fn no_build_error() -> Result<()> {
4815
4942
error: Distribution `django-allauth==0.51.0 @ registry+https://pypi.org/simple` can't be installed because it is marked as `--no-build` but has no binary distribution
4816
4943
"### ) ;
4817
4944
4818
- uv_snapshot ! ( context. filters( ) , context. sync( ) . arg( "--no-build" ) , @r### "
4945
+ uv_snapshot ! ( context. filters( ) , context. sync( ) . arg( "--no-build" ) , @r"
4819
4946
success: false
4820
4947
exit_code: 2
4821
4948
----- stdout -----
4822
4949
4823
4950
----- stderr -----
4824
4951
Resolved 19 packages in [TIME]
4825
- error: Distribution `project ==0.1 .0 @ virtual+. ` can't be installed because it is marked as `--no-build` but has no binary distribution
4826
- "### ) ;
4952
+ error: Distribution `django-allauth ==0.51 .0 @ registry+https://pypi.org/simple ` can't be installed because it is marked as `--no-build` but has no binary distribution
4953
+ " ) ;
4827
4954
4828
- uv_snapshot ! ( context. filters( ) , context. sync( ) . arg( "--reinstall" ) . env( "UV_NO_BUILD" , "1" ) , @r### "
4955
+ uv_snapshot ! ( context. filters( ) , context. sync( ) . arg( "--reinstall" ) . env( "UV_NO_BUILD" , "1" ) , @r"
4829
4956
success: false
4830
4957
exit_code: 2
4831
4958
----- stdout -----
4832
4959
4833
4960
----- stderr -----
4834
4961
Resolved 19 packages in [TIME]
4835
- error: Distribution `project ==0.1 .0 @ virtual+. ` can't be installed because it is marked as `--no-build` but has no binary distribution
4836
- "### ) ;
4962
+ error: Distribution `django-allauth ==0.51 .0 @ registry+https://pypi.org/simple ` can't be installed because it is marked as `--no-build` but has no binary distribution
4963
+ " ) ;
4837
4964
4838
4965
uv_snapshot ! ( context. filters( ) , context. sync( ) . arg( "--reinstall" ) . env( "UV_NO_BUILD_PACKAGE" , "django-allauth" ) , @r###"
4839
4966
success: false
0 commit comments