* Adding version support. Adding detection logic to prevent mismatch version upload between source and setup. Fixed formatting for pep8.

* Adding bump version config file

* Setting alpha version

* Adding versioning for read me rst files

* Adding README rst files to bump config

* Clearing clean directory issue

* Version changes clean start

* Versioning starting at 1.0.0.a0 for alpha releases

* Adding bumpversion with initial version config

* Updating requirement's version along with adding bumpversion

* Fixing lint issue

* Fixing issues in mssqltoolsservice versioning

* Fixing python 2 issue regarding opening a file.

* Fixing IO.open to catch IOError instead of OS error.
This commit is contained in:
Ronald Quan 2017-05-03 10:16:33 -07:00 коммит произвёл GitHub
Родитель f19255191a
Коммит 10dd94cdac
11 изменённых файлов: 166 добавлений и 42 удалений

25
.bumpversion.cfg Normal file
Просмотреть файл

@ -0,0 +1,25 @@
[bumpversion]
current_version = 1.0.0a0
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)((?P<release>.*))(?P<release_version>\d+)
serialize =
{major}.{minor}.{patch}{release}{release_version}
[bumpversion:part:release]
optional_value = production
values =
a
rc
production
[bumpversion:file:setup.py]
[bumpversion:file:mssqltoolsservice/setup.py]
[bumpversion:file:mssqlscripter/__init__.py]
[bumpversion:file:mssqltoolsservice/mssqltoolsservice/__init__.py]
[bumpversion:file:README.rst]
[bumpversion:file:mssqltoolsservice/README.rst]

Просмотреть файл

@ -1,5 +1,5 @@
mssql-scripter 0.1.1.alpha9
===========================
mssql-scripter 1.0.0a0
============================
Were excited to introduce mssql-scripter, a multi-platform command line
experience for scripting SQL Server databases.

Просмотреть файл

@ -1,2 +0,0 @@
Microsoft Sql Scripter Module
=============================

Просмотреть файл

@ -2,3 +2,5 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
__version__='1.0.0a0'

Просмотреть файл

@ -5,6 +5,7 @@
import argparse
import getpass
import mssqlscripter
import os
import sys
@ -18,7 +19,8 @@ def parse_arguments(args):
"""
parser = argparse.ArgumentParser(
prog=u'mssql-scripter',
description=u'mssql-scripter tool used for scripting out databases')
description=u'Microsoft SQL Server Scripter Command Line Tool. ' +
'Version {}'.format(mssqlscripter.__version__))
group_connection_options = parser.add_mutually_exclusive_group()
group_connection_options.add_argument(
@ -373,6 +375,11 @@ def parse_arguments(args):
default=False,
help=u'Enable verbose logging.')
parser.add_argument(
u'--version',
action=u'version',
version='{}'.format(mssqlscripter.__version__))
parameters = parser.parse_args(args)
if parameters.Server:

Просмотреть файл

@ -1,5 +1,5 @@
mssqltoolsservice 0.1.1.alpha9
==============================
mssqltoolsservice 1.0.0a0
===============================
The platform specific mssqltoolsservice package provides external
dependencies to the mssql-scripter tool.

Просмотреть файл

@ -9,6 +9,8 @@
import os
import platform
__version__='1.0.0a0'
def get_executable_path():
"""
Find mssqltoolsservice executable relative to this package.

Просмотреть файл

