Skip to content

Commit 1c2c349

Browse files
Merge pull request #48 from rpanderson/self-contained-version
Obtain own version without external functions
2 parents 3520677 + 2cb4041 commit 1c2c349

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

labscript_devices/__init__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@
2121
from labscript_utils import labscript_suite_install_dir, dedent
2222
from labscript_utils.labconfig import LabConfig
2323

24-
from labscript_utils.versions import get_version, NoVersionInfo
25-
from pathlib import Path
26-
__version__ = get_version(__name__, import_path=Path(__file__).parent.parent)
27-
if __version__ is NoVersionInfo:
28-
__version__ = None
24+
from .__version__ import __version__
2925

3026
check_version('qtutils', '2.0.0', '3.0.0')
3127
check_version('labscript', '2.6', '3')

labscript_devices/__version__.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import os
2+
from pathlib import Path
3+
try:
4+
import importlib.metadata as importlib_metadata
5+
except ImportError:
6+
import importlib_metadata
7+
8+
VERSION_SCHEME = {
9+
"version_scheme": os.getenv("SCM_VERSION_SCHEME", "guess-next-dev"),
10+
"local_scheme": os.getenv("SCM_LOCAL_SCHEME", "node-and-date"),
11+
}
12+
13+
root = Path(__file__).parent.parent
14+
if (root / '.git').is_dir():
15+
from setuptools_scm import get_version
16+
__version__ = get_version(root, **VERSION_SCHEME)
17+
else:
18+
try:
19+
__version__ = importlib_metadata.version(__package__)
20+
except importlib_metadata.PackageNotFoundError:
21+
__version__ = None

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ packages = find:
2626
python_requires = >=3.6
2727
install_requires =
2828
blacs>=2.7.0
29+
importlib_metadata
2930
labscript>=2.6.0
3031
labscript_utils>=2.13.2
3132
numpy>=1.15.1

0 commit comments

Comments
 (0)