Skip to content

Commit

Permalink
Refactor setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
romis2012 committed Sep 19, 2024
1 parent 582f4a4 commit d7f9423
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ HTTP basic authentication middleware for aiohttp 3.0+.
Inspired by [Flask-BasicAuth](https://github.com/jpvanhal/flask-basicauth).

## Requirements
- Python >= 3.5.3
- Python >= 3.7
- aiohttp >= 3.0

## Installation
Expand Down
36 changes: 17 additions & 19 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
#!/usr/bin/env python
import codecs
import os
import re
import sys

try:
from setuptools import setup
except ImportError:
from distutils.core import setup
from setuptools import setup

version = None

with codecs.open(os.path.join(os.path.abspath(os.path.dirname(
__file__)), 'aiohttp_basicauth', '__init__.py'), 'r', 'latin1') as fp:
try:
version = re.findall(r"^__version__ = '([^']+)'\r?$",
fp.read(), re.M)[0]
except IndexError:
raise RuntimeError('Unable to determine version.')
if sys.version_info < (3, 7):
raise RuntimeError('aiohttp-basicauth requires Python 3.7+')

if sys.version_info < (3, 5, 3):
raise RuntimeError("aiohttp_basicauth requires Python 3.5.3+")

with open('README.md') as f:
long_description = f.read()
def get_version():
here = os.path.dirname(os.path.abspath(__file__))
filename = os.path.join(here, 'aiohttp_basicauth', '__init__.py')
contents = open(filename).read()
pattern = r"^__version__ = '(.*?)'$"
return re.search(pattern, contents, re.MULTILINE).group(1)


def get_long_description():
with open('README.md', mode='r', encoding='utf8') as f:
return f.read()


setup(
name='aiohttp_basicauth',
author='Roman Snegirev',
author_email='[email protected]',
version=version,
version=get_version(),
license='Apache 2',
url='https://github.com/romis2012/aiohttp-basicauth',
description='HTTP basic authentication middleware for aiohttp 3.0+',
long_description=long_description,
long_description=get_long_description(),
long_description_content_type='text/markdown',
packages=['aiohttp_basicauth'],
keywords='aiohttp http basic auth',
Expand Down

0 comments on commit d7f9423

Please sign in to comment.