sdv-installer 0.0.0.dev11__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sdv_installer/__init__.py +7 -0
- sdv_installer/authentication/__init__.py +8 -0
- sdv_installer/authentication/authentication.py +74 -0
- sdv_installer/cli/__init__.py +1 -0
- sdv_installer/cli/__main__.py +165 -0
- sdv_installer/config.py +19 -0
- sdv_installer/constants.py +130 -0
- sdv_installer/installation/__init__.py +17 -0
- sdv_installer/installation/installer.py +490 -0
- sdv_installer/utils/__init__.py +52 -0
- sdv_installer/utils/console_utils.py +277 -0
- sdv_installer/utils/data_storage.py +86 -0
- sdv_installer/utils/package_utils.py +268 -0
- sdv_installer/utils/request_error_handling.py +53 -0
- sdv_installer/utils/system_requirements.py +173 -0
- sdv_installer-0.0.0.dev11.dist-info/METADATA +120 -0
- sdv_installer-0.0.0.dev11.dist-info/RECORD +21 -0
- sdv_installer-0.0.0.dev11.dist-info/WHEEL +5 -0
- sdv_installer-0.0.0.dev11.dist-info/entry_points.txt +2 -0
- sdv_installer-0.0.0.dev11.dist-info/licenses/LICENSE +21 -0
- sdv_installer-0.0.0.dev11.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"""Licensing authentication module."""
|
|
2
|
+
|
|
3
|
+
from functools import wraps
|
|
4
|
+
|
|
5
|
+
import requests
|
|
6
|
+
from requests.exceptions import RequestException
|
|
7
|
+
|
|
8
|
+
from sdv_installer import config
|
|
9
|
+
from sdv_installer.utils import (
|
|
10
|
+
get_password_input,
|
|
11
|
+
print_failed_to_connect,
|
|
12
|
+
print_invalid_credentials,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def authenticate_user_and_license_key(username, license_key):
|
|
17
|
+
"""Authenticate the user and license key by sending a request to the authentication API.
|
|
18
|
+
|
|
19
|
+
Constructs an authentication request using the provided username and license key,
|
|
20
|
+
sends it to the appropriate API endpoint, and returns a boolean indicating whether
|
|
21
|
+
the authentication was successful.
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
username (str):
|
|
25
|
+
The username to authenticate.
|
|
26
|
+
license_key (str):
|
|
27
|
+
The license key to authenticate.
|
|
28
|
+
|
|
29
|
+
Raises:
|
|
30
|
+
InvalidLoginCredentials:
|
|
31
|
+
If the user has provided invalid login credentials.
|
|
32
|
+
|
|
33
|
+
Returns:
|
|
34
|
+
bool:
|
|
35
|
+
True if authentication is successful, False otherwise.
|
|
36
|
+
"""
|
|
37
|
+
post_data = {'username': username, 'license_key': license_key}
|
|
38
|
+
try:
|
|
39
|
+
response = requests.post(
|
|
40
|
+
config.API_VALIDATE, json=post_data, headers=config.HEADERS, timeout=config.TIMEOUT
|
|
41
|
+
)
|
|
42
|
+
except RequestException:
|
|
43
|
+
print_failed_to_connect()
|
|
44
|
+
return False
|
|
45
|
+
|
|
46
|
+
response_dict = response.json()
|
|
47
|
+
valid = response_dict.get('valid', False)
|
|
48
|
+
authenticated = bool(response.status_code == requests.codes.ok and valid)
|
|
49
|
+
if not authenticated:
|
|
50
|
+
print_invalid_credentials()
|
|
51
|
+
|
|
52
|
+
return authenticated
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def authenticate(function):
|
|
56
|
+
"""Authenticate wrapper to be used by other functions."""
|
|
57
|
+
|
|
58
|
+
@wraps(function)
|
|
59
|
+
def wrapper(*args, **kwargs):
|
|
60
|
+
if kwargs.get('username') and kwargs.get('license_key'):
|
|
61
|
+
username = kwargs['username']
|
|
62
|
+
license_key = kwargs['license_key']
|
|
63
|
+
|
|
64
|
+
else:
|
|
65
|
+
username = input('Username: ')
|
|
66
|
+
license_key = get_password_input('License Key: ')
|
|
67
|
+
kwargs['username'] = username
|
|
68
|
+
kwargs['license_key'] = license_key
|
|
69
|
+
|
|
70
|
+
authenticated = authenticate_user_and_license_key(username, license_key)
|
|
71
|
+
if authenticated:
|
|
72
|
+
return function(*args, **kwargs)
|
|
73
|
+
|
|
74
|
+
return wrapper
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""SDV-Installer command line interface."""
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"""SDV-Installer command line interface."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
from sdv_installer.installation import (
|
|
7
|
+
download_packages,
|
|
8
|
+
install_packages,
|
|
9
|
+
install_packages_from_folder,
|
|
10
|
+
list_packages,
|
|
11
|
+
uninstall_packages,
|
|
12
|
+
)
|
|
13
|
+
from sdv_installer.utils.system_requirements import print_check_results
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def install_action(args):
|
|
17
|
+
"""Install the `SDV-Enterprise` packages."""
|
|
18
|
+
if args.folder:
|
|
19
|
+
install_packages_from_folder(
|
|
20
|
+
folder=args.folder,
|
|
21
|
+
package=args.package,
|
|
22
|
+
options=args.options,
|
|
23
|
+
debug=args.debug,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
else:
|
|
27
|
+
install_packages(
|
|
28
|
+
package=args.package,
|
|
29
|
+
options=args.options,
|
|
30
|
+
debug=args.debug,
|
|
31
|
+
version=args.version,
|
|
32
|
+
upgrade=args.upgrade,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def uninstall_action(args):
|
|
37
|
+
"""Uninstall the `SDV-Enterprise` packages."""
|
|
38
|
+
uninstall_packages(debug=args.debug)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def download_action(args):
|
|
42
|
+
"""Download SDV-Enterprise packages for offline install."""
|
|
43
|
+
download_packages(
|
|
44
|
+
package=args.package,
|
|
45
|
+
python_version=args.python_version,
|
|
46
|
+
platform=args.platform,
|
|
47
|
+
folder=args.folder,
|
|
48
|
+
version=args.version,
|
|
49
|
+
options=args.options,
|
|
50
|
+
debug=args.debug,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def list_action(args, parser=None):
|
|
55
|
+
"""List all packages the user has access to."""
|
|
56
|
+
list_packages()
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def perform_check_action(args):
|
|
60
|
+
"""Perform a check on the user's system to verify compatibility with SDV-Enterprise."""
|
|
61
|
+
print_check_results()
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def get_parser():
|
|
65
|
+
"""Return the argparser for the SDV-Installer application."""
|
|
66
|
+
parser = argparse.ArgumentParser(description='SDV Installer.')
|
|
67
|
+
parser.set_defaults(action=None)
|
|
68
|
+
|
|
69
|
+
action = parser.add_subparsers(title='action')
|
|
70
|
+
|
|
71
|
+
# Install
|
|
72
|
+
install_parser = action.add_parser('install', help='Install your SDV Enterprise Packages.')
|
|
73
|
+
install_parser.set_defaults(action=install_action)
|
|
74
|
+
install_parser.add_argument(
|
|
75
|
+
'--package',
|
|
76
|
+
required=False,
|
|
77
|
+
help='The package that you want to install.',
|
|
78
|
+
)
|
|
79
|
+
install_parser.add_argument(
|
|
80
|
+
'--options', help='Optional dependencies to install.', required=False, nargs='+'
|
|
81
|
+
)
|
|
82
|
+
install_parser.add_argument('--folder', type=str, help='Install from a local folder.')
|
|
83
|
+
install_parser.add_argument('--debug', action='store_true', help='Print pip install commands.')
|
|
84
|
+
install_parser.add_argument(
|
|
85
|
+
'-v', '--version', required=False, help='SDV-Enterprise version (e.g., 0.23.0).'
|
|
86
|
+
)
|
|
87
|
+
install_parser.add_argument(
|
|
88
|
+
'-u',
|
|
89
|
+
'--upgrade',
|
|
90
|
+
required=False,
|
|
91
|
+
help='Upgrade the current installed packages.',
|
|
92
|
+
action='store_true',
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
# Uninstall
|
|
96
|
+
uninstall_parser = action.add_parser(
|
|
97
|
+
'uninstall', help='Uninstall your SDV Enterprise Packages.'
|
|
98
|
+
)
|
|
99
|
+
uninstall_parser.set_defaults(action=uninstall_action)
|
|
100
|
+
uninstall_parser.add_argument(
|
|
101
|
+
'--debug', action='store_true', help='Print pip install commands.'
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
# Download
|
|
105
|
+
download_parser = action.add_parser(
|
|
106
|
+
'download',
|
|
107
|
+
help='Download your SDV Enterprise Packages for offline installation.',
|
|
108
|
+
)
|
|
109
|
+
download_parser.set_defaults(action=download_action)
|
|
110
|
+
download_parser.add_argument(
|
|
111
|
+
'--package',
|
|
112
|
+
required=False,
|
|
113
|
+
help=(
|
|
114
|
+
'The package that you want to download. If not provided, all '
|
|
115
|
+
'packages will be downloaded',
|
|
116
|
+
),
|
|
117
|
+
)
|
|
118
|
+
download_parser.add_argument(
|
|
119
|
+
'--python-version', required=False, help='Python version (e.g., 39).'
|
|
120
|
+
)
|
|
121
|
+
download_parser.add_argument(
|
|
122
|
+
'--platform',
|
|
123
|
+
required=False,
|
|
124
|
+
help='Platform tag(s) (e.g., macosx_14_0_arm64). You can specify this multiple times.',
|
|
125
|
+
action='append',
|
|
126
|
+
)
|
|
127
|
+
download_parser.add_argument(
|
|
128
|
+
'--folder', required=True, help='Destination folder for downloaded packages.'
|
|
129
|
+
)
|
|
130
|
+
download_parser.add_argument(
|
|
131
|
+
'--debug', action='store_true', help='Print pip download commands.'
|
|
132
|
+
)
|
|
133
|
+
download_parser.add_argument(
|
|
134
|
+
'--version', required=False, help='SDV-Enterprise version (e.g., 0.23).'
|
|
135
|
+
)
|
|
136
|
+
download_parser.add_argument(
|
|
137
|
+
'--options', help='Optional dependencies to install.', required=False, nargs='+'
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
# List
|
|
141
|
+
list_parser = action.add_parser('list-packages', help='List all packages you have access to.')
|
|
142
|
+
list_parser.set_defaults(action=list_action)
|
|
143
|
+
|
|
144
|
+
# Check Requirements
|
|
145
|
+
check_parser = action.add_parser(
|
|
146
|
+
'check-requirements', help='Check if your system meets SDV Enterprise requirements.'
|
|
147
|
+
)
|
|
148
|
+
check_parser.set_defaults(action=perform_check_action)
|
|
149
|
+
|
|
150
|
+
return parser
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def run_cli():
|
|
154
|
+
"""Run command line interface."""
|
|
155
|
+
parser = get_parser()
|
|
156
|
+
if len(sys.argv) < 2:
|
|
157
|
+
parser.print_help()
|
|
158
|
+
sys.exit(0)
|
|
159
|
+
|
|
160
|
+
args = parser.parse_args()
|
|
161
|
+
args.action(args)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
if __name__ == '__main__':
|
|
165
|
+
run_cli()
|
sdv_installer/config.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""Configuration module for SDV-Installer."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
# Default API URL that will be used
|
|
6
|
+
LKS_URL = os.getenv('LKS_URL', 'https://lks.datacebo.com')
|
|
7
|
+
|
|
8
|
+
# Endpoints
|
|
9
|
+
API_PACKAGE_PERMISSIONS = f'{LKS_URL}/api/v1/package_permissions/active'
|
|
10
|
+
API_VALIDATE = f'{LKS_URL}/api/v1/licenses/validate'
|
|
11
|
+
|
|
12
|
+
# Pypi Server to be used
|
|
13
|
+
PYPI_URL = os.getenv('PYPI_URL', 'pypi.datacebo.com')
|
|
14
|
+
|
|
15
|
+
# Headers
|
|
16
|
+
HEADERS = {'accept': 'application/json', 'Content-Type': 'application/json'}
|
|
17
|
+
|
|
18
|
+
# Timeout Value for API Calls
|
|
19
|
+
TIMEOUT = os.getenv('SDV_API_TIMEOUT', 10)
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"""Constants used across the SDV-Installer."""
|
|
2
|
+
|
|
3
|
+
from enum import IntEnum
|
|
4
|
+
|
|
5
|
+
try:
|
|
6
|
+
from enum import StrEnum as StringEnum
|
|
7
|
+
|
|
8
|
+
except ImportError:
|
|
9
|
+
from enum import Enum as StringEnum
|
|
10
|
+
|
|
11
|
+
from packaging.version import Version
|
|
12
|
+
|
|
13
|
+
from sdv_installer.config import PYPI_URL
|
|
14
|
+
|
|
15
|
+
MIN_PYTHON_VERSION = Version('3.8')
|
|
16
|
+
MAX_PYTHON_VERSION = Version('3.13')
|
|
17
|
+
REQUIRED_BITNESS = '64-bit'
|
|
18
|
+
|
|
19
|
+
SUPPORTED_PLATFORM_TAGS = [
|
|
20
|
+
'macosx_10_9_x86_64',
|
|
21
|
+
'macosx_11_0_universal2',
|
|
22
|
+
'macosx_11_0_x86_64',
|
|
23
|
+
'macosx_12_0_arm64',
|
|
24
|
+
'macosx_12_0_x86_64',
|
|
25
|
+
'macosx_13_0_arm64',
|
|
26
|
+
'macosx_13_0_x86_64',
|
|
27
|
+
'macosx_14_0_arm64',
|
|
28
|
+
'macosx_14_0_x86_64',
|
|
29
|
+
'manylinux2010_x86_64',
|
|
30
|
+
'manylinux2014_x86_64',
|
|
31
|
+
'manylinux_2_17_x86_64',
|
|
32
|
+
'manylinux_2_28_x86_64',
|
|
33
|
+
'musllinux_1_1_x86_64',
|
|
34
|
+
'win_amd64',
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
EXPECTED_PACKAGES = set([
|
|
38
|
+
'sdv-enterprise',
|
|
39
|
+
'sdv-enterprise-full',
|
|
40
|
+
'bundle-cag',
|
|
41
|
+
'bundle-ai-connectors',
|
|
42
|
+
'bundle-xsynthesizers',
|
|
43
|
+
'bundle-differential-privacy',
|
|
44
|
+
])
|
|
45
|
+
|
|
46
|
+
TRUSTED_HOSTS = [
|
|
47
|
+
'pypi.org',
|
|
48
|
+
'pypi.python.org',
|
|
49
|
+
'files.pythonhosted.org',
|
|
50
|
+
PYPI_URL,
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
CONNECTORS_PACKAGES = [
|
|
54
|
+
'bundle-ai-connectors',
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
ACTION_SUCCESS_MESSAGE = {
|
|
59
|
+
'install': 'Installed!',
|
|
60
|
+
'uninstall -y': 'Uninstalled!',
|
|
61
|
+
'download': 'Downloaded!',
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
ACTION_SUCCESS_ALREADY_INSTALLED = {
|
|
65
|
+
'install': 'N/A (already installed)',
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
ACTION_SUCCESS_ALREADY_UPDATED = {
|
|
69
|
+
'install': 'N/A (already installed and up-to-date)',
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
ACTION_ERROR_MESSAGE = {
|
|
73
|
+
'install': 'Installation failed. Use --debug for more details.',
|
|
74
|
+
'uninstall -y': 'Uninstall failed. Use --debug for more details.',
|
|
75
|
+
'download': 'Download failed. Use --debug for more details.',
|
|
76
|
+
}
|
|
77
|
+
ADDITIONAL_DEPS_MESSAGE_PREFIX = (
|
|
78
|
+
'Note: This package has additional required dependencies that were also installed'
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
# Constants for keypresses
|
|
82
|
+
ENTER_KEY = '\r'
|
|
83
|
+
BACKSPACE_KEYS = ['\x08', '\x7f']
|
|
84
|
+
NEWLINE_KEY = '\n'
|
|
85
|
+
|
|
86
|
+
# Constants for Summary Messages
|
|
87
|
+
SUMMARY_SUCCESS_MESSAGE = {
|
|
88
|
+
'install': ('Success! All packages have been installed. You are ready to use SDV Enterprise.'),
|
|
89
|
+
'download': (
|
|
90
|
+
'Success! All packages have been downloaded. '
|
|
91
|
+
'Please install the packages to use SDV Enterprise.'
|
|
92
|
+
),
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
SUMMARY_PARTIAL_SUCCESS_MESSAGE = {
|
|
96
|
+
'install': (
|
|
97
|
+
'Notice! All packages were installed, but `sdv-enterprise` was not included.\n'
|
|
98
|
+
'To use SDV Enterprise, please make sure it is installed.'
|
|
99
|
+
),
|
|
100
|
+
'download': (
|
|
101
|
+
'Notice! All packages were downloaded, but `sdv-enterprise` was not included.\n'
|
|
102
|
+
'Please make sure that you have downloaded SDV-Enterprise in order to '
|
|
103
|
+
'be able to install it later.'
|
|
104
|
+
),
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
SUMMARY_WARNING_MESSAGE = {
|
|
108
|
+
'install': (
|
|
109
|
+
'Warning! Some packages that you have access to could not be installed. '
|
|
110
|
+
'Please check your setup and contact DataCebo to troubleshoot.'
|
|
111
|
+
),
|
|
112
|
+
'download': (
|
|
113
|
+
'Warning! Some packages that you have access to could not be downloaded. '
|
|
114
|
+
'Please check your setup and contact DataCebo to troubleshoot.'
|
|
115
|
+
),
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
class ProductType(StringEnum):
|
|
120
|
+
"""Product type enum."""
|
|
121
|
+
|
|
122
|
+
BASE = 'base'
|
|
123
|
+
BUNDLE = 'bundle'
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
class ExitCode(IntEnum):
|
|
127
|
+
"""Exit Code Representation."""
|
|
128
|
+
|
|
129
|
+
SUCCESS = 0
|
|
130
|
+
ERROR = 1
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""Installation Module."""
|
|
2
|
+
|
|
3
|
+
from sdv_installer.installation.installer import (
|
|
4
|
+
download_packages,
|
|
5
|
+
install_packages_from_folder,
|
|
6
|
+
install_packages,
|
|
7
|
+
list_packages,
|
|
8
|
+
uninstall_packages,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
__all__ = (
|
|
12
|
+
'download_packages',
|
|
13
|
+
'install_packages',
|
|
14
|
+
'install_packages_from_folder',
|
|
15
|
+
'list_packages',
|
|
16
|
+
'uninstall_packages',
|
|
17
|
+
)
|