forked from Seagate/cortx-ha
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
104 lines (91 loc) · 3.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
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
96
97
98
99
100
101
102
103
104
#!/usr/bin/env python3
# Copyright (c) 2021 Seagate Technology LLC and/or its Affiliates
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# For any questions about this software or licensing,
# please email opensource@seagate.com or cortx-questions@seagate.com.
import os
import sys
from setuptools import setup
# Get the installation dir and version from command line
install_dir = "/opt/seagate/cortx/ha/" #default value
version = "2.0.0"
for argument in sys.argv:
if argument.startswith("--install-dir"):
install_dir = argument.split("=")[1]
# remove it. setup doesn't need it.
sys.argv.remove(argument)
for argument in sys.argv:
if argument.startswith("--version"):
version = argument.split("=")[1]
# remove it. setup doesn't need it.
sys.argv.remove(argument)
with open('README.md', 'r') as rf:
long_description = rf.read()
def get_data_files() -> list:
data_files = [(install_dir + '/meta-info', ['LICENSE', 'README.md', 'jenkins/requirements.txt'])]
ignore_dirs = ['v1', 'iostack-ha']
replace_dirs_in_dest = ('v2', 'common', 'mini_provisioner')
conf_dir = 'conf'
for root, _, file_names in os.walk(conf_dir):
dest_root = root
last_dir = root.split("/")[-1]
if last_dir in ignore_dirs:
continue
if dest_root.endswith(replace_dirs_in_dest):
dest_root = "/".join(dest_root.split("/")[:-1])
# Repeat the check for double such sufixes
if dest_root.endswith(replace_dirs_in_dest):
dest_root = "/".join(dest_root.split("/")[:-1])
dest_root = install_dir + '/' + dest_root
dest_root = dest_root.replace('/common/', '/')
dest_root = dest_root.replace('/v2/', '/')
dest_root = dest_root.replace('/mini_provisioner/', '/')
src_files = []
for a_file in file_names:
src_files.append(root+"/"+a_file)
if len(src_files) != 0:
data_files.append((dest_root, src_files))
# See if same dest_root multiple times create a problem
return data_files
def get_packages() -> list:
ignore_list = ['pcswrap', 'test', '__pycache__']
packages = ['ha']
package_root = 'ha'
for root, directories, _ in os.walk(package_root):
for a_dir in directories:
package = root + '/' + a_dir
package = package.replace('/', '.')
if len(set(package.split('.')).intersection(set(ignore_list))) == 0:
packages.append(package)
return packages
def get_install_requirements() -> list:
install_requires = []
with open('jenkins/requirements.txt') as r:
install_requires = [line.strip() for line in r]
return install_requires
setup(name='cortx-ha',
version=version,
url='https://github.com/Seagate/cortx-ha',
license='Seagate',
author='Ajay Srivastava',
author_email='ajay.srivastava@seagate.com',
description='High availability for CORTX',
package_dir={'ha': 'ha'},
packages=get_packages(),
package_data={
'ha': ['py.typed'],
},
data_files = get_data_files(),
long_description=long_description,
zip_safe=False,
python_requires='>=3.6',
install_requires=get_install_requirements())