From e917ce06841ff7c5222fa7bb51aae7f1ba62ca1e Mon Sep 17 00:00:00 2001 From: Andrin <65789180+Puncher1@users.noreply.github.com> Date: Sun, 8 Sep 2024 23:31:45 +0200 Subject: [PATCH] Revert "Remove setup.py" This reverts commit a8e574b6bbff90442ce49577ef9c61225c90224b. --- setup.py | 62 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/setup.py b/setup.py index 7d4c5ea08ea6..2481afeb428c 100644 --- a/setup.py +++ b/setup.py @@ -1,31 +1,31 @@ -# from setuptools import setup -# import re -# -# def derive_version() -> str: -# version = '' -# with open('discord/__init__.py') as f: -# version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), re.MULTILINE).group(1) -# -# if not version: -# raise RuntimeError('version is not set') -# -# if version.endswith(('a', 'b', 'rc')): -# # append version identifier based on commit count -# try: -# import subprocess -# -# p = subprocess.Popen(['git', 'rev-list', '--count', 'HEAD'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) -# out, err = p.communicate() -# if out: -# version += out.decode('utf-8').strip() -# p = subprocess.Popen(['git', 'rev-parse', '--short', 'HEAD'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) -# out, err = p.communicate() -# if out: -# version += '+g' + out.decode('utf-8').strip() -# except Exception: -# pass -# -# return version -# -# -# setup(version=derive_version()) +from setuptools import setup +import re + +def derive_version() -> str: + version = '' + with open('discord/__init__.py') as f: + version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), re.MULTILINE).group(1) + + if not version: + raise RuntimeError('version is not set') + + if version.endswith(('a', 'b', 'rc')): + # append version identifier based on commit count + try: + import subprocess + + p = subprocess.Popen(['git', 'rev-list', '--count', 'HEAD'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, err = p.communicate() + if out: + version += out.decode('utf-8').strip() + p = subprocess.Popen(['git', 'rev-parse', '--short', 'HEAD'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, err = p.communicate() + if out: + version += '+g' + out.decode('utf-8').strip() + except Exception: + pass + + return version + + +setup(version=derive_version())