-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright (c) Twisted Matrix Laboratories. | ||
# See LICENSE for details. | ||
|
||
import os | ||
import shlex | ||
from typing import TypedDict | ||
|
||
from hatchling.version.source.plugin.interface import VersionSourceInterface | ||
from hatchling.plugin import hookimpl | ||
|
||
from incremental import _load_pyproject_toml, _existing_version | ||
|
||
|
||
class _VersionData(TypedDict): | ||
version: str | ||
|
||
|
||
class IncrementalVersionSource(VersionSourceInterface): | ||
PLUGIN_NAME = "incremental" | ||
|
||
def get_version_data(self) -> _VersionData: | ||
config = _load_pyproject_toml(os.path.join(self.root, "./pyproject.toml")) | ||
return {"version": _existing_version(config.path).public()} | ||
|
||
def set_version(self, version: str, version_data: dict): | ||
raise NotImplementedError( | ||
f"Run `python -m incremental.version --newversion" | ||
f" {shlex.quote(version)}` to set the version.\n\n" | ||
f" See `python -m incremental.version --help` for more options." | ||
) | ||
|
||
|
||
@hookimpl | ||
def hatch_register_version_source(): | ||
return [IncrementalVersionSource] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from ._version import __version__ | ||
|
||
__all__ = ["__version__"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
""" | ||
Provides example_hatchling version information. | ||
""" | ||
|
||
# This file is auto-generated! Do not edit! | ||
# Use `python -m incremental.update example_hatchling` to change this file. | ||
|
||
from incremental import Version | ||
|
||
__version__ = Version("example_hatchling", 24, 7, 0) | ||
__all__ = ["__version__"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[build-system] | ||
requires = [ | ||
"hatchling", | ||
"incremental", | ||
] | ||
build-backend = "hatchling.build" | ||
|
||
[project] | ||
name = "example_hatchling" | ||
dependencies = [ | ||
"incremental", | ||
] | ||
dynamic = ["version"] | ||
|
||
[tool.hatch.version] | ||
source = "incremental" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters