Skip to content

Commit 52d5a7a

Browse files
committed
Code unification & restore windows build
1 parent 9776595 commit 52d5a7a

15 files changed

+108
-160
lines changed

.azure_pipelines/run_tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
- script: |
4747
pip install pytest pytest-sugar pytest-cov
4848
49-
pytest -vvv --junitxml=unit_result.xml --cov=threaded --cov-report=xml --cov-report=html --cov-report term test
49+
pytest --junitxml=unit_result.xml --cov=threaded --cov-report=xml --cov-report=html --cov-report term test
5050
displayName: PyTest
5151
5252
- task: PublishTestResults@2

.coveragerc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[run]
22
source =
3-
threaded
3+
threaded
44
omit =
5-
test/*
5+
test/*
66
branch = True
77
[report]
88
exclude_lines =

.github/workflows/pythonpackage.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ jobs:
2828
python setup.py develop -v
2929
- name: Test with pytest
3030
run: |
31-
py.test -vvv --cov-config .coveragerc --cov-report= --cov=threaded test
31+
py.test --cov-config .coveragerc --cov-report= --cov=threaded test
3232
coverage report -m --fail-under 90

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
### Test results
22
/*_result*.xml
33
/report.html
4+
/mypy_report
45
/assets/*
56
.cache/*
67
.pytest_cache/*
@@ -10,7 +11,7 @@
1011

1112
### Generated code
1213
/threaded/*.c
13-
/pip-wheel-metadata/
14+
/pip-wheel-metadata
1415
### TortoiseGit template
1516
# Project-level settings
1617
/.tgitconfig

.pylintrc

+1-3
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,9 @@ enable=all
6666

6767
disable=non-ascii-bytes-literal,
6868
raw-checker-failed,
69-
bad-inline-option,
7069
locally-disabled,
7170
file-ignored,
7271
suppressed-message,
73-
no-absolute-import,
74-
old-division,
7572
comprehension-escape,
7673
similarities,
7774
too-many-ancestors,
@@ -83,6 +80,7 @@ disable=non-ascii-bytes-literal,
8380
too-many-locals,
8481
too-many-statements,
8582
too-many-instance-attributes,
83+
too-many-lines,
8684
misplaced-comparison-constant,
8785
bad-continuation,
8886
broad-except,

.travis.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ _helpers:
2121
- &install_cython pip install --upgrade Cython
2222
- &build_package python setup.py bdist_wheel
2323
- &install_built pip install threaded --no-index -f dist
24-
- &test_no_cov py.test -vv test
24+
- &test_no_cov py.test -vvv test
2525
- &test_cythonized
2626
stage: Test cythonized
2727
install:
@@ -47,7 +47,7 @@ _helpers:
4747

4848
script:
4949
- python setup.py develop -v
50-
- py.test -vv --cov-config .coveragerc --cov-report= --cov=threaded test
50+
- py.test --cov-config .coveragerc --cov-report= --cov=threaded test
5151
- coverage report -m --fail-under 87
5252
after_success:
5353
- coveralls
@@ -75,7 +75,7 @@ jobs:
7575
install:
7676
- *upgrade_python_toolset
7777
- *install_deps
78-
- pip install --upgrade "mypy >= 0.700"
78+
- pip install --upgrade "mypy >= 0.720"
7979
script:
8080
- python setup.py --version
8181
- mypy --strict threaded

azure-pipelines.yml

+65-65
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
displayName: 'Install dependencies'
2121
2222
- script: |
23-
pytest -vvv --flake8 -m flake8 --junitxml=flake8_result.xml threaded
23+
pytest --flake8 -m flake8 --junitxml=flake8_result.xml threaded
2424
displayName: 'PEP8'
2525
2626
- task: PublishTestResults@2
@@ -74,7 +74,7 @@ jobs:
7474
python -m pip install --upgrade pip
7575
pip install -U setuptools
7676
pip install -r requirements.txt
77-
pip install -U mypy
77+
pip install -U "mypy>=0.700"
7878
displayName: 'Install dependencies'
7979
8080
- script: |
@@ -98,66 +98,66 @@ jobs:
9898
- template: .azure_pipelines/run_tests.yml
9999
parameters: {name: 'Python_37', python: '3.7', architecture: 'x64', kind: 'native'}
100100

101-
# - template: .azure_pipelines/run_tests.yml
102-
# parameters: {name: 'Python_36', python: '3.6', architecture: 'x64', kind: 'cython'}
103-
# - template: .azure_pipelines/run_tests.yml
104-
# parameters: {name: 'Python_36', python: '3.6', architecture: 'x86', kind: 'cython'}
105-
# - template: .azure_pipelines/run_tests.yml
106-
# parameters: {name: 'Python_37', python: '3.7', architecture: 'x64', kind: 'cython'}
107-
# - template: .azure_pipelines/run_tests.yml
108-
# parameters: {name: 'Python_37', python: '3.7', architecture: 'x86', kind: 'cython'}
109-
110-
111-
# - job: 'Build_and_deploy'
112-
# dependsOn:
113-
# - Python_36_x64_native
114-
# - Python_37_x64_native
115-
#
116-
## - Python_36_x64_cython
117-
## - Python_36_x86_cython
118-
## - Python_37_x64_cython
119-
## - Python_37_x86_cython
120-
# condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
121-
# pool:
122-
# vmIMage: 'VS2017-Win2016'
123-
# strategy:
124-
# maxParallel: 6
125-
# matrix:
126-
# Python36_x64:
127-
# python.version: '3.6'
128-
# python.architecture: 'x64'
129-
# Python36_x86:
130-
# python.version: '3.6'
131-
# python.architecture: 'x86'
132-
# Python37_x64:
133-
# python.version: '3.7'
134-
# python.architecture: 'x64'
135-
# Python37_x86:
136-
# python.version: '3.7'
137-
# python.architecture: 'x86'
138-
#
139-
# steps:
140-
# - task: UsePythonVersion@0
141-
# inputs:
142-
# versionSpec: '$(python.version)'
143-
# architecture: '$(python.architecture)'
144-
#
145-
# - script: |
146-
# python -m pip install --upgrade pip
147-
# pip install -U setuptools
148-
# pip install -r build_requirements.txt
149-
# displayName: 'Install dependencies'
150-
#
151-
# - script: |
152-
# python setup.py bdist_wheel
153-
# displayName: 'Build'
154-
#
155-
# - task: TwineAuthenticate@0
156-
# displayName: 'Twine Authenticate '
157-
# inputs:
158-
# externalFeeds: PyPI
159-
#
160-
# - script: |
161-
# pip install -U twine
162-
# twine upload -r PyPI --config-file $(PYPIRC_PATH) dist/threaded-* --skip-existing
163-
# displayName: 'Deploy'
101+
- template: .azure_pipelines/run_tests.yml
102+
parameters: {name: 'Python_36', python: '3.6', architecture: 'x64', kind: 'cython'}
103+
- template: .azure_pipelines/run_tests.yml
104+
parameters: {name: 'Python_36', python: '3.6', architecture: 'x86', kind: 'cython'}
105+
- template: .azure_pipelines/run_tests.yml
106+
parameters: {name: 'Python_37', python: '3.7', architecture: 'x64', kind: 'cython'}
107+
- template: .azure_pipelines/run_tests.yml
108+
parameters: {name: 'Python_37', python: '3.7', architecture: 'x86', kind: 'cython'}
109+
110+
111+
- job: 'Build_and_deploy'
112+
dependsOn:
113+
- Python_36_x64_native
114+
- Python_37_x64_native
115+
116+
- Python_36_x64_cython
117+
- Python_36_x86_cython
118+
- Python_37_x64_cython
119+
- Python_37_x86_cython
120+
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
121+
pool:
122+
vmIMage: 'VS2017-Win2016'
123+
strategy:
124+
maxParallel: 6
125+
matrix:
126+
Python36_x64:
127+
python.version: '3.6'
128+
python.architecture: 'x64'
129+
Python36_x86:
130+
python.version: '3.6'
131+
python.architecture: 'x86'
132+
Python37_x64:
133+
python.version: '3.7'
134+
python.architecture: 'x64'
135+
Python37_x86:
136+
python.version: '3.7'
137+
python.architecture: 'x86'
138+
139+
steps:
140+
- task: UsePythonVersion@0
141+
inputs:
142+
versionSpec: '$(python.version)'
143+
architecture: '$(python.architecture)'
144+
145+
- script: |
146+
python -m pip install --upgrade pip
147+
pip install -U setuptools
148+
pip install -r build_requirements.txt
149+
displayName: 'Install dependencies'
150+
151+
- script: |
152+
python setup.py bdist_wheel
153+
displayName: 'Build'
154+
155+
- task: TwineAuthenticate@0
156+
displayName: 'Twine Authenticate '
157+
inputs:
158+
externalFeeds: PyPI
159+
160+
- script: |
161+
pip install -U twine
162+
twine upload -r PyPI --config-file $(PYPIRC_PATH) dist/threaded-* --skip-existing
163+
displayName: 'Deploy'

build_requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Cython; platform_python_implementation == "CPython"
2-
wheel<0.32.0
2+
wheel==0.31.1
33
-r CI_REQUIREMENTS.txt
44
-r requirements.txt

pyproject.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# Minimum requirements for the build system to execute.
33
# PEP 508 specifications for PEP 518.
44
requires = [
5-
"setuptools >= 21.0.0,!=24.0.0,!=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,!=36.2.0",
5+
"setuptools >= 21.0.0,!=24.0.0,!=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,!=36.2.0", # PSF/ZPL
66
"wheel",
7-
"setuptools_scm"
7+
"setuptools_scm",
88
]
99
build-backend="setuptools.build_meta"
1010

pytest.ini

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[pytest]
22
addopts = -vvv -s -p no:django -p no:ipdb
33
testpaths = test
4+
mock_use_standalone_module = false

setup.cfg

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ project_urls =
44
Bug Tracker = https://github.com/python-useful-helpers/threaded/issues
55
Documentation = https://threaded.readthedocs.io/
66

7+
long_description = file: README.rst
8+
79
[options]
810
zip_safe = False
911
packages = find:
@@ -37,6 +39,8 @@ exclude =
3739
ignore =
3840
E203,
3941
# whitespace before ':'
42+
W503,
43+
# line break before binary operator
4044
D401,
4145
# First line should be in imperative mood; try rephrasing
4246
D202,

setup.py

+19-16
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
# Standard Library
1818
import ast
19-
import collections
2019
import distutils.errors
2120
import os.path
2221
import shutil
@@ -38,7 +37,6 @@
3837
except ImportError:
3938
cythonize = None
4039

41-
4240
PACKAGE_NAME = "threaded"
4341

4442
with open(os.path.join(os.path.dirname(__file__), PACKAGE_NAME, "__init__.py")) as f:
@@ -52,15 +50,19 @@
5250

5351

5452
# noinspection PyCallingNonCallable
55-
if cythonize is not None and "win32" != sys.platform:
53+
if cythonize is not None:
5654
REQUIRES_OPTIMIZATION = [
5755
setuptools.Extension("threaded.class_decorator", ["threaded/class_decorator.pyx"]),
5856
setuptools.Extension("threaded._base_threaded", ["threaded/_base_threaded.py"]),
5957
setuptools.Extension("threaded._asynciotask", ["threaded/_asynciotask.pyx"]),
6058
setuptools.Extension("threaded._threaded", ["threaded/_threaded.pyx"]),
6159
setuptools.Extension("threaded._threadpooled", ["threaded/_threadpooled.py"]),
62-
setuptools.Extension("threaded.__init__", ["threaded/__init__.pyx"]),
60+
6361
]
62+
if "win32" != sys.platform:
63+
# NOTE: Do not make pyx/pxd - it kills windows
64+
REQUIRES_OPTIMIZATION.append(setuptools.Extension("threaded.__init__", ["threaded/__init__.py"]),)
65+
6466
INTERFACES = ["class_decorator.pxd", "_asynciotask.pxd", "_threaded.pxd"]
6567

6668
EXT_MODULES = cythonize(
@@ -104,7 +106,7 @@ def run(self):
104106
shutil.copyfile(src, dst)
105107
except (
106108
distutils.errors.DistutilsPlatformError,
107-
getattr(globals()["__builtins__"], "FileNotFoundError", OSError),
109+
FileNotFoundError,
108110
):
109111
raise BuildFailed()
110112

@@ -127,7 +129,7 @@ def build_extension(self, ext):
127129
# noinspection PyUnresolvedReferences
128130
def get_simple_vars_from_src(
129131
src: str
130-
) -> "typing.Dict[str, typing.Union[str, bytes, int, float, complex, list, set, dict, tuple, None]]":
132+
) -> "typing.Dict[str, typing.Union[str, bytes, int, float, complex, list, set, dict, tuple, None, bool, Ellipsis]]":
131133
"""Get simple (string/number/boolean and None) assigned values from source.
132134
133135
:param src: Source code
@@ -139,7 +141,7 @@ def get_simple_vars_from_src(
139141
str, bytes,
140142
int, float, complex,
141143
list, set, dict, tuple,
142-
None,
144+
None, bool, Ellipsis
143145
]
144146
]
145147
@@ -152,32 +154,33 @@ def get_simple_vars_from_src(
152154
153155
>>> string_sample = "a = '1'"
154156
>>> get_simple_vars_from_src(string_sample)
155-
OrderedDict([('a', '1')])
157+
{'a': '1'}
156158
157159
>>> int_sample = "b = 1"
158160
>>> get_simple_vars_from_src(int_sample)
159-
OrderedDict([('b', 1)])
161+
{'b': 1}
160162
161163
>>> list_sample = "c = [u'1', b'1', 1, 1.0, 1j, None]"
162164
>>> result = get_simple_vars_from_src(list_sample)
163-
>>> result == collections.OrderedDict(
164-
... [('c', [u'1', b'1', 1, 1.0, 1j, None])]
165-
... )
165+
>>> result == {'c': [u'1', b'1', 1, 1.0, 1j, None]}
166166
True
167167
168168
>>> iterable_sample = "d = ([1], {1: 1}, {1})"
169169
>>> get_simple_vars_from_src(iterable_sample)
170-
OrderedDict([('d', ([1], {1: 1}, {1}))])
170+
{'d': ([1], {1: 1}, {1})}
171171
172172
>>> multiple_assign = "e = f = g = 1"
173173
>>> get_simple_vars_from_src(multiple_assign)
174-
OrderedDict([('e', 1), ('f', 1), ('g', 1)])
174+
{'e': 1, 'f': 1, 'g': 1}
175175
"""
176-
ast_data = (ast.Str, ast.Num, ast.List, ast.Set, ast.Dict, ast.Tuple, ast.Bytes, ast.NameConstant)
176+
if sys.version_info[:2] < (3, 8):
177+
ast_data = (ast.Str, ast.Num, ast.List, ast.Set, ast.Dict, ast.Tuple, ast.Bytes, ast.NameConstant, ast.Ellipsis)
178+
else:
179+
ast_data = ast.Constant
177180

178181
tree = ast.parse(src)
179182

180-
result = collections.OrderedDict()
183+
result = {}
181184

182185
for node in ast.iter_child_nodes(tree):
183186
if not isinstance(node, ast.Assign): # We parse assigns only

threaded/__init__.pxd

-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +0,0 @@
1-
cpdef tuple __all__
2-
3-
cpdef str __version__
4-
cpdef str __author__
5-
cpdef str __author_email__
6-
cpdef dict __maintainers__
7-
cpdef str __url__
8-
cpdef str __description__
9-
cpdef str __license__

0 commit comments

Comments
 (0)