Skip to content

Commit 1a9ca96

Browse files
authored
Setup windows CI and switch to SCM version (#32)
1 parent b131000 commit 1a9ca96

File tree

5 files changed

+107
-111
lines changed

5 files changed

+107
-111
lines changed

.azure_pipelines/run_tests.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
parameters:
2+
name: ""
3+
python: ""
4+
architecture: "x64"
5+
kind: "native"
6+
7+
jobs:
8+
- job: ${{ format('{0}_{1}_{2}', parameters.name, parameters.architecture, parameters.kind) }}
9+
dependsOn: PyLint
10+
pool:
11+
vmImage: "vs2017-win2016"
12+
13+
steps:
14+
# ensure the required Python versions are available
15+
- task: UsePythonVersion@0
16+
displayName: setup python
17+
inputs:
18+
versionSpec: ${{ parameters.python }}
19+
architecture: ${{ parameters.architecture }}
20+
21+
- script: "python -c \"import sys; print(sys.version); print(sys.executable)\""
22+
displayName: show python information
23+
24+
- script: |
25+
python -m pip install --upgrade pip
26+
pip install -U setuptools
27+
displayName: upgrade pip and setuptools
28+
29+
- script: |
30+
pip install -r requirements.txt
31+
displayName: Install dependencies
32+
33+
- ${{ if eq(parameters.kind, 'cython') }}:
34+
- script: |
35+
pip install -r build_requirements.txt
36+
displayName: Install build requirements
37+
38+
- script: |
39+
pip install -U wheel
40+
python setup.py bdist_wheel
41+
pip install --pre --no-index -f dist advanced-descriptors
42+
displayName: Build and install
43+
44+
- script: |
45+
pip install pytest pytest-sugar
46+
47+
pytest -vvv --junitxml=unit_result.xml test
48+
displayName: PyTest
49+
50+
- task: PublishTestResults@2
51+
displayName: publish test results via junit
52+
condition: succeededOrFailed()
53+
inputs:
54+
testResultsFormat: "JUnit"
55+
testResultsFiles: ${{ format('$(System.DefaultWorkingDirectory)/unit_result.xml') }}
56+
testRunTitle: ${{ format('{0}_{1}_{2}', parameters.name, parameters.architecture, parameters.kind) }}

advanced_descriptors/__init__.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,25 @@
1313

1414
"""Advanced descriptors for special cases."""
1515

16+
import pkg_resources
17+
1618
from .separate_class_method import SeparateClassMethod
1719
from .advanced_property import AdvancedProperty
1820
from .log_on_access import LogOnAccess
1921

2022
__all__ = ("SeparateClassMethod", "AdvancedProperty", "LogOnAccess")
2123

22-
__version__ = "2.2.1"
24+
try:
25+
__version__ = pkg_resources.get_distribution(__name__).version
26+
except pkg_resources.DistributionNotFound:
27+
# package is not installed, try to get from SCM
28+
try:
29+
import setuptools_scm # type: ignore
30+
31+
__version__ = setuptools_scm.get_version()
32+
except ImportError:
33+
pass
34+
2335
__author__ = "Alexey Stepanov"
2436
__author_email__ = "penguinolog@gmail.com"
2537
__maintainers__ = {

azure-pipelines.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,29 @@ jobs:
2424
pip install -U pylint
2525
pylint -f msvs advanced_descriptors
2626
displayName: 'PyLint'
27+
28+
- template: .azure_pipelines/run_tests.yml
29+
parameters: {name: 'Python_34', python: '3.4', architecture: 'x64', kind: 'native'}
30+
- template: .azure_pipelines/run_tests.yml
31+
parameters: {name: 'Python_35', python: '3.5', architecture: 'x64', kind: 'native'}
32+
- template: .azure_pipelines/run_tests.yml
33+
parameters: {name: 'Python_36', python: '3.6', architecture: 'x64', kind: 'native'}
34+
- template: .azure_pipelines/run_tests.yml
35+
parameters: {name: 'Python_37', python: '3.7', architecture: 'x64', kind: 'native'}
36+
37+
- template: .azure_pipelines/run_tests.yml
38+
parameters: {name: 'Python_34', python: '3.4', architecture: 'x64', kind: 'cython'}
39+
- template: .azure_pipelines/run_tests.yml
40+
parameters: {name: 'Python_34', python: '3.4', architecture: 'x86', kind: 'cython'}
41+
- template: .azure_pipelines/run_tests.yml
42+
parameters: {name: 'Python_35', python: '3.5', architecture: 'x64', kind: 'cython'}
43+
- template: .azure_pipelines/run_tests.yml
44+
parameters: {name: 'Python_35', python: '3.5', architecture: 'x86', kind: 'cython'}
45+
- template: .azure_pipelines/run_tests.yml
46+
parameters: {name: 'Python_36', python: '3.6', architecture: 'x64', kind: 'cython'}
47+
- template: .azure_pipelines/run_tests.yml
48+
parameters: {name: 'Python_36', python: '3.6', architecture: 'x86', kind: 'cython'}
49+
- template: .azure_pipelines/run_tests.yml
50+
parameters: {name: 'Python_37', python: '3.7', architecture: 'x64', kind: 'cython'}
51+
- template: .azure_pipelines/run_tests.yml
52+
parameters: {name: 'Python_37', python: '3.7', architecture: 'x86', kind: 'cython'}

doc/source/conf.py

Lines changed: 5 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -13,110 +13,10 @@
1313
# All configuration values have a default; values that are commented out
1414
# serve to show the default.
1515

16-
import ast
17-
import collections
18-
import os.path
19-
import sys
20-
21-
PY3 = sys.version_info[:2] > (2, 7)
22-
PY34 = sys.version_info[:2] > (3, 3)
23-
24-
with open(
25-
os.path.join(
26-
os.path.dirname(__file__), '..', '..',
27-
'advanced_descriptors', '__init__.py'
28-
)
29-
) as f:
30-
source = f.read()
31-
32-
33-
# noinspection PyUnresolvedReferences
34-
def get_simple_vars_from_src(src):
35-
"""Get simple (string/number/boolean and None) assigned values from source.
36-
37-
:param src: Source code
38-
:type src: str
39-
:returns: OrderedDict with keys, values = variable names, values
40-
:rtype: typing.Dict[
41-
str,
42-
typing.Union[
43-
str, bytes,
44-
int, float, complex,
45-
list, set, dict, tuple,
46-
None,
47-
]
48-
]
49-
50-
Limitations: Only defined from scratch variables.
51-
Not supported by design:
52-
* Imports
53-
* Executable code, including string formatting and comprehensions.
54-
55-
Examples:
56-
57-
>>> string_sample = "a = '1'"
58-
>>> get_simple_vars_from_src(string_sample)
59-
OrderedDict([('a', '1')])
60-
61-
>>> int_sample = "b = 1"
62-
>>> get_simple_vars_from_src(int_sample)
63-
OrderedDict([('b', 1)])
64-
65-
>>> list_sample = "c = [u'1', b'1', 1, 1.0, 1j, None]"
66-
>>> result = get_simple_vars_from_src(list_sample)
67-
>>> result == collections.OrderedDict(
68-
... [('c', [u'1', b'1', 1, 1.0, 1j, None])]
69-
... )
70-
True
71-
72-
>>> iterable_sample = "d = ([1], {1: 1}, {1})"
73-
>>> get_simple_vars_from_src(iterable_sample)
74-
OrderedDict([('d', ([1], {1: 1}, {1}))])
75-
76-
>>> multiple_assign = "e = f = g = 1"
77-
>>> get_simple_vars_from_src(multiple_assign)
78-
OrderedDict([('e', 1), ('f', 1), ('g', 1)])
79-
"""
80-
ast_data = (
81-
ast.Str, ast.Num,
82-
ast.List, ast.Set, ast.Dict, ast.Tuple
83-
)
84-
if PY3:
85-
ast_data += (ast.Bytes,)
86-
if PY34:
87-
ast_data += (ast.NameConstant,)
88-
89-
tree = ast.parse(src)
90-
91-
result = collections.OrderedDict()
92-
93-
for node in ast.iter_child_nodes(tree):
94-
if not isinstance(node, ast.Assign): # We parse assigns only
95-
continue
96-
try:
97-
if isinstance(node.value, ast_data):
98-
value = ast.literal_eval(node.value)
99-
elif isinstance( # NameConstant in python < 3.4
100-
node.value, ast.Name
101-
) and isinstance(
102-
node.value.ctx, ast.Load # Read constant
103-
):
104-
value = ast.literal_eval(node.value)
105-
else:
106-
continue
107-
except ValueError:
108-
continue
109-
for tgt in node.targets:
110-
if isinstance(
111-
tgt, ast.Name
112-
) and isinstance(
113-
tgt.ctx, ast.Store
114-
):
115-
result[tgt.id] = value
116-
return result
117-
118-
119-
variables = get_simple_vars_from_src(source)
16+
import pkg_resources
17+
18+
release = pkg_resources.get_distribution("logwrap").version
19+
version = '.'.join(release.split('.')[:2])
12020

12121
# If extensions (or modules to document with autodoc) are in another directory,
12222
# add these directories to sys.path here. If the directory is relative to the
@@ -168,9 +68,8 @@ def get_simple_vars_from_src(src):
16868
# built documents.
16969
#
17070
# The short X.Y version.
171-
version = variables['__version__']
71+
17272
# The full version, including alpha/beta/rc tags.
173-
release = variables['__version__']
17473

17574
# The language for content autogenerated by Sphinx. Refer to documentation
17675
# for a list of supported languages.

setup.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ def get_simple_vars_from_src(src):
216216
"{name} <{email}>".format(name=name, email=email) for name, email in variables["__maintainers__"].items()
217217
),
218218
url=variables["__url__"],
219-
version=variables["__version__"],
220219
license=variables["__license__"],
221220
description=variables["__description__"],
222221
long_description=long_description,
@@ -229,9 +228,13 @@ def get_simple_vars_from_src(src):
229228
# situations as progressive releases of projects are done.
230229
# Blacklist setuptools 34.0.0-34.3.2 due to https://github.com/pypa/setuptools/issues/951
231230
# Blacklist setuptools 36.2.0 due to https://github.com/pypa/setuptools/issues/1086
232-
setup_requires="setuptools >= 21.0.0,!=24.0.0,"
233-
"!=34.0.0,!=34.0.1,!=34.0.2,!=34.0.3,!=34.1.0,!=34.1.1,!=34.2.0,!=34.3.0,!=34.3.1,!=34.3.2,"
234-
"!=36.2.0",
231+
setup_requires=[
232+
"setuptools >= 21.0.0,!=24.0.0,"
233+
"!=34.0.0,!=34.0.1,!=34.0.2,!=34.0.3,!=34.1.0,!=34.1.1,!=34.2.0,!=34.3.0,!=34.3.1,!=34.3.2,"
234+
"!=36.2.0",
235+
"setuptools_scm",
236+
],
237+
use_scm_version=True,
235238
install_requires=required,
236239
package_data={"advanced_descriptors": ["py.typed"]},
237240
)

0 commit comments

Comments
 (0)