-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks.py
53 lines (44 loc) · 1.4 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
# coding: utf-8
import sys
import subprocess
from invoke import task
from pathlib import Path
REPO_HOME = Path.cwd()
def get_python_interpreters():
available_pythons = [
pyver
for pyver in subprocess.check_output("py -0").decode("utf-8").split()
if pyver.startswith("-")
]
for python in available_pythons:
exe = (
subprocess.check_output(
["py", python, "-c", "import sys;print(sys.executable)"]
)
.decode(sys.getdefaultencoding())
.strip()
)
yield (exe, python[-2:])
@task
def build_wheels(c, release=True, strip=True, sdist=True):
i_args = {
exe: "i686-pc-windows-msvc" if arch == "32" else "x86_64-pc-windows-msvc"
for (exe, arch) in get_python_interpreters()
}
for (interpreter_path, target) in i_args.items():
print(f"Building wheel for Python {interpreter_path} using target {target}")
build_command = " ".join(
[
"maturin build",
"--release" if release else "",
"--strip" if strip else "",
"--sdist",
f"-i {interpreter_path}",
f"--target {target}",
]
)
c.run(build_command)
@task
def upload_wheels(c):
with c.cd(REPO_HOME):
c.run(r'twine upload "./target/wheels/*" --non-interactive --skip-existing')