@@ -2558,9 +2558,8 @@ def test_installer_should_use_the_locked_version_of_git_dependencies_without_ref
2558
2558
)
2559
2559
2560
2560
2561
- # https://github.com/python-poetry/poetry/issues/6710
2562
2561
@pytest .mark .parametrize ("env_platform" , ["darwin" , "linux" ])
2563
- def test_installer_distinguishes_locked_packages_by_source (
2562
+ def test_installer_distinguishes_locked_packages_with_local_version_by_source (
2564
2563
pool : RepositoryPool ,
2565
2564
locker : Locker ,
2566
2565
installed : CustomInstalledRepository ,
@@ -2569,6 +2568,7 @@ def test_installer_distinguishes_locked_packages_by_source(
2569
2568
package : ProjectPackage ,
2570
2569
env_platform : str ,
2571
2570
) -> None :
2571
+ """https://github.com/python-poetry/poetry/issues/6710"""
2572
2572
# Require 1.11.0+cpu from pytorch for most platforms, but specify 1.11.0 and pypi on
2573
2573
# darwin.
2574
2574
package .add_dependency (
@@ -2661,6 +2661,110 @@ def test_installer_distinguishes_locked_packages_by_source(
2661
2661
)
2662
2662
2663
2663
2664
+ @pytest .mark .parametrize ("env_platform_machine" , ["aarch64" , "amd64" ])
2665
+ def test_installer_distinguishes_locked_packages_with_same_version_by_source (
2666
+ pool : RepositoryPool ,
2667
+ locker : Locker ,
2668
+ installed : CustomInstalledRepository ,
2669
+ config : Config ,
2670
+ repo : Repository ,
2671
+ package : ProjectPackage ,
2672
+ env_platform_machine : str ,
2673
+ ) -> None :
2674
+ """https://github.com/python-poetry/poetry/issues/8303"""
2675
+ package .add_dependency (
2676
+ Factory .create_dependency (
2677
+ "kivy" ,
2678
+ {
2679
+ "version" : "2.2.1" ,
2680
+ "markers" : "platform_machine == 'aarch64'" ,
2681
+ "source" : "pywheels" ,
2682
+ },
2683
+ )
2684
+ )
2685
+ package .add_dependency (
2686
+ Factory .create_dependency (
2687
+ "kivy" ,
2688
+ {
2689
+ "version" : "2.2.1" ,
2690
+ "markers" : "platform_machine != 'aarch64'" ,
2691
+ "source" : "PyPI" ,
2692
+ },
2693
+ )
2694
+ )
2695
+
2696
+ # Locking finds both the pypi and the pyhweels packages.
2697
+ locker .locked (True )
2698
+ locker .mock_lock_data (
2699
+ {
2700
+ "package" : [
2701
+ {
2702
+ "name" : "kivy" ,
2703
+ "version" : "2.2.1" ,
2704
+ "optional" : False ,
2705
+ "files" : [],
2706
+ "python-versions" : "*" ,
2707
+ },
2708
+ {
2709
+ "name" : "kivy" ,
2710
+ "version" : "2.2.1" ,
2711
+ "optional" : False ,
2712
+ "files" : [],
2713
+ "python-versions" : "*" ,
2714
+ "source" : {
2715
+ "type" : "legacy" ,
2716
+ "url" : "https://www.piwheels.org/simple" ,
2717
+ "reference" : "pywheels" ,
2718
+ },
2719
+ },
2720
+ ],
2721
+ "metadata" : {
2722
+ "python-versions" : "*" ,
2723
+ "platform" : "*" ,
2724
+ "content-hash" : "123456789" ,
2725
+ },
2726
+ }
2727
+ )
2728
+ installer = Installer (
2729
+ NullIO (),
2730
+ MockEnv (platform_machine = env_platform_machine ),
2731
+ package ,
2732
+ locker ,
2733
+ pool ,
2734
+ config ,
2735
+ installed = installed ,
2736
+ executor = Executor (
2737
+ MockEnv (platform_machine = env_platform_machine ),
2738
+ pool ,
2739
+ config ,
2740
+ NullIO (),
2741
+ ),
2742
+ )
2743
+ result = installer .run ()
2744
+ assert result == 0
2745
+
2746
+ # Results of installation are consistent with the platform requirements.
2747
+ version = "2.2.1"
2748
+ if env_platform_machine == "aarch64" :
2749
+ source_type = "legacy"
2750
+ source_url = "https://www.piwheels.org/simple"
2751
+ source_reference = "pywheels"
2752
+ else :
2753
+ source_type = None
2754
+ source_url = None
2755
+ source_reference = None
2756
+
2757
+ assert isinstance (installer .executor , Executor )
2758
+ assert len (installer .executor .installations ) == 1
2759
+ assert installer .executor .installations [0 ] == Package (
2760
+ "kivy" ,
2761
+ version ,
2762
+ source_type = source_type ,
2763
+ source_url = source_url ,
2764
+ source_reference = source_reference ,
2765
+ )
2766
+
2767
+
2664
2768
@pytest .mark .parametrize ("env_platform" , ["darwin" , "linux" ])
2665
2769
def test_explicit_source_dependency_with_direct_origin_dependency (
2666
2770
pool : RepositoryPool ,
@@ -2675,12 +2779,13 @@ def test_explicit_source_dependency_with_direct_origin_dependency(
2675
2779
A dependency with explicit source should not be satisfied by
2676
2780
a direct origin dependency even if there is a version match.
2677
2781
"""
2782
+ demo_url = "https://python-poetry.org/distributions/demo-0.1.0-py2.py3-none-any.whl"
2678
2783
package .add_dependency (
2679
2784
Factory .create_dependency (
2680
2785
"demo" ,
2681
2786
{
2682
2787
"markers" : "sys_platform != 'darwin'" ,
2683
- "url" : "https://python-poetry.org/distributions/demo-0.1.0-py2.py3-none-any.whl" ,
2788
+ "url" : demo_url ,
2684
2789
},
2685
2790
)
2686
2791
)
@@ -2698,6 +2803,50 @@ def test_explicit_source_dependency_with_direct_origin_dependency(
2698
2803
repo .add_package (get_package ("pendulum" , "1.4.4" ))
2699
2804
repo .add_package (get_package ("demo" , "0.1.0" ))
2700
2805
2806
+ # Locking finds both the direct origin and the explicit source packages.
2807
+ locker .locked (True )
2808
+ locker .mock_lock_data (
2809
+ {
2810
+ "package" : [
2811
+ {
2812
+ "name" : "demo" ,
2813
+ "version" : "0.1.0" ,
2814
+ "optional" : False ,
2815
+ "files" : [],
2816
+ "python-versions" : "*" ,
2817
+ "dependencies" : {"pendulum" : ">=1.4.4" },
2818
+ "source" : {
2819
+ "type" : "url" ,
2820
+ "url" : demo_url ,
2821
+ },
2822
+ },
2823
+ {
2824
+ "name" : "demo" ,
2825
+ "version" : "0.1.0" ,
2826
+ "optional" : False ,
2827
+ "files" : [],
2828
+ "python-versions" : "*" ,
2829
+ "source" : {
2830
+ "type" : "legacy" ,
2831
+ "url" : "https://www.demo.org/simple" ,
2832
+ "reference" : "repo" ,
2833
+ },
2834
+ },
2835
+ {
2836
+ "name" : "pendulum" ,
2837
+ "version" : "1.4.4" ,
2838
+ "optional" : False ,
2839
+ "files" : [],
2840
+ "python-versions" : "*" ,
2841
+ },
2842
+ ],
2843
+ "metadata" : {
2844
+ "python-versions" : "*" ,
2845
+ "platform" : "*" ,
2846
+ "content-hash" : "123456789" ,
2847
+ },
2848
+ }
2849
+ )
2701
2850
installer = Installer (
2702
2851
NullIO (),
2703
2852
MockEnv (platform = env_platform ),
@@ -2725,8 +2874,16 @@ def test_explicit_source_dependency_with_direct_origin_dependency(
2725
2874
"demo" ,
2726
2875
"0.1.0" ,
2727
2876
source_type = "url" ,
2728
- source_url = "https://python-poetry.org/distributions/demo-0.1.0-py2.py3-none-any.whl" ,
2877
+ source_url = demo_url ,
2729
2878
),
2730
2879
]
2731
2880
else :
2732
- assert installer .executor .installations == [Package ("demo" , "0.1.0" )]
2881
+ assert installer .executor .installations == [
2882
+ Package (
2883
+ "demo" ,
2884
+ "0.1.0" ,
2885
+ source_type = "legacy" ,
2886
+ source_url = "https://www.demo.org/simple" ,
2887
+ source_reference = "repo" ,
2888
+ )
2889
+ ]
0 commit comments