From 24e55f27087e1e73064d43f3b3fe58a8c831f970 Mon Sep 17 00:00:00 2001 From: Josh Pieper Date: Wed, 12 Jul 2023 14:24:41 -0400 Subject: [PATCH] Support python 3.10 and Ubuntu 22.04 Ubuntu 22.04 only ships libbcm_host.so on aarch64, *not* libbcm_host.so.0, which is what Raspberry Pi OS ships (in addition to libbcm_host.so). Work around that by forcing the LD requires to only point to libbcm_host.so for our python extension library. --- BUILD | 11 +++++++++-- lib/python/BUILD | 11 ++++++++--- lib/python/moteus_pi3hat/BUILD | 3 ++- make_release.py | 4 ++-- tools/workspace/bazel_deps/repository.bzl | 4 ++-- tools/workspace/pybind11/package.BUILD | 9 +++++++++ tools/workspace/pybind11/repository.bzl | 4 ++-- .../raspberrypi-firmware/package.BUILD | 19 +++++++++++++++++-- 8 files changed, 51 insertions(+), 14 deletions(-) diff --git a/BUILD b/BUILD index 2e7ea81..2da434f 100644 --- a/BUILD +++ b/BUILD @@ -1,6 +1,6 @@ # -*- python -*- -# Copyright 2020-2022 Josh Pieper, jjp@pobox.com. +# Copyright 2020-2023 Josh Pieper, jjp@pobox.com. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ test_suite( "cpu": arch, }, ) - for pyver in ['3.7', '3.9'] + for pyver in ['3.7', '3.9', '3.10'] for arch in ['armeabihf', 'aarch64'] ] @@ -74,3 +74,10 @@ config_setting( "define": "PYTHON=3.9", }, ) + +config_setting( + name = "python310", + values = { + "define": "PYTHON=3.10", + }, +) diff --git a/lib/python/BUILD b/lib/python/BUILD index 7c34100..71dea5f 100644 --- a/lib/python/BUILD +++ b/lib/python/BUILD @@ -1,6 +1,6 @@ # -*- python -*- -# Copyright 2020-2022 Josh Pieper, jjp@pobox.com. +# Copyright 2020-2023 Josh Pieper, jjp@pobox.com. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,17 +22,20 @@ load("//tools/workspace:template_file.bzl", "template_file") VERSION="0.3.26" -PYTHON_SHORT_VERSIONS = ['37', '39'] +PYTHON_SHORT_VERSIONS = ['37', '39', '310'] ARCHITECTURES = ['armv7l', 'aarch64'] ABITAG = { '37': 'abi3', '39': 'cp39', + '310': 'cp310', } PTAG = { '37_armv7l': 'linux', '37_aarch64': 'manylinux_2_17', '39_armv7l': 'manylinux_2_17', '39_aarch64': 'manylinux_2_17', + '310_armv7l': 'manylinux_2_17', + '310_aarch64': 'manylinux_2_17', } @@ -84,7 +87,7 @@ pkg_tar( "tar xf $(location wheel_tar) -C $$BUILDDIR && " + "cp $(location setup_{pyshortver}.py) $(location README.md) $$BUILDDIR && " + "cd $$BUILDDIR && " + - "python3.9 setup_{pyshortver}.py bdist_wheel " + + "python3 setup_{pyshortver}.py bdist_wheel " + " --plat-name {ptag}_{architecture} " + " --py-limited-api cp{pyshortver} " + " --dist-dir .. " + @@ -114,5 +117,7 @@ filegroup( "//:python37_aarch64" : [":bdist_wheel_37_aarch64"], "//:python39_armeabihf" : [":bdist_wheel_39_armv7l"], "//:python39_aarch64" : [":bdist_wheel_39_aarch64"], + "//:python310_armeabihf" : [":bdist_wheel_310_armv7l"], + "//:python310_aarch64" : [":bdist_wheel_310_aarch64"], }), ) diff --git a/lib/python/moteus_pi3hat/BUILD b/lib/python/moteus_pi3hat/BUILD index 953d826..d1a53a2 100644 --- a/lib/python/moteus_pi3hat/BUILD +++ b/lib/python/moteus_pi3hat/BUILD @@ -1,6 +1,6 @@ # -*- python -*- -# Copyright 2020-2021 Josh Pieper, jjp@pobox.com. +# Copyright 2020-2023 Josh Pieper, jjp@pobox.com. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ cc_binary( "//conditions:default" : [], "//:python37" : ["@com_github_pybind_pybind11//:pybind11_37"], "//:python39" : ["@com_github_pybind_pybind11//:pybind11_39"], + "//:python310" : ["@com_github_pybind_pybind11//:pybind11_310"], }), linkshared = True, ) diff --git a/make_release.py b/make_release.py index cdb7c8f..d6ee6c5 100755 --- a/make_release.py +++ b/make_release.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -# Copyright 2020-2022 Josh Pieper, jjp@pobox.com. +# Copyright 2020-2023 Josh Pieper, jjp@pobox.com. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ def main(): run(f'cp bazel-bin/fw/pi3_hat.elf {outdir}/{datestr}-pi3hat-{git_hash}.elf') - for pyver in ['3.7', '3.9']: + for pyver in ['3.7', '3.9', '3.10']: for arch in ['pi', 'pi64']: pyarch = { 'pi' : 'armv7l', diff --git a/tools/workspace/bazel_deps/repository.bzl b/tools/workspace/bazel_deps/repository.bzl index 0d43e27..ecb7c2a 100644 --- a/tools/workspace/bazel_deps/repository.bzl +++ b/tools/workspace/bazel_deps/repository.bzl @@ -20,6 +20,6 @@ def bazel_deps_repository(name): github_archive( name = name, repo = "mjbots/bazel_deps", - commit = "0d73d14eeb80b6555eedda769094afde6b147dc3", - sha256 = "dabb0dccc3a8d15cc1f72896c15c2e313d0e917d8b84a70a9a21bae294e41f34", + commit = "6c9ba1867b5d0ab5e59a7f1205adfd750a6c3610", + sha256 = "617989e5ca59c691d4e3e601dc899745aa9ace4c21d0f70b6128cc8125754cbd", ) diff --git a/tools/workspace/pybind11/package.BUILD b/tools/workspace/pybind11/package.BUILD index 0bc5b03..28d1080 100644 --- a/tools/workspace/pybind11/package.BUILD +++ b/tools/workspace/pybind11/package.BUILD @@ -33,3 +33,12 @@ cc_library( "@python39//:headers", ], ) + +cc_library( + name = "pybind11_310", + hdrs = glob(["include/**"]), + includes = ["include"], + deps = [ + "@python310//:headers", + ], +) diff --git a/tools/workspace/pybind11/repository.bzl b/tools/workspace/pybind11/repository.bzl index 3aae1d4..2ca1ac6 100644 --- a/tools/workspace/pybind11/repository.bzl +++ b/tools/workspace/pybind11/repository.bzl @@ -21,7 +21,7 @@ def pybind11_repository(name): github_archive( name = name, repo = "pybind/pybind11", - commit = "0964a9093a728dbf67b9b98c6371752b1a346f25", - sha256 = "cf4cd95f8bb70dc205dd906e4c849f9fbc6a292653e4488860b18b9a581ebec2", + commit = "6d22dba82f1789f11a8eb2c2debbcbd4d2d8a969", + sha256 = "ecbce06af56a59f0c6bac5241c655fd67d8a107c9aa46249e90ea4ed0fb36c98", build_file = Label("//tools/workspace/pybind11:package.BUILD"), ) diff --git a/tools/workspace/raspberrypi-firmware/package.BUILD b/tools/workspace/raspberrypi-firmware/package.BUILD index 0f7b9fe..c74f885 100644 --- a/tools/workspace/raspberrypi-firmware/package.BUILD +++ b/tools/workspace/raspberrypi-firmware/package.BUILD @@ -26,6 +26,21 @@ config_setting( values = {"cpu" : "aarch64"}, ) +# Some distros, like Ubuntu, only have libbcm_host.so without a .0, +# however the official raspberry pi package expects the aarch64 +# version to be libbcm_host.so.0. +# +# Make things work on both of them by manually patching the soname +# before linking. This will result in any libraries that link against +# this only requiring "libbcm_host.so". +genrule( + name = "soless_bcm_host", + outs = ["libbcm_host.so"], + srcs = ["aarch64/usr/lib/aarch64-linux-gnu/libbcm_host.so"], + cmd = "cp $< $@ && patchelf --set-soname libbcm_host.so $@", +) + + cc_library( name = "bcm_host", hdrs = select({ @@ -42,7 +57,7 @@ cc_library( }), srcs = select({ ":armeabihf" : ["hardfp/opt/vc/lib/libbcm_host.so"], - ":aarch64" : ["aarch64/usr/lib/aarch64-linux-gnu/libbcm_host.so"], + ":aarch64" : [":soless_bcm_host"], }), includes = select({ ":armeabihf" : [ @@ -51,7 +66,7 @@ cc_library( "aarch64" : [ "aarch64/usr/include", ], - }) + }), ) cc_library(