-
Notifications
You must be signed in to change notification settings - Fork 7
/
setup.py
95 lines (87 loc) · 3.16 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import os.path
from pathlib import Path
from tempfile import TemporaryDirectory
from contextlib import contextmanager
import shutil
from setuptools import setup
from textwrap import dedent
def get_version():
cur_dir = os.path.dirname(__file__)
init_path = os.path.join(cur_dir, "edbterraform", "__init__.py")
with open(init_path) as f:
for line in f:
if line.startswith("__version__"):
return line.split('"')[1]
raise Exception("Version information not found in %s" % init_path)
def get_long_description():
cur_dir = os.path.dirname(__file__)
with open(os.path.join(cur_dir, "README.md")) as f:
return f.read()
def get_requirements():
cur_dir = os.path.dirname(__file__)
requirements_path = os.path.join(cur_dir, "requirements.txt")
with open(requirements_path) as f:
return f.read().splitlines()
@contextmanager
def temp_directory_context():
'''
Create a temporary directory with the source code.
This is needed to avoid leftover artifacts from the build process.
Ref: https://github.com/pypa/build/issues/455
Ref: https://github.com/pypa/setuptools/issues/1347
Ref: https://github.com/pypa/setuptools/issues/1871
'''
cwd = Path.cwd().resolve()
with TemporaryDirectory(prefix='setuptools-', dir=cwd) as temp_dir:
try:
temp_dir = Path(temp_dir).resolve()
temp_src = temp_dir / 'src'
shutil.copytree(src=cwd, dst=temp_src, symlinks=True, ignore=lambda dir, files: [file for file in files if str(temp_dir) in str((Path(dir) / file).resolve())])
os.chdir(temp_src)
yield
finally:
os.chdir(cwd)
with temp_directory_context():
setup(
name="edb-terraform",
version=get_version(),
author="EDB",
author_email="[email protected]",
packages=[
"edbterraform",
],
url="https://github.com/EnterpriseDB/edb-terraform/",
entry_points = {
'console_scripts': [
'edb-terraform = edbterraform.__main__:entry_point',
]
},
license="BSD",
description=dedent("""
Terraform templates aimed to provide easy to use YAML configuration file
describing the target cloud infrastrure.
"""),
long_description=get_long_description(),
long_description_content_type="text/markdown",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python :: 3",
"Topic :: Database",
],
keywords="terraform cloud yaml edb cli aws rds aurora azure aks gcloud gke kubernetes k8s",
python_requires=">=3.8",
install_requires=get_requirements(),
extras_require={},
data_files=[], # Deprecated
package_data={
'edbterraform': [
'data/terraform/*',
'data/terraform/*/modules/*/*',
'data/templates/**/*',
'utils/*',
'parser/*',
],
}
)