Skip to content

Commit

Permalink
unpin numpy (commaai#33132)
Browse files Browse the repository at this point in the history
* unlock numpy

* remove old cache

* sheel

* lock

* remove temp

* depends

* export

* put this back

* use __version__

* move this

---------

Co-authored-by: quebec <[email protected]>
old-commit-hash: 9536dd0
  • Loading branch information
maxime-desroches and quebec authored Jul 30, 2024
1 parent 44afd8b commit 6c1d735
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 8 deletions.
5 changes: 3 additions & 2 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ env = Environment(
COMPILATIONDB_USE_ABSPATH=True,
REDNOSE_ROOT="#",
tools=["default", "cython", "compilation_db", "rednose_filter"],
toolpath=["#rednose_repo/site_scons/site_tools"],
toolpath=["#site_scons/site_tools", "#rednose_repo/site_scons/site_tools"],
)

if arch == "Darwin":
Expand Down Expand Up @@ -268,7 +268,8 @@ if arch == "Darwin":
else:
envCython["LINKFLAGS"] = ["-pthread", "-shared"]

Export('envCython')
np_version = SCons.Script.Value(np.__version__)
Export('envCython', 'np_version')

# Qt build environment
qt_env = env.Clone()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dependencies = [
"pycapnp",
"Cython",
"setuptools",
"numpy < 2.0.0", # control does not support numpy 2
"numpy",

# body / webrtcd
"aiohttp",
Expand Down
3 changes: 2 additions & 1 deletion selfdrive/controls/lib/lateral_mpc_lib/SConscript
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Import('env', 'envCython', 'arch', 'msgq_python', 'common_python', 'opendbc_python')
Import('env', 'envCython', 'arch', 'msgq_python', 'common_python', 'opendbc_python', 'np_version')

gen = "c_generated_code"

Expand Down Expand Up @@ -88,3 +88,4 @@ lenv2.Command(libacados_ocp_solver_c,
f' {acados_ocp_solver_pyx.get_labspath()}')
lib_cython = lenv2.Program(f'{gen}/acados_ocp_solver_pyx.so', [libacados_ocp_solver_c])
lenv2.Depends(lib_cython, lib_solver)
lenv2.Depends(libacados_ocp_solver_c, np_version)
3 changes: 2 additions & 1 deletion selfdrive/controls/lib/longitudinal_mpc_lib/SConscript
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Import('env', 'envCython', 'arch', 'msgq_python', 'common_python', 'opendbc_python')
Import('env', 'envCython', 'arch', 'msgq_python', 'common_python', 'opendbc_python', 'np_version')

gen = "c_generated_code"

Expand Down Expand Up @@ -94,3 +94,4 @@ lenv2.Command(libacados_ocp_solver_c,
f' {acados_ocp_solver_pyx.get_labspath()}')
lib_cython = lenv2.Program(f'{gen}/acados_ocp_solver_pyx.so', [libacados_ocp_solver_c])
lenv2.Depends(lib_cython, lib_solver)
lenv2.Depends(libacados_ocp_solver_c, np_version)
3 changes: 3 additions & 0 deletions site_scons/site_tools/cython.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
import SCons
from SCons.Action import Action
from SCons.Scanner import Scanner
import numpy as np

pyx_from_import_re = re.compile(r'^from\s+(\S+)\s+cimport', re.M)
pyx_import_re = re.compile(r'^cimport\s+(\S+)', re.M)
cdef_import_re = re.compile(r'^cdef extern from\s+.(\S+).:', re.M)

np_version = SCons.Script.Value(np.__version__)

def pyx_scan(node, env, path, arg=None):
contents = node.get_text_contents()
env.Depends(str(node).split('.')[0] + env['CYTHONCFILESUFFIX'], np_version)

# from <module> cimport ...
matches = pyx_from_import_re.findall(contents)
Expand Down
6 changes: 3 additions & 3 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6c1d735

Please sign in to comment.