File tree Expand file tree Collapse file tree 3 files changed +41
-0
lines changed
testdata/context/overrides/settings Expand file tree Collapse file tree 3 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -192,6 +192,15 @@ class ResolverDist(pydantic.BaseModel):
192192 .. versionadded:: 0.52
193193 """
194194
195+ use_pypi_org_metadata : bool | None = None
196+ """Can use metadata from pypi.org JSON / Simple API?
197+
198+ None (default) is for auto-setting. Packages with customizations (config,
199+ patches, plugins) don't use pypi.org metadata by default.
200+
201+ .. versionadded:: 0.70
202+ """
203+
195204 @pydantic .model_validator (mode = "after" )
196205 def validate_ignore_platform (self ) -> typing .Self :
197206 if self .ignore_platform and not self .include_wheels :
@@ -814,6 +823,21 @@ def resolver_ignore_platform(self) -> bool:
814823 """Ignore the platform when resolving with wheels?"""
815824 return self ._ps .resolver_dist .ignore_platform
816825
826+ @property
827+ def use_pypi_org_metadata (self ) -> bool :
828+ """Can use metadata from pypi.org JSON / Simple API?
829+
830+ By default, packages with customizations do not use public
831+ pypi.org metadata.
832+ """
833+ ps = self ._ps
834+ flag = ps .resolver_dist .use_pypi_org_metadata
835+ if flag is not None :
836+ # flag is set
837+ return flag
838+ # return True if package does not have any customizations
839+ return not self .has_customizations
840+
817841 def build_dir (self , sdist_root_dir : pathlib .Path ) -> pathlib .Path :
818842 """Build directory for package (e.g. subdirectory)"""
819843 build_dir = self ._ps .build_dir
Original file line number Diff line number Diff line change 7979 "include_wheels" : True ,
8080 "sdist_server_url" : "https://sdist.test/egg" ,
8181 "ignore_platform" : True ,
82+ "use_pypi_org_metadata" : True ,
8283 },
8384 "variants" : {
8485 "cpu" : {
138139 "include_sdists" : True ,
139140 "include_wheels" : False ,
140141 "ignore_platform" : False ,
142+ "use_pypi_org_metadata" : None ,
141143 },
142144 "variants" : {},
143145}
176178 "include_sdists" : True ,
177179 "include_wheels" : False ,
178180 "ignore_platform" : False ,
181+ "use_pypi_org_metadata" : None ,
179182 },
180183 "variants" : {
181184 "cpu" : {
@@ -785,3 +788,16 @@ def test_pbi_annotations(testdata_context: context.WorkContext) -> None:
785788
786789 pbi = testdata_context .settings .package_build_info (TEST_EMPTY_PKG )
787790 assert pbi .annotations == {}
791+
792+
793+ def test_use_pypi_org_metadata (testdata_context : context .WorkContext ) -> None :
794+ pbi = testdata_context .settings .package_build_info (TEST_PKG )
795+ assert pbi .use_pypi_org_metadata
796+
797+ pbi = testdata_context .settings .package_build_info (TEST_EMPTY_PKG )
798+ assert not pbi .use_pypi_org_metadata
799+
800+ pbi = testdata_context .settings .package_build_info (
801+ "somepackage_without_customization"
802+ )
803+ assert pbi .use_pypi_org_metadata
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ resolver_dist:
4040 include_sdists : true
4141 include_wheels : true
4242 ignore_platform : true
43+ use_pypi_org_metadata : true
4344variants :
4445 cpu :
4546 annotations :
You can’t perform that action at this time.
0 commit comments