From 245625212c6a377d8945e414d8699ae014155ffb Mon Sep 17 00:00:00 2001 From: theOehrly <23384863+theOehrly@users.noreply.github.com> Date: Sat, 23 Dec 2023 23:19:41 +0100 Subject: [PATCH] MNT: internal version from setuptools_scm --- .gitignore | 3 +++ fastf1/__init__.py | 9 ++++++++- fastf1/ergast/interface.py | 2 +- fastf1/mvapi/api.py | 3 +-- fastf1/version.py | 1 - pyproject.toml | 1 + 6 files changed, 14 insertions(+), 5 deletions(-) delete mode 100644 fastf1/version.py diff --git a/.gitignore b/.gitignore index 56166fd96..9405efa62 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,9 @@ dist/ build/ fastf1.egg-info/ +# version info dynamically created by setuptools-scm +fastf1/_version.py + # temporary testrun directories fastf1/tests/testenv/ fastf1/tests/mpl-results/ diff --git a/fastf1/__init__.py b/fastf1/__init__.py index 67550bd5f..782e96e54 100644 --- a/fastf1/__init__.py +++ b/fastf1/__init__.py @@ -82,6 +82,14 @@ For more information see :ref:`logging`. """ +try: + from . import _version +except ImportError: + _version = None + +__version__ = getattr(_version, 'version', 'UNKNOWN') + + from typing import Dict from fastf1.events import (get_session, # noqa: F401 @@ -94,7 +102,6 @@ from fastf1.logger import set_log_level # noqa: F401 from fastf1.req import Cache, RateLimitExceededError # noqa: F401 -from fastf1.version import __version__ # noqa: F401 _DRIVER_TEAM_MAPPING: Dict[str, Dict[str, str]] = { diff --git a/fastf1/ergast/interface.py b/fastf1/ergast/interface.py index 674a68e9d..44519543a 100644 --- a/fastf1/ergast/interface.py +++ b/fastf1/ergast/interface.py @@ -2,9 +2,9 @@ import json from typing import List, Literal, Optional, Union +from fastf1 import __version__ from fastf1.req import Cache import fastf1.ergast.structure as API -from fastf1.version import __version__ import pandas as pd diff --git a/fastf1/mvapi/api.py b/fastf1/mvapi/api.py index 21081fe69..f2b812674 100644 --- a/fastf1/mvapi/api.py +++ b/fastf1/mvapi/api.py @@ -2,10 +2,9 @@ from typing import Optional +from fastf1 import __version__ from fastf1.mvapi.internals import _logger from fastf1.req import Cache -from fastf1.version import __version__ - PROTO = "https" HOST = "api.multiviewer.app" diff --git a/fastf1/version.py b/fastf1/version.py deleted file mode 100644 index f71b21a5d..000000000 --- a/fastf1/version.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = '3.1.2' diff --git a/pyproject.toml b/pyproject.toml index 279b20012..10fe0e6c4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,6 +42,7 @@ exclude = ["fastf1/testing*"] namespaces = false [tool.setuptools_scm] +write_to = "fastf1/_version.py" [tool.ruff] line-length = 79