Skip to content

Commit 6295e46

Browse files
author
Pietro Albini
committed
Workaround some backward incompatible changes of invoke
This doesn't affect botogram at all, but the build process.
1 parent 30b216e commit 6295e46

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

tasks.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@
3030
import invoke
3131

3232

33+
# This is because invoke can't keep backward compatibility...
34+
_invoke_v = invoke.__version__.split(".")
35+
if int(_invoke_v[0]) == 0 and int(_invoke_v[1]) <= 12:
36+
invoke.task = invoke.ctask
37+
38+
3339
BASE = os.path.dirname(__file__)
3440
PYTHON = "python3"
3541
PROJECT = "botogram"
@@ -74,7 +80,7 @@ def remove_dir_content(path):
7480

7581

7682
@invoke.task
77-
def clean():
83+
def clean(ctx):
7884
"""Clean all the build things"""
7985
for dir in "build", "%s.egg-info" % PROJECT:
8086
path = os.path.join(BASE, dir)
@@ -125,7 +131,7 @@ def i18n_available():
125131

126132

127133
@invoke.task(name="i18n-compile")
128-
def i18n_compile():
134+
def i18n_compile(ctx):
129135
"""Compile the translation files"""
130136
env = create_env("build", requirements=True)
131137

@@ -139,7 +145,7 @@ def i18n_compile():
139145

140146

141147
@invoke.task(name="i18n-extract")
142-
def i18n_extract():
148+
def i18n_extract(ctx):
143149
"""Extract all the messages from the source code"""
144150
env = create_env("build", requirements=True)
145151

@@ -158,7 +164,7 @@ def i18n_extract():
158164

159165

160166
@invoke.task(name="i18n-new")
161-
def i18n_new(lang):
167+
def i18n_new(ctx, lang):
162168
"""Create a new language file"""
163169
env = create_env("build", requirements=True)
164170

@@ -179,13 +185,13 @@ def i18n_new(lang):
179185

180186

181187
@invoke.task
182-
def devel():
188+
def devel(ctx):
183189
"""Setup the development environment"""
184190
create_env("devel", self=True, force=True)
185191

186192

187193
@invoke.task(pre=[i18n_compile])
188-
def build():
194+
def build(ctx):
189195
"""Create a new build"""
190196
env = create_env("build", requirements=True)
191197

@@ -198,7 +204,7 @@ def build():
198204

199205

200206
@invoke.task(pre=[build])
201-
def install():
207+
def install(ctx):
202208
"""Install the program on this environment"""
203209
invoke.run("python3 -m pip install --upgrade build/packages/*whl")
204210

@@ -210,7 +216,7 @@ def install():
210216

211217

212218
@invoke.task
213-
def test():
219+
def test(ctx):
214220
"""Run the test suite"""
215221
env = create_env("test", requirements=True, self=True)
216222

@@ -223,7 +229,7 @@ def test():
223229

224230

225231
@invoke.task
226-
def lint():
232+
def lint(ctx):
227233
"""Lint the source code"""
228234
FLAKE8_OPTIONS = "--select=E,W,F,C9,N8"
229235
env = create_env("lint", requirements=True)
@@ -237,7 +243,7 @@ def lint():
237243

238244

239245
@invoke.task
240-
def docs():
246+
def docs(ctx):
241247
"""Build the documentation"""
242248
env = create_env("docs", requirements=True)
243249

@@ -255,7 +261,7 @@ def docs():
255261

256262

257263
@invoke.task(name="deps-sync")
258-
def deps_sync():
264+
def deps_sync(ctx):
259265
"""Sync dependencies versions"""
260266
env = create_env("tools", requirements=True)
261267

@@ -270,7 +276,7 @@ def deps_sync():
270276

271277

272278
@invoke.task(name="deps-compile")
273-
def deps_compile():
279+
def deps_compile(ctx):
274280
"""Compile new requirements-*.txt"""
275281
env = create_env("tools", requirements=True)
276282

0 commit comments

Comments
 (0)