From 9fdd3acd82955a0e06a89465353519948a91e900 Mon Sep 17 00:00:00 2001 From: justdont0 <97027325+justdont0@users.noreply.github.com> Date: Sat, 31 Aug 2024 15:01:59 +0300 Subject: [PATCH 1/2] Fix --- setup.py | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index a3a0b35..e0e03a6 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,5 @@ from setuptools import setup, find_packages - -from ufpy import __version__ +import re with open('README.md', 'r', encoding='utf-8') as mdf: long_description = mdf.read() @@ -15,6 +14,33 @@ project_name = 'ufpy' github_url = f'https://github.com/{organization_name}/{project_name}' +def derive_version() -> str: # this function is stolen from discord.py + version = '' + with open('ufpy/__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 + +__version__ = derive_version() setup( name=project_name, From 3af6d6b4c9ef28660c4233a5118c10a7064b2b46 Mon Sep 17 00:00:00 2001 From: n0n1m <97027325+n0n1m@users.noreply.github.com> Date: Sat, 31 Aug 2024 15:06:51 +0300 Subject: [PATCH 2/2] Update setup.py --- setup.py | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/setup.py b/setup.py index e0e03a6..dac9053 100644 --- a/setup.py +++ b/setup.py @@ -22,22 +22,6 @@ def derive_version() -> str: # this function is stolen from discord.py 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 __version__ = derive_version()