Simplify setup with pathlib
This commit is contained in:
parent
741c0861c2
commit
26667afea4
11
setup.py
11
setup.py
|
@ -3,6 +3,7 @@ import textwrap
|
||||||
|
|
||||||
from glob import glob
|
from glob import glob
|
||||||
from os.path import dirname
|
from os.path import dirname
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from setuptools import find_packages
|
from setuptools import find_packages
|
||||||
|
|
||||||
|
@ -12,14 +13,11 @@ except ImportError:
|
||||||
from distutils.core import setup
|
from distutils.core import setup
|
||||||
|
|
||||||
NAME = "Solaar"
|
NAME = "Solaar"
|
||||||
|
version = Path("lib/solaar/version").read_text().strip()
|
||||||
with open("lib/solaar/version", "r") as vfile:
|
|
||||||
version = vfile.read().strip()
|
|
||||||
|
|
||||||
try: # get commit from git describe
|
try: # get commit from git describe
|
||||||
commit = subprocess.check_output(["git", "describe", "--always"], stderr=subprocess.DEVNULL).strip().decode()
|
commit = subprocess.check_output(["git", "describe", "--always"], stderr=subprocess.DEVNULL).strip().decode()
|
||||||
with open("lib/solaar/commit", "w") as vfile:
|
Path("lib/solaar/commit").write_text(f"{commit}\n")
|
||||||
vfile.write(f"{commit}\n")
|
|
||||||
except Exception: # get commit from Ubuntu dpkg-parsechangelog
|
except Exception: # get commit from Ubuntu dpkg-parsechangelog
|
||||||
try:
|
try:
|
||||||
commit = (
|
commit = (
|
||||||
|
@ -28,8 +26,7 @@ except Exception: # get commit from Ubuntu dpkg-parsechangelog
|
||||||
.decode()
|
.decode()
|
||||||
)
|
)
|
||||||
commit = commit.split("~")
|
commit = commit.split("~")
|
||||||
with open("lib/solaar/commit", "w") as vfile:
|
Path("lib/solaar/commit").write_text(f"{commit[0]}\n")
|
||||||
vfile.write(f"{commit[0]}\n")
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Exception using dpkg-parsechangelog", e)
|
print("Exception using dpkg-parsechangelog", e)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue