File tree Expand file tree Collapse file tree 4 files changed +29
-2
lines changed Expand file tree Collapse file tree 4 files changed +29
-2
lines changed Original file line number Diff line number Diff line change 33
44bugfix
55------
6+
7+ * fix #919: restore legacy version-file behaviour for external callers + add Deprecation warning
68* fix #918: use packaging from setuptools for self-build
79* fix #914: ignore the deprecated git archival plugin as its integrated now
810* fix #912: ensure mypy safety of the version template + regression test
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ def main(args: list[str] | None = None) -> None:
3131 )
3232 config = Configuration (inferred_root )
3333
34- version = _get_version (config )
34+ version = _get_version (config , force_write_version_files = False )
3535 if version is None :
3636 raise SystemExit ("ERROR: no version found for" , opts )
3737 if opts .strip_dev :
Original file line number Diff line number Diff line change @@ -84,12 +84,20 @@ def write_version_files(
8484
8585
8686def _get_version (
87- config : Configuration , force_write_version_files : bool = False
87+ config : Configuration , force_write_version_files : bool | None = None
8888) -> str | None :
8989 parsed_version = parse_version (config )
9090 if parsed_version is None :
9191 return None
9292 version_string = _format_version (parsed_version )
93+ if force_write_version_files is None :
94+ force_write_version_files = True
95+ warnings .warn (
96+ "force_write_version_files ought to be set,"
97+ " presuming the legacy True value" ,
98+ DeprecationWarning ,
99+ )
100+
93101 if force_write_version_files :
94102 write_version_files (config , version = version_string , scm_version = parsed_version )
95103
Original file line number Diff line number Diff line change @@ -242,3 +242,20 @@ def __repr__(self) -> str:
242242 # to create a test?
243243 # monkeypatch.setenv(setuptools_scm.PRETEND_KEY, "1.0.1")
244244 # assert setuptools_scm.get_version(version_cls=MyVersion) == "1"
245+
246+
247+ def test_internal_get_version_warns_for_version_files (tmp_path : Path ) -> None :
248+ tmp_path .joinpath ("PKG-INFO" ).write_text ("Version: 0.1" )
249+ c = Configuration (root = tmp_path , fallback_root = tmp_path )
250+ with pytest .warns (
251+ DeprecationWarning ,
252+ match = "force_write_version_files ought to be set,"
253+ " presuming the legacy True value" ,
254+ ):
255+ ver = setuptools_scm ._get_version (c )
256+ assert ver == "0.1"
257+
258+ # force write won't write as no version file is configured
259+ assert setuptools_scm ._get_version (c , force_write_version_files = False ) == ver
260+
261+ assert setuptools_scm ._get_version (c , force_write_version_files = True ) == ver
You can’t perform that action at this time.
0 commit comments