-
Notifications
You must be signed in to change notification settings - Fork 35
/
tasks.py
89 lines (65 loc) · 2.37 KB
/
tasks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
from pathlib import Path
from invoke import task, Collection
import build_tasks
from nassl import __version__
root_path = Path(__file__).parent.absolute()
@task
def test(ctx):
ctx.run("pytest --durations 5")
ctx.run("python sample_client.py")
@task
def lint(ctx):
ctx.run("ruff format .")
ctx.run("ruff check . --fix")
ctx.run("mypy sample_client.py nassl")
@task
def package_linux_wheels(ctx):
"""Build the Linux 32 and 64 bit wheels using Docker."""
ctx.run(f"docker run --rm -v {root_path}:/io quay.io/pypa/manylinux2010_i686 bash /io/build_linux_wheels.sh")
ctx.run(f"docker run --rm -v {root_path}:/io quay.io/pypa/manylinux2010_x86_64 bash /io/build_linux_wheels.sh")
@task
def package_wheel(ctx):
"""Build the binary wheel for the current system; works on Windows anc macOS."""
ctx.run("python setup.py bdist_wheel")
@task
def package_windows_wheels(ctx):
"""Build the binary wheels for Windows; this expects Python to be installed at specific locations."""
for python_exe in [
"%userprofile%\\AppData\\Local\\Programs\\Python\\Python37\\python.exe",
"%userprofile%\\AppData\\Local\\Programs\\Python\\Python38\\python.exe",
]:
ctx.run(f"{python_exe} setup.py bdist_wheel")
@task
def release(ctx):
raise NotImplementedError()
response = input(f'Release version "{__version__}" ? y/n')
if response.lower() != "y":
print("Cancelled")
return
# Ensure the tests pass
test(ctx)
# Add the git tag
ctx.run(f"git tag -a {__version__} -m '{__version__}'")
ctx.run("git push --tags")
# Build the Windows wheel
package_wheel(ctx)
# Build the Linux wheels
package_linux_wheels(ctx)
# Setup all the tasks
ns = Collection()
ns.add_task(release)
ns.add_task(test)
ns.add_task(lint)
package = Collection("package")
package.add_task(package_linux_wheels, "linux_wheels")
package.add_task(package_windows_wheels, "windows_wheels")
package.add_task(package_wheel, "wheel")
ns.add_collection(package)
build = Collection("build")
build.add_task(build_tasks.build_zlib, "zlib")
build.add_task(build_tasks.build_legacy_openssl, "legacy_openssl")
build.add_task(build_tasks.build_modern_openssl, "modern_openssl")
build.add_task(build_tasks.build_deps, "deps")
build.add_task(build_tasks.build_nassl, "nassl")
build.add_task(build_tasks.build_all, "all")
ns.add_collection(build)