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( config_setting(
name = "release", name = "release",
values = { values = {
@ -26,5 +28,16 @@ alias(
visibility = ["//visibility:public"], 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 # for version info
exports_files(["defs.bzl"]) 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 ## 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: and installed:
On Mac/Linux:
``` ```
bazel build -c opt //pylib/anki:wheel ./scripts/build
bazel build -c opt //qt/aqt:wheel ```
On Windows:
```
.\scripts\build.bat
``` ```
The generated wheel paths will be printed as the build completes. 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 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 ## Running tests
From inside the source folder: From inside the source folder:

View file

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

View file

@ -114,6 +114,7 @@ py_wheel(
"qt", "qt",
], ],
version = anki_version, version = anki_version,
visibility = ["//visibility:public"],
deps = [ deps = [
":aqt_pkg", ":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