chore: add setuptools-scm with version
All checks were successful
build / build (push) Successful in 2m14s
All checks were successful
build / build (push) Successful in 2m14s
This commit is contained in:
parent
df5295258f
commit
b90cf8c38f
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -160,3 +160,5 @@ cython_debug/
|
|||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
|
||||
joj3_config_generator/_version.py
|
||||
|
|
|
@ -1,61 +1,70 @@
|
|||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.4.0
|
||||
hooks:
|
||||
- id: check-yaml
|
||||
- id: check-toml
|
||||
- id: end-of-file-fixer
|
||||
- id: trailing-whitespace
|
||||
- repo: https://github.com/Lucas-C/pre-commit-hooks
|
||||
rev: v1.5.5
|
||||
hooks:
|
||||
- id: remove-crlf
|
||||
- id: remove-tabs
|
||||
- repo: https://github.com/google/yamlfmt
|
||||
rev: v0.13.0
|
||||
hooks:
|
||||
- id: yamlfmt
|
||||
exclude: '^tests/'
|
||||
- repo: https://github.com/pdm-project/pdm
|
||||
rev: 2.19.2
|
||||
hooks:
|
||||
- id: pdm-lock-check
|
||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||
rev: v1.11.2
|
||||
hooks:
|
||||
- id: mypy
|
||||
additional_dependencies:
|
||||
- pydantic
|
||||
- types-PyYAML
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v3.17.0
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
- repo: https://github.com/hadialqattan/pycln
|
||||
rev: v2.5.0
|
||||
hooks:
|
||||
- id: pycln
|
||||
args: [-a, --config=pyproject.toml]
|
||||
- repo: https://github.com/PyCQA/bandit
|
||||
rev: 1.7.10
|
||||
hooks:
|
||||
- id: bandit
|
||||
args: [-c, pyproject.toml]
|
||||
additional_dependencies: ["bandit[toml]"]
|
||||
- repo: https://github.com/PyCQA/isort
|
||||
rev: 5.13.2
|
||||
hooks:
|
||||
- id: isort
|
||||
args: [--profile, black, --filter-files]
|
||||
- repo: https://github.com/psf/black
|
||||
rev: 24.8.0
|
||||
hooks:
|
||||
- id: black
|
||||
# - repo: local
|
||||
# hooks:
|
||||
# - id: pytest-check
|
||||
# name: pytest-check
|
||||
# entry: pdm run test
|
||||
# language: system
|
||||
# pass_filenames: false
|
||||
# always_run: true
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.4.0
|
||||
hooks:
|
||||
- id: check-yaml
|
||||
- id: check-toml
|
||||
- id: end-of-file-fixer
|
||||
- id: trailing-whitespace
|
||||
- repo: https://github.com/Lucas-C/pre-commit-hooks
|
||||
rev: v1.5.5
|
||||
hooks:
|
||||
- id: remove-crlf
|
||||
- id: remove-tabs
|
||||
- repo: https://github.com/google/yamlfmt
|
||||
rev: v0.13.0
|
||||
hooks:
|
||||
- id: yamlfmt
|
||||
exclude: '^tests/'
|
||||
- repo: https://github.com/pdm-project/pdm
|
||||
rev: 2.19.2
|
||||
hooks:
|
||||
- id: pdm-lock-check
|
||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||
rev: v1.11.2
|
||||
hooks:
|
||||
- id: mypy
|
||||
additional_dependencies:
|
||||
- pydantic
|
||||
- types-PyYAML
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v3.17.0
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
- repo: https://github.com/hadialqattan/pycln
|
||||
rev: v2.5.0
|
||||
hooks:
|
||||
- id: pycln
|
||||
args: [-a, --config=pyproject.toml]
|
||||
- repo: https://github.com/PyCQA/bandit
|
||||
rev: 1.7.10
|
||||
hooks:
|
||||
- id: bandit
|
||||
args: [-c, pyproject.toml]
|
||||
additional_dependencies: ["bandit[toml]"]
|
||||
- repo: https://github.com/PyCQA/isort
|
||||
rev: 5.13.2
|
||||
hooks:
|
||||
- id: isort
|
||||
args: [--profile, black, --filter-files]
|
||||
- repo: https://github.com/psf/black
|
||||
rev: 24.8.0
|
||||
hooks:
|
||||
- id: black
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: generate-version-file
|
||||
name: generate _version.py
|
||||
entry: pdm build --no-wheel
|
||||
language: system
|
||||
pass_filenames: false
|
||||
always_run: true
|
||||
|
||||
# - repo: local
|
||||
# hooks:
|
||||
# - id: pytest-check
|
||||
# name: pytest-check
|
||||
# entry: pdm run test
|
||||
# language: system
|
||||
# pass_filenames: false
|
||||
# always_run: true
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
try:
|
||||
from ._version import version as __version__
|
||||
except ImportError:
|
||||
__version__ = "0.0.0+development-untracked"
|
||||
|
||||
|
||||
def get_version() -> str:
|
||||
return __version__
|
|
@ -6,6 +6,7 @@ import tomlkit
|
|||
import typer
|
||||
from typing_extensions import Annotated
|
||||
|
||||
from joj3_config_generator import get_version
|
||||
from joj3_config_generator.generator import (
|
||||
convert_joj1_conf,
|
||||
convert_joj3_conf,
|
||||
|
@ -19,7 +20,31 @@ from joj3_config_generator.loader import (
|
|||
from joj3_config_generator.models.const import JOJ3_CONFIG_ROOT
|
||||
from joj3_config_generator.utils.logger import logger
|
||||
|
||||
app = typer.Typer(add_completion=False)
|
||||
app = typer.Typer(add_completion=False, name="joj3-forge")
|
||||
|
||||
|
||||
def version_callback(value: bool) -> None:
|
||||
if value:
|
||||
print(f"{app.info.name} Version: {get_version()}")
|
||||
raise typer.Exit()
|
||||
|
||||
|
||||
@app.callback()
|
||||
def common(
|
||||
ctx: typer.Context,
|
||||
version: Annotated[
|
||||
Optional[bool],
|
||||
typer.Option(
|
||||
"--version",
|
||||
help="Show the application version and exit.",
|
||||
callback=version_callback,
|
||||
is_eager=True,
|
||||
),
|
||||
] = None,
|
||||
) -> None:
|
||||
if ctx.resilient_parsing:
|
||||
return
|
||||
logger.info(f"Running '{ctx.invoked_subcommand}' command. Version: {get_version()}")
|
||||
|
||||
|
||||
@app.command(hidden=True)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[build-system]
|
||||
requires = ["pdm-backend"]
|
||||
build-backend = "pdm.backend"
|
||||
requires = ["pdm-backend", "setuptools>=64", "setuptools-scm>=8"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "JOJ3-config-generator"
|
||||
|
@ -71,3 +71,7 @@ init_forbid_extra = true
|
|||
init_typed = true
|
||||
warn_required_dynamic_aliases = true
|
||||
warn_untyped_fields = true
|
||||
|
||||
[tool.setuptools_scm]
|
||||
write_to = "joj3_config_generator/_version.py"
|
||||
fallback_version = "0.0.0+unknown"
|
||||
|
|
Loading…
Reference in New Issue
Block a user