Updated standard Python setup
This commit is contained in:
parent
e233afe15e
commit
ca10c6989b
21
setup.py
21
setup.py
|
@ -15,29 +15,32 @@ PACKAGE_NAME = 'pbcabi'
|
|||
with open('README.md') as f:
|
||||
readme = f.read()
|
||||
|
||||
with open(PACKAGE_NAME + '/_version.py') as f:
|
||||
text = f.read()
|
||||
def parse_version_file(text: str) -> str:
|
||||
match = re.match(r'^__version__\s*=\s*(["\'])([\d\.]+)\1$', text)
|
||||
version = match.group(2)
|
||||
del match, text
|
||||
if match is None:
|
||||
msg = 'Malformed _version.py file!'
|
||||
raise Exception(msg)
|
||||
return match.group(2)
|
||||
|
||||
with open(PACKAGE_NAME + '/_version.py') as f:
|
||||
version = parse_version_file(f.read())
|
||||
|
||||
def parse_requirements(text: str) -> list[str]:
|
||||
return text.strip().split('\n')
|
||||
|
||||
|
||||
def read_requirements(path: str):
|
||||
def read_requirements(path: str) -> list[str]:
|
||||
with open(path) as f:
|
||||
return parse_requirements(f.read())
|
||||
|
||||
|
||||
def get_short_description(readme: str):
|
||||
def determine_short_description(readme: str) -> str:
|
||||
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)
|
||||
try:
|
||||
return m.group(1)
|
||||
except AttributeError as err:
|
||||
msg = 'Could not determine short description'
|
||||
msg = f'Could not determine short description: {readme}'
|
||||
raise Exception(msg) from err
|
||||
|
||||
|
||||
|
@ -54,7 +57,7 @@ pytest
|
|||
setup(
|
||||
name=PACKAGE_NAME,
|
||||
version=version,
|
||||
description=get_short_description(readme),
|
||||
description=determine_short_description(readme),
|
||||
long_description=readme,
|
||||
long_description_content_type='text/markdown',
|
||||
author='Jmaa',
|
||||
|
|
Loading…
Reference in New Issue
Block a user