diff --git a/pyproject.toml b/pyproject.toml index d894f16..869fef5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,4 +12,4 @@ build-backend = 'setuptools.build_meta' [tool.setuptools.dynamic] # dependencies = { file = ['requirements.txt'] } -version = { attr = 'ktools.VERSION' } +version = { attr = 'ktools.__version__' } diff --git a/setup.py b/setup.py index e7ec623..bf92518 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,29 @@ +from codecs import open as codecs_open +from os.path import abspath, dirname, join from pathlib import Path from setuptools import setup + +def read(rel_path): + here = abspath(dirname(__file__)) + with codecs_open(join(here, rel_path), 'r') as fp: + return fp.read() + + +def get_version(rel_path): + for line in read(rel_path).splitlines(): + if line.startswith('__version__'): + delim = '"' if '"' in line else "'" + return line.split(delim)[1] + else: + raise RuntimeError("Unable to find version string.") + +print('XXX', get_version(rel_path='src/ktools/__init__.py')) + setup( name='py-ktools', - version='1.0.1', + version=get_version(rel_path='src/ktools/__init__.py'), # packages=['ktools'], install_requires=[ ], @@ -14,7 +33,7 @@ setup( 'typing_extensions~=4.4', 'Unidecode~=1.3.6', 'rjsmin~=1.2.1', - 'Jinja2==3.1.2', + 'Jinja2~=3.1.2', ] }, author='László Károlyi', diff --git a/src/ktools/__init__.py b/src/ktools/__init__.py index 93c5f40..858de17 100644 --- a/src/ktools/__init__.py +++ b/src/ktools/__init__.py @@ -1 +1 @@ -VERSION = '1.0.4' +__version__ = '1.0.5'