simplify wheel building

This commit is contained in:
Damien Elmes 2020-12-10 20:27:21 +10:00
parent daf9ca5e5e
commit 0cbb60169c
6 changed files with 54 additions and 4 deletions

View File

@ -1,3 +1,5 @@
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
config_setting(
name = "release",
values = {
@ -26,5 +28,16 @@ alias(
visibility = ["//visibility:public"],
)
pkg_tar(
name = "dist",
srcs = [
"//pylib/anki:wheel",
"//qt/aqt:wheel",
],
mode = "0644",
package_dir = "bazel-dist",
tags = ["manual"],
)
# for version info
exports_files(["defs.bzl"])

View File

@ -64,12 +64,19 @@ If you'd like to contribute translations, please see <https://translating.ankiwe
## Building redistributable wheels
Run the following commands to create Python packages that can be redistributed
Run the following command to create Python packages that can be redistributed
and installed:
On Mac/Linux:
```
bazel build -c opt //pylib/anki:wheel
bazel build -c opt //qt/aqt:wheel
./scripts/build
```
On Windows:
```
.\scripts\build.bat
```
The generated wheel paths will be printed as the build completes.
@ -79,9 +86,11 @@ Follow the steps in the "Pre-built Python wheels" section above, but replace the
"pip install aqt" line with something like:
```
pip install /path/to/anki.whl /path/to/aqt.whl
pip install --upgrade bazel-dist/*.whl
```
On Windows you'll need to list out the filenames manually.
## Running tests
From inside the source folder:

View File

@ -124,6 +124,7 @@ py_wheel(
"pylib",
],
version = anki_version,
visibility = ["//visibility:public"],
deps = [":anki_pkg"],
)

View File

@ -114,6 +114,7 @@ py_wheel(
"qt",
],
version = anki_version,
visibility = ["//visibility:public"],
deps = [
":aqt_pkg",
],

12
scripts/build Executable file
View File

@ -0,0 +1,12 @@
#!/bin/bash
set -e
test -e WORKSPACE || (
echo "Run from project root"
exit 1
)
rm -rf bazel-dist
bazel build -c opt dist
tar xvf bazel-bin/dist.tar

14
scripts/build.bat Executable file
View File

@ -0,0 +1,14 @@
@echo off
if not exist WORKSPACE (
echo Run from project root
exit /b 1
)
rd /s /q bazel-dist
call .\bazel build -k -c opt dist --color=yes
:: repeat on failure
IF %ERRORLEVEL% NEQ 0 call .\bazel build -k -c opt dist --color=yes
tar xvf bazel-bin\dist.tar