~hristoast/mousikofidi

0400514e8460bbce363b60a3a6f7ae18c82a657a — Hristos N. Triantafillou 9 months ago 10a6be4
Derive the version number from git commits/tags (#60)

If not git executable is found, then just use the current date/time
mashed into a string.
1 files changed, 33 insertions(+), 2 deletions(-)

M setup.py
M setup.py => setup.py +33 -2
@@ 13,13 13,17 @@
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
import shutil
import subprocess


from datetime import datetime
from setuptools import setup


with open("README.md", "r") as r:
    long_desc = r.read()


with open("requirements.txt", "r") as f:
    _req = f.readlines()



@@ 27,9 31,36 @@ req = []
for r in _req:
    req.append(r.strip("\n"))

git = shutil.which("git")

if git:
    exact_tag = subprocess.run(
        ["git", "describe", "--exact-match", "--tags", "HEAD"],
        stderr=subprocess.PIPE,
        stdout=subprocess.PIPE,
    )

    err = exact_tag.stderr.decode()
    if not err:
        ver = exact_tag.stdout.decode().strip("\n")

    not_tag = subprocess.run(
        ["git", "describe", "--tags"], stderr=subprocess.PIPE, stdout=subprocess.PIPE
    )

    err2 = not_tag.stderr.decode()
    if not err2:
        ver = not_tag.stdout.decode().strip("\n")

else:
    fmt = "%Y%m%d%H%M%S"
    now = datetime.now()
    ver = now.strftime(fmt)


setup(
    name="MousikoFidi",
    version="0.16",
    version=ver,
    author="Hristos N. Triantafillou",
    author_email="me@hristos.co",
    description="MousikóFídi: Your Music Cloud",