-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetup.py
57 lines (46 loc) · 1.81 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
import re
import sys
from pathlib import Path
from setuptools import find_packages, setup
from setuptools.command.test import test as TestCommand
projectRoot: Path = Path(__file__).parent
# Grab the version number out of __init__.py
VERSION_FILE = "src/gwpycore/__init__.py"
version: str = ""
with (projectRoot / VERSION_FILE).open("rt") as f:
try:
version = re.findall(r"^__version__\s*=\s*['\"]([^'\"]+)['\"]\r?$", f.read(), re.M)[0]
except IndexError:
raise RuntimeError("Unable to determine version. __version__ is not defined in __init__.py")
# Grab the required modules out of requirements.txt
with (projectRoot / "requirements.txt").open("rt") as f:
required = f.read().splitlines()
required[:] = [line for line in required if not line.startswith("#")]
# class PyTest(TestCommand):
# user_options = []
# def run(self):
# import subprocess
# import sys
# errno = subprocess.call([sys.executable, "-m", "pytest", "--cov-report", "html", "--cov-report", "term", "--cov", f"{MODULE}/"])
# raise SystemExit(errno)
# print(f"projectRoot = {projectRoot}")
# print(f"version = {version}")
# print(f"required = {required}")
if __name__ == "__main__":
try:
setup(
# Most of the settings are in setup.cfg
version=version,
# use_scm_version={"version_scheme": "no-guess-dev"}
install_requires=required,
# cmdclass=dict(test=PyTest),
# setup_requires=["wheel"],
)
except: # noqa
print(
"\n\nAn error occurred while building the project, "
"please ensure you have the most updated version of setuptools, "
"setuptools_scm and wheel with:\n"
" pip install -U setuptools setuptools_scm wheel\n\n"
)
raise