Skip to content

Commit

Permalink
Upgrade to latest and download the SqlToolsService (dbcli#506)
Browse files Browse the repository at this point in the history
* Upgrade to latest sqltoolsservice
* Change pip resolution in dev_setup.py
* Download the sqltoolsservice platform specific packages from github
  • Loading branch information
pensivebrian authored Jan 29, 2021
1 parent b879daf commit 80c6df1
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 6 deletions.
11 changes: 9 additions & 2 deletions dev_setup.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
#!/usr/bin/env python
from __future__ import print_function

import os
import sys
import utility

PIP = os.getenv('CUSTOM_PIP', 'pip')
PYTHON = os.getenv('CUSTOM_PYTHON', sys.executable)

print('Running dev setup...')
print('Root directory \'%s\'\n' % utility.ROOT_DIR)

# install general requirements.
utility.exec_command('%s install --no-cache-dir -r requirements-dev.txt' % PIP,
utility.exec_command('%s -m pip install --no-cache-dir -r requirements-dev.txt' % PYTHON,
utility.ROOT_DIR)

import mssqlcli.mssqltoolsservice.externals as mssqltoolsservice

# download the sqltoolssevice binaries for all platforms
mssqltoolsservice.download_sqltoolsservice_binaries()

# install mssqltoolsservice if this platform supports it.
utility.copy_current_platform_mssqltoolsservice()

Expand Down
25 changes: 21 additions & 4 deletions mssqlcli/mssqltoolsservice/externals.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,43 @@
import tarfile
import zipfile
from future.standard_library import install_aliases
import requests
import utility

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-netcoreapp2.2.tar.gz',
'Microsoft.SqlTools.ServiceLayer-rhel-x64-netcoreapp3.1.tar.gz',
'macosx_10_11_intel': SQLTOOLSSERVICE_BASE + 'macosx_10_11_intel/' +
'Microsoft.SqlTools.ServiceLayer-osx-x64-netcoreapp2.2.tar.gz',
'Microsoft.SqlTools.ServiceLayer-osx-x64-netcoreapp3.1.tar.gz',
'win_amd64': SQLTOOLSSERVICE_BASE + 'win_amd64/' +
'Microsoft.SqlTools.ServiceLayer-win-x64-netcoreapp2.2.zip',
'Microsoft.SqlTools.ServiceLayer-win-x64-netcoreapp3.1.zip',
'win32': SQLTOOLSSERVICE_BASE + 'win32/' +
'Microsoft.SqlTools.ServiceLayer-win-x86-netcoreapp2.2.zip'
'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)
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):
"""
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 80c6df1

Please sign in to comment.