Commit 2f16de1 1 parent 1db58c0 commit 2f16de1 Copy full SHA for 2f16de1
File tree 1 file changed +14
-8
lines changed
1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change 45
45
except ModuleNotFoundError :
46
46
from importlib_metadata import version , PackageNotFoundError
47
47
try :
48
+ # This gives the version if the boututils package was installed
48
49
__version__ = version (__name__ )
49
50
except PackageNotFoundError :
51
+ # This branch handles the case when boututils is used from the git repo
50
52
try :
51
53
from setuptools_scm import get_version
52
- except ModuleNotFoundError as e :
53
- error_info = (
54
- "'setuptools_scm' is required to get the version number when running "
55
- "boututils from the git repo. Please install 'setuptools_scm'."
56
- )
57
- print (error_info )
58
- raise ModuleNotFoundError (str (e ) + ". " + error_info )
59
- else :
60
54
from pathlib import Path
61
55
path = Path (__file__ ).resolve ()
62
56
__version__ = get_version (root = ".." , relative_to = path )
57
+ except (ModuleNotFoundError , LookupError ) as e :
58
+ # ModuleNotFoundError if setuptools_scm is not installed.
59
+ # LookupError if git is not installed, or the code is not in a git repo even
60
+ # though it has not been installed.
61
+ from warnings import warn
62
+ warn (
63
+ "'setuptools_scm' and git are required to get the version number when "
64
+ "running boututils from the git repo. Please install 'setuptools_scm' and "
65
+ "check 'git rev-parse HEAD' works. Setting __version__='dev' as a "
66
+ "workaround."
67
+ )
68
+ __version__ = "dev"
You can’t perform that action at this time.
0 commit comments