mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 10:11:52 +00:00
Fix version parsing
This commit is contained in:
parent
66f0868f45
commit
aebccd1139
6 changed files with 27 additions and 11 deletions
4
Makefile
4
Makefile
|
|
@ -70,11 +70,11 @@ clean:
|
|||
|
||||
.PHONY: isort
|
||||
isort:
|
||||
$(py) isort aiogram tests
|
||||
$(py) isort aiogram tests scripts
|
||||
|
||||
.PHONY: black
|
||||
black:
|
||||
$(py) black aiogram tests
|
||||
$(py) black aiogram tests scripts
|
||||
|
||||
.PHONY: flake8
|
||||
flake8:
|
||||
|
|
|
|||
|
|
@ -27,5 +27,5 @@ __all__ = (
|
|||
"handler",
|
||||
)
|
||||
|
||||
__version__ = "3.0.0a6"
|
||||
__api_version__ = "5.0"
|
||||
__version__ = "3.0.0-alpha.6"
|
||||
__api_version__ = "4.9"
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
3.0.0a5
|
||||
3.0.0a6
|
||||
|
|
|
|||
2
poetry.lock
generated
2
poetry.lock
generated
|
|
@ -1322,7 +1322,7 @@ proxy = ["aiohttp-socks"]
|
|||
[metadata]
|
||||
lock-version = "1.1"
|
||||
python-versions = "^3.7"
|
||||
content-hash = "04fb2562ab4dccbd2b7125670b37a3124c7eeab55dbec4d1e05a7a8d10f97175"
|
||||
content-hash = "ee4cbf4fb0a62ec777bec179dad21e7cea1ced466ab2a5424f54f8764f2955d3"
|
||||
|
||||
[metadata.files]
|
||||
aiofiles = [
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ furo = "^2020.11.15-beta.17"
|
|||
sphinx-prompt = "^1.3.0"
|
||||
Sphinx-Substitution-Extensions = "^2020.9.30"
|
||||
black = "^20.8b1"
|
||||
toml = "^0.10.2"
|
||||
|
||||
[tool.poetry.extras]
|
||||
fast = ["uvloop"]
|
||||
|
|
|
|||
|
|
@ -1,18 +1,33 @@
|
|||
import re
|
||||
from pathlib import Path
|
||||
|
||||
from poetry.factory import Factory
|
||||
from poetry.masonry.metadata import Metadata
|
||||
import toml
|
||||
|
||||
BASE_PATTERN = r'({variable} = ")[a-z0-9.+]+(")'
|
||||
PACKAGE_VERSION = re.compile(BASE_PATTERN.format(variable="__version__"))
|
||||
API_VERSION = re.compile(BASE_PATTERN.format(variable="__api_version__"))
|
||||
|
||||
STAGE_MAPPING = {
|
||||
"alpha": "a",
|
||||
"beta": "b",
|
||||
}
|
||||
|
||||
|
||||
def get_package_version() -> str:
|
||||
poetry_instance = Factory().create_poetry(Path.cwd())
|
||||
meta: Metadata = Metadata.from_package(poetry_instance.package)
|
||||
return meta.version
|
||||
data = toml.load(Path("pyproject.toml").absolute())
|
||||
raw_version: str = data["tool"]["poetry"]["version"]
|
||||
if "-" not in raw_version:
|
||||
return raw_version
|
||||
|
||||
version, stage_build = raw_version.split("-", maxsplit=1)
|
||||
if stage_build:
|
||||
stage, build = stage_build.split(".")
|
||||
if stage_str := STAGE_MAPPING.get(stage):
|
||||
version += f"{stage_str}{build}"
|
||||
else:
|
||||
return raw_version
|
||||
|
||||
return version
|
||||
|
||||
|
||||
def get_telegram_api_version() -> str:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue