From 993eeaf6942f54868a9e1ca0612f827d2e307394 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Thu, 16 Jul 2020 13:59:32 -0700 Subject: [PATCH] Rebuild cython extensions when dependency version changes (#1886) * rebuild cython extensions when python/cython/distutils version changes * submodules and boardd * kalman and transformations old-commit-hash: 165e14d10384a67777ec5ed787cf1ec82ec61ccb --- SConstruct | 6 ++++++ cereal | 2 +- common/SConscript | 10 +++++----- common/kalman/SConscript | 6 +++--- common/transformations/SConscript | 11 +++++------ opendbc | 2 +- selfdrive/boardd/SConscript | 8 ++++---- 7 files changed, 25 insertions(+), 20 deletions(-) diff --git a/SConstruct b/SConstruct index 7e5a412b56..322bdd5f9f 100644 --- a/SConstruct +++ b/SConstruct @@ -1,3 +1,5 @@ +import Cython +import distutils import os import shutil import subprocess @@ -12,6 +14,10 @@ AddOption('--asan', action='store_true', help='turn on ASAN') +# Rebuild cython extensions if python, distutils, or cython change +cython_dependencies = [Value(v) for v in (sys.version, distutils.__version__, Cython.__version__)] +Export('cython_dependencies') + arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip() if platform.system() == "Darwin": arch = "Darwin" diff --git a/cereal b/cereal index f725dcd617..7b78cda876 160000 --- a/cereal +++ b/cereal @@ -1 +1 @@ -Subproject commit f725dcd617b0ff577ad5caee8b9b3c861d6be4a8 +Subproject commit 7b78cda8767a79c4ac6797d71fbd7bcb03e1f737 diff --git a/common/SConscript b/common/SConscript index 103d416f53..35abeb9ee4 100644 --- a/common/SConscript +++ b/common/SConscript @@ -1,6 +1,6 @@ -Import('env') +Import('env', 'cython_dependencies') -# parser -env.Command(['common_pyx.so'], - ['common_pyx_setup.py', 'clock.pyx'], - "cd common && python3 common_pyx_setup.py build_ext --inplace") +# Build cython clock module +env.Command(['common_pyx.so', 'clock.cpp'], + cython_dependencies + ['common_pyx_setup.py', 'clock.pyx'], + "cd common && python3 common_pyx_setup.py build_ext --inplace") diff --git a/common/kalman/SConscript b/common/kalman/SConscript index abd7e04375..3d7011fe29 100644 --- a/common/kalman/SConscript +++ b/common/kalman/SConscript @@ -1,6 +1,6 @@ -Import('env') +Import('env', 'cython_dependencies') env.Command(['simple_kalman_impl.so'], - ['simple_kalman_impl.pyx', 'simple_kalman_impl.pxd', 'simple_kalman_setup.py'], - "cd common/kalman && python3 simple_kalman_setup.py build_ext --inplace") + cython_dependencies + ['simple_kalman_impl.pyx', 'simple_kalman_impl.pxd', 'simple_kalman_setup.py'], + "cd common/kalman && python3 simple_kalman_setup.py build_ext --inplace") diff --git a/common/transformations/SConscript b/common/transformations/SConscript index 7c051746a3..0f72952259 100644 --- a/common/transformations/SConscript +++ b/common/transformations/SConscript @@ -1,9 +1,8 @@ -Import('env') +Import('env', 'cython_dependencies') d = Dir('.') -env.Command( - ['transformations.so'], - ['transformations.pxd', 'transformations.pyx', - 'coordinates.cc', 'orientation.cc', 'coordinates.hpp', 'orientation.hpp'], - 'cd ' + d.path + ' && python3 setup.py build_ext --inplace') +env.Command(['transformations.so'], + cython_dependencies + ['transformations.pxd', 'transformations.pyx', + 'coordinates.cc', 'orientation.cc', 'coordinates.hpp', 'orientation.hpp'], + 'cd ' + d.path + ' && python3 setup.py build_ext --inplace') diff --git a/opendbc b/opendbc index 2265c9c3dc..9ee0069ecc 160000 --- a/opendbc +++ b/opendbc @@ -1 +1 @@ -Subproject commit 2265c9c3dcff4d58a9cc2cd434a6c704350a4729 +Subproject commit 9ee0069ecc01c154a0b77130f0da02b10cacbdfa diff --git a/selfdrive/boardd/SConscript b/selfdrive/boardd/SConscript index d7e575d064..b29b886369 100644 --- a/selfdrive/boardd/SConscript +++ b/selfdrive/boardd/SConscript @@ -1,9 +1,9 @@ -Import('env', 'common', 'cereal', 'messaging') +Import('env', 'common', 'cereal', 'messaging', 'cython_dependencies') env.Program('boardd.cc', LIBS=['usb-1.0', common, cereal, messaging, 'pthread', 'zmq', 'capnp', 'kj']) env.Library('libcan_list_to_can_capnp', ['can_list_to_can_capnp.cc']) -env.Command(['boardd_api_impl.so'], - ['libcan_list_to_can_capnp.a', 'boardd_api_impl.pyx', 'boardd_setup.py'], - "cd selfdrive/boardd && python3 boardd_setup.py build_ext --inplace") +env.Command(['boardd_api_impl.so', 'boardd_api_impl.cpp'], + cython_dependencies + ['libcan_list_to_can_capnp.a', 'boardd_api_impl.pyx', 'boardd_setup.py'], + "cd selfdrive/boardd && python3 boardd_setup.py build_ext --inplace")