@@ -1319,6 +1319,99 @@ fn run_with_pyvenv_cfg_file() -> Result<()> {
13191319 Ok ( ( ) )
13201320}
13211321
1322+ #[ test]
1323+ fn run_with_overlay_interpreter ( ) -> Result < ( ) > {
1324+ let context = TestContext :: new ( "3.12" ) ;
1325+
1326+ let pyproject_toml = context. temp_dir . child ( "pyproject.toml" ) ;
1327+ pyproject_toml. write_str ( indoc ! { r#"
1328+ [project]
1329+ name = "foo"
1330+ version = "1.0.0"
1331+ requires-python = ">=3.8"
1332+ dependencies = []
1333+
1334+ [build-system]
1335+ requires = ["setuptools>=42"]
1336+ build-backend = "setuptools.build_meta"
1337+
1338+ [project.scripts]
1339+ main = "foo:main"
1340+ "#
1341+ } ) ?;
1342+
1343+ let foo = context. temp_dir . child ( "src" ) . child ( "foo" ) ;
1344+ foo. create_dir_all ( ) ?;
1345+ let init_py = foo. child ( "__init__.py" ) ;
1346+ init_py. write_str ( indoc ! { r#"
1347+ def main():
1348+ import sys
1349+ print(sys.executable)
1350+ "#
1351+ } ) ?;
1352+
1353+ // The project's entrypoint should be rewritten to use the overlay interpreter.
1354+ uv_snapshot ! ( context. filters( ) , context. run( ) . arg( "--with" ) . arg( "iniconfig" ) . arg( "main" ) , @r"
1355+ success: true
1356+ exit_code: 0
1357+ ----- stdout -----
1358+ [CACHE_DIR]/builds-v0/[TMP]/python
1359+
1360+ ----- stderr -----
1361+ Resolved 1 package in [TIME]
1362+ Prepared 1 package in [TIME]
1363+ Installed 1 package in [TIME]
1364+ + foo==1.0.0 (from file://[TEMP_DIR]/)
1365+ Resolved 1 package in [TIME]
1366+ Prepared 1 package in [TIME]
1367+ Installed 1 package in [TIME]
1368+ + iniconfig==2.0.0
1369+ " ) ;
1370+
1371+ // When layering the project on top (via `--with`), the overlay interpreter also should be used.
1372+ uv_snapshot ! ( context. filters( ) , context. run( ) . arg( "--no-project" ) . arg( "--with" ) . arg( "." ) . arg( "main" ) , @r"
1373+ success: true
1374+ exit_code: 0
1375+ ----- stdout -----
1376+ [CACHE_DIR]/builds-v0/[TMP]/python
1377+
1378+ ----- stderr -----
1379+ Resolved 1 package in [TIME]
1380+ Prepared 1 package in [TIME]
1381+ Installed 1 package in [TIME]
1382+ + foo==1.0.0 (from file://[TEMP_DIR]/)
1383+ " ) ;
1384+
1385+ // Switch to a relocatable virtual environment.
1386+ context. venv ( ) . arg ( "--relocatable" ) . assert ( ) . success ( ) ;
1387+
1388+ // The project's entrypoint should be rewritten to use the overlay interpreter.
1389+ uv_snapshot ! ( context. filters( ) , context. run( ) . arg( "--with" ) . arg( "iniconfig" ) . arg( "main" ) , @r"
1390+ success: true
1391+ exit_code: 0
1392+ ----- stdout -----
1393+ [CACHE_DIR]/builds-v0/[TMP]/python
1394+
1395+ ----- stderr -----
1396+ Resolved 1 package in [TIME]
1397+ Audited 1 package in [TIME]
1398+ Resolved 1 package in [TIME]
1399+ " ) ;
1400+
1401+ // When layering the project on top (via `--with`), the overlay interpreter also should be used.
1402+ uv_snapshot ! ( context. filters( ) , context. run( ) . arg( "--no-project" ) . arg( "--with" ) . arg( "." ) . arg( "main" ) , @r"
1403+ success: true
1404+ exit_code: 0
1405+ ----- stdout -----
1406+ [CACHE_DIR]/builds-v0/[TMP]/python
1407+
1408+ ----- stderr -----
1409+ Resolved 1 package in [TIME]
1410+ " ) ;
1411+
1412+ Ok ( ( ) )
1413+ }
1414+
13221415#[ test]
13231416fn run_with_build_constraints ( ) -> Result < ( ) > {
13241417 let context = TestContext :: new ( "3.9" ) ;
0 commit comments