-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsetuputil.py
More file actions
75 lines (57 loc) · 1.88 KB
/
setuputil.py
File metadata and controls
75 lines (57 loc) · 1.88 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
import platform
import sys
import os
import importlib
import re
# import setuptools
def find_version(fnam, version="VERSION"):
with open(fnam) as f:
cont = f.read()
regex = f'{version}\\s*=\\s*["]([^"]+)["]'
match = re.search(regex, cont)
if match is None:
raise Exception(
f"version with spec={version} not found, use double quotes for version string"
)
return match.group(1)
def find_projectname():
cwd = os.getcwd()
name = os.path.basename(cwd)
return name
def load_requirements():
with open("requirements.txt") as f:
lines = f.readlines()
lines = map(lambda x: x.strip(), lines)
lines = filter(lambda x: len(x) > 0, lines)
lines = filter(lambda x: x[0] != "#", lines)
return list(lines)
def get_scripts(projectname):
# console_scripts = []
# gui_scripts = []
# try:
# mod = importlib.import_module(f"{projectname}.__main__")
# if "main_func" in dir(mod):
# console_scripts = [
# f"{projectname} = {projectname}.__main__:main_func",
# ]
# if "gui_func" in dir(mod):
# gui_scripts = [
# f"{projectname}-ui = {projectname}.__main__:gui_func",
# ]
# except:
# print("no scripts found", file=sys.stderr)
# raise Exception()
entry_points = {
"console_scripts": ["gtcd=gitonic.gtcd:main_func", "gtls=gitonic.gtls:main_func"],
"gui_scripts": ["gitonic=gitonic.gitonic:main_func"],
}
return entry_points
pyver = platform.python_version_tuple()[:2]
pyversion = ".".join(pyver)
python_requires = f">={pyversion}"
#python_requires = f">=3.12,<3.13"
projectname = find_projectname()
file = os.path.join(projectname, "core", "const.py")
version = find_version(file)
install_requires = load_requirements()
entry_points = get_scripts(projectname)