Skip to content

Commit 7df3871

Browse files
committed
Moving to invoke & versioneer !nocl
pyinvoke for running tasks versioneer for version reporting some test skips on unsupported platforms.
1 parent 778b1d1 commit 7df3871

14 files changed

Lines changed: 2478 additions & 70 deletions

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
webdrivermanager/_version.py export-subst

MANIFEST.in

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
include requirements*.txt CHANGELOG README.rst LICENSE
2-
exclude dodo.py .gitignore azure-pipelines.yml azure/* test/*
1+
include requirements.txt CHANGELOG README.rst LICENSE
2+
exclude tasks.py .gitignore azure-pipelines.yml azure/* test/*
3+
include versioneer.py
4+
include webdrivermanager/_version.py

dodo.py

Lines changed: 0 additions & 43 deletions
This file was deleted.

mypy.ini

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Global options:
2+
3+
[mypy]
4+
python_version = 3.7
5+
warn_return_any = False
6+
warn_unused_configs = True
7+
python_executable = python
8+
ignore_missing_imports = True
9+
files=webdrivermanager/*.py
10+
# Per-module options:

requirements-dev.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ pylint_junit; python_version >= '3.4'
1212
python-language-server[all]
1313
backports.tempfile; python_version < '3.0'
1414
coverage
15-
doit==0.29; python_version < '3.0'
16-
doit>0.29; python_version > '3.0'
1715
unittest-xml-reporting; python_version > '3.0'
1816
unittest-xml-reporting==2.5.2; python_version < '3.0'
17+
invoke
1918
flaky
2019
pyfakefs==3.5.2
21-
git+https://github.com/rasjani/gitchangelog.git@fix-115
20+
gcg
2221
tox
2322
tox-pyenv
2423
tox-venv
24+
mypy
2525
-r requirements.txt

setup.cfg

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,10 @@ length_sort=1
4646
forced_separate=
4747
default_section=FIRSTPARTY
4848
no_lines_before=LOCALFOLDER
49+
50+
[versioneer]
51+
VCS = git
52+
style = pep440
53+
versionfile_source = webdrivermanager/_version.py
54+
versionfile_build = webdrivermanager/_version.py
55+
tag_prefix =

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from os.path import join, abspath, dirname
55

66
from setuptools import setup
7+
import versioneer
78

89
CWD = abspath(dirname(__file__))
910
PACKAGE_NAME='webdrivermanager'
@@ -14,8 +15,6 @@
1415

1516
# Get version
1617
CWD = abspath(dirname(__file__))
17-
VERSION_PATH = join(CWD, PACKAGE_NAME, 'version.py')
18-
exec(compile(open(VERSION_PATH).read(), VERSION_PATH, 'exec'))
1918

2019
with open(join(CWD, 'requirements.txt'), encoding="utf-8") as f:
2120
REQUIREMENTS = f.read().splitlines()
@@ -44,7 +43,8 @@
4443
'''.strip().splitlines()
4544

4645
setup(name=PACKAGE_NAME,
47-
version=VERSION,
46+
version=versioneer.get_version(),
47+
cmdclass=versioneer.get_cmdclass(),
4848
description='Module for facilitating download and deploy of WebDriver binaries.',
4949
long_description=long_description,
5050
classifiers=CLASSIFIERS,

tasks.py

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# flake8: noqa
2+
from pathlib import Path
3+
from invoke import task
4+
from pathlib import Path
5+
import os
6+
import shutil
7+
8+
9+
QUOTE = "\"" if os.name == "nt" else "'"
10+
11+
CHANGELOG = "CHANGELOG"
12+
filters = ["poc", "new release", "wip", "cleanup", "!nocl"]
13+
14+
15+
def filter_entries(filename):
16+
buffer = []
17+
with open(filename) as old_file:
18+
buffer = old_file.read().split("\n")
19+
20+
with open(filename, "w") as new_file:
21+
for line in buffer:
22+
if not any(bad_word in line.lower() for bad_word in filters):
23+
new_file.write(line + "\n")
24+
25+
26+
assert Path.cwd() == Path(__file__).parent
27+
28+
29+
@task()
30+
def build(ctx):
31+
"""Generates dist tar ball"""
32+
ctx.run("python setup.py sdist")
33+
34+
@task
35+
def flake(ctx):
36+
"""Runs flake8 against whole project"""
37+
ctx.run("flake8")
38+
39+
40+
@task
41+
def mypy(ctx):
42+
"""Runs mypy against the codebase"""
43+
ctx.run("mypy --config mypy.ini")
44+
45+
46+
@task
47+
def black(ctx):
48+
"""Reformat code with black"""
49+
ctx.run("black -l130 -tpy37 src")
50+
51+
52+
@task
53+
def clean(ctx):
54+
to_be_removed = [
55+
"report",
56+
"dist/",
57+
".coverage*",
58+
"output*",
59+
]
60+
61+
for item in to_be_removed:
62+
fs_entry = Path(item)
63+
if fs_entry.is_dir:
64+
shutil.rmtree(item)
65+
elif fs_entry.is_file():
66+
fs_entry.unlink()
67+
else:
68+
for fs_entry in Path().glob(item):
69+
fs_entry.unlink()
70+
71+
72+
@task
73+
def changelog(ctx, version=None):
74+
if version is not None:
75+
version = f"-c {version}"
76+
else:
77+
version = ""
78+
ctx.run(f"gcg -x -o {CHANGELOG} -O rpm {version}")
79+
filter_entries(CHANGELOG)
80+
81+
82+
@task
83+
def release(ctx, version=None):
84+
assert version != None
85+
changelog(ctx, version)
86+
ctx.run(f"git add {CHANGELOG}")
87+
ctx.run(f"git commit -m {QUOTE}New Release {version}{QUOTE}")
88+
ctx.run(f"git tag {version}")
89+
build(ctx)

test/test_acceptance.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from os import mkdir
55
from os.path import join, isfile, abspath, dirname
66
from unittest import TestCase
7-
from unittest import skipIf
7+
from unittest import skipUnless
88
from unittest import main as run_tests
99
from flaky import flaky
1010

@@ -232,14 +232,14 @@ def test_download_and_install(self):
232232
class EdgeChromiumDriverManagerTestsWithAutomaticLocations(AutomaticBaseTest):
233233
DRIVER_MANAGER = webdrivermanager.EdgeChromiumDriverManager
234234

235-
@skipIf(sys.platform.startswith("lin"), "No EdgeChromium for linux")
235+
@skipUnless(sys.platform.startswith("win"), "No EdgeChromium on this platform")
236236
@flaky
237237
def test_download(self):
238238
self.instance = self.DRIVER_MANAGER()
239239
filename = self.instance.download(show_progress_bar=False)
240240
self.assertTrue(isfile(filename), 'Downloading and saving seems to have failed')
241241

242-
@skipIf(sys.platform.startswith("lin"), "No EdgeChromium for linux")
242+
@skipUnless(sys.platform.startswith("win"), "No EdgeChromium on this platform")
243243
@flaky
244244
def test_download_and_install(self):
245245
self.instance = self.DRIVER_MANAGER()
@@ -251,14 +251,14 @@ def test_download_and_install(self):
251251
class EdgeChromiumDriverManagerTestsWithExplicitLocations(ExplicitBaseTest):
252252
DRIVER_MANAGER = webdrivermanager.EdgeChromiumDriverManager
253253

254-
@skipIf(sys.platform.startswith("lin"), "No EdgeChromium for linux")
254+
@skipUnless(sys.platform.startswith("win"), "No EdgeChromium on this platform")
255255
@flaky
256256
def test_download(self):
257257
self.instance = self.DRIVER_MANAGER(download_root=self.temp_dir.name)
258258
filename = self.instance.download(show_progress_bar=False)
259259
self.assertTrue(isfile(filename), 'Downloading and saving seems to have failed')
260260

261-
@skipIf(sys.platform.startswith("lin"), "No EdgeChromium for linux")
261+
@skipUnless(sys.platform.startswith("win"), "No EdgeChromium on this platform")
262262
@flaky
263263
def test_download_and_install(self):
264264
link_path = self.make_link_dir()

0 commit comments

Comments
 (0)