-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
76 lines (64 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
67
68
69
70
71
72
73
74
75
76
# LICENSE
# This software is the exclusive property of Gencovery SAS.
# The use and distribution of this software is prohibited without the prior consent of Gencovery SAS.
# About us: https://gencovery.com
import json
import os
import sys
from subprocess import check_call
import setuptools
from setuptools.command.install import install
with open("settings.json", "r", encoding="utf-8") as fh:
settings = json.load(fh)
name = settings["name"]
description = settings["description"]
version = settings["version"]
author = settings.get("author", "")
author_email = settings.get("author_email", "")
with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
class InstallHook(install):
"""Installation hooks (for production mode)."""
def _run_install(self, what):
cwd = os.path.join(self.install_lib, name)
script_path = os.path.join(cwd, ".hooks", f"{what}-install.sh")
if os.path.exists(script_path):
check_call(["bash", script_path], cwd=cwd)
script_path = os.path.join(cwd, ".hooks", f"{what}-install.py")
if os.path.exists(script_path):
check_call([sys.executable, script_path], cwd=cwd)
def _run_pre_install(self):
self.announce("Running pre-install hook ...")
self._run_install("pre")
self.announce("Done!")
def _run_post_install(self):
self.announce("Running post-install hook ...")
self._run_install("post")
self.announce("Done!")
def run(self):
self._run_pre_install()
install.run(self)
self._run_post_install()
setuptools.setup(
name=name,
version=version,
author=author,
author_email=author_email,
description=description,
long_description=long_description,
long_description_content_type="text/markdown",
# url="https://github.com/pypa/sampleproject",
# project_urls={
# "Bug Tracker": "https://github.com/pypa/sampleproject/issues",
# },
classifiers=[
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
],
package_dir={"": "src"},
packages=setuptools.find_packages(where="src"),
python_requires=">=3.8",
cmdclass={
'install': InstallHook,
},
)