Skip to content

Commit 690a174

Browse files
committed
Fixed setup.py and setup.cfg
1 parent 830b5ec commit 690a174

File tree

3 files changed

+32
-8
lines changed

3 files changed

+32
-8
lines changed

pyproject.toml

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

setup.cfg

+6-1
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,6 +29,10 @@ 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+
pathlib2; python_version < "3"
3136

3237
[bdist_wheel]
3338
# This flag says that the code is written to work on both Python 2 and Python

setup.py

+23-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
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+
if __name__ == "__main__":
26+
setup(version=extract_global_vars(Path(__file__).absolute().parent / "kaitaistruct.py")["__version__"])

0 commit comments

Comments
 (0)