48 lines
1.2 KiB
Python
48 lines
1.2 KiB
Python
#!/usr/bin/env python
|
|
import re
|
|
|
|
from setuptools import setup
|
|
|
|
PACKAGE_NAME = 'pbcabi'
|
|
|
|
with open('README.md') as f:
|
|
readme = f.read()
|
|
|
|
with open(PACKAGE_NAME + '/_version.py') as f:
|
|
text = f.read()
|
|
match = re.match(r'^__version__\s*=\s*(["\'])([\d\.]+)\1$', text)
|
|
version = match.group(2)
|
|
del match, text
|
|
|
|
|
|
def read_requirements(path: str = 'requirements.txt'):
|
|
with open(path) as f:
|
|
return f.read().strip().split('\n')
|
|
|
|
|
|
def get_short_description(readme: str):
|
|
readme = re.sub(r'#+[^\n]*\n+', '', 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'
|
|
raise Exception(msg) from err
|
|
|
|
|
|
setup(
|
|
name=PACKAGE_NAME,
|
|
version=version,
|
|
description=get_short_description(readme),
|
|
long_description=readme,
|
|
long_description_content_type='text/markdown',
|
|
author='Jmaa',
|
|
author_email='jonjmaa@gmail.com',
|
|
url='https://gitfub.space/Jmaa/' + PACKAGE_NAME,
|
|
packages=[PACKAGE_NAME],
|
|
install_requires=read_requirements(),
|
|
extras_require={
|
|
'test': read_requirements('requirements_test.txt'),
|
|
},
|
|
)
|