Skip to content

Commit 1099a61

Browse files
It adds support to Python 3.9 (#391)
* it fixes the duplicated progressbar error * it also fix the kwargs use in monkeypatch * it fixes the upper case Ks * it adds VS2019 build image to support py39 on appveyor * it fixes setuptools warning
1 parent 3ef47b0 commit 1099a61

12 files changed

+64
-31
lines changed

Diff for: .travis.yml

+7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ matrix:
1414
env: TOX_ENV=py37
1515
- python: 3.8
1616
env: TOX_ENV=py38
17+
- python: 3.9
18+
env: TOX_ENV=py39
1719
- os: osx
1820
# Using "generic" because osx in Travis doesn't support python
1921
language: generic
@@ -40,6 +42,11 @@ matrix:
4042
env:
4143
- TOX_ENV=py38
4244
- PYTHON_VERSION='3.8.3'
45+
- os: osx
46+
language: generic
47+
env:
48+
- TOX_ENV=py39
49+
- PYTHON_VERSION='3.9.1'
4350
- os: osx
4451
language: generic
4552
env:

Diff for: appveyor.yml

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ environment:
1414
TOX_ENV: py37
1515
- PYTHON: "C:\\Python38"
1616
TOX_ENV: py38
17+
- PYTHON: "C:\\Python39"
18+
TOX_ENV: py39
19+
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
1720
- PYTHON: "C:\\Python35"
1821
TOX_ENV: freeze
1922

Diff for: requirements.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ six
66
toml
77

88
click==7.0
9-
tqdm==4.11.2
9+
tqdm==4.55.1
1010
scrapinghub>=2.3.1
1111

1212
# address known vulnerabilities

Diff for: requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ retrying==1.3.3 # via -r requirements.in, scrapinghub
1616
scrapinghub==2.3.1 # via -r requirements.in
1717
six==1.15.0 # via -r requirements.in, docker, retrying, scrapinghub
1818
toml==0.10.1 # via -r requirements.in
19-
tqdm==4.11.2 # via -r requirements.in
19+
tqdm==4.55.1 # via -r requirements.in
2020
urllib3==1.25.9 # via requests
2121
websocket-client==0.57.0 # via docker

Diff for: setup.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
'requests',
3838
'scrapinghub>=2.3.1',
3939
'six>=1.7.0',
40-
'tqdm==4.11.2',
40+
'tqdm==4.55.1',
4141
'toml',
4242
],
4343
classifiers=[
@@ -51,6 +51,7 @@
5151
'Programming Language :: Python :: 3.6',
5252
'Programming Language :: Python :: 3.7',
5353
'Programming Language :: Python :: 3.8',
54+
'Programming Language :: Python :: 3.9',
5455
'Operating System :: OS Independent',
5556
'Environment :: Console',
5657
'Topic :: Internet :: WWW/HTTP',

Diff for: shub/image/deploy.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,11 @@ def show(self):
153153
super(_DeployProgress, self).show()
154154
# it's possible that release process finishes instantly without
155155
# providing enough information to fill progress bar completely
156-
if self.result_event and self.result_event['status'] == 'ok':
156+
if (
157+
self.result_event
158+
and self.result_event['status'] == 'ok'
159+
and self.progress_bar.n != self.progress_bar.total
160+
):
157161
delta = max(self.progress_bar.total - self.progress_bar.n, 0)
158162
self.progress_bar.update(delta)
159163
self.progress_bar.close()

Diff for: shub/utils.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from __future__ import absolute_import
2+
import setuptools # noqa: F401
23
import contextlib
34
import datetime
45
import errno

Diff for: tests/image/conftest.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77

88
from shub.image.utils import ProgressBar
99

10+
try:
11+
# https://stackoverflow.com/a/55000090
12+
from inspect import getfullargspec as get_args
13+
except ImportError:
14+
from inspect import getargspec as get_args
15+
1016
from .utils import (
1117
FakeProjectDirectory, add_scrapy_fake_config, add_sh_fake_config,
1218
add_fake_dockerfile, add_fake_setup_py,
@@ -35,15 +41,20 @@ def project_dir():
3541

3642
@pytest.fixture
3743
def monkeypatch_bar_rate(monkeypatch):
38-
args, _, _, _ = inspect.getargspec(ProgressBar.format_meter)
44+
# Converting to List instead to unpacking the Tuple
45+
# because get_args returns different tuple sizes between py versions.
46+
args = list(get_args(ProgressBar.format_meter))[0]
3947
rate_arg_idx = args.index('rate')
4048

4149
def override_rate(func):
4250

4351
@wraps(func)
4452
def wrapper(*args, **kwargs):
4553
args = list(args)
46-
args[rate_arg_idx] = 10 ** 6
54+
if 'rate' in args:
55+
args[rate_arg_idx] = 10 ** 6
56+
elif 'rate' in kwargs:
57+
kwargs['rate'] = 10 ** 6
4758
return func(*args, **kwargs)
4859

4960
return wrapper

Diff for: tests/image/test_deploy.py

+2
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ def test_progress_bar_logic():
174174
'Progress: 65%|██████▌ | 65/100'
175175
'Progress: 75%|███████▌ | 75/100'
176176
'Progress: 100%|██████████| 100/100'
177+
'Progress: 100%|██████████| 100/100'
177178
'Deploy results:'
178179
)
179180
assert expected in clean_progress_output(result.output)
@@ -195,6 +196,7 @@ def test_progress_bar_logic_incomplete():
195196
'Progress: 25%|██▌ | 25/100'
196197
'Progress: 30%|███ | 30/100'
197198
'Progress: 100%|██████████| 100/100'
199+
'Progress: 100%|██████████| 100/100'
198200
'Deploy results:'
199201
)
200202
assert expected in clean_progress_output(result.output)

