magic-afm 1.0.0b0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
magic_afm/__init__.py ADDED
File without changes
@@ -0,0 +1,36 @@
1
+ import pathlib
2
+ import subprocess
3
+
4
+ filename = pathlib.Path(__file__).parent / "_version.py"
5
+
6
+
7
+ def get():
8
+ return subprocess.run(
9
+ ["git", "describe", "--dirty", "--long", "--tags"],
10
+ capture_output=True,
11
+ check=True,
12
+ ).stdout.decode()[:-1]
13
+
14
+
15
+ def read():
16
+ import runpy
17
+
18
+ try:
19
+ return runpy.run_path(filename)["__version__"]
20
+ except FileNotFoundError:
21
+ return ""
22
+
23
+
24
+ def write(version):
25
+ version_str = f"""\
26
+ __version__ = '{version}'
27
+ """
28
+ with filename.open("w", encoding="utf8") as f:
29
+ f.write(version_str)
30
+
31
+
32
+ if __name__ == "__main__":
33
+ __version__ = get()
34
+
35
+ if not read() == __version__:
36
+ write(__version__)