Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #905 - correct version file template for older python versions #907

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@

v8.0.1
======

bugfix
------

* update version file template to work on older python versions by using type comments

v8.0.0
======

Expand Down
6 changes: 2 additions & 4 deletions src/setuptools_scm/_integration/dump_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
".py": """\
# file generated by setuptools_scm
# don't change, don't track in version control
from __future__ import annotations
__version__ : str = version : str = {version!r}
__version_tuple__ : 'tuple[int | str, ...]' = \\
version_tuple : 'tuple[int | str, ...]' = {version_tuple!r}
__version__ = version = {version!r} # type: str
__version_tuple__ = version_tuple = {version_tuple!r} # type: tuple[int | str, ...]
RonnyPfannschmidt marked this conversation as resolved.
Show resolved Hide resolved
""",
".txt": "{version}",
}
Expand Down
8 changes: 4 additions & 4 deletions testing/test_basic_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ def read(name: str) -> str:
scm_version = meta("1.0", distance=42, config=c)
dump_version(tmp_path, version, "first.py", scm_version=scm_version)
lines = read("first.py").splitlines()
assert lines[3:] == [
"__version__ : str = version : str = '1.0.dev42'",
"__version_tuple__ : 'tuple[int | str, ...]' = \\",
" version_tuple : 'tuple[int | str, ...]' = (1, 0, 'dev42')",
assert lines[-2:] == [
"__version__ = version = '1.0.dev42' # type: str",
"__version_tuple__ = version_tuple = (1, 0, 'dev42')"
" # type: tuple[int | str, ...]",
RonnyPfannschmidt marked this conversation as resolved.
Show resolved Hide resolved
]

version = "1.0.1+g4ac9d2c"
Expand Down
20 changes: 20 additions & 0 deletions testing/test_functions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import annotations

import shutil
import subprocess
from pathlib import Path

import pytest
Expand Down Expand Up @@ -108,6 +110,24 @@ def test_dump_version_modern(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) ->
assert target.read_text() == version


def test_dump_version_on_old_python(tmp_path: Path) -> None:
python37 = shutil.which("python3.7")
if python37 is None:
pytest.skip("python3.7 not found")
from setuptools_scm._integration.dump_version import write_version_to_path

version = "1.2.3"
scm_version = meta(version, config=c)
write_version_to_path(
tmp_path / "VERSION.py", template=None, version=version, scm_version=scm_version
)
subprocess.run(
[python37, "-c", "import VERSION;print(VERSION.version)"],
cwd=tmp_path,
check=True,
)


def test_has_command() -> None:
with pytest.warns(RuntimeWarning, match="yadayada"):
assert not has_command("yadayada_setuptools_aint_ne")
Expand Down
Loading