Skip to content
This repository was archived by the owner on May 7, 2024. It is now read-only.

Commit 24a5dc8

Browse files
authored
Use SqlToolsService built on .NET Core 2.0 and a build script updates (#131)
* Bump version to 1.0.0a19 * Use .NET Core 2.0 RTM built sqltoolsservice * Add build script to upload to azure blob storage * Upgrade to VS 2017 * Remove 3.3 as supported Python version
1 parent ca49239 commit 24a5dc8

File tree

15 files changed

+178
-42
lines changed

15 files changed

+178
-42
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 1.0.0a18
2+
current_version = 1.0.0a19
33
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)((?P<release>.*))(?P<release_version>\d+)
44
serialize =
55
{major}.{minor}.{patch}{release}{release_version}

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ matrix:
1010
env: TOXENV=py27
1111
- os: linux
1212
python: "2.7"
13-
- os: linux
14-
python: "3.3"
1513
- os: linux
1614
python: "3.4"
1715
- os: linux

appveyor.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ environment:
33
matrix:
44
- TOXENV: "py27"
55
PYTHON: "C:\\Python27"
6-
- TOXENV: "py33"
7-
PYTHON: "C:\\Python33"
86
- TOXENV: "py34"
97
PYTHON: "C:\\Python34"
108
- TOXENV: "py35"

