Skip to content

Commit

Permalink
Fixed setup.py and setup.cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
KOLANICH committed Feb 12, 2020
1 parent 830b5ec commit fb65e81
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools>=41", "wheel"]
build-backend = "setuptools.build_meta"
5 changes: 4 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = kaitaistruct
version = attr: kaitaistruct.__version__
version = attr: __version__
author = Kaitai Project
author_email = [email protected]
url = http://kaitai.io
Expand All @@ -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

Expand All @@ -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
Expand Down
33 changes: 26 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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__"])

0 comments on commit fb65e81

Please sign in to comment.