-
Notifications
You must be signed in to change notification settings - Fork 4
/
__init__.py
54 lines (44 loc) · 1.77 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# This file is part of the PESCy technique package
#
__all__ = ["PESCy"]
import pkg_resources
#from PESCy import PESCy
# --- Define version -----------------------------------------------------------
try:
# this places a runtime dependency on setuptools
#
# note: if there's any distribution metadata in your source files, then this
# will find a version based on those files. Keep distribution metadata
# out of your repository unless you've intentionally installed the package
# as editable (e.g. `pip install -e {PESCy_directory_root}`),
# but then __version__ will not be updated with each commit, it is
# frozen to the version at time of install.
#
#: `PESCy` version string
__version__ = pkg_resources.get_distribution("PESCy").version
except pkg_resources.DistributionNotFound:
# package is not installed
fallback_version = "unknown"
try:
# code most likely being used from source
# if setuptools_scm is installed then generate a version
from setuptools_scm import get_version
__version__ = get_version(
root="..", relative_to=__file__, fallback_version=fallback_version
)
del get_version
warn_add = "setuptools_scm failed to detect the version"
except ModuleNotFoundError:
# setuptools_scm is not installed
__version__ = fallback_version
warn_add = "setuptools_scm is not installed"
if __version__ == fallback_version:
from warnings import warn
warn(
f"PESCy.__version__ not generated (set to 'unknown'), PESCy is "
f"not an installed package and {warn_add}.",
RuntimeWarning,
)
del warn
del fallback_version, warn_add
del pkg_resources