-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.py
66 lines (55 loc) · 2.25 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
from setuptools import setup
from os import environ, path, walk
BASE_PATH = path.abspath(path.dirname(__file__))
def get_version():
"""Find the version of the package"""
version = None
version_file = path.join(BASE_PATH, "ovos_mark1/version.py")
major, minor, build, alpha = (None, None, None, None)
with open(version_file) as f:
for line in f:
if "VERSION_MAJOR" in line:
major = line.split("=")[1].strip()
elif "VERSION_MINOR" in line:
minor = line.split("=")[1].strip()
elif "VERSION_BUILD" in line:
build = line.split("=")[1].strip()
elif "VERSION_ALPHA" in line:
alpha = line.split("=")[1].strip()
if (major and minor and build and alpha) or "# END_VERSION_BLOCK" in line:
break
version = f"{major}.{minor}.{build}"
if alpha and int(alpha) > 0:
version += f"a{alpha}"
return version
def required(requirements_file):
""" Read requirements file and remove comments and empty lines. """
with open(path.join(BASE_PATH, requirements_file), 'r') as f:
requirements = f.read().splitlines()
if 'MYCROFT_LOOSE_REQUIREMENTS' in environ:
print('USING LOOSE REQUIREMENTS!')
requirements = [r.replace('==', '>=').replace('~=', '>=') for r in requirements]
return [pkg for pkg in requirements
if pkg.strip() and not pkg.startswith("#")]
def package_files(directory):
paths = []
for (p, directories, filenames) in walk(directory):
for filename in filenames:
paths.append(path.join('..', p, filename))
return paths
with open(path.join(BASE_PATH, "README.md"), "r") as f:
long_description = f.read()
setup(
name="ovos-mark1-utils",
version=get_version(),
url="https://github.com/OpenVoiceOS/ovos-mark1-utils",
license="Apache-2.0",
install_requires=required("requirements.txt"),
author="Jarbas",
author_email="jarbas@openvoiceos.com",
long_description=long_description,
long_description_content_type="text/markdown",
packages=["ovos_mark1", "ovos_mark1.eyes", "ovos_mark1.faceplate"],
package_data={"": package_files("ovos_mark1")},
include_package_data=True,
)