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

Commit ad37035

Browse files
authored
Merging dev to master for release 1.0.0a20 (#141)
* 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 * Fix perf issue where main event loop takes 100% of CPU (#132) Fix perf issue where main event loop takes 100% of CPU We have a 2 threads: Thread #1 runs in a loop polling the response queue Thread #2 runs in a loop decoding responses from the sqltoolsservice over stdout and posting them to the response queue Since thread #1 doesn't sleep, it's takes 100% CPU. In addition, running python 2.7 on windows, #2 doesn’t preempt the CPU due to #1 taking all of the CPU cycles, so no response is processed. Fix is simple – thread #1 needs to sleep so thread #2 can get scheduled and get it’s work done. * Refine event loop perf fix in main.py Refine event loop perf fix in main.py * Fixing regular expression Previous regex would result in release:a1 and release_version: 12. Modified the regex for part Release to only pick up lower case letters. * Adding missing forward slash on test pypi url * fixing typos/grammar (#138) fixing typos/grammar. * Updating to release version 1.0.0a20.
1 parent 0717f08 commit ad37035

18 files changed

+177
-46
lines changed

.bumpversion.cfg

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[bumpversion]
2-
current_version = 1.0.0a18
3-
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)((?P<release>.*))(?P<release_version>\d+)
2+
current_version = 1.0.0a20
3+
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)((?P<release>[a-z]+))(?P<release_version>\d+)
44
serialize =
55
{major}.{minor}.{patch}{release}{release_version}
66

.travis.yml

-2
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

-2
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

+124
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

+2-1
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

+3-5
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.')

doc/installation_guide.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Installation Guide
22

33
## Quick Start
4-
mssql-scritper is installed via pip. If you know pip, you can install mssql-scripter using command
4+
mssql-scripter is installed via pip. If you know pip, you can install mssql-scripter using command
55
```shell
66
$ pip install mssql-scripter
77
```
@@ -70,7 +70,7 @@ $ sudo apt-get install python-pip
7070
$ sudo pip install --upgrade pip
7171
```
7272

73-
Install mssql-scritper using command:
73+
Install mssql-scripter using command:
7474

7575
```shell
7676
$ sudo pip install mssql-scripter
@@ -103,7 +103,7 @@ More information can be found at:
103103

104104
- [Development guide](development_guide.md#Environment_Setup)
105105

106-
## Error: Could not find version that satifies the requirement mssql-scripter
106+
## Error: Could not find version that satisfies the requirement mssql-scripter
107107
If you see the above error running `pip install mssql-scripter`, this means the pip version used is out-of-date. Upgrade pip using the command:
108108
```shell
109109
$ sudo apt-get install python-pip
@@ -141,7 +141,7 @@ $ sudo apt-get install libunwind8
141141
```
142142

143143
### Debian 8
144-
The file `/etc/apt/sources.list' needs to updated with the following line
144+
The file `/etc/apt/sources.list' needs to be updated with the following line
145145
```
146146
deb http://ftp.us.debian.org/debian/ jessie main
147147
```

doc/pypi_release_steps.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ bumpversion release_version  -> 1.0.0a<b>1</b>
8686
    pypitest
8787
 
8888
[pypitest]
89-
repository = https://test.pypi.org/legacy
89+
repository = https://test.pypi.org/legacy/
9090
username = your_username
9191
password = your_password
9292
```

mssqlscripter/__init__.py

+1-1
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.0a20'

mssqlscripter/jsonrpc/contracts/tests/test_scripting.py

+1-1
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)

mssqlscripter/main.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,11 @@ def main(args):
8787

8888
while not scripting_request.completed():
8989
response = scripting_request.get_response()
90-
9190
if response:
9291
scriptercallbacks.handle_response(response, parameters.DisplayProgress)
92+
else:
93+
# The sleep prevents burning up the CPU and lets other threads get scheduled.
94+
time.sleep(0.1)
9395

9496
# Only write to stdout if user did not provide a file path.
9597
logger.info('stdout current encoding: {}'.format(sys.stdout.encoding))

mssqltoolsservice/buildwheels.py

+11-11
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

+2-2
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.0a20'
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

+1-1
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.0a20'
1616

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

setup.py

+3-4
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.0a20'
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

+4-6
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
<OutputPath>.</OutputPath>
1212
<ProjectTypeGuids>{888888a0-9f3d-457c-b088-3a5042f75d52}</ProjectTypeGuids>
1313
<LaunchProvider>Standard Python launcher</LaunchProvider>
14-
<InterpreterId />
15-
<InterpreterVersion />
1614
<CommandLineArguments>-S localhost -d AdventureWorks2014</CommandLineArguments>
1715
<EnableNativeCodeDebugging>False</EnableNativeCodeDebugging>
1816
<IsWindowsApplication>False</IsWindowsApplication>
@@ -21,10 +19,11 @@
2119
<PropertyGroup Condition="'$(Configuration)' == 'Release'" />
2220
<PropertyGroup>
2321
<VisualStudioVersion Condition=" '$(VisualStudioVersion)' == '' ">10.0</VisualStudioVersion>
24-
<PtvsTargetsFile>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets</PtvsTargetsFile>
2522
</PropertyGroup>
2623
<ItemGroup>
2724
<Content Include=".gitignore" />
25+
<Content Include="appveyor.yml" />
26+
<Content Include="dev_requirements.txt" />
2827
<Content Include="doc\README.md" />
2928
<Content Include="doc\architecture_guide.md" />
3029
<Content Include="doc\development_guide.md" />
@@ -43,13 +42,13 @@
4342
<Content Include="mssqltoolsservice\README.rst" />
4443
<Content Include="mssqltoolsservice\setup.cfg" />
4544
<Content Include="README.rst" />
46-
<Content Include="requirements.txt" />
4745
<Content Include="setup.cfg" />
4846
<Content Include="tox.ini" />
4947
<Content Include=".bumpversion.cfg" />
5048
<Content Include=".travis.yml" />
5149
</ItemGroup>
5250
<ItemGroup>
51+
<Compile Include="build.py" />
5352
<Compile Include="dev_setup.py" />
5453
<Compile Include="mssqlscripter\argparser.py" />
5554
<Compile Include="mssqlscripter\jsonrpc\contracts\scriptingservice.py" />
@@ -87,6 +86,5 @@
8786
<Folder Include="mssqltoolsservice\" />
8887
<Folder Include="mssqltoolsservice\mssqltoolsservice\" />
8988
</ItemGroup>
90-
<Import Project="$(PtvsTargetsFile)" Condition="Exists($(PtvsTargetsFile))" />
91-
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" Condition="!Exists($(PtvsTargetsFile))" />
89+
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />
9290
</Project>

0 commit comments

Comments
 (0)