Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix requirement being used before installing #53

Merged
merged 2 commits into from
Aug 31, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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
n0n1m marked this conversation as resolved.
Show resolved Hide resolved
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)
n0n1m marked this conversation as resolved.
Show resolved Hide resolved
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,
Expand Down
Loading