Skip to content

Allow updates to version file containing only a version #1375

Closed

Description

@tclarke

Feature Request

Description

Add a mode to version_variables which adds a bare version number to a file instead of replacing a python variable.

Use cases

A "version" file which contains just a version number (no quotes, etc.). This makes it easier to support multi-language repos which load the contents of that file into their respective version variables. Example of mixed python and c++ via conan:

pyproject.toml

...
[tool.hatch.version]
path = "./version"
pattern = '(?P<version>.+$)'

conanfile.py

...
def set_version(self):
  with open(os.path.join(self.recipe_folder, "version"), "rt") as v:
    self.version = v.read().strip()

Possible implementation

version_variables = [
  "version::nf"
]

Alternative solutions

I'm currently using a build_command:

#!/bin/sh
echo $NEW_VERSION > version

Activity

  1. added
    featureA new feature or a feature request
    triagewaiting for initial maintainer review
    on Nov 19, 2025
  2. added
    confirmedPrevent from becoming stale
    and removed
    triagewaiting for initial maintainer review
    on Dec 15, 2025
  3. codejedi365 commented on Jul 4, 2026

    @codejedi365
    Contributor

    🎉 This issue has been resolved in v10.6.0 🎉

    You can find more information about this release on the GitHub Releases page.

    If your issue persists, please reply here and we will re-open the issue. If you receive a new error, please open a new issue and reference this issue there.

  4. added and removed
    needs-updateNeeds status update from maintainers
    confirmedPrevent from becoming stale
    on Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureA new feature or a feature requestreleased

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions