-
Notifications
You must be signed in to change notification settings - Fork 348
Expand file tree
/
Copy pathsetup.py
More file actions
75 lines (68 loc) · 1.86 KB
/
setup.py
File metadata and controls
75 lines (68 loc) · 1.86 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python
import os
from setuptools import setup
import subprocess
def get_version():
"""
Get the version from a git tag
Executes
git tag |grep -Eo '[0-9]+\\.[0-9]+\\.[0-9]+' |sort | tail -1
and returns the result
"""
tag_proc = subprocess.Popen(
["git", "tag"],
cwd=".",
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
)
grep_proc = subprocess.Popen(
[
"grep",
"-Eo",
"[0-9]+\\.[0-9]+\\.[0-9]+"
],
stdin=tag_proc.stdout,
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
)
sort_proc = subprocess.Popen(
["sort"],
stdin=grep_proc.stdout,
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
)
tail_proc = subprocess.Popen(
["tail", "-1"],
stdin=sort_proc.stdout,
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
)
(stdout, _) = tail_proc.communicate()
stdout = stdout.decode()
return stdout.strip()
def enumerate_modules() -> list[str]:
"""
Enumerate all additional modules that need to be included in the package.
:return: The list of modules that should be included in the package
"""
modules = []
dotpy = ".py"
for root_dir, _, files in os.walk("canopen"):
for f in files:
if f.endswith(dotpy):
modules.append(
f"{root_dir.replace('/', '.')}.{f.replace(dotpy, '')}"
)
return modules
setup(
name="canopen",
version=get_version(),
description="CANopen stack implementation",
url="https://github.com/christiansandberg/canopen",
author="Christian Sandberg",
author_email="christiansandberg@me.com",
license="MIT",
py_modules=enumerate_modules(),
install_requires=[],
)