-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks.py
75 lines (61 loc) · 1.83 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
# coding: utf-8
import sys
import subprocess
from invoke import task
from pathlib import Path
REPO_HOME = Path.cwd()
PYTHON_TARGETS = [
f"3.{x}-{arch}"
for x in range(8, 11)
for arch in ("32", "64")
]
def get_python_path(py_ident):
try:
return subprocess.check_output([
"py",
f"-{py_ident}",
"-c",
"import sys;print(sys.executable)"
]).decode(sys.getfilesystemencoding())
except subprocess.CalledProcessError:
pass
@task
def build_all(c, release=False):
c.run(" ".join([
"cargo",
"build",
"--all",
"--release" if release else "",
]))
print("Build all completed")
@task
def build_wheels(c, release=False, strip=False):
i_args = {
f'"{py_path}"': "i686-pc-windows-msvc" if ident.endswith("32") else "x86_64-pc-windows-msvc"
for ident in PYTHON_TARGETS
if (py_path := get_python_path(ident))
}
with c.cd(REPO_HOME / "docrpy"):
for (pypath, arch) in i_args.items():
build_command = " ".join([
"maturin build",
"--release" if release else "",
"--strip" if strip else "",
f"-i {pypath}"
])
c.run(
build_command,
env={'CARGO_BUILD_TARGET': arch}
)
@task
def copy_artifacts(c, release=False):
print("Copying artifacts to dist folder...")
REPO_HOME.joinpath("dist").mkdir(parents=True, exist_ok=True)
subfolder = 'release' if release else 'debug'
c.run(f"cp ./target/{subfolder}/*.exe ./dist")
c.run(f"cp ./target/{subfolder}/*lib.dll ./dist")
c.run("cp ./target/wheels/*.whl ./dist")
@task
def upload_wheels(c):
with c.cd(REPO_HOME):
c.run(r'twine upload "./target/wheels/*" --non-interactive --skip-existing')