From dbe70e66761d20f69d7a9e378e27c211a4001907 Mon Sep 17 00:00:00 2001 From: Gary Tierney Date: Mon, 17 May 2021 09:57:14 +0100 Subject: [PATCH 1/2] Use version from setuptools if available --- soulstruct/__init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/soulstruct/__init__.py b/soulstruct/__init__.py index 0808f477..017cce35 100644 --- a/soulstruct/__init__.py +++ b/soulstruct/__init__.py @@ -1,10 +1,14 @@ from pathlib import Path +from pkg_resources import require from .base.models.flver import FLVER from .config import * from soulstruct.containers import Binder from soulstruct.containers.dcx import DCX - -with (Path(__file__).parent / "../VERSION").open("r") as _vfp: - __version__ = _vfp.read().strip() +soulstruct_pkg = require("soulstruct") +if soulstruct_pkg is not None: + __version__ = soulstruct_pkg[0].version +else: + with (Path(__file__).parent / "../VERSION").open("r") as _vfp: + __version__ = _vfp.read().strip() From 3f91363a6e4fc2659538c6fd8164ba396bfbae61 Mon Sep 17 00:00:00 2001 From: Gary Tierney Date: Sat, 21 Aug 2021 02:24:33 +0100 Subject: [PATCH 2/2] Fix version checking in non-pip environments --- soulstruct/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/soulstruct/__init__.py b/soulstruct/__init__.py index 017cce35..81234ec5 100644 --- a/soulstruct/__init__.py +++ b/soulstruct/__init__.py @@ -1,14 +1,14 @@ from pathlib import Path -from pkg_resources import require +from pkg_resources import require, DistributionNotFound from .base.models.flver import FLVER from .config import * from soulstruct.containers import Binder from soulstruct.containers.dcx import DCX -soulstruct_pkg = require("soulstruct") -if soulstruct_pkg is not None: +try: + soulstruct_pkg = require("soulstruct") __version__ = soulstruct_pkg[0].version -else: +except DistributionNotFound: with (Path(__file__).parent / "../VERSION").open("r") as _vfp: __version__ = _vfp.read().strip()