1
0

Improved setup.py

This commit is contained in:
Jon Michael Aanes 2024-03-11 20:48:20 +01:00
parent 8f678c341f
commit 47c9ad958e
Signed by: Jmaa
SSH Key Fingerprint: SHA256:Ab0GfHGCblESJx7JRE4fj4bFy/KRpeLhi41y4pF3sNA

View File

@ -1,13 +1,14 @@
#!/usr/bin/env python #!/usr/bin/env python
from setuptools import setup
import re import re
from setuptools import setup
PACKAGE_NAME = 'requests_util' PACKAGE_NAME = 'requests_util'
with open('README.md', 'r') as f: with open('README.md') as f:
readme = f.read() readme = f.read()
with open(PACKAGE_NAME + '/_version.py', 'r') as f: with open(PACKAGE_NAME + '/_version.py') as f:
text = f.read() text = f.read()
match = re.match(r'^__version__\s*=\s*(["\'])([\d\.]+)\1$', text) match = re.match(r'^__version__\s*=\s*(["\'])([\d\.]+)\1$', text)
version = match.group(2) version = match.group(2)
@ -16,9 +17,12 @@ with open(PACKAGE_NAME + '/_version.py', 'r') as f:
def get_short_description(readme: str): def get_short_description(readme: str):
readme = re.sub(r'#+[^\n]*\n+', '', readme) readme = re.sub(r'#+[^\n]*\n+', '', readme)
m = re.search(r'^\s*(\w+[\w\s,]+\.)', readme) m = re.search(r'^\s*(\w+[\w\s,`]+\.)', readme)
readme = m.group(1) try:
return readme return m.group(1)
except AttributeError as err:
msg = 'Could not determine short description'
raise Exception(msg) from err
setup( setup(