sdv-installer 0.2.1.dev0__tar.gz → 0.3.1.dev0__tar.gz
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-0.2.1.dev0/sdv_installer.egg-info → sdv_installer-0.3.1.dev0}/PKG-INFO +1 -1
- {sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/pyproject.toml +1 -1
- {sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/sdv_installer/__init__.py +1 -1
- {sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/sdv_installer/cli/__main__.py +25 -2
- {sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/sdv_installer/config.py +1 -0
- {sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/sdv_installer/constants.py +1 -0
- {sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/sdv_installer/installation/__init__.py +2 -0
- {sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/sdv_installer/installation/installer.py +87 -0
- {sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0/sdv_installer.egg-info}/PKG-INFO +1 -1
- {sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/LICENSE +0 -0
- {sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/README.md +0 -0
- {sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/sdv_installer/authentication/__init__.py +0 -0
- {sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/sdv_installer/authentication/authentication.py +4 -4
- {sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/sdv_installer/cli/__init__.py +0 -0
- {sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/sdv_installer/utils/__init__.py +0 -0
- {sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/sdv_installer/utils/console_utils.py +0 -0
- {sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/sdv_installer/utils/data_storage.py +0 -0
- {sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/sdv_installer/utils/package_utils.py +0 -0
- {sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/sdv_installer/utils/request_error_handling.py +0 -0
- {sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/sdv_installer/utils/system_requirements.py +0 -0
- {sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/sdv_installer.egg-info/SOURCES.txt +0 -0
- {sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/sdv_installer.egg-info/dependency_links.txt +0 -0
- {sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/sdv_installer.egg-info/entry_points.txt +0 -0
- {sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/sdv_installer.egg-info/requires.txt +0 -0
- {sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/sdv_installer.egg-info/top_level.txt +0 -0
- {sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/setup.cfg +0 -0
|
@@ -165,7 +165,7 @@ max-doc-length = 100
|
|
|
165
165
|
max-line-length = 100
|
|
166
166
|
|
|
167
167
|
[tool.bumpversion]
|
|
168
|
-
current_version = "0.
|
|
168
|
+
current_version = "0.3.1.dev0"
|
|
169
169
|
parse = '(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<release>[a-z]+)(?P<candidate>\d+))?'
|
|
170
170
|
serialize = [
|
|
171
171
|
'{major}.{minor}.{patch}.{release}{candidate}',
|
|
@@ -5,6 +5,7 @@ import sys
|
|
|
5
5
|
|
|
6
6
|
from sdv_installer.installation import (
|
|
7
7
|
download_packages,
|
|
8
|
+
get_auth_file,
|
|
8
9
|
install_packages,
|
|
9
10
|
install_packages_from_folder,
|
|
10
11
|
list_packages,
|
|
@@ -13,7 +14,7 @@ from sdv_installer.installation import (
|
|
|
13
14
|
from sdv_installer.utils.system_requirements import print_check_results
|
|
14
15
|
|
|
15
16
|
# Adding a new version here to avoid circular imports
|
|
16
|
-
SDV_INSTALLER_VERSION = '0.
|
|
17
|
+
SDV_INSTALLER_VERSION = '0.3.1.dev0'
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
def install_action(args):
|
|
@@ -67,6 +68,16 @@ def list_action(args, parser=None):
|
|
|
67
68
|
)
|
|
68
69
|
|
|
69
70
|
|
|
71
|
+
def authenticate_action(args):
|
|
72
|
+
"""Download auth file."""
|
|
73
|
+
get_auth_file(
|
|
74
|
+
username=args.username,
|
|
75
|
+
license_key=args.license_key,
|
|
76
|
+
folder=args.folder,
|
|
77
|
+
credentials=args.credentials,
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
|
|
70
81
|
def perform_check_action(args):
|
|
71
82
|
"""Perform a check on the user's system to verify compatibility with SDV-Enterprise."""
|
|
72
83
|
print_check_results()
|
|
@@ -130,7 +141,7 @@ def get_parser():
|
|
|
130
141
|
required=False,
|
|
131
142
|
help=(
|
|
132
143
|
'The package that you want to download. If not provided, all '
|
|
133
|
-
'packages will be downloaded'
|
|
144
|
+
'packages will be downloaded'
|
|
134
145
|
),
|
|
135
146
|
)
|
|
136
147
|
download_parser.add_argument(
|
|
@@ -171,6 +182,18 @@ def get_parser():
|
|
|
171
182
|
'--credentials', required=False, help='Path to a credentials json file.'
|
|
172
183
|
)
|
|
173
184
|
|
|
185
|
+
# Authenticate
|
|
186
|
+
auth_parser = action.add_parser(
|
|
187
|
+
'authenticate', help='Download auth file to required destination or specified folder.'
|
|
188
|
+
)
|
|
189
|
+
auth_parser.set_defaults(action=authenticate_action)
|
|
190
|
+
auth_parser.add_argument('--username', required=False, help='SDV-Enterprise username.')
|
|
191
|
+
auth_parser.add_argument('--license-key', required=False, help='SDV-Enterprise license key.')
|
|
192
|
+
auth_parser.add_argument('--folder', required=False, help='Destination folder for auth file.')
|
|
193
|
+
auth_parser.add_argument(
|
|
194
|
+
'--credentials', required=False, help='Path to a credentials json file.'
|
|
195
|
+
)
|
|
196
|
+
|
|
174
197
|
# Check Requirements
|
|
175
198
|
check_parser = action.add_parser(
|
|
176
199
|
'check-requirements', help='Check if your system meets SDV Enterprise requirements.'
|
|
@@ -8,6 +8,7 @@ LKS_URL = os.getenv('LKS_URL', 'https://lks.datacebo.com')
|
|
|
8
8
|
# Endpoints
|
|
9
9
|
API_PACKAGE_PERMISSIONS = f'{LKS_URL}/api/v1/package_permissions/active'
|
|
10
10
|
API_VALIDATE = f'{LKS_URL}/api/v1/licenses/validate'
|
|
11
|
+
API_AUTH_FILE = f'{LKS_URL}/api/v1/licenses/auth_file'
|
|
11
12
|
|
|
12
13
|
# Pypi Server to be used
|
|
13
14
|
PYPI_URL = os.getenv('PYPI_URL', 'pypi.datacebo.com')
|
{sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/sdv_installer/installation/__init__.py
RENAMED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from sdv_installer.installation.installer import (
|
|
4
4
|
download_packages,
|
|
5
|
+
get_auth_file,
|
|
5
6
|
install_packages_from_folder,
|
|
6
7
|
install_packages,
|
|
7
8
|
list_packages,
|
|
@@ -10,6 +11,7 @@ from sdv_installer.installation.installer import (
|
|
|
10
11
|
|
|
11
12
|
__all__ = (
|
|
12
13
|
'download_packages',
|
|
14
|
+
'get_auth_file',
|
|
13
15
|
'install_packages',
|
|
14
16
|
'install_packages_from_folder',
|
|
15
17
|
'list_packages',
|
{sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/sdv_installer/installation/installer.py
RENAMED
|
@@ -3,16 +3,21 @@
|
|
|
3
3
|
import glob
|
|
4
4
|
import json
|
|
5
5
|
import logging
|
|
6
|
+
import os
|
|
7
|
+
import pathlib
|
|
8
|
+
import shutil
|
|
6
9
|
import subprocess
|
|
7
10
|
import sys
|
|
8
11
|
from typing import Dict, List, Optional, Union
|
|
9
12
|
|
|
10
13
|
import requests
|
|
14
|
+
from platformdirs import user_data_dir
|
|
11
15
|
from requests.exceptions import RequestException
|
|
12
16
|
|
|
13
17
|
from sdv_installer import config
|
|
14
18
|
from sdv_installer.authentication import authenticate
|
|
15
19
|
from sdv_installer.constants import (
|
|
20
|
+
AUTH_FILE_NAME,
|
|
16
21
|
CONNECTORS_PACKAGES,
|
|
17
22
|
EXPECTED_PACKAGES,
|
|
18
23
|
TRUSTED_HOSTS,
|
|
@@ -336,6 +341,85 @@ def _get_packages(username, license_key, package=None, options=None):
|
|
|
336
341
|
return package_to_product_type
|
|
337
342
|
|
|
338
343
|
|
|
344
|
+
def _create_user_data_dir(data_dir, error_message=None):
|
|
345
|
+
if not error_message:
|
|
346
|
+
error_message = "Unable to write auth file to user's data directory. Permissions required."
|
|
347
|
+
try:
|
|
348
|
+
data_dir_path = pathlib.Path(data_dir)
|
|
349
|
+
data_dir_path.mkdir(parents=True, exist_ok=True)
|
|
350
|
+
except PermissionError:
|
|
351
|
+
raise RuntimeError(error_message)
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
def _save_auth_file(username, license_key, folder=None):
|
|
355
|
+
"""Retrieve the auth file for a user and save it to their appdata folder.
|
|
356
|
+
|
|
357
|
+
Args:
|
|
358
|
+
username (str):
|
|
359
|
+
Username of user to get auth file for.
|
|
360
|
+
license_key (str):
|
|
361
|
+
User's license key.
|
|
362
|
+
folder (str | None):
|
|
363
|
+
Folder to save the auth file to.
|
|
364
|
+
"""
|
|
365
|
+
error_message = None
|
|
366
|
+
if folder:
|
|
367
|
+
data_dir = folder
|
|
368
|
+
error_message = 'Unable to create specified folder. Permissions required.'
|
|
369
|
+
else:
|
|
370
|
+
data_dir = user_data_dir(appname='sdv-enterprise', appauthor='Datacebo')
|
|
371
|
+
|
|
372
|
+
_create_user_data_dir(data_dir, error_message)
|
|
373
|
+
auth_file_path = pathlib.Path(data_dir, AUTH_FILE_NAME)
|
|
374
|
+
try:
|
|
375
|
+
response = requests.post(
|
|
376
|
+
config.API_AUTH_FILE,
|
|
377
|
+
data=json.dumps({'username': username, 'license_key': license_key}),
|
|
378
|
+
headers=config.HEADERS,
|
|
379
|
+
)
|
|
380
|
+
response.raise_for_status()
|
|
381
|
+
except requests.HTTPError as e:
|
|
382
|
+
raise RuntimeError('Could not fetch auth file') from e
|
|
383
|
+
|
|
384
|
+
auth_json = response.json()
|
|
385
|
+
with open(auth_file_path, 'w') as f:
|
|
386
|
+
json.dump(auth_json, f)
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
def _move_auth_file(source_folder, destination=None):
|
|
390
|
+
"""Move the auth file to the required location.
|
|
391
|
+
|
|
392
|
+
Args:
|
|
393
|
+
source_folder (str):
|
|
394
|
+
The folder the auth file is in.
|
|
395
|
+
destination (str | None):
|
|
396
|
+
The path to move the file to. If None, then move to the user data dir.
|
|
397
|
+
"""
|
|
398
|
+
if destination is None:
|
|
399
|
+
destination = user_data_dir(appname='sdv-enterprise', appauthor='Datacebo')
|
|
400
|
+
_create_user_data_dir(destination)
|
|
401
|
+
|
|
402
|
+
auth_file_path = pathlib.Path(source_folder, AUTH_FILE_NAME)
|
|
403
|
+
if os.path.exists(auth_file_path):
|
|
404
|
+
shutil.copy(auth_file_path, pathlib.Path(destination) / AUTH_FILE_NAME)
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
@authenticate
|
|
408
|
+
def get_auth_file(username=None, license_key=None, folder=None, **kwargs):
|
|
409
|
+
"""Retrieve the auth file from the license key service.
|
|
410
|
+
|
|
411
|
+
Args:
|
|
412
|
+
username (str):
|
|
413
|
+
The username for SDV Enterprise.
|
|
414
|
+
license_key (str):
|
|
415
|
+
The license key.
|
|
416
|
+
folder (str):
|
|
417
|
+
The folder path to save the auth file to. If None, it will save to the
|
|
418
|
+
location SDV Enterprise requires.
|
|
419
|
+
"""
|
|
420
|
+
_save_auth_file(username=username, license_key=license_key, folder=folder)
|
|
421
|
+
|
|
422
|
+
|
|
339
423
|
@authenticate
|
|
340
424
|
def install_packages(
|
|
341
425
|
username=None,
|
|
@@ -348,6 +432,7 @@ def install_packages(
|
|
|
348
432
|
**kwargs,
|
|
349
433
|
):
|
|
350
434
|
"""Install packages in the current environment (online)."""
|
|
435
|
+
_save_auth_file(username, license_key)
|
|
351
436
|
all_sdv_enterprise_related_pkgs = _get_accessible_packages(username, license_key)
|
|
352
437
|
packages_before_install = list_current_installed_packages()
|
|
353
438
|
|
|
@@ -381,6 +466,7 @@ def install_packages(
|
|
|
381
466
|
def install_packages_from_folder(folder, package=None, options=None, debug=False):
|
|
382
467
|
"""Install packages from a folder (offline)."""
|
|
383
468
|
wheels = glob.glob(f'{folder}/*.whl')
|
|
469
|
+
_move_auth_file(folder)
|
|
384
470
|
packages = set()
|
|
385
471
|
for wheel in wheels:
|
|
386
472
|
package_name = get_package_name(wheel)
|
|
@@ -468,6 +554,7 @@ def download_packages(
|
|
|
468
554
|
**kwargs,
|
|
469
555
|
):
|
|
470
556
|
"""Download packages into a local folder for offline installation."""
|
|
557
|
+
_save_auth_file(username, license_key, folder=folder)
|
|
471
558
|
packages = _get_packages(
|
|
472
559
|
username=username, license_key=license_key, package=package, options=options
|
|
473
560
|
)
|
|
File without changes
|
|
File without changes
|
{sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/sdv_installer/authentication/__init__.py
RENAMED
|
File without changes
|
{sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/sdv_installer/authentication/authentication.py
RENAMED
|
@@ -28,13 +28,13 @@ def authenticate_user_and_license_key(username, license_key):
|
|
|
28
28
|
license_key (str):
|
|
29
29
|
The license key to authenticate.
|
|
30
30
|
|
|
31
|
-
Raises:
|
|
32
|
-
InvalidLoginCredentials:
|
|
33
|
-
If the user has provided invalid login credentials.
|
|
34
|
-
|
|
35
31
|
Returns:
|
|
36
32
|
bool:
|
|
37
33
|
True if authentication is successful, False otherwise.
|
|
34
|
+
|
|
35
|
+
Raises:
|
|
36
|
+
InvalidLoginCredentials:
|
|
37
|
+
If the user has provided invalid login credentials.
|
|
38
38
|
"""
|
|
39
39
|
post_data = {'username': username, 'license_key': license_key}
|
|
40
40
|
try:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/sdv_installer/utils/request_error_handling.py
RENAMED
|
File without changes
|
{sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/sdv_installer/utils/system_requirements.py
RENAMED
|
File without changes
|
|
File without changes
|
{sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/sdv_installer.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{sdv_installer-0.2.1.dev0 → sdv_installer-0.3.1.dev0}/sdv_installer.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|