build.py

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#!/usr/bin/env python
2+
3+
# --------------------------------------------------------------------------------------------
4+
# Copyright (c) Microsoft Corporation. All rights reserved.
5+
# Licensed under the MIT License. See License.txt in the project root for license information.
6+
# --------------------------------------------------------------------------------------------
7+
8+
from __future__ import print_function
9+
import os
10+
import re
11+
import sys
12+
import tempfile
13+
import utility
14+
from azure.storage.blob import BlockBlobService, ContentSettings
15+
16+
AZURE_STORAGE_CONNECTION_STRING = os.environ.get('AZURE_STORAGE_CONNECTION_STRING')
17+
BLOB_CONTAINER_NAME = 'simple'
18+
UPLOADED_PACKAGE_LINKS = []
19+
20+
21+
def print_heading(heading, f=None):
22+
print('{0}\n{1}\n{0}'.format('=' * len(heading), heading), file=f)
23+
24+
25+
def upload_index_file(service, blob_name, title, links):
26+
print('Uploading index file {}'.format(blob_name))
27+
service.create_blob_from_text(
28+
container_name=BLOB_CONTAINER_NAME,
29+
blob_name=blob_name,
30+
text="<html><head><title>{0}</title></head><body><h1>{0}</h1>{1}</body></html>"
31+
.format(title, '\n'.join(
32+
['<a href="{0}">{0}</a><br/>'.format(link) for link in links])),
33+
content_settings=ContentSettings(
34+
content_type='text/html',
35+
content_disposition=None,
36+
content_encoding=None,
37+
content_language=None,
38+
content_md5=None,
39+
cache_control=None
40+
)
41+
)
42+
43+
44+
def gen_pkg_index_html(service, pkg_name):
45+
links = []
46+
index_file_name = pkg_name+'/'
47+
for blob in list(service.list_blobs(BLOB_CONTAINER_NAME, prefix=index_file_name)):
48+
if blob.name == index_file_name:
49+
# Exclude the index file from being added to the list
50+
continue
51+
links.append(blob.name.replace(index_file_name, ''))
52+
upload_index_file(service, index_file_name, 'Links for {}'.format(pkg_name), links)
53+
UPLOADED_PACKAGE_LINKS.append(index_file_name)
54+
55+
56+
def upload_package(service, file_path, pkg_name):
57+
print('Uploading {}'.format(file_path))
58+
file_name = os.path.basename(file_path)
59+
blob_name = '{}/{}'.format(pkg_name, file_name)
60+
service.create_blob_from_path(
61+
container_name=BLOB_CONTAINER_NAME,
62+
blob_name=blob_name,
63+
file_path=file_path
64+
)
65+
gen_pkg_index_html(service, pkg_name)
66+
67+
68+
def build(options):
69+
70+
supported_actions = ['nightly']
71+
action = None
72+
73+
if len(options) >= 1:
74+
if options[0] not in supported_actions:
75+
print('Please provide a supported action {}.'.format(supported_actions))
76+
return
77+
action = options[0]
78+
79+
if action == 'nightly':
80+
assert AZURE_STORAGE_CONNECTION_STRING, 'Set AZURE_STORAGE_CONNECTION_STRING environment variable'
81+
82+
print_heading('Cleanup')
83+
84+
# clean
85+
utility.clean_up(utility.MSSQLSCRIPTER_DIST_DIRECTORY)
86+
utility.clean_up(utility.MSSQLTOOLSSERVICE_DIST_DIRECTORY)
87+
utility.cleaun_up_egg_info_sub_directories(utility.ROOT_DIR)
88+
utility.cleaun_up_egg_info_sub_directories(utility.MSSQLTOOLSSERVICE_DIRECTORY)
89+
90+
print_heading('Running setup')
91+
92+
# install general requirements.
93+
utility.exec_command('pip install -r dev_requirements.txt', utility.ROOT_DIR)
94+
95+
print_heading('Running mssql-scripter tests')
96+
utility.exec_command('tox', utility.ROOT_DIR, continue_on_error = False)
97+
98+
print_heading('Building mssql-scripter pip package')
99+
utility.exec_command('python setup.py check -r -s sdist', utility.ROOT_DIR, continue_on_error = False)
100+
101+
print_heading('Building mssqltoolsservice pip package')
102+
utility.exec_command('python buildwheels.py', utility.MSSQLTOOLSSERVICE_DIRECTORY, continue_on_error = False)
103+
104+
if action == 'nightly':
105+
blob_service = BlockBlobService(connection_string=AZURE_STORAGE_CONNECTION_STRING)
106+
107+
print_heading('Uploading packages to blob storage ')
108+
for pkg in os.listdir(utility.MSSQLSCRIPTER_DIST_DIRECTORY):
109+
pkg_path = os.path.join(utility.MSSQLSCRIPTER_DIST_DIRECTORY, pkg)
110+
print('Uploading package {}'.format(pkg_path))
111+
upload_package(blob_service, pkg_path, 'mssql-scripter')
112+
113+
for pkg in os.listdir(utility.MSSQLTOOLSSERVICE_DIST_DIRECTORY):
114+
pkg_path = os.path.join(utility.MSSQLTOOLSSERVICE_DIST_DIRECTORY, pkg)
115+
pkg_name = os.path.basename(pkg_path).split('-')[0].replace('_', '-').lower()
116+
print('Uploading package {}'.format(pkg_name))
117+
upload_package(blob_service, pkg_path, pkg_name)
118+
119+
# Upload the final index file
120+
upload_index_file(blob_service, 'index.html', 'Simple Index', UPLOADED_PACKAGE_LINKS)
121+
122+
123+
if __name__ == '__main__':
124+
build(sys.argv[1:])

dev_requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ flake8 >= 3.3.0
1111
pytest >= 3.0.7
1212
pytest-cov >= 2.5.1
1313
readme_renderer >= 17.2
14-
docutils >= 0.13.1
14+
docutils >= 0.13.1
15+
azure-storage >= 0.33.0

dev_setup.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,16 @@
1212
import setup
1313
import utility
1414

15-
root_dir = os.path.abspath(os.path.join(os.path.abspath(__file__), '..'))
16-
1715
print('Running dev setup...')
18-
print('Root directory \'{}\'\n'.format(root_dir))
16+
print('Root directory \'{}\'\n'.format(utility.ROOT_DIR))
1917

2018
# install general requirements.
21-
utility.exec_command('pip install -r dev_requirements.txt', root_dir)
19+
utility.exec_command('pip install -r dev_requirements.txt', utility.ROOT_DIR)
2220

2321
# install mssqltoolsservice if this platform supports it.
2422
mssqltoolsservice_package_name = os.environ['MSSQLTOOLSSERVICE_PACKAGE_NAME']
2523
print('Installing {}...'.format(mssqltoolsservice_package_name))
2624
# mssqltoolsservice package name is retrieved from environment variable set by setup.py.
27-
utility.exec_command('pip install {}'.format(mssqltoolsservice_package_name), root_dir)
25+
utility.exec_command('pip install {}'.format(mssqltoolsservice_package_name), utility.ROOT_DIR)
2826

