()
| 101 | |
| 102 | |
| 103 | def test_clp_prereleases_resolver(): |
| 104 | # type: () -> None |
| 105 | |
| 106 | def build_prerelease_pex(pex_options): |
| 107 | # type: (Namespace) -> PEXBuilder |
| 108 | target_config = target_options.configure(pex_options, pip_configuration=PipConfiguration()) |
| 109 | return build_pex( |
| 110 | requirement_configuration=requirement_options.configure(pex_options), |
| 111 | resolver_configuration=resolver_options.configure(pex_options), |
| 112 | interpreter_constraints=target_config.interpreter_constraints, |
| 113 | targets=target_config.resolve_targets(), |
| 114 | options=pex_options, |
| 115 | ) |
| 116 | |
| 117 | with built_wheel(name="prerelease-dep", version="1.2.3b1") as prerelease_dep, built_wheel( |
| 118 | name="transitive-dep", install_reqs=["prerelease-dep"] |
| 119 | ) as transitive_dep, built_wheel( |
| 120 | name="dep", install_reqs=["prerelease-dep>=1.2", "transitive-dep"] |
| 121 | ) as dep, temporary_dir() as dist_dir, temporary_dir() as cache_dir: |
| 122 | for dist in (prerelease_dep, transitive_dep, dep): |
| 123 | safe_copy(dist, os.path.join(dist_dir, os.path.basename(dist))) |
| 124 | |
| 125 | parser = configure_clp() |
| 126 | |
| 127 | options = parser.parse_args( |
| 128 | args=[ |
| 129 | "--no-index", |
| 130 | "--find-links", |
| 131 | dist_dir, |
| 132 | "--cache-dir", |
| 133 | cache_dir, # Avoid dangling {pex_root}. |
| 134 | "--no-pre", |
| 135 | "dep", |
| 136 | ] |
| 137 | ) |
| 138 | assert not options.allow_prereleases |
| 139 | |
| 140 | if PipVersion.DEFAULT > PipVersion.v25_3: |
| 141 | # N.B.: Pip 26 (via vendoring packaging 26), comes in line with the spec which says that |
| 142 | # if the only available version that satisfies the version specifier is a pre-release it |
| 143 | # should be used by default. |
| 144 | # See: |
| 145 | # + https://packaging.python.org/en/latest/specifications/version-specifiers/#handling-of-pre-releases |
| 146 | # + https://github.com/pypa/packaging/pull/872 |
| 147 | # + https://github.com/pypa/pip/pull/13746 |
| 148 | assert ( |
| 149 | len(build_prerelease_pex(options).info.distributions) == 3 |
| 150 | ), "Should have resolved deps" |
| 151 | else: |
| 152 | with pytest.raises(SystemExit): |
| 153 | build_prerelease_pex(options) |
| 154 | |
| 155 | # When we specify `--pre`, allow_prereleases is True |
| 156 | options = parser.parse_args( |
| 157 | args=[ |
| 158 | "--no-index", |
| 159 | "--find-links", |
| 160 | dist_dir, |
nothing calls this directly
no test coverage detected