-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
40 lines (34 loc) · 1.08 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from os import getcwd, chdir
from re import findall
from setuptools import setup
from subprocess import call
def pep_version(s: str) -> str:
"""Take initial numeric part from the string, to comply with PEP-440"""
return "0.1"
for i in range(0, len(s)):
if not s[i] in "0123456789.":
break
return s[:i].rstrip(".")
with open("debian/changelog", "r") as clog:
_, version, _ = findall(
r"(?P<src>.*) \((?P<version>.*)\) (?P<suite>.*); .*",
clog.readline().strip(),
)[0]
print("Building a definitions file")
curdir = getcwd()
chdir("mknetlinkdefs")
result = call(["make"])
if result:
raise RuntimeError(f"make failed with result={result}")
chdir(curdir)
print(f"configuring package with version {pep_version(version)}")
setup(
name="netlinklib",
version=pep_version(version),
description="Higher performance netlink library",
author="Eugene Crosser",
author_email="[email protected]",
packages=["netlinklib"],
package_data={'netlinklib': ["py.typed"]},
tests_require=["black", "pylint", "mypy"],
)