-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathsetup.py
76 lines (67 loc) · 2.41 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
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
76
import setuptools
import os
import glob
import sys
import git # pip install gitpython
from pathlib import Path
PACKAGE = 'funscript_editor'
DESCRIPTION = "A tool to create funscripts"
INCLUDE_REQUIREMENTS = False
DOCS = ['docs/app/site', 'docs/code/_build/html']
try:
TAGS = sorted(git.Repo('.').tags, key=lambda x: x.commit.committed_datetime) if os.path.exists('.git') else []
except:
print("Warning: not a git repository")
TAGS = []
VERSION = str(TAGS[-1]) if len(TAGS) > 0 else "0.0.0"
try:
src = [os.path.join('..', x) \
for x in git.Git('.').ls_files().splitlines() \
if x.startswith(PACKAGE+os.sep) \
and os.path.exists(x)]
except:
# TODO untested
print("Warning fallback to glob")
src = [os.path.join('..', f) for f in glob.glob(PACKAGE+os.sep+"**"+os.sep+"*", recursive=True)]
docs = []
for docs_dir in DOCS:
docs += [os.path.join('.', x) \
for x in Path(docs_dir).rglob('**/*') \
if os.path.isfile(x)]
with open("README.md", "r", encoding="utf-8") as f:
long_description = f.read()
if INCLUDE_REQUIREMENTS:
with open("requirements.txt", "r", encoding="utf-8") as f:
requirements = [x.strip() for x in f.readlines()\
if not any(a in x.lower() for a in ['opencv', 'pyqt'])]
#NOTE: I recommend to install this packages with your favorite package manager.
# Otherwise they will not work reliably. e.g. use pacman -Sy python-opencv python-pyqt5 ...
else:
requirements = []
with open(os.path.join(PACKAGE, 'VERSION.txt'), 'w') as f:
f.write(VERSION)
src += [os.path.join('..', PACKAGE, 'VERSION.txt')]
setuptools.setup(
name=PACKAGE.replace('_', '-'),
version=VERSION.replace('v', ''),
author="btw i use arch",
author_email="git@local",
description=DESCRIPTION,
long_description=long_description,
long_description_content_type="text/markdown",
classifiers=[
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
],
entry_points={
'console_scripts': [
str(PACKAGE.replace('_', '-') + '=' + PACKAGE + '.__main__:main'),
]
},
install_requires=requirements,
packages=[PACKAGE],
package_data={PACKAGE: src},
data_files=[(os.path.join('/', PACKAGE, os.path.dirname(x)), [x]) for x in docs],
python_requires=">=3.6",
setup_requires=['wheel', 'gitpython'],
)