2927
print('Finished dev setup.')

mssqlscripter/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
# Licensed under the MIT License. See License.txt in the project root for license information.
44
# --------------------------------------------------------------------------------------------
55

6-
__version__ = '1.0.0a18'
6+
__version__ = '1.0.0a19'

mssqlscripter/jsonrpc/contracts/tests/test_scripting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ def generate_new_baseline(self, file_name):
362362
# Point sqltoolsservice output to file.
363363
with io.open(file_name, 'wb') as baseline:
364364
tools_service_process = subprocess.Popen(
365-
'D:\\GitHub\\sqltoolsservice\\src\\Microsoft.SqlTools.ServiceLayer\\bin\\Debug\\netcoreapp1.0\\win7-x64\\Microsoft.SqlTools.ServiceLayer.exe',
365+
'D:\\GitHub\\sqltoolsservice\\src\\Microsoft.SqlTools.ServiceLayer\\bin\\Debug\\netcoreapp2.0\\win7-x64\\MicrosoftSqlToolsServiceLayer.exe',
366366
bufsize=0,
367367
stdin=subprocess.PIPE,
368368
stdout=baseline)

mssqltoolsservice/buildwheels.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@
1717
from urllib.request import urlopen
1818

1919

20-
DOWNLOAD_URL_BASE = 'https://mssqlscripter.blob.core.windows.net/sqltoolsservice-08-01-2017/'
20+
DOWNLOAD_URL_BASE = 'https://mssqlscripter.blob.core.windows.net/sqltoolsservice-08-16-2017/'
2121

2222
# Supported platform key's must match those in mssqlscript's setup.py.
2323
SUPPORTED_PLATFORMS = {
24-
'CentOS_7': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-centos-x64-netcoreapp1.0.tar.gz',
25-
'Debian_8': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-debian-x64-netcoreapp1.0.tar.gz',
26-
'Fedora_23': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-fedora-x64-netcoreapp1.0.tar.gz',
27-
'openSUSE_13_2': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-opensuse-x64-netcoreapp1.0.tar.gz',
28-
'OSX_10_11_64': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-osx-x64-netcoreapp1.0.tar.gz',
29-
'RHEL_7': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-rhel-x64-netcoreapp1.0.tar.gz',
30-
'Ubuntu_14': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-ubuntu14-x64-netcoreapp1.0.tar.gz',
31-
'Ubuntu_16': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-ubuntu16-x64-netcoreapp1.0.tar.gz',
32-
'Windows_7_64': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-win-x64-netcoreapp1.0.zip',
33-
'Windows_7_86': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-win-x86-netcoreapp1.0.zip',
24+
'CentOS_7': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-centos-x64-netcoreapp2.0.tar.gz',
25+
'Debian_8': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-debian-x64-netcoreapp2.0.tar.gz',
26+
'Fedora_23': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-fedora-x64-netcoreapp2.0.tar.gz',
27+
'openSUSE_13_2': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-opensuse-x64-netcoreapp2.0.tar.gz',
28+
'OSX_10_11_64': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-osx-x64-netcoreapp2.0.tar.gz',
29+
'RHEL_7': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-rhel-x64-netcoreapp2.0.tar.gz',
30+
'Ubuntu_14': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-ubuntu14-x64-netcoreapp2.0.tar.gz',
31+
'Ubuntu_16': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-ubuntu16-x64-netcoreapp2.0.tar.gz',
32+
'Windows_7_64': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-win-x64-netcoreapp2.0.zip',
33+
'Windows_7_86': DOWNLOAD_URL_BASE + 'microsoft.sqltools.servicelayer-win-x86-netcoreapp2.0.zip'
3434
}
3535

3636
CURRENT_DIRECTORY = os.path.abspath(os.path.join(os.path.abspath(__file__), '..'))

mssqltoolsservice/mssqltoolsservice/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import os
1010
import platform
1111

12-
__version__ = '1.0.0a18'
12+
__version__ = '1.0.0a19'
1313

