@@ -13208,6 +13208,170 @@ fn lock_explicit_index() -> Result<()> {
13208
13208
Ok(())
13209
13209
}
13210
13210
13211
+ #[test]
13212
+ fn lock_explicit_default_index() -> Result<()> {
13213
+ let context = TestContext::new("3.12");
13214
+
13215
+ let pyproject_toml = context.temp_dir.child("pyproject.toml");
13216
+ pyproject_toml.write_str(
13217
+ r#"
13218
+ [project]
13219
+ name = "project"
13220
+ version = "0.1.0"
13221
+ requires-python = ">=3.12"
13222
+ dependencies = ["iniconfig==2.0.0"]
13223
+
13224
+ [build-system]
13225
+ requires = ["setuptools>=42"]
13226
+ build-backend = "setuptools.build_meta"
13227
+
13228
+ [tool.uv.sources]
13229
+ iniconfig = { index = "test" }
13230
+
13231
+ [[tool.uv.index]]
13232
+ name = "test"
13233
+ url = "https://test.pypi.org/simple"
13234
+ explicit = true
13235
+ default = true
13236
+ "#,
13237
+ )?;
13238
+
13239
+ uv_snapshot!(context.filters(), context.lock(), @r###"
13240
+ success: true
13241
+ exit_code: 0
13242
+ ----- stdout -----
13243
+
13244
+ ----- stderr -----
13245
+ Resolved 2 packages in [TIME]
13246
+ "###);
13247
+
13248
+ let lock = fs_err::read_to_string(context.temp_dir.join("uv.lock")).unwrap();
13249
+
13250
+ insta::with_settings!({
13251
+ filters => context.filters(),
13252
+ }, {
13253
+ assert_snapshot!(
13254
+ lock, @r###"
13255
+ version = 1
13256
+ requires-python = ">=3.12"
13257
+
13258
+ [options]
13259
+ exclude-newer = "2024-03-25T00:00:00Z"
13260
+
13261
+ [[package]]
13262
+ name = "iniconfig"
13263
+ version = "2.0.0"
13264
+ source = { registry = "https://test.pypi.org/simple" }
13265
+ sdist = { url = "https://test-files.pythonhosted.org/packages/d7/4b/cbd8e699e64a6f16ca3a8220661b5f83792b3017d0f79807cb8708d33913/iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3", size = 4646 }
13266
+ wheels = [
13267
+ { url = "https://test-files.pythonhosted.org/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374", size = 5892 },
13268
+ ]
13269
+
13270
+ [[package]]
13271
+ name = "project"
13272
+ version = "0.1.0"
13273
+ source = { editable = "." }
13274
+ dependencies = [
13275
+ { name = "iniconfig" },
13276
+ ]
13277
+
13278
+ [package.metadata]
13279
+ requires-dist = [{ name = "iniconfig", specifier = "==2.0.0", index = "https://test.pypi.org/simple" }]
13280
+ "###
13281
+ );
13282
+ });
13283
+
13284
+ pyproject_toml.write_str(
13285
+ r#"
13286
+ [project]
13287
+ name = "project"
13288
+ version = "0.1.0"
13289
+ requires-python = ">=3.12"
13290
+ dependencies = ["anyio"]
13291
+
13292
+ [build-system]
13293
+ requires = ["setuptools>=42"]
13294
+ build-backend = "setuptools.build_meta"
13295
+
13296
+ [[tool.uv.index]]
13297
+ name = "test"
13298
+ url = "https://test.pypi.org/simple"
13299
+ explicit = true
13300
+ default = true
13301
+ "#,
13302
+ )?;
13303
+
13304
+ uv_snapshot!(context.filters(), context.lock().arg("--verbose"), @r###"
13305
+ success: false
13306
+ exit_code: 1
13307
+ ----- stdout -----
13308
+
13309
+ ----- stderr -----
13310
+ DEBUG uv [VERSION] ([COMMIT] DATE)
13311
+ DEBUG Found workspace root: `[TEMP_DIR]/`
13312
+ DEBUG Adding current workspace member: `[TEMP_DIR]/`
13313
+ DEBUG Using Python request `>=3.12` from `requires-python` metadata
13314
+ DEBUG The virtual environment's Python version satisfies `>=3.12`
13315
+ DEBUG Using request timeout of [TIME]
13316
+ DEBUG Found static `pyproject.toml` for: project @ file://[TEMP_DIR]/
13317
+ DEBUG No workspace root found, using project root
13318
+ DEBUG Ignoring existing lockfile due to mismatched `requires-dist` for: `project==0.1.0`
13319
+ Expected: {Requirement { name: PackageName("anyio"), extras: [], marker: true, source: Registry { specifier: VersionSpecifiers([]), index: None }, origin: None }}
13320
+ Actual: {Requirement { name: PackageName("iniconfig"), extras: [], marker: true, source: Registry { specifier: VersionSpecifiers([VersionSpecifier { operator: Equal, version: "2.0.0" }]), index: Some(Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("test.pypi.org")), port: None, path: "/simple", query: None, fragment: None }) }, origin: None }}
13321
+ DEBUG Solving with installed Python version: 3.12.[X]
13322
+ DEBUG Solving with target Python version: >=3.12
13323
+ DEBUG Adding direct dependency: project*
13324
+ DEBUG Searching for a compatible version of project @ file://[TEMP_DIR]/ (*)
13325
+ DEBUG Adding transitive dependency for project==0.1.0: anyio*
13326
+ DEBUG Searching for a compatible version of anyio (*)
13327
+ DEBUG No compatible version found for: anyio
13328
+ DEBUG Searching for a compatible version of project @ file://[TEMP_DIR]/ (<0.1.0 | >0.1.0)
13329
+ DEBUG No compatible version found for: project
13330
+ × No solution found when resolving dependencies:
13331
+ ╰─▶ Because anyio was not found in the provided package locations and your project depends on anyio, we can conclude that your project's requirements are unsatisfiable.
13332
+
13333
+ hint: Packages were unavailable because index lookups were disabled and no additional package locations were provided (try: `--find-links <uri>`)
13334
+ "###);
13335
+
13336
+ let lock = fs_err::read_to_string(context.temp_dir.join("uv.lock")).unwrap();
13337
+
13338
+ insta::with_settings!({
13339
+ filters => context.filters(),
13340
+ }, {
13341
+ assert_snapshot!(
13342
+ lock, @r###"
13343
+ version = 1
13344
+ requires-python = ">=3.12"
13345
+
13346
+ [options]
13347
+ exclude-newer = "2024-03-25T00:00:00Z"
13348
+
13349
+ [[package]]
13350
+ name = "iniconfig"
13351
+ version = "2.0.0"
13352
+ source = { registry = "https://test.pypi.org/simple" }
13353
+ sdist = { url = "https://test-files.pythonhosted.org/packages/d7/4b/cbd8e699e64a6f16ca3a8220661b5f83792b3017d0f79807cb8708d33913/iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3", size = 4646 }
13354
+ wheels = [
13355
+ { url = "https://test-files.pythonhosted.org/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374", size = 5892 },
13356
+ ]
13357
+
13358
+ [[package]]
13359
+ name = "project"
13360
+ version = "0.1.0"
13361
+ source = { editable = "." }
13362
+ dependencies = [
13363
+ { name = "iniconfig" },
13364
+ ]
13365
+
13366
+ [package.metadata]
13367
+ requires-dist = [{ name = "iniconfig", specifier = "==2.0.0", index = "https://test.pypi.org/simple" }]
13368
+ "###
13369
+ );
13370
+ });
13371
+
13372
+ Ok(())
13373
+ }
13374
+
13211
13375
#[test]
13212
13376
fn lock_named_index() -> Result<()> {
13213
13377
let context = TestContext::new("3.12");
0 commit comments