@@ -1344,6 +1344,9 @@ fn run_with_overlay_interpreter() -> Result<()> {
1344
1344
1345
1345
[project.scripts]
1346
1346
main = "foo:main"
1347
+
1348
+ [project.gui-scripts]
1349
+ main_gui = "foo:main_gui"
1347
1350
"#
1348
1351
} ) ?;
1349
1352
@@ -1362,10 +1365,19 @@ fn run_with_overlay_interpreter() -> Result<()> {
1362
1365
base = Path(sys.executable)
1363
1366
shutil.copyfile(base.with_name("main").with_suffix(base.suffix), sys.argv[1])
1364
1367
1368
+ def copy_gui_entrypoint():
1369
+ base = Path(sys.executable)
1370
+ shutil.copyfile(base.with_name("main_gui").with_suffix(base.suffix), sys.argv[1])
1371
+
1365
1372
def main():
1366
1373
show_python()
1367
1374
if len(sys.argv) > 1:
1368
1375
copy_entrypoint()
1376
+
1377
+ def main_gui():
1378
+ show_python()
1379
+ if len(sys.argv) > 1:
1380
+ copy_gui_entrypoint()
1369
1381
"#
1370
1382
} ) ?;
1371
1383
@@ -1390,6 +1402,20 @@ fn run_with_overlay_interpreter() -> Result<()> {
1390
1402
+ iniconfig==2.0.0
1391
1403
" ) ;
1392
1404
1405
+ // The project's gui entrypoint should be rewritten to use the overlay interpreter.
1406
+ #[ cfg( windows) ]
1407
+ uv_snapshot ! ( context. filters( ) , context. run( ) . arg( "--with" ) . arg( "iniconfig" ) . arg( "main_gui" ) . arg( context. temp_dir. child( "main_gui" ) . as_os_str( ) ) , @r"
1408
+ success: true
1409
+ exit_code: 0
1410
+ ----- stdout -----
1411
+ [CACHE_DIR]/builds-v0/[TMP]/pythonw
1412
+
1413
+ ----- stderr -----
1414
+ Resolved 6 packages in [TIME]
1415
+ Audited 4 packages in [TIME]
1416
+ Resolved 1 package in [TIME]
1417
+ " ) ;
1418
+
1393
1419
#[ cfg( unix) ]
1394
1420
insta:: with_settings!( {
1395
1421
filters => context. filters( ) ,
@@ -1439,9 +1465,26 @@ fn run_with_overlay_interpreter() -> Result<()> {
1439
1465
+ sniffio==1.3.1
1440
1466
" ) ;
1441
1467
1468
+ // When layering the project on top (via `--with`), the overlay gui interpreter also should be used.
1469
+ #[ cfg( windows) ]
1470
+ uv_snapshot ! ( context. filters( ) , context. run( ) . arg( "--no-project" ) . arg( "--gui-script" ) . arg( "--with" ) . arg( "." ) . arg( "main_gui" ) , @r"
1471
+ success: true
1472
+ exit_code: 0
1473
+ ----- stdout -----
1474
+ [CACHE_DIR]/builds-v0/[TMP]/pythonw
1475
+
1476
+ ----- stderr -----
1477
+ Resolved 4 packages in [TIME]
1478
+ " ) ;
1479
+
1442
1480
// Switch to a relocatable virtual environment.
1443
1481
context. venv ( ) . arg ( "--relocatable" ) . assert ( ) . success ( ) ;
1444
1482
1483
+ // Cleanup previous shutil
1484
+ fs_err:: remove_file ( context. temp_dir . child ( "main" ) ) ?;
1485
+ #[ cfg( windows) ]
1486
+ fs_err:: remove_file ( context. temp_dir . child ( "main_gui" ) ) ?;
1487
+
1445
1488
// The project's entrypoint should be rewritten to use the overlay interpreter.
1446
1489
uv_snapshot ! ( context. filters( ) , context. run( ) . arg( "--with" ) . arg( "iniconfig" ) . arg( "main" ) . arg( context. temp_dir. child( "main" ) . as_os_str( ) ) , @r"
1447
1490
success: true
@@ -1455,6 +1498,20 @@ fn run_with_overlay_interpreter() -> Result<()> {
1455
1498
Resolved 1 package in [TIME]
1456
1499
" ) ;
1457
1500
1501
+ // The project's gui entrypoint should be rewritten to use the overlay interpreter.
1502
+ #[ cfg( windows) ]
1503
+ uv_snapshot ! ( context. filters( ) , context. run( ) . arg( "--with" ) . arg( "iniconfig" ) . arg( "main_gui" ) . arg( context. temp_dir. child( "main_gui" ) . as_os_str( ) ) , @r"
1504
+ success: true
1505
+ exit_code: 0
1506
+ ----- stdout -----
1507
+ [CACHE_DIR]/builds-v0/[TMP]/pythonw
1508
+
1509
+ ----- stderr -----
1510
+ Resolved 6 packages in [TIME]
1511
+ Audited 4 packages in [TIME]
1512
+ Resolved 1 package in [TIME]
1513
+ " ) ;
1514
+
1458
1515
// The package, its dependencies, and the overlay dependencies should be available.
1459
1516
context
1460
1517
. run ( )
@@ -1498,6 +1555,18 @@ fn run_with_overlay_interpreter() -> Result<()> {
1498
1555
Resolved 4 packages in [TIME]
1499
1556
" ) ;
1500
1557
1558
+ // When layering the project on top (via `--with`), the overlay gui interpreter also should be used.
1559
+ #[ cfg( windows) ]
1560
+ uv_snapshot ! ( context. filters( ) , context. run( ) . arg( "--no-project" ) . arg( "--gui-script" ) . arg( "--with" ) . arg( "." ) . arg( "main_gui" ) , @r"
1561
+ success: true
1562
+ exit_code: 0
1563
+ ----- stdout -----
1564
+ [CACHE_DIR]/builds-v0/[TMP]/pythonw
1565
+
1566
+ ----- stderr -----
1567
+ Resolved 4 packages in [TIME]
1568
+ " ) ;
1569
+
1501
1570
Ok ( ( ) )
1502
1571
}
1503
1572
0 commit comments