Diff for: tests/image/test_push.py

+25-21
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,20 @@ def test_cli_with_progress(docker_client_mock):
5555
expected = format_expected_progress(
5656
'Login to registry.io succeeded.'
5757
'Pushing registry.io/user/project:test to the registry.'
58-
'Layers: 0%| | 0/1 '
59-
'Layers: 0%| | 0/1 '
60-
'Layers: 0%| | 0/2 '
61-
'Layers: 0%| | 0/3 '
62-
'Layers: 0%| | 0/3 '
58+
'Layers: 0%| | 0/1'
59+
'Layers: 0%| | 0/1'
60+
'Layers: 0%| | 0/2'
6361
'Layers: 0%| | 0/3'
64-
'abc: 2%|▏ | 512/24.8K [1.00MB/s] '
6562
'Layers: 0%| | 0/3'
66-
'egh: 100%|██████████| 57.3K/57.3K [1.00MB/s] '
67-
'Layers: 33%|███▎ | 1/3 '
63+
'Layers: 0%| | 0/3'
64+
'abc: 2%|▏ | 512/24.8k [1.00MB/s]'
65+
'Layers: 0%| | 0/3'
66+
'egh: 100%|██████████| 57.3k/57.3k [1.00MB/s]'
67+
'Layers: 33%|███▎ | 1/3'
6868
'Layers: 67%|██████▋ | 2/3'
6969
'Layers: 100%|██████████| 3/3'
70-
'abc: 100%|██████████| 24.8K/24.8K [1.00MB/s]'
70+
'abc: 100%|██████████| 24.8k/24.8k [1.00MB/s]'
71+
'egh: 100%|██████████| 57.3k/57.3k [1.00MB/s]'
7172
'The image registry.io/user/project:test pushed successfully.'
7273
)
7374
assert expected in clean_progress_output(result.output)
@@ -99,22 +100,25 @@ def test_progress_no_total(docker_client_mock):
99100
result = runner.invoke(cli, ["dev", "--version", "test"])
100101
assert result.exit_code == 0
101102
expected = format_expected_progress(
102-
'Layers: 0%| | 0/1 '
103-
'Layers: 0%| | 0/1 '
104-
'Layers: 0%| | 0/2 '
105-
'Layers: 0%| | 0/3 '
106-
'Layers: 0%| | 0/4 '
107-
'Layers: 0%| | 0/4 '
108-
'Layers: 0%| | 0/4 '
103+
'Login to registry.io succeeded.'
104+
'Pushing registry.io/user/project:test to the registry.'
105+
'Layers: 0%| | 0/1'
106+
'Layers: 0%| | 0/1'
107+
'Layers: 0%| | 0/2'
108+
'Layers: 0%| | 0/3'
109+
'Layers: 0%| | 0/4'
110+
'Layers: 0%| | 0/4'
111+
'Layers: 0%| | 0/4'
109112
'Layers: 0%| | 0/4'
110-
'abc: 100%|██████████| 512/512 [1.00MB/s] '
113+
'abc: 100%|██████████| 512/512 [1.00MB/s]'
111114
'Layers: 0%| | 0/4'
112-
'egh: 100%|██████████| 57.3K/57.3K [1.00MB/s] '
113-
'Layers: 25%|██▌ | 1/4 '
114-
'Layers: 50%|█████ | 2/4 '
115+
'egh: 100%|██████████| 57.3k/57.3k [1.00MB/s]'
116+
'Layers: 25%|██▌ | 1/4'
117+
'Layers: 50%|█████ | 2/4'
115118
'Layers: 75%|███████▌ | 3/4'
116119
'Layers: 100%|██████████| 4/4'
117-
'abc: 100%|██████████| 24.8K/24.8K [1.00MB/s]'
120+
'abc: 100%|██████████| 24.8k/24.8k [1.00MB/s]'
121+
'egh: 100%|██████████| 57.3k/57.3k [1.00MB/s]'
118122
'The image registry.io/user/project:test pushed successfully.'
119123
)
120124
assert expected in clean_progress_output(result.output)

Diff for: tests/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import mock
77
from click.testing import CliRunner
8-
from tqdm._utils import _supports_unicode
8+
from tqdm.utils import _supports_unicode
99

1010
from shub import config
1111

Diff for: tox.ini

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py27,py35,py36,py37,py38
2+
envlist = py27,py35,py36,py37,py38,py39
33

44
[testenv]
55
setenv =
@@ -23,9 +23,9 @@ install_command =
2323
python -m pip install {opts} {packages}
2424
deps =
2525
-rrequirements.txt
26-
pyinstaller
26+
pyinstaller==4.0
2727
pytest
28-
packaging
28+
packaging==20.4
2929
; address https://github.com/pyinstaller/pyinstaller/issues/2162 with hidden imports
3030
setuptools==41.0.1
3131
; address https://github.com/pyinstaller/pyinstaller/issues/3806

0 commit comments

Comments
 (0)