1414

1515
def get_executable_path():
@@ -28,7 +28,7 @@ def get_executable_path():
2828
'bin'))
2929

3030
# Format name based on platform.
31-
mssqltoolsservice_name = u'Microsoft.SqlTools.ServiceLayer{}'.format(
31+
mssqltoolsservice_name = u'MicrosoftSqlToolsServiceLayer{}'.format(
3232
u'.exe' if (platform.system() == u'Windows') else u'')
3333

3434
mssqltoolsservice_full_path = os.path.abspath(os.path.join(mssqltoolsservice_base_path, mssqltoolsservice_name))

mssqltoolsservice/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
# This version number is in place in two places and must be in sync with
1414
# mssqlscripter's version in setup.py.
15-
MSSQLTOOLSSERVICE_VERSION = '1.0.0a18'
15+
MSSQLTOOLSSERVICE_VERSION = '1.0.0a19'
1616

1717
# If we have source, validate version numbers match to prevent
1818
# uploading releases with mismatched versions.

setup.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
# This version number is in place in two places and must be in sync with
1616
# mssqltoolsservice's version in setup.py.
17-
MSSQLSCRIPTER_VERSION = '1.0.0a18'
17+
MSSQLSCRIPTER_VERSION = '1.0.0a19'
1818

1919
# If we have the source, validate our setup version matches source version.
2020
# This will prevent uploading releases with mismatched versions. This will
@@ -56,7 +56,7 @@
5656
toolsservice_version.group(1)))
5757
sys.exit(1)
5858

59-
MSSQLTOOLSSERVICE_PACKAGE_NAME = 'mssqltoolsservice_{}=={}'
59+
MSSQLTOOLSSERVICE_PACKAGE_NAME = 'mssqltoolsservice-{}=={}'
6060
MSSQLTOOLSSERVICE_PACKAGE_SUFFIX = [
6161
'CentOS_7',
6262
'Debian_8',
@@ -204,7 +204,7 @@ def get_mssqltoolsservice_package_name(run_time_id=_get_runtime_id()):
204204
# set package suffix name for other uses like building wheels outside of setup.py.
205205
os.environ['MSSQLTOOLSSERVICE_PACKAGE_SUFFIX'] = run_time_id
206206
return MSSQLTOOLSSERVICE_PACKAGE_NAME.format(
207-
run_time_id, MSSQLSCRIPTER_VERSION)
207+
run_time_id, MSSQLSCRIPTER_VERSION).replace('_', '-').lower()
208208

209209
raise EnvironmentError('mssqltoolsservice is not supported on this platform.')
210210

@@ -217,7 +217,6 @@ def get_mssqltoolsservice_package_name(run_time_id=_get_runtime_id()):
217217
'Programming Language :: Python :: 2',
218218
'Programming Language :: Python :: 2.7',
219219
'Programming Language :: Python :: 3',
220-
'Programming Language :: Python :: 3.3',
221220
'Programming Language :: Python :: 3.4',
222221
'Programming Language :: Python :: 3.5',
223222
'Programming Language :: Python :: 3.6',

