Skip to content

Commit

Permalink
fix for Single-sourcing the package version.
Browse files Browse the repository at this point in the history
  • Loading branch information
alainivars committed Jun 17, 2019
1 parent b60d04a commit 162a96b
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 30 deletions.
25 changes: 1 addition & 24 deletions conf.py
Original file line number Diff line number Diff line change
@@ -1,24 +1 @@
# -*- coding: utf-8 -*-

extensions = ['recommonmark']
templates_path = [
'/home/docs/checkouts/readthedocs.org/readthedocs/templates/sphinx',
'templates', '_templates', '.templates']
source_suffix = {
'.rst': 'restructuredtext',
'.txt': 'markdown',
'.md': 'markdown',
}
master_doc = 'index'
project = u'drf-microservice'
copyright = u'2017-2019'
version = 'v0.7.1'
release = 'latest'
exclude_patterns = ['_build']
pygments_style = 'sphinx'
htmlhelp_basename = 'drf-microservice'
file_insertion_enabled = False
latex_documents = [
('index', 'drf-microservice.tex', u'drf-microservice Documentation',
u'', 'manual'),
]
# we use the one in docs dir for but sphinx actually want this file!!!
5 changes: 4 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#
import os
import sys

from docs import version

sys.path.insert(0, os.path.abspath('.'))


Expand All @@ -22,7 +25,7 @@
author = 'Alain Ivars'

# The full version, including alpha/beta/rc tags
release = 'v0.7.1'
release = version.__version__


# -- General configuration ---------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions docs/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '0.7.1'
1 change: 0 additions & 1 deletion my_api/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
__version__ = '0.7.1'
2 changes: 1 addition & 1 deletion my_api/rest/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from rest_framework.response import Response
from rest_framework import status

from my_api import __version__
from docs.version import __version__
from my_api.rest.serializers import FileToFilesystemSerializer


Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ botocore==1.12.169
s3transfer==0.2.1

# Dynamic Documentations
certifi==2019.3.9 # coreapi dependency
certifi==2019.6.16 # coreapi dependency
coreschema==0.0.4 # coreapi dependency
itypes==1.1.0 # coreapi dependency
uritemplate==3.0.0 # coreapi dependency
Expand Down
18 changes: 16 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
#!/usr/bin/env python

import os
import re
from setuptools import setup, find_packages

import my_api

def read(f): # from DRF setup
return open(f, 'r', encoding='utf-8').read()


def get_version(package): # from DRF setup
"""
Return package version as listed in `__version__` in `init.py`.
"""
init_py = open(os.path.join(package, 'version.py')).read()
return re.search("__version__ = ['\"]([^'\"]+)['\"]", init_py).group(1)


version = get_version('.')

here = os.path.dirname(os.path.abspath(__file__))
with open(os.path.join(here, 'README.rst')) as f:
long_description = f.read().strip()

setup(
name='drf-microservice',
version=my_api.__version__,
version=version,
author='Alain IVARS',
author_email='alainivars@gmail.com',
url='http://github.com/alainivars/drf-microservice',
Expand Down
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ envlist =
docs

[testenv]
skip_install = True
deps =
-r{toxinidir}/requirements.txt
-r{toxinidir}/requirements_test.txt
commands =
/usr/bin/env SECRET_KEY=test pytest --ds=my_api.config.common -v --cov my_api/rest --cov-report term-missing

[testenv:docs]
skip_install = True
changedir=docs
#basepython=python3.6
deps =
Expand Down

0 comments on commit 162a96b

Please sign in to comment.