Skip to content

Commit

Permalink
Switch to setuptools-scm.
Browse files Browse the repository at this point in the history
  • Loading branch information
jezdez committed Dec 3, 2019
1 parent bd61710 commit 42641f5
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ htmlcov/
*.pyc
dist/
tests/docs/_build/
.eggs/
8 changes: 4 additions & 4 deletions configurations/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# flake8: noqa
from .base import Configuration
from .decorators import pristinemethod
from .base import Configuration # noqa
from .decorators import pristinemethod # noqa
from .version import __version__ # noqa


__version__ = '2.1'
__all__ = ['Configuration', 'pristinemethod']


Expand Down
4 changes: 2 additions & 2 deletions configurations/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ def stylize(text):
and os.environ.get('RUN_MAIN') == 'true'):

message = ("django-configurations version {0}, using "
"configuration '{1}'".format(__version__,
self.name))
"configuration {1}".format(__version__ or "",
self.name))
self.logger.debug(stylize(message))

def find_module(self, fullname, path=None):
Expand Down
7 changes: 7 additions & 0 deletions configurations/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from pkg_resources import get_distribution, DistributionNotFound

try:
__version__ = get_distribution(__name__).version
except DistributionNotFound:
# package is not installed
__version__ = None
3 changes: 2 additions & 1 deletion docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ v2.2 (2019-12-03)

- Replace ``django.utils.six`` with ``six`` to support Django >= 3.

- Start using tox-travis for simplified test harness management.
- Start using tox-travis and setuptools-scm for simplified test harness
and release management.

v2.1 (2018-08-16)
^^^^^^^^^^^^^^^^^
Expand Down
14 changes: 6 additions & 8 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import sys
import os

from pkg_resources import get_distribution

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
Expand Down Expand Up @@ -48,14 +50,10 @@
# |version| and |release|, also used in various other places throughout the
# built documents.
#
try:
from configurations import __version__
# The short X.Y version.
version = '.'.join(__version__.split('.')[:2])
# The full version, including alpha/beta/rc tags.
release = __version__
except ImportError:
version = release = 'dev'
# The full version, including alpha/beta/rc tags.
release = get_distribution("django-configurations").version
# The short X.Y version.
version = ".".join(release.split(".")[:2])

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ parallel = 1
include = configurations/*,tests/*

[flake8]
exclude = .tox,docs/*
exclude = .tox,docs/*,.eggs
ignore = E501,E127,E128,E124,W503
19 changes: 2 additions & 17 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,19 @@
from __future__ import print_function
import ast
import os
import codecs
from setuptools import setup


class VersionFinder(ast.NodeVisitor):
def __init__(self):
self.version = None

def visit_Assign(self, node):
if node.targets[0].id == '__version__':
self.version = node.value.s


def read(*parts):
filename = os.path.join(os.path.dirname(__file__), *parts)
with codecs.open(filename, encoding='utf-8') as fp:
return fp.read()


def find_version(*parts):
finder = VersionFinder()
finder.visit(ast.parse(read(*parts)))
return finder.version


setup(
name="django-configurations",
version=find_version("configurations", "__init__.py"),
use_scm_version={"version_scheme": "post-release", "local_scheme": "dirty-tag"},
setup_requires=["setuptools_scm"],
url='https://django-configurations.readthedocs.io/',
license='BSD',
description="A helper for organizing Django settings.",
Expand Down

0 comments on commit 42641f5

Please sign in to comment.