diff --git a/docs/conf.py b/docs/conf.py index ad457b5..87d1cd1 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -3,18 +3,15 @@ import re import sys import alabaster +from setuptools.config import read_configuration # 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('..')) -pkgmeta = {} -pkgmeta_file = os.path.join(os.path.dirname(__file__), '..', 'sigal', - 'pkgmeta.py') -with open(pkgmeta_file) as f: - code = compile(f.read(), 'pkgmeta.py', 'exec') - exec(code, pkgmeta) +conf_dict = read_configuration('../setup.cfg') +__version__ = conf_dict['metadata']['version'] # -- General configuration ---------------------------------------------------- @@ -45,16 +42,16 @@ master_doc = 'index' # General information about the project. project = 'Sigal' -copyright = '2012-2013, ' + pkgmeta['__author__'] +copyright = '2012-2019, Simon Conseil' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = re.match('\d+\.\d+', pkgmeta['__version__']).group() +version = re.match(r'\d+\.\d+', __version__).group() # The full version, including alpha/beta/rc tags. -release = pkgmeta['__version__'] +release = __version__ # 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 c754a0a..8ff3ebb 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,49 @@ -[wheel] -universal = 1 +[metadata] +name = sigal +version = attr: sigal.__version__ +description = Simple static gallery generator +long_description = file: README.rst +author = Simon Conseil +author_email = contact@saimon.org +url = https://github.com/saimn/sigal +keywords = gallery, static, generator, image, video, galleria +license = MIT License +classifiers = + Development Status :: 5 - Production/Stable + Environment :: Console + License :: OSI Approved :: MIT License + Operating System :: OS Independent + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.5 + Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 + Topic :: Internet :: WWW/HTTP + Topic :: Multimedia :: Graphics :: Viewers + Topic :: Software Development :: Libraries :: Python Modules + +[options] +zip_safe = False +include_package_data = True +packages = find: +python_requires = >=3.5 +install_requires = + blinker + click + Jinja2 + Markdown + Pillow>=4.0.0 + pilkit + +[options.extras_require] +all = boto; brotli; feedgenerator; zopfli + +[options.packages.find] +exclude = + tests + +[options.entry_points] +console_scripts = + sigal = sigal:main [check-manifest] ignore = diff --git a/setup.py b/setup.py index 0f4ac46..f30a037 100644 --- a/setup.py +++ b/setup.py @@ -1,55 +1,7 @@ -import os import sys -from setuptools import setup, find_packages +from setuptools import setup if sys.version_info[:2] < (3, 5): sys.exit('Sigal supports Python 3.5+ only') -with open('README.rst') as f: - README = f.read() - -# Load package meta from the pkgmeta module without loading the package. -pkgmeta = {} -pkgmeta_file = os.path.join(os.path.dirname(__file__), 'sigal', 'pkgmeta.py') -with open(pkgmeta_file) as f: - code = compile(f.read(), 'pkgmeta.py', 'exec') - exec(code, pkgmeta) - -setup( - name='sigal', - version=pkgmeta['__version__'], - url=pkgmeta['__url__'], - license='MIT', - author=pkgmeta['__author__'], - author_email='contact@saimon.org', - description='Simple static gallery generator', - long_description=README, - packages=find_packages(exclude=['tests*']), - zip_safe=False, - include_package_data=True, - platforms='any', - python_requires='>=3.5', - keywords=['gallery', 'static', 'generator', 'image', 'video', 'galleria'], - install_requires=['blinker', 'click', 'Jinja2', 'Markdown', - 'Pillow>=4.0.0', 'pilkit'], - tests_require=['pytest'], - extras_require={ - 'all': ['boto', 'brotli', 'feedgenerator', 'zopfli'] - }, - entry_points={ - 'console_scripts': ['sigal = sigal:main'] - }, - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Environment :: Console', - 'License :: OSI Approved :: MIT License', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Topic :: Internet :: WWW/HTTP', - 'Topic :: Multimedia :: Graphics :: Viewers', - 'Topic :: Software Development :: Libraries :: Python Modules', - ], -) +setup() diff --git a/sigal/__init__.py b/sigal/__init__.py index ff3b71d..90b5cd5 100644 --- a/sigal/__init__.py +++ b/sigal/__init__.py @@ -32,10 +32,12 @@ from http import server from .gallery import Gallery from .log import init_logging -from .pkgmeta import __version__ from .settings import read_settings from .utils import copy +__version__ = '2.1.dev' +__url__ = 'https://github.com/saimn/sigal' + _DEFAULT_CONFIG_FILE = 'sigal.conf.py' if sys.version_info[:2] < (3, 5): diff --git a/sigal/pkgmeta.py b/sigal/pkgmeta.py deleted file mode 100644 index c154bce..0000000 --- a/sigal/pkgmeta.py +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (c) 2013-2018 - Simon Conseil - -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: - -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. - -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. - -__title__ = 'sigal' -__author__ = 'Simon Conseil' -__version__ = '2.0' -__license__ = 'MIT' -__url__ = 'https://github.com/saimn/sigal' -__all__ = ['__title__', '__author__', '__version__', '__license__', '__url__'] diff --git a/sigal/plugins/media_page.py b/sigal/plugins/media_page.py index 25ad904..2cb52c3 100644 --- a/sigal/plugins/media_page.py +++ b/sigal/plugins/media_page.py @@ -34,7 +34,6 @@ import os from sigal import signals from sigal.writer import AbstractWriter from sigal.utils import url_from_path -from sigal.pkgmeta import __url__ as sigal_link class PageWriter(AbstractWriter): @@ -45,6 +44,7 @@ class PageWriter(AbstractWriter): def write(self, album, media_group): ''' Generate the media page and save it ''' + from sigal import __url__ as sigal_link file_path = os.path.join(album.dst_path, media_group[0].filename) page = self.template.render({ diff --git a/sigal/writer.py b/sigal/writer.py index 9e5e5b3..8042fde 100644 --- a/sigal/writer.py +++ b/sigal/writer.py @@ -31,7 +31,6 @@ from distutils.dir_util import copy_tree from jinja2 import Environment, FileSystemLoader, ChoiceLoader, PrefixLoader from jinja2.exceptions import TemplateNotFound -from .pkgmeta import __url__ as sigal_link from .utils import url_from_path THEMES_PATH = os.path.normpath(os.path.join( @@ -99,6 +98,7 @@ class AbstractWriter(object): def generate_context(self, album): """Generate the context dict for the given path.""" + from . import __url__ as sigal_link self.logger.info("Output album : %r", album) return { 'album': album,