From fb65e81416b4b10bfc5199c7505acb0884b602ae Mon Sep 17 00:00:00 2001 From: KOLANICH Date: Mon, 3 Feb 2020 02:28:41 +0300 Subject: [PATCH] Fixed setup.py and setup.cfg --- pyproject.toml | 3 +++ setup.cfg | 5 ++++- setup.py | 33 ++++++++++++++++++++++++++------- 3 files changed, 33 insertions(+), 8 deletions(-) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..cefdfab --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools>=41", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/setup.cfg b/setup.cfg index e347cdf..eae6c22 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = kaitaistruct -version = attr: kaitaistruct.__version__ +version = attr: __version__ author = Kaitai Project author_email = greycat@kaitai.io url = http://kaitai.io @@ -20,6 +20,7 @@ classifiers = Programming Language :: Python :: 3.5 Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 Programming Language :: Python :: Implementation :: CPython Programming Language :: Python :: Implementation :: PyPy @@ -28,6 +29,8 @@ zip_safe = True include_package_data = True py_modules = kaitaistruct python_requires = >=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.* +install_requires = + enum34; python_version < "3.4" [bdist_wheel] # This flag says that the code is written to work on both Python 2 and Python diff --git a/setup.py b/setup.py index 3b29c93..226fedb 100755 --- a/setup.py +++ b/setup.py @@ -1,10 +1,29 @@ -import os from setuptools import setup -from setuptools.config import read_configuration +import ast +try: + from pathlib import Path +except: + from pathlib2 import Path -this_dir = os.path.dirname(__file__) -cfg = read_configuration(os.path.join(this_dir, 'setup.cfg')) -cfg["options"].update(cfg["metadata"]) -cfg = cfg["options"] -setup(**cfg) +def extract_global_vars(file): + t = file.read_text(encoding="utf-8") + m = ast.parse(t) + res = {} + for s in m.body: + if isinstance(s, ast.Assign): + vo = s.value + v = None + if isinstance(vo, ast.Str): + v = vo.s + elif isinstance(vo, ast.Num): + v = vo.n + + if v is not None: + for t in s.targets: + if isinstance(t, ast.Name): + res[t.id] = v + return res + +if __name__ == "__main__": + setup(version=extract_global_vars(Path(__file__).absolute().parent / "kaitaistruct.py")["__version__"])