diff --git a/.gitignore b/.gitignore index a9d47db..533ef3c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ *_flymake .coverage .DS_Store +.eggs/ .pytest_cache/ .ropeproject/ .tox/ diff --git a/docs/conf.py b/docs/conf.py index 87d1cd1..dfa0ca5 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,18 +1,14 @@ import os -import re import sys import alabaster -from setuptools.config import read_configuration +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. sys.path.append(os.path.abspath('..')) -conf_dict = read_configuration('../setup.cfg') -__version__ = conf_dict['metadata']['version'] - # -- General configuration ---------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. @@ -49,9 +45,10 @@ copyright = '2012-2019, Simon Conseil' # built documents. # # The short X.Y version. -version = re.match(r'\d+\.\d+', __version__).group() -# The full version, including alpha/beta/rc tags. -release = __version__ +release = get_distribution('sigal').version +# for example take major/minor +version = '.'.join(release.split('.')[:2]) + # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/setup.cfg b/setup.cfg index 8ff3ebb..825e7b0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,5 @@ [metadata] name = sigal -version = attr: sigal.__version__ description = Simple static gallery generator long_description = file: README.rst author = Simon Conseil @@ -8,6 +7,7 @@ author_email = contact@saimon.org url = https://github.com/saimn/sigal keywords = gallery, static, generator, image, video, galleria license = MIT License +license_file = LICENSE classifiers = Development Status :: 5 - Production/Stable Environment :: Console @@ -26,6 +26,8 @@ zip_safe = False include_package_data = True packages = find: python_requires = >=3.5 +setup_requires = + setuptools_scm install_requires = blinker click diff --git a/setup.py b/setup.py index f30a037..a936873 100644 --- a/setup.py +++ b/setup.py @@ -4,4 +4,4 @@ from setuptools import setup if sys.version_info[:2] < (3, 5): sys.exit('Sigal supports Python 3.5+ only') -setup() +setup(use_scm_version=True) diff --git a/sigal/__init__.py b/sigal/__init__.py index 90b5cd5..500456c 100644 --- a/sigal/__init__.py +++ b/sigal/__init__.py @@ -29,13 +29,19 @@ import time from click import argument, option from http import server +from pkg_resources import get_distribution, DistributionNotFound from .gallery import Gallery from .log import init_logging from .settings import read_settings from .utils import copy -__version__ = '2.1.dev' +try: + __version__ = get_distribution(__name__).version +except DistributionNotFound: + # package is not installed + pass + __url__ = 'https://github.com/saimn/sigal' _DEFAULT_CONFIG_FILE = 'sigal.conf.py'