Consolidate version strings in pyproject.toml

Storing the current version in a single place greatly simplifies
issuing new package releases.
This commit is contained in:
Justin Mayer 2019-07-03 23:31:38 +02:00
commit 54911fff39
3 changed files with 26 additions and 3 deletions

View file

@ -22,7 +22,7 @@ copyright = '2010 present, Alexis Metaireau and contributors'
exclude_patterns = ['_build']
release = __version__
version = '.'.join(release.split('.')[:1])
last_stable = '4.0.1'
last_stable = __version__
rst_prolog = '''
.. |last_stable| replace:: :pelican-doc:`{0}`
'''.format(last_stable)

View file

@ -32,7 +32,12 @@ from pelican.utils import (clean_output_dir, file_watcher,
folder_watcher, maybe_pluralize)
from pelican.writers import Writer
__version__ = "4.0.2.dev0"
try:
__version__ = __import__('pkg_resources') \
.get_distribution('pelican').version
except Exception:
__version__ = "unknown"
DEFAULT_CONFIG_NAME = 'pelicanconf.py'
logger = logging.getLogger(__name__)

View file

@ -1,4 +1,5 @@
#!/usr/bin/env python
import re
import sys
from io import open
from os import walk
@ -6,6 +7,23 @@ from os.path import join, relpath
from setuptools import setup
def get_version():
VERSION_REGEX = re.compile(
r"^version\s*=\s*\"(?P<version>.*)\"$"
)
with open("pyproject.toml") as f:
for line in f:
match = VERSION_REGEX.match(line)
if match:
return match.group("version")
return None
version = get_version()
requires = ['feedgenerator >= 1.9', 'jinja2 >= 2.7', 'pygments', 'docutils',
'pytz >= 0a', 'blinker', 'unidecode', 'six >= 1.4',
'python-dateutil']
@ -28,7 +46,7 @@ if sys.version_info.major < 3:
setup(
name='pelican',
version='4.0.2.dev0',
version=version,
url='https://getpelican.com/',
author='Alexis Metaireau',
maintainer='Justin Mayer',