|
16 | 16 |
|
17 | 17 | load("@rules_testing//lib:test_suite.bzl", "test_suite") |
18 | 18 | load("//python/private:repo_utils.bzl", "REPO_DEBUG_ENV_VAR", "REPO_VERBOSITY_ENV_VAR", "repo_utils") # buildifier: disable=bzl-visibility |
19 | | -load("//python/private/pypi:evaluate_markers.bzl", "evaluate_markers") # buildifier: disable=bzl-visibility |
20 | 19 | load("//python/private/pypi:parse_requirements.bzl", "select_requirement", _parse_requirements = "parse_requirements") # buildifier: disable=bzl-visibility |
21 | 20 | load("//python/private/pypi:pep508_env.bzl", pep508_env = "env") # buildifier: disable=bzl-visibility |
22 | 21 | load("//tests/support/mocks:mocks.bzl", "mocks") |
@@ -68,7 +67,7 @@ foo==0.0.1 --hash=sha256:deadbeef |
68 | 67 | foo[extra]==0.0.1 --hash=sha256:deadbeef |
69 | 68 | """, |
70 | 69 | "requirements_marker": """\ |
71 | | -foo[extra]==0.0.1 ;marker --hash=sha256:deadbeef |
| 70 | +foo[extra]==0.0.1 ; os_name == 'nt' --hash=sha256:deadbeef |
72 | 71 | bar==0.0.1 --hash=sha256:deadbeef |
73 | 72 | """, |
74 | 73 | "requirements_multi_version": """\ |
@@ -441,22 +440,24 @@ def _test_select_requirement_none_platform(env): |
441 | 440 | _tests.append(_test_select_requirement_none_platform) |
442 | 441 |
|
443 | 442 | def _test_env_marker_resolution(env): |
444 | | - """Test environment marker resolution with ``evaluate_markers``.""" |
445 | | - |
446 | | - def _mock_eval_markers(input): |
447 | | - ret = { |
448 | | - "foo[extra]==0.0.1 ;marker --hash=sha256:deadbeef": ["cp311_windows_x86_64"], |
449 | | - } |
450 | | - |
451 | | - env.expect.that_collection(input.keys()).contains_exactly(ret.keys()) |
452 | | - env.expect.that_collection(input.values()[0]).contains_exactly(["cp311_linux_super_exotic", "cp311_windows_x86_64"]) |
453 | | - return ret |
| 443 | + """Test environment marker resolution with platform env information.""" |
454 | 444 |
|
455 | 445 | got = parse_requirements( |
456 | 446 | requirements_by_platform = { |
457 | 447 | "requirements_marker": ["cp311_linux_super_exotic", "cp311_windows_x86_64"], |
458 | 448 | }, |
459 | | - evaluate_markers = _mock_eval_markers, |
| 449 | + platforms = { |
| 450 | + "cp311_linux_super_exotic": struct( |
| 451 | + env = pep508_env(os = "linux", arch = "x86_64", python_version = "3.11.0"), |
| 452 | + whl_abi_tags = [], |
| 453 | + whl_platform_tags = [], |
| 454 | + ), |
| 455 | + "cp311_windows_x86_64": struct( |
| 456 | + env = pep508_env(os = "windows", arch = "x86_64", python_version = "3.11.0"), |
| 457 | + whl_abi_tags = [], |
| 458 | + whl_platform_tags = [], |
| 459 | + ), |
| 460 | + }, |
460 | 461 | ) |
461 | 462 | env.expect.that_collection(got).contains_exactly([ |
462 | 463 | struct( |
@@ -797,17 +798,6 @@ def _test_get_index_urls_different_versions(env): |
797 | 798 | }, |
798 | 799 | ), |
799 | 800 | }, |
800 | | - evaluate_markers = lambda requirements: evaluate_markers( |
801 | | - requirements = requirements, |
802 | | - platforms = { |
803 | | - "cp310_linux_x86_64": struct( |
804 | | - env = {"python_full_version": "3.10.0"}, |
805 | | - ), |
806 | | - "cp39_linux_x86_64": struct( |
807 | | - env = {"python_full_version": "3.9.0"}, |
808 | | - ), |
809 | | - }, |
810 | | - ), |
811 | 801 | ) |
812 | 802 |
|
813 | 803 | env.expect.that_collection(got).contains_exactly([ |
@@ -891,14 +881,6 @@ def _test_get_index_urls_cross_platform(env): |
891 | 881 | ), |
892 | 882 | }, |
893 | 883 | get_index_urls = _get_index_urls, |
894 | | - evaluate_markers = lambda requirements: evaluate_markers( |
895 | | - requirements = requirements, |
896 | | - platforms = { |
897 | | - "cp39_osx_x86_64": struct( |
898 | | - env = {"python_full_version": "3.9.0"}, |
899 | | - ), |
900 | | - }, |
901 | | - ), |
902 | 884 | ) |
903 | 885 |
|
904 | 886 | # distributions must include packages from ALL files, even those with |
@@ -947,14 +929,6 @@ def _test_get_index_urls_single_py_version(env): |
947 | 929 | }, |
948 | 930 | ), |
949 | 931 | }, |
950 | | - evaluate_markers = lambda requirements: evaluate_markers( |
951 | | - requirements = requirements, |
952 | | - platforms = { |
953 | | - "cp310_linux_x86_64": struct( |
954 | | - env = {"python_full_version": "3.10.0"}, |
955 | | - ), |
956 | | - }, |
957 | | - ), |
958 | 932 | ) |
959 | 933 |
|
960 | 934 | env.expect.that_collection(got).contains_exactly([ |
@@ -1004,14 +978,6 @@ def _test_get_index_urls_all_versions(env): |
1004 | 978 | ), |
1005 | 979 | }, |
1006 | 980 | get_index_urls = _get_index_urls, |
1007 | | - evaluate_markers = lambda requirements: evaluate_markers( |
1008 | | - requirements = requirements, |
1009 | | - platforms = { |
1010 | | - "cp39_linux_x86_64": struct( |
1011 | | - env = {"python_full_version": "3.9.0"}, |
1012 | | - ), |
1013 | | - }, |
1014 | | - ), |
1015 | 981 | ) |
1016 | 982 |
|
1017 | 983 | env.expect.that_collection(calls).contains_exactly([ |
|
0 commit comments