@ -6,11 +6,37 @@
# --------------------------------------------------------------------------------------------
from setuptools import setup
import io
import os
import sys
# This version number is in place in two places and must be in sync with mssqlscripter's version in setup.py.
MSSQTOOLSSERVICE_VERSION = "0.1.1a12"
# This version number is in place in two places and must be in sync with
# mssqlscripter's version in setup.py.
MSSQLTOOLSSERVICE_VERSION = '1.0.0a0'
# If we have source, validate version numbers match to prevent
# uploading releases with mismatched versions.
try:
with io.open('mssqltoolsservice/__init__.py', 'r', encoding='utf-8') as f:
content = f.read()
except IOError:
pass
else:
import re
import sys
# use regex to look for version.
m = re.search(r'__version__\s*=\s*[\'"](.+?)[\'"]', content)
if not m:
print('Could not find __version__ in mssqltoolsservice/__init__.py')
sys.exit(1)
if m.group(1) != MSSQLTOOLSSERVICE_VERSION:
print(
'mssqltoolsservice mismatch source = "{}"; setup = "{}"'.format(
m.group(1),
MSSQLTOOLSSERVICE_VERSION))
sys.exit(1)
# Find the platform we are building against.
# This file should not be called directly.
PLATFORM = os.environ['MSSQLTOOLSSERVICE_PLATFORM']
@ -31,7 +57,7 @@ CLASSIFIERS = [
setup(
name='mssqltoolsservice_{}'.format(PLATFORM),
version=MSSQTOOLSSERVICE_VERSION,
version=MSSQLTOOLSSERVICE_VERSION,
description='Microsoft SQL Tools Service',
license='MIT',
author='Microsoft Corporation',

Просмотреть файл

@ -8,8 +8,10 @@ import sys
import utility
MSSQLSCRIPTER_DIST_DIRECTORY = os.path.abspath(os.path.join(os.path.abspath(__file__), '..', 'dist'))
MSSQLTOOLSSERVICE_DIST_DIRECTORY = os.path.abspath(os.path.join(os.path.abspath(__file__), '..', 'mssqltoolsservice', 'dist'))
MSSQLSCRIPTER_DIST_DIRECTORY = os.path.abspath(
os.path.join(os.path.abspath(__file__), '..', 'dist'))
MSSQLTOOLSSERVICE_DIST_DIRECTORY = os.path.abspath(os.path.join(
os.path.abspath(__file__), '..', 'mssqltoolsservice', 'dist'))
def register_or_upload_to_pypi(options):
@ -27,17 +29,31 @@ def register_or_upload_to_pypi(options):
if len(options) == 2:
# We were provided a explicity repo to target.
# If we were not provided a repo nor does a .pypirc file exists,
# twine will use environment variable TWINE_REPOSITORY, TWINE_USERNAME, and TWINE_PASSWORD.
# twine will use environment variable TWINE_REPOSITORY, TWINE_USERNAME,
# and TWINE_PASSWORD.
repository = '-r {}'.format(options[1])
print('Repository argument was provided, targeting {}'.format(options[1]))
for wheel_name in os.listdir(MSSQLTOOLSSERVICE_DIST_DIRECTORY):
# Run twine action for mssqltoolsservice wheels.
utility.exec_command('twine {} {} {}'.format(action, wheel_name, repository), MSSQLTOOLSSERVICE_DIST_DIRECTORY)
print(
'Repository argument was provided, targeting {}'.format(
options[1]))
mssqlscripter_sdist_name = os.listdir(MSSQLSCRIPTER_DIST_DIRECTORY)[0]
# Run twine action for mssqlscripter.
utility.exec_command('twine {} {} {}'.format(action, mssqlscripter_sdist_name, repository), MSSQLSCRIPTER_DIST_DIRECTORY)
utility.exec_command(
'twine {} {} {}'.format(
action,
mssqlscripter_sdist_name,
repository),
MSSQLSCRIPTER_DIST_DIRECTORY)
for wheel_name in os.listdir(MSSQLTOOLSSERVICE_DIST_DIRECTORY):
# Run twine action for mssqltoolsservice wheels.
utility.exec_command(
'twine {} {} {}'.format(
action,
wheel_name,
repository),
MSSQLTOOLSSERVICE_DIST_DIRECTORY)
if __name__ == '__main__':
register_or_upload_to_pypi(sys.argv[1:])

Просмотреть файл

@ -1,10 +1,11 @@
# Requirements for both dev and production.
enum34 == 1.1.6
future == 0.16.0
setuptools == 30.4.0
requests == 2.13.0
wheel == 0.29.0
enum34 >= 1.1.6
future >= 0.16.0
setuptools >= 30.4.0
requests >= 2.13.0
wheel >= 0.29.0
#Development requirements.
coverage == 4.3.4
twine == 1.8.1
coverage >= 4.3.4
twine >= 1.8.1
bumpversion >= 0.5.3

Просмотреть файл

@ -11,10 +11,51 @@ import platform as _platform
import sys
from setuptools import setup
from setuptools.command.install import install
# This version number is in place in two places and must be in sync with mssqltoolsservice's version in setup.py.
MSSQLSCRIPTER_VERSION = "0.1.1a12"
# This version number is in place in two places and must be in sync with
# mssqltoolsservice's version in setup.py.
MSSQLSCRIPTER_VERSION = '1.0.0a0'
# If we have the source, validate our setup version matches source version.
# This will prevent uploading releases with mismatched versions. This will
# also ensure mssqlscripter's version is in sync with mssqltoolsservice.
try:
with io.open('mssqlscripter/__init__.py', 'r', encoding='utf-8') as f:
mssqlscripter_info = f.read()
with io.open('mssqltoolsservice/mssqltoolsservice/__init__.py', 'r', encoding='utf-8') as f:
mssqltoolsservice_info = f.read()
except IOError:
pass
else:
import re
import sys
# Use regex to parse for version.
scripter_version = re.search(
r'__version__\s*=\s*[\'"](.+?)[\'"]',
mssqlscripter_info)
toolsservice_version = re.search(
r'__version__\s*=\s*[\'"](.+?)[\'"]',
mssqltoolsservice_info)
if not scripter_version:
print('Could not find __version__ in mssqlscripter/__init__.py')
sys.exit(1)
if not toolsservice_version:
print(
'Could not find __version__ in mssqltoolsservice/mssqltoolsservice/__init__.py')
sys.exit(1)
# Validate mssqlscripter source and setup versions.
if scripter_version.group(1) != MSSQLSCRIPTER_VERSION:
print('mssqlscripter version mismatch, source = "{}"; setup = "{}"'.format(
scripter_version.group(1), MSSQLSCRIPTER_VERSION))
sys.exit(1)
# Validate mssqlscripter version with mssqltoolsservice.
if scripter_version.group(1) != toolsservice_version.group(1):
print(
'mssqltoolsservice version mismatch, mssqscripter = "{}"; mssqltoolsservice = "{}"'.format(
scripter_version.group(1),
toolsservice_version.group(1)))
sys.exit(1)
MSSQLTOOLSSERVICE_PACKAGE_NAME = 'mssqltoolsservice_{}=={}'
MSSQLTOOLSSERVICE_PACKAGE_SUFFIX = [
@ -23,10 +64,10 @@ MSSQLTOOLSSERVICE_PACKAGE_SUFFIX = [
'Fedora_23',
'openSUSE_13_2',
'OSX_10_11_64',
'RHEL_7',
'RHEL_7',
'Ubuntu_14',
'Ubuntu_16',
'Windows_7_64',
'Ubuntu_16',
'Windows_7_64',
'Windows_7_86'
]
@ -65,6 +106,7 @@ LINUX_DISTRO_WITH_VERSION = {
},
}
def _get_runtime_id_helper(name, version):
"""
Checks if linux distro name and version match to a supported package.
@ -78,6 +120,7 @@ def _get_runtime_id_helper(name, version):
return LINUX_DISTRO_WITH_VERSION[name][supported_version]
return None
def _get_linux_distro_runtime_id(content):
"""
Parse content for linux distro run time id.
@ -110,6 +153,7 @@ def _get_linux_distro_runtime_id(content):
return run_time_id
def _get_linux_distro_from_file():
"""
Find linux distro based on
@ -122,12 +166,13 @@ def _get_linux_distro_from_file():
elif os.path.exists('/usr/lib/os-release'):
os_release_info_file = '/usr/lib/os-release'
else:
raise EnvironmentError('Error detecting Linux distro version')
raise EnvironmentError('Error detecting Linux distro version.')
with io.open(os_release_info_file, 'r', encoding='utf-8') as os_release_file:
content = os_release_file.read()
return _get_linux_distro_runtime_id(content)
def _get_runtime_id(
system=_platform.system(),
architecture=_platform.architecture()[0],
@ -157,11 +202,13 @@ def get_mssqltoolsservice_package_name(run_time_id=_get_runtime_id()):
Retrieve sql tools service package name for this platform if supported.
"""
if run_time_id and run_time_id in MSSQLTOOLSSERVICE_PACKAGE_SUFFIX:
return MSSQLTOOLSSERVICE_PACKAGE_NAME.format(run_time_id, MSSQLSCRIPTER_VERSION)
raise EnvironmentError(u'mssqltoolsservice is not supported on this platform.')
return MSSQLTOOLSSERVICE_PACKAGE_NAME.format(
run_time_id, MSSQLSCRIPTER_VERSION)
raise EnvironmentError(
u'mssqltoolsservice is not supported on this platform.')
CLASSIFIERS = [
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
@ -177,16 +224,16 @@ CLASSIFIERS = [
]
DEPENDENCIES = [
'future==0.16.0',
'wheel==0.29.0'
'future>=0.16.0',
'wheel>=0.29.0'
]
if sys.version_info < (3, 4):
DEPENDENCIES.append('enum34')
DEPENDENCIES.append('enum34>=1.1.6')
DEPENDENCIES.append(get_mssqltoolsservice_package_name())
# Using a environment variable to communicate mssqltoolsservice package name for
# Using a environment variable to communicate mssqltoolsservice package name for
# other modules that need that info like dev_setup.py.
os.environ['MSSQLTOOLSSERVICE_PACKAGE_NAME'] = DEPENDENCIES[-1]