diff --git a/.gitignore b/.gitignore index 404ce6a..20c72c1 100644 --- a/.gitignore +++ b/.gitignore @@ -181,3 +181,6 @@ hugo/binaries/* # Hugo builder cache hugo_cache/ + +# Hugo version file +hugo/VERSION diff --git a/hugo/cli.py b/hugo/cli.py index 61c344a..5730bcd 100644 --- a/hugo/cli.py +++ b/hugo/cli.py @@ -14,7 +14,8 @@ from sys import argv from sys import platform as sysplatform -HUGO_VERSION = "0.124.1" +with open(path.join(path.dirname(__file__), "VERSION")) as f: # noqa: PTH123, PTH120, PTH118 + HUGO_VERSION = f.read().strip() FILE_EXT = ".exe" if sysplatform == "win32" else "" diff --git a/setup.py b/setup.py index 96fe146..aa4aede 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,6 @@ from setuptools.command.build_py import build_py from wheel.bdist_wheel import bdist_wheel -# Has to be kept in sync with the version in hugo/cli.py HUGO_VERSION = "0.124.1" HUGO_RELEASE = ( f"https://github.com/gohugoio/hugo/archive/refs/tags/v{HUGO_VERSION}.tar.gz" @@ -66,7 +65,7 @@ def finalize_options(self) -> None: def run(self) -> None: """Write the version of Hugo being built to hugo/VERSION.""" - with Path.open("hugo/VERSION", "w") as version_file: + with open("hugo/VERSION", "w") as version_file: # noqa: PTH123 version_file.write(HUGO_VERSION) version_file.write("\n") @@ -356,6 +355,7 @@ def run(self): ) ], cmdclass={ + "build_py": HugoWriter, "build_ext": HugoBuilder, "clean": Cleaner, "bdist_wheel": HugoWheel,