-
Notifications
You must be signed in to change notification settings - Fork 193
Expand file tree
/
Copy pathexternals.py
More file actions
82 lines (66 loc) · 3.21 KB
/
externals.py
File metadata and controls
82 lines (66 loc) · 3.21 KB
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
from __future__ import print_function
import os
import sys
import tarfile
import zipfile
from future.standard_library import install_aliases
import requests
import utility
import platform
install_aliases()
SQLTOOLSSERVICE_RELEASE = "v3.0.0-release.72"
SQLTOOLSSERVICE_BASE = os.path.join(utility.ROOT_DIR, 'sqltoolsservice/')
# Supported platform key's must match those in mssqlscript's setup.py.
SUPPORTED_PLATFORMS = {
'manylinux1_x86_64': SQLTOOLSSERVICE_BASE + 'manylinux1/' +
'Microsoft.SqlTools.ServiceLayer-rhel-x64-netcoreapp3.1.tar.gz',
manylinux2014_aarch64': SQLTOOLSSERVICE_BASE + 'manylinux2014/' +
'v3.0.0-release.72.tar.gz',
'macosx_10_11_intel': SQLTOOLSSERVICE_BASE + 'macosx_10_11_intel/' +
'Microsoft.SqlTools.ServiceLayer-osx-x64-netcoreapp3.1.tar.gz',
'win_amd64': SQLTOOLSSERVICE_BASE + 'win_amd64/' +
'Microsoft.SqlTools.ServiceLayer-win-x64-netcoreapp3.1.zip',
'win32': SQLTOOLSSERVICE_BASE + 'win32/' +
'Microsoft.SqlTools.ServiceLayer-win-x86-netcoreapp3.1.zip'
}
TARGET_DIRECTORY = os.path.abspath(os.path.join(os.path.abspath(__file__), '..', 'bin'))
def download_sqltoolsservice_binaries():
"""
Download each for the plaform specific sqltoolsservice packages
"""
for packageFilePath in SUPPORTED_PLATFORMS.values():
if not os.path.exists(os.path.dirname(packageFilePath)):
os.makedirs(os.path.dirname(packageFilePath))
packageFileName = os.path.basename(packageFilePath)
if platform.machine() == 'aarch64':
githubUrl = 'https://github.com/microsoft/sqltoolsservice/archive/refs/tags/v3.0.0-release.72.tar.gz'
else:
githubUrl = 'https://github.com/microsoft/sqltoolsservice/releases/download/{}/{}'.format(SQLTOOLSSERVICE_RELEASE, packageFileName)
print('Downloading {}'.format(githubUrl))
r = requests.get(githubUrl)
with open(packageFilePath, 'wb') as f:
f.write(r.content)
def copy_sqltoolsservice(platform):
"""
For each supported platform, build a universal wheel.
"""
# Clean up dangling directories if previous run was interrupted.
utility.clean_up(directory=TARGET_DIRECTORY)
if not platform or platform not in SUPPORTED_PLATFORMS:
print('{} is not supported.'.format(platform))
print('Please provide a valid platform flag.' +
'[win32, win_amd64, manylinux1_x86_64, macosx_10_11_intel, manylinux2014_aarch64]')
sys.exit(1)
copy_file_path = SUPPORTED_PLATFORMS[platform]
print('Sqltoolsservice archive found at {}'.format(copy_file_path))
if copy_file_path.endswith('tar.gz'):
compressed_file = tarfile.open(name=copy_file_path, mode='r:gz')
elif copy_file_path.endswith('.zip'):
compressed_file = zipfile.ZipFile(copy_file_path)
if not os.path.exists(TARGET_DIRECTORY):
os.makedirs(TARGET_DIRECTORY)
print(u'Bin placing sqltoolsservice for this platform: {}.'.format(platform))
print(u'Extracting files from {}'.format(copy_file_path))
compressed_file.extractall(TARGET_DIRECTORY)
def clean_up_sqltoolsservice():
utility.clean_up(directory=TARGET_DIRECTORY)