Skip to content

Commit 135a031

Browse files
committed
Fixed setup.py and setup.cfg
and 1 formatting issue
1 parent b54805c commit 135a031

File tree

4 files changed

+36
-11
lines changed

4 files changed

+36
-11
lines changed

kaitaistruct.py

+1
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ def __init__(self, max, actual, io, src_path):
457457
self.max = max
458458
self.actual = actual
459459

460+
460461
class ValidationNotAnyOfError(ValidationFailedError):
461462
"""Signals validation failure: we required "actual" value to be
462463
from the list, but it turned out that it's not.

pyproject.toml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["setuptools>=44", "wheel", "pathlib2; python_version < '3'"]
3+
build-backend = "setuptools.build_meta"

setup.cfg

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = kaitaistruct
3-
version = attr: kaitaistruct.__version__
3+
version = attr: __version__
44
author = Kaitai Project
55
author_email = greycat@kaitai.io
66
url = http://kaitai.io
@@ -20,6 +20,7 @@ classifiers =
2020
Programming Language :: Python :: 3.5
2121
Programming Language :: Python :: 3.6
2222
Programming Language :: Python :: 3.7
23+
Programming Language :: Python :: 3.8
2324
Programming Language :: Python :: Implementation :: CPython
2425
Programming Language :: Python :: Implementation :: PyPy
2526

@@ -28,16 +29,19 @@ zip_safe = True
2829
include_package_data = True
2930
py_modules = kaitaistruct
3031
python_requires = >=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*
32+
install_requires =
33+
enum34; python_version < "3.4"
34+
setup_requires =
35+
setuptools>=44
36+
wheel
37+
pathlib2; python_version < "3"
3138

3239
[bdist_wheel]
3340
# This flag says that the code is written to work on both Python 2 and Python
3441
# 3. If at all possible, it is good practice to do this. If you cannot, you
3542
# will need to generate wheels for each Python version that you support.
3643
universal=1
3744

38-
[build-system]
39-
requires = ["setuptools", "wheel"]
40-
4145
[pycodestyle]
4246
max-line-length = 140
4347
statistics = True

setup.py

+24-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
1-
import os
21
from setuptools import setup
3-
from setuptools.config import read_configuration
2+
import ast
3+
try:
4+
from pathlib import Path
5+
except ImportError:
6+
from pathlib2 import Path
47

5-
this_dir = os.path.dirname(__file__)
6-
cfg = read_configuration(os.path.join(this_dir, 'setup.cfg'))
7-
cfg["options"].update(cfg["metadata"])
8-
cfg = cfg["options"]
98

10-
setup(**cfg)
9+
def extract_global_vars(file):
10+
t = file.read_bytes()
11+
m = ast.parse(t)
12+
res = {}
13+
for s in m.body:
14+
if isinstance(s, ast.Assign):
15+
try:
16+
v = ast.literal_eval(s.value)
17+
for t in s.targets:
18+
if isinstance(t, ast.Name):
19+
res[t.id] = v
20+
except ValueError:
21+
continue
22+
23+
return res
24+
25+
26+
if __name__ == "__main__":
27+
setup(version=extract_global_vars(Path(__file__).absolute().parent / "kaitaistruct.py")["__version__"])

0 commit comments

Comments
 (0)