sql-xplat-cli.pyproj

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,27 @@
55
<SchemaVersion>2.0</SchemaVersion>
66
<ProjectGuid>{f4bb6290-43f3-4f35-b26e-067c5ef8e64b}</ProjectGuid>
77
<ProjectHome />
8-
<StartupFile>mssqlscripter\main.py</StartupFile>
8+
<StartupFile>build.py</StartupFile>
99
<SearchPath>.</SearchPath>
1010
<WorkingDirectory>.</WorkingDirectory>
1111
<OutputPath>.</OutputPath>
1212
<ProjectTypeGuids>{888888a0-9f3d-457c-b088-3a5042f75d52}</ProjectTypeGuids>
1313
<LaunchProvider>Standard Python launcher</LaunchProvider>
14-
<InterpreterId />
15-
<InterpreterVersion />
16-
<CommandLineArguments>-S localhost -d AdventureWorks2014</CommandLineArguments>
14+
<InterpreterId>Global|PythonCore|2.7</InterpreterId>
15+
<CommandLineArguments>
16+
</CommandLineArguments>
1717
<EnableNativeCodeDebugging>False</EnableNativeCodeDebugging>
1818
<IsWindowsApplication>False</IsWindowsApplication>
1919
</PropertyGroup>
2020
<PropertyGroup Condition="'$(Configuration)' == 'Debug'" />
2121
<PropertyGroup Condition="'$(Configuration)' == 'Release'" />
2222
<PropertyGroup>
2323
<VisualStudioVersion Condition=" '$(VisualStudioVersion)' == '' ">10.0</VisualStudioVersion>
24-
<PtvsTargetsFile>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets</PtvsTargetsFile>
2524
</PropertyGroup>
2625
<ItemGroup>
2726
<Content Include=".gitignore" />
28-
<Content Include="doc\README.md" />
27+
<Content Include="appveyor.yml" />
28+
<Content Include="dev_requirements.txt" />
2929
<Content Include="doc\architecture_guide.md" />
3030
<Content Include="doc\development_guide.md" />
3131
<Content Include="doc\pypi_release_steps.md" />
@@ -43,13 +43,15 @@
4343
<Content Include="mssqltoolsservice\README.rst" />
4444
<Content Include="mssqltoolsservice\setup.cfg" />
4545
<Content Include="README.rst" />
46-
<Content Include="requirements.txt" />
4746
<Content Include="setup.cfg" />
4847
<Content Include="tox.ini" />
4948
<Content Include=".bumpversion.cfg" />
5049
<Content Include=".travis.yml" />
5150
</ItemGroup>
5251
<ItemGroup>
52+
<Compile Include="build.py">
53+
<SubType>Code</SubType>
54+
</Compile>
5355
<Compile Include="dev_setup.py" />
5456
<Compile Include="mssqlscripter\argparser.py" />
5557
<Compile Include="mssqlscripter\jsonrpc\contracts\scriptingservice.py" />
@@ -87,6 +89,9 @@
8789
<Folder Include="mssqltoolsservice\" />
8890
<Folder Include="mssqltoolsservice\mssqltoolsservice\" />
8991
</ItemGroup>
90-
<Import Project="$(PtvsTargetsFile)" Condition="Exists($(PtvsTargetsFile))" />
91-
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" Condition="!Exists($(PtvsTargetsFile))" />
92+
<ItemGroup>
93+
<InterpreterReference Include="Global|PythonCore|2.7" />
94+
<InterpreterReference Include="Global|PythonCore|3.6" />
95+
</ItemGroup>
96+
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />
9297
</Project>

sql-xplat-cli.sln

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 14
4-
VisualStudioVersion = 14.0.25420.1
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.26730.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "sql-xplat-cli", "sql-xplat-cli.pyproj", "{F4BB6290-43F3-4F35-B26E-067C5EF8E64B}"
77
EndProject
@@ -17,4 +17,7 @@ Global
1717
GlobalSection(SolutionProperties) = preSolution
1818
HideSolutionNode = FALSE
1919
EndGlobalSection
20+
GlobalSection(ExtensibilityGlobals) = postSolution
21+
SolutionGuid = {1DD06426-BEB7-4299-B45E-04535B761301}
22+
EndGlobalSection
2023
EndGlobal

utility.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
import shutil
1010
import sys
1111

12+
ROOT_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..'))
13+
14+
MSSQLTOOLSSERVICE_DIRECTORY = os.path.abspath(os.path.join(
15+
os.path.abspath(__file__), '..', 'mssqltoolsservice'))
1216

1317
MSSQLSCRIPTER_DIST_DIRECTORY = os.path.abspath(
1418
os.path.join(os.path.abspath(__file__), '..', 'dist'))
@@ -32,6 +36,12 @@ def exec_command(command, directory, continue_on_error=True):
3236
pass
3337

3438

39+
def cleaun_up_egg_info_sub_directories(directory):
40+
for f in os.listdir(directory):
41+
if f.endswith(".egg-info"):
42+
clean_up(os.path.join(directory, f))
43+
44+
3545
def clean_up(directory):
3646
"""
3747
Delete directory.

0 commit comments

Comments
 (0)