-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Draft support for python3.9 as present in Raspberry Pi OS "bullseye"
- Loading branch information
Showing
7 changed files
with
83 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# -*- python -*- | ||
|
||
# Copyright 2020 Josh Pieper, [email protected]. | ||
# Copyright 2020-2021 Josh Pieper, [email protected]. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
|
@@ -47,3 +47,17 @@ test_suite( | |
"//lib/cpp/mjbots/moteus:test", | ||
], | ||
) | ||
|
||
config_setting( | ||
name = "python37", | ||
values = { | ||
"define": "PYTHON=3.7", | ||
}, | ||
) | ||
|
||
config_setting( | ||
name = "python39", | ||
values = { | ||
"define": "PYTHON=3.9", | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# -*- python -*- | ||
|
||
# Copyright 2020 Josh Pieper, [email protected]. | ||
# Copyright 2020-2021 Josh Pieper, [email protected]. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
|
@@ -22,6 +22,9 @@ load("//tools/workspace:template_file.bzl", "template_file") | |
|
||
VERSION="0.3.14" | ||
|
||
PYTHON_SHORT_VERSIONS = ['37', '39'] | ||
|
||
|
||
# It would be nice to pull this from the python source. As it is, the | ||
# below genrule will fail if they don't match, so at least there is | ||
# some verification. | ||
|
@@ -35,32 +38,50 @@ pkg_tar( | |
], | ||
) | ||
|
||
template_file( | ||
name = "setup.py", | ||
src = "setup.py.TPL", | ||
substitutions = { | ||
"{{VERSION}}" : '"{}"'.format(VERSION), | ||
}, | ||
) | ||
|
||
genrule( | ||
name = "bdist_wheel", | ||
srcs = ["setup.py", ":wheel_tar", "README.md"], | ||
[ | ||
template_file( | ||
name = "setup_{pyshortver}.py".format(pyshortver=pyshortver), | ||
src = "setup.py.TPL", | ||
substitutions = { | ||
"{{VERSION}}" : '"{}"'.format(VERSION), | ||
"{{PYTHON_SHORT_VERSION}}" : '"{}"'.format(pyshortver), | ||
}, | ||
) | ||
for pyshortver in PYTHON_SHORT_VERSIONS | ||
] | ||
|
||
|
||
[genrule( | ||
name = "bdist_wheel_{pyshortver}".format(pyshortver=pyshortver), | ||
srcs = ["setup_{pyshortver}.py".format(pyshortver=pyshortver), | ||
":wheel_tar", "README.md"], | ||
outs = [ | ||
"moteus_pi3hat-{ver}-cp37-abi3-linux_armv7l.whl".format(ver=VERSION), | ||
"moteus_pi3hat-{ver}-cp{pyshortver}-abi3-linux_armv7l.whl".format( | ||
ver=VERSION, pyshortver=pyshortver), | ||
], | ||
cmd = ( | ||
"OUTDIR=$$(dirname $(location moteus_pi3hat-{ver}-cp37-abi3-linux_armv7l.whl)) && " + | ||
"OUTDIR=$$(dirname $(location moteus_pi3hat-{ver}-cp{pyshortver}-abi3-linux_armv7l.whl)) && " + | ||
"BUILDDIR=$$OUTDIR/build && " + | ||
"mkdir -p $$BUILDDIR && " + | ||
"tar xf $(location wheel_tar) -C $$BUILDDIR && " + | ||
"cp $(location setup.py) $(location README.md) $$BUILDDIR && " + | ||
"cp $(location setup_{pyshortver}.py) $(location README.md) $$BUILDDIR && " + | ||
"cd $$BUILDDIR && " + | ||
"python3 setup.py bdist_wheel " + | ||
"python3.9 setup_{pyshortver}.py bdist_wheel " + | ||
" --plat-name linux_armv7l " + | ||
" --py-limited-api cp37 " + | ||
" --py-limited-api cp{pyshortver} " + | ||
" --dist-dir .. " + | ||
" 1>/dev/null" + | ||
"" | ||
).format(ver=VERSION), | ||
).format(ver=VERSION, pyshortver=pyshortver), | ||
) | ||
for pyshortver in PYTHON_SHORT_VERSIONS | ||
] | ||
|
||
filegroup( | ||
name="bdist_wheel", | ||
srcs = select({ | ||
"//:python37" : [":bdist_wheel_37"], | ||
"//:python39" : [":bdist_wheel_39"], | ||
}), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# -*- python -*- | ||
|
||
# Copyright 2020 Josh Pieper, [email protected]. | ||
# Copyright 2020-2021 Josh Pieper, [email protected]. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
|
@@ -22,11 +22,14 @@ cc_binary( | |
"_pi3hat_router.cc", | ||
], | ||
deps = [ | ||
"@com_github_pybind_pybind11//:pybind11", | ||
"//lib/cpp/mjbots/pi3hat:libpi3hat", | ||
"//lib/cpp/mjbots/moteus:common", | ||
"@org_llvm_libcxx//:libcxx", | ||
], | ||
] + select({ | ||
"//conditions:default" : [], | ||
"//:python37" : ["@com_github_pybind_pybind11//:pybind11_37"], | ||
"//:python39" : ["@com_github_pybind_pybind11//:pybind11_39"], | ||
}), | ||
linkshared = True, | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# -*- python -*- | ||
|
||
# Copyright 2020 Josh Pieper, [email protected]. | ||
# Copyright 2020-2021 Josh Pieper, [email protected]. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
|
@@ -50,7 +50,9 @@ setuptools.setup( | |
entry_points = { | ||
'moteus.transports': [ 'pi3hat=moteus_pi3hat:Pi3HatFactory' ], | ||
}, | ||
python_requires = '>=3.7, <4', | ||
python_requires = {"37" : ">=3.7, <3.8", | ||
"39" : ">=3.9, <3.10" | ||
}[{{PYTHON_SHORT_VERSION}}], | ||
install_requires = [ | ||
'moteus>=0.3.22', | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!/usr/bin/python3 | ||
|
||
# Copyright 2020 Josh Pieper, [email protected]. | ||
# Copyright 2020-2021 Josh Pieper, [email protected]. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
|
@@ -48,8 +48,13 @@ def main(): | |
|
||
run(f'cp bazel-bin/fw/pi3_hat.elf {outdir}/{datestr}-pi3hat-{git_hash}.elf') | ||
|
||
run('tools/bazel build --config=pi -c opt //:pi3hat_tools') | ||
run(f'cp bazel-bin/pi3hat_tools.tar.bz2 {outdir}/{datestr}-pi3hat_tools-{git_hash}.tar.bz2') | ||
for pyver in ['3.7', '3.9']: | ||
run(f'tools/bazel build --config=pi --define PYTHON={pyver} -c opt //:pi3hat_tools') | ||
run(f'cp bazel-bin/pi3hat_tools.tar.bz2 {outdir}/{datestr}-pi3hat_tools-cp{pyver.replace(".","")}-{git_hash}.tar.bz2') | ||
|
||
wheel_name = subprocess.check_output("tar --list -f bazel-bin/pi3hat_tools.tar.bz2 | grep \.whl$", shell=True).decode('utf8').strip() | ||
run(f'tar -C {outdir} --strip-components 2 --extract -f bazel-bin/pi3hat_tools.tar.bz2 {wheel_name}') | ||
|
||
|
||
print() | ||
print('DONE') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters