@@ -446,6 +446,182 @@ def test_custom_platlibdir_posix(self):
446
446
actual = getpath (ns , expected )
447
447
self .assertEqual (expected , actual )
448
448
449
+ def test_framework_macos (self ):
450
+ """ Test framework layout on macOS
451
+
452
+ This layout is primarily detected using a compile-time option
453
+ (WITH_NEXT_FRAMEWORK).
454
+ """
455
+ ns = MockPosixNamespace (
456
+ os_name = "darwin" ,
457
+ argv0 = "/Library/Frameworks/Python.framework/Versions/9.8/Resources/Python.app/Contents/MacOS/Python" ,
458
+ WITH_NEXT_FRAMEWORK = 1 ,
459
+ PREFIX = "/Library/Frameworks/Python.framework/Versions/9.8" ,
460
+ EXEC_PREFIX = "/Library/Frameworks/Python.framework/Versions/9.8" ,
461
+ ENV___PYVENV_LAUNCHER__ = "/Library/Frameworks/Python.framework/Versions/9.8/bin/python9.8" ,
462
+ real_executable = "/Library/Frameworks/Python.framework/Versions/9.8/Resources/Python.app/Contents/MacOS/Python" ,
463
+ library = "/Library/Frameworks/Python.framework/Versions/9.8/Python" ,
464
+ )
465
+ ns .add_known_xfile ("/Library/Frameworks/Python.framework/Versions/9.8/Resources/Python.app/Contents/MacOS/Python" )
466
+ ns .add_known_xfile ("/Library/Frameworks/Python.framework/Versions/9.8/bin/python9.8" )
467
+ ns .add_known_dir ("/Library/Frameworks/Python.framework/Versions/9.8/lib/python9.8/lib-dynload" )
468
+ ns .add_known_file ("/Library/Frameworks/Python.framework/Versions/9.8/lib/python9.8/os.py" )
469
+
470
+ # This is definitely not the stdlib (see discusion in bpo-46890)
471
+ #ns.add_known_file("/Library/Frameworks/lib/python98.zip")
472
+
473
+ expected = dict (
474
+ executable = "/Library/Frameworks/Python.framework/Versions/9.8/bin/python9.8" ,
475
+ prefix = "/Library/Frameworks/Python.framework/Versions/9.8" ,
476
+ exec_prefix = "/Library/Frameworks/Python.framework/Versions/9.8" ,
477
+ base_executable = "/Library/Frameworks/Python.framework/Versions/9.8/bin/python9.8" ,
478
+ base_prefix = "/Library/Frameworks/Python.framework/Versions/9.8" ,
479
+ base_exec_prefix = "/Library/Frameworks/Python.framework/Versions/9.8" ,
480
+ module_search_paths_set = 1 ,
481
+ module_search_paths = [
482
+ "/Library/Frameworks/Python.framework/Versions/9.8/lib/python98.zip" ,
483
+ "/Library/Frameworks/Python.framework/Versions/9.8/lib/python9.8" ,
484
+ "/Library/Frameworks/Python.framework/Versions/9.8/lib/python9.8/lib-dynload" ,
485
+ ],
486
+ )
487
+ actual = getpath (ns , expected )
488
+ self .assertEqual (expected , actual )
489
+
490
+ def test_alt_framework_macos (self ):
491
+ """ Test framework layout on macOS with alternate framework name
492
+
493
+ ``--with-framework-name=DebugPython``
494
+
495
+ This layout is primarily detected using a compile-time option
496
+ (WITH_NEXT_FRAMEWORK).
497
+ """
498
+ ns = MockPosixNamespace (
499
+ argv0 = "/Library/Frameworks/DebugPython.framework/Versions/9.8/Resources/Python.app/Contents/MacOS/DebugPython" ,
500
+ os_name = "darwin" ,
501
+ WITH_NEXT_FRAMEWORK = 1 ,
502
+ PREFIX = "/Library/Frameworks/DebugPython.framework/Versions/9.8" ,
503
+ EXEC_PREFIX = "/Library/Frameworks/DebugPython.framework/Versions/9.8" ,
504
+ ENV___PYVENV_LAUNCHER__ = "/Library/Frameworks/DebugPython.framework/Versions/9.8/bin/python9.8" ,
505
+ real_executable = "/Library/Frameworks/DebugPython.framework/Versions/9.8/Resources/Python.app/Contents/MacOS/DebugPython" ,
506
+ library = "/Library/Frameworks/DebugPython.framework/Versions/9.8/DebugPython" ,
507
+ PYTHONPATH = None ,
508
+ ENV_PYTHONHOME = None ,
509
+ ENV_PYTHONEXECUTABLE = None ,
510
+ executable_dir = None ,
511
+ py_setpath = None ,
512
+ )
513
+ ns .add_known_xfile ("/Library/Frameworks/DebugPython.framework/Versions/9.8/Resources/Python.app/Contents/MacOS/DebugPython" )
514
+ ns .add_known_xfile ("/Library/Frameworks/DebugPython.framework/Versions/9.8/bin/python9.8" )
515
+ ns .add_known_dir ("/Library/Frameworks/DebugPython.framework/Versions/9.8/lib/python9.8/lib-dynload" )
516
+ ns .add_known_xfile ("/Library/Frameworks/DebugPython.framework/Versions/9.8/lib/python9.8/os.py" )
517
+
518
+ # This is definitely not the stdlib (see discusion in bpo-46890)
519
+ #ns.add_known_xfile("/Library/lib/python98.zip")
520
+ expected = dict (
521
+ executable = "/Library/Frameworks/DebugPython.framework/Versions/9.8/bin/python9.8" ,
522
+ prefix = "/Library/Frameworks/DebugPython.framework/Versions/9.8" ,
523
+ exec_prefix = "/Library/Frameworks/DebugPython.framework/Versions/9.8" ,
524
+ base_executable = "/Library/Frameworks/DebugPython.framework/Versions/9.8/bin/python9.8" ,
525
+ base_prefix = "/Library/Frameworks/DebugPython.framework/Versions/9.8" ,
526
+ base_exec_prefix = "/Library/Frameworks/DebugPython.framework/Versions/9.8" ,
527
+ module_search_paths_set = 1 ,
528
+ module_search_paths = [
529
+ "/Library/Frameworks/DebugPython.framework/Versions/9.8/lib/python98.zip" ,
530
+ "/Library/Frameworks/DebugPython.framework/Versions/9.8/lib/python9.8" ,
531
+ "/Library/Frameworks/DebugPython.framework/Versions/9.8/lib/python9.8/lib-dynload" ,
532
+ ],
533
+ )
534
+ actual = getpath (ns , expected )
535
+ self .assertEqual (expected , actual )
536
+
537
+ def test_venv_framework_macos (self ):
538
+ """Test a venv layout on macOS using a framework build
539
+ """
540
+ venv_path = "/tmp/workdir/venv"
541
+ ns = MockPosixNamespace (
542
+ os_name = "darwin" ,
543
+ argv0 = "/Library/Frameworks/Python.framework/Versions/9.8/Resources/Python.app/Contents/MacOS/Python" ,
544
+ WITH_NEXT_FRAMEWORK = 1 ,
545
+ PREFIX = "/Library/Frameworks/Python.framework/Versions/9.8" ,
546
+ EXEC_PREFIX = "/Library/Frameworks/Python.framework/Versions/9.8" ,
547
+ ENV___PYVENV_LAUNCHER__ = f"{ venv_path } /bin/python" ,
548
+ real_executable = "/Library/Frameworks/Python.framework/Versions/9.8/Resources/Python.app/Contents/MacOS/Python" ,
549
+ library = "/Library/Frameworks/Python.framework/Versions/9.8/Python" ,
550
+ )
551
+ ns .add_known_dir (venv_path )
552
+ ns .add_known_dir (f"{ venv_path } /bin" )
553
+ ns .add_known_dir (f"{ venv_path } /lib" )
554
+ ns .add_known_dir (f"{ venv_path } /lib/python9.8" )
555
+ ns .add_known_xfile (f"{ venv_path } /bin/python" )
556
+ ns .add_known_xfile ("/Library/Frameworks/Python.framework/Versions/9.8/Resources/Python.app/Contents/MacOS/Python" )
557
+ ns .add_known_xfile ("/Library/Frameworks/Python.framework/Versions/9.8/bin/python9.8" )
558
+ ns .add_known_dir ("/Library/Frameworks/Python.framework/Versions/9.8/lib/python9.8/lib-dynload" )
559
+ ns .add_known_xfile ("/Library/Frameworks/Python.framework/Versions/9.8/lib/python9.8/os.py" )
560
+ ns .add_known_file (f"{ venv_path } /pyvenv.cfg" , [
561
+ "home = /Library/Frameworks/Python.framework/Versions/9.8/bin"
562
+ ])
563
+ expected = dict (
564
+ executable = f"{ venv_path } /bin/python" ,
565
+ prefix = "/Library/Frameworks/Python.framework/Versions/9.8" ,
566
+ exec_prefix = "/Library/Frameworks/Python.framework/Versions/9.8" ,
567
+ base_executable = "/Library/Frameworks/Python.framework/Versions/9.8/bin/python9.8" ,
568
+ base_prefix = "/Library/Frameworks/Python.framework/Versions/9.8" ,
569
+ base_exec_prefix = "/Library/Frameworks/Python.framework/Versions/9.8" ,
570
+ module_search_paths_set = 1 ,
571
+ module_search_paths = [
572
+ "/Library/Frameworks/Python.framework/Versions/9.8/lib/python98.zip" ,
573
+ "/Library/Frameworks/Python.framework/Versions/9.8/lib/python9.8" ,
574
+ "/Library/Frameworks/Python.framework/Versions/9.8/lib/python9.8/lib-dynload" ,
575
+ ],
576
+ )
577
+ actual = getpath (ns , expected )
578
+ self .assertEqual (expected , actual )
579
+
580
+ def test_venv_alt_framework_macos (self ):
581
+ """Test a venv layout on macOS using a framework build
582
+
583
+ ``--with-framework-name=DebugPython``
584
+ """
585
+ venv_path = "/tmp/workdir/venv"
586
+ ns = MockPosixNamespace (
587
+ os_name = "darwin" ,
588
+ argv0 = "/Library/Frameworks/DebugPython.framework/Versions/9.8/Resources/Python.app/Contents/MacOS/DebugPython" ,
589
+ WITH_NEXT_FRAMEWORK = 1 ,
590
+ PREFIX = "/Library/Frameworks/DebugPython.framework/Versions/9.8" ,
591
+ EXEC_PREFIX = "/Library/Frameworks/DebugPython.framework/Versions/9.8" ,
592
+ ENV___PYVENV_LAUNCHER__ = f"{ venv_path } /bin/python" ,
593
+ real_executable = "/Library/Frameworks/DebugPython.framework/Versions/9.8/Resources/Python.app/Contents/MacOS/DebugPython" ,
594
+ library = "/Library/Frameworks/DebugPython.framework/Versions/9.8/DebugPython" ,
595
+ )
596
+ ns .add_known_dir (venv_path )
597
+ ns .add_known_dir (f"{ venv_path } /bin" )
598
+ ns .add_known_dir (f"{ venv_path } /lib" )
599
+ ns .add_known_dir (f"{ venv_path } /lib/python9.8" )
600
+ ns .add_known_xfile (f"{ venv_path } /bin/python" )
601
+ ns .add_known_xfile ("/Library/Frameworks/DebugPython.framework/Versions/9.8/Resources/Python.app/Contents/MacOS/DebugPython" )
602
+ ns .add_known_xfile ("/Library/Frameworks/DebugPython.framework/Versions/9.8/bin/python9.8" )
603
+ ns .add_known_dir ("/Library/Frameworks/DebugPython.framework/Versions/9.8/lib/python9.8/lib-dynload" )
604
+ ns .add_known_xfile ("/Library/Frameworks/DebugPython.framework/Versions/9.8/lib/python9.8/os.py" )
605
+ ns .add_known_file (f"{ venv_path } /pyvenv.cfg" , [
606
+ "home = /Library/Frameworks/DebugPython.framework/Versions/9.8/bin"
607
+ ])
608
+ expected = dict (
609
+ executable = f"{ venv_path } /bin/python" ,
610
+ prefix = "/Library/Frameworks/DebugPython.framework/Versions/9.8" ,
611
+ exec_prefix = "/Library/Frameworks/DebugPython.framework/Versions/9.8" ,
612
+ base_executable = "/Library/Frameworks/DebugPython.framework/Versions/9.8/bin/python9.8" ,
613
+ base_prefix = "/Library/Frameworks/DebugPython.framework/Versions/9.8" ,
614
+ base_exec_prefix = "/Library/Frameworks/DebugPython.framework/Versions/9.8" ,
615
+ module_search_paths_set = 1 ,
616
+ module_search_paths = [
617
+ "/Library/Frameworks/DebugPython.framework/Versions/9.8/lib/python98.zip" ,
618
+ "/Library/Frameworks/DebugPython.framework/Versions/9.8/lib/python9.8" ,
619
+ "/Library/Frameworks/DebugPython.framework/Versions/9.8/lib/python9.8/lib-dynload" ,
620
+ ],
621
+ )
622
+ actual = getpath (ns , expected )
623
+ self .assertEqual (expected , actual )
624
+
449
625
def test_venv_macos (self ):
450
626
"""Test a venv layout on macOS.
451
627
@@ -787,6 +963,7 @@ def __init__(self, *a, argv0=None, config=None, **kw):
787
963
self ["config" ] = DEFAULT_CONFIG .copy ()
788
964
self ["os_name" ] = "posix"
789
965
self ["PLATLIBDIR" ] = "lib"
966
+ self ["WITH_NEXT_FRAMEWORK" ] = 0
790
967
super ().__init__ (* a , ** kw )
791
968
if argv0 :
792
969
self ["config" ]["orig_argv" ] = [argv0 ]
0 commit comments