Skip to content

Commit 4b75d28

Browse files
authored
Merge pull request #6 from nside/openapi-version
Use proper version in openapi spec
2 parents 643d45b + 1831f3d commit 4b75d28

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

setup.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
from setuptools import setup, find_packages
2+
import re
23

34
# Read the contents of the README file
45
with open('README.md', 'r') as f:
56
long_description = f.read()
67

8+
9+
def find_version():
10+
with open('sqlite2rest/__init__.py', 'r') as f:
11+
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", f.read(), re.M)
12+
if version_match:
13+
return version_match.group(1)
14+
raise RuntimeError("Unable to find version string.")
15+
716
setup(
817
name='sqlite2rest',
9-
version='1.3.0',
18+
version=find_version(),
1019
description='A Python library for creating a RESTful API from an SQLite database using Flask.',
1120
author='Denis Laprise',
1221
author_email='[email protected]',

sqlite2rest/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
__version__ = "0.4.0"
12
from .app import create_app
23
from .database import Database

sqlite2rest/openapi.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from flask import current_app
22
from openapi_spec_validator import validate_spec
33
import yaml
4+
from . import __version__
45

56
def get_operation_summary(method):
67
return {
@@ -90,7 +91,7 @@ def generate_openapi_spec(db):
9091
"openapi": "3.0.0",
9192
"info": {
9293
"title": "SQLite2REST",
93-
"version": "1.0.0"
94+
"version": __version__
9495
},
9596
"paths": {}
9697
}

0 commit comments

Comments
 (0)