mirror of
https://github.com/Garmelon/PFERD.git
synced 2026-04-12 23:45:05 +02:00
Store version in project metadata
This commit is contained in:
parent
21a266e302
commit
f600d682e7
11 changed files with 45 additions and 22 deletions
4
.github/workflows/build-and-release.yml
vendored
4
.github/workflows/build-and-release.yml
vendored
|
|
@ -41,7 +41,9 @@ jobs:
|
|||
run: git diff --exit-code
|
||||
|
||||
- name: Build
|
||||
run: ./scripts/build
|
||||
run: |
|
||||
./scripts/build
|
||||
./dist/pferd${{ matrix.os == 'windows-latest' && '.exe' || '' }} --version
|
||||
|
||||
- name: Rename binary
|
||||
# Glob in source location because on windows pyinstaller creates a file
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
import importlib.metadata
|
||||
import warnings
|
||||
|
||||
try:
|
||||
__version__ = importlib.metadata.version(__name__)
|
||||
except importlib.metadata.PackageNotFoundError as e:
|
||||
warnings.warn(f"Could not determine version of {__name__}."
|
||||
f"Did you install it correctly?\n{e!s}", stacklevel=2)
|
||||
__version__ = "unknown"
|
||||
|
|
@ -2,9 +2,9 @@ from typing import Optional, Tuple
|
|||
|
||||
import keyring
|
||||
|
||||
from .. import __name__ as NAME
|
||||
from ..logging import log
|
||||
from ..utils import agetpass, ainput
|
||||
from ..version import NAME
|
||||
from .authenticator import Authenticator, AuthError, AuthSection
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,18 @@
|
|||
# importing itself, we get a few linting warnings, which we're disabling as
|
||||
# well.
|
||||
|
||||
from . import command_local # noqa: F401 imported but unused
|
||||
from . import command_ilias_web # noqa: F401 imported but unused
|
||||
from . import command_kit_ilias_web # noqa: F401 imported but unused
|
||||
from . import command_kit_ipd # noqa: F401 imported but unused
|
||||
from .parser import PARSER, ParserLoadError, load_default_section # noqa: F401 imported but unused
|
||||
from . import command_local
|
||||
from . import command_ilias_web
|
||||
from . import command_kit_ilias_web
|
||||
from . import command_kit_ipd
|
||||
from .parser import PARSER, ParserLoadError, load_default_section
|
||||
|
||||
__all__ = [
|
||||
"command_local",
|
||||
"command_ilias_web",
|
||||
"command_kit_ilias_web",
|
||||
"command_kit_ipd",
|
||||
"PARSER",
|
||||
"ParserLoadError",
|
||||
"load_default_section"
|
||||
]
|
||||
|
|
|
|||
|
|
@ -4,8 +4,9 @@ from argparse import ArgumentTypeError
|
|||
from pathlib import Path
|
||||
from typing import Any, Callable, List, Optional, Sequence, Union
|
||||
|
||||
from .. import __name__ as NAME
|
||||
from .. import __version__ as VERSION
|
||||
from ..output_dir import OnConflict, Redownload
|
||||
from ..version import NAME, VERSION
|
||||
|
||||
|
||||
class ParserLoadError(Exception):
|
||||
|
|
|
|||
|
|
@ -8,11 +8,12 @@ import aiohttp
|
|||
import certifi
|
||||
from aiohttp.client import ClientTimeout
|
||||
|
||||
from .. import __name__ as NAME
|
||||
from .. import __version__ as VERSION
|
||||
from ..auth import Authenticator
|
||||
from ..config import Config
|
||||
from ..logging import log
|
||||
from ..utils import fmt_real_path
|
||||
from ..version import NAME, VERSION
|
||||
from .crawler import Crawler, CrawlerSection
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
NAME = "PFERD"
|
||||
VERSION = "3.5.2"
|
||||
|
|
@ -17,9 +17,7 @@
|
|||
rec {
|
||||
default = pkgs.python3Packages.buildPythonApplication rec {
|
||||
pname = "pferd";
|
||||
# Performing black magic
|
||||
# Don't worry, I sacrificed enough goats for the next few years
|
||||
version = (pkgs.lib.importTOML ./PFERD/version.py).VERSION;
|
||||
version = (pkgs.lib.importTOML ./pyproject.toml).package.version;
|
||||
format = "pyproject";
|
||||
|
||||
src = ./.;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,14 @@ build-backend = "setuptools.build_meta"
|
|||
|
||||
[project]
|
||||
name = "PFERD"
|
||||
version = "3.5.2"
|
||||
classifiers = [
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: 3.12",
|
||||
]
|
||||
dependencies = [
|
||||
"aiohttp>=3.8.1",
|
||||
"beautifulsoup4>=4.10.0",
|
||||
|
|
@ -11,15 +19,11 @@ dependencies = [
|
|||
"keyring>=23.5.0",
|
||||
"certifi>=2021.10.8"
|
||||
]
|
||||
dynamic = ["version"]
|
||||
requires-python = ">=3.9"
|
||||
|
||||
[project.scripts]
|
||||
pferd = "PFERD.__main__:main"
|
||||
|
||||
[tool.setuptools.dynamic]
|
||||
version = {attr = "PFERD.version.VERSION"}
|
||||
|
||||
[tool.flake8]
|
||||
max-line-length = 110
|
||||
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
set -e
|
||||
|
||||
pyinstaller --onefile pferd.py
|
||||
pyinstaller --onefile --copy-metadata PFERD pferd.py
|
||||
|
|
|
|||
|
|
@ -41,12 +41,12 @@ def extract_changes(lines):
|
|||
|
||||
|
||||
def update_version(version):
|
||||
with open("PFERD/version.py") as f:
|
||||
with open("pyproject.toml") as f:
|
||||
text = f.read()
|
||||
|
||||
text = re.sub(r'VERSION = ".*"', f'VERSION = "{version}"', text)
|
||||
text = re.sub(r'version = ".*"', f'version = "{version}"', text)
|
||||
|
||||
with open("PFERD/version.py", "w") as f:
|
||||
with open("pyproject.toml", "w") as f:
|
||||
f.write(text)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue