Skip to content

Allow updates to version file containing only a version #1375

@tclarke

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmedPrevent from becoming stalefeatureA new feature or a feature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions