diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..e252f4d --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools>=44", "wheel", "pathlib2; python_version < '3'"] +build-backend = "setuptools.build_meta" diff --git a/setup.cfg b/setup.cfg index e347cdf..f87e114 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,12 @@ 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" +setup_requires = + setuptools>=44 + wheel + pathlib2; python_version < "3" [bdist_wheel] # This flag says that the code is written to work on both Python 2 and Python @@ -35,9 +42,6 @@ python_requires = >=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.* # will need to generate wheels for each Python version that you support. universal=1 -[build-system] -requires = ["setuptools", "wheel"] - [pycodestyle] max-line-length = 140 statistics = True diff --git a/setup.py b/setup.py index 3b29c93..770f60c 100755 --- a/setup.py +++ b/setup.py @@ -1,10 +1,27 @@ -import os from setuptools import setup -from setuptools.config import read_configuration +import ast +try: + from pathlib import Path +except ImportError: + 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_bytes() + m = ast.parse(t) + res = {} + for s in m.body: + if isinstance(s, ast.Assign): + try: + v = ast.literal_eval(s.value) + for t in s.targets: + if isinstance(t, ast.Name): + res[t.id] = v + except ValueError: + continue + + return res + + +if __name__ == "__main__": + setup(version=extract_global_vars(Path(__file__).absolute().parent / "kaitaistruct.py")["__version__"])