From 3537404a18b0382e3521d19aca0b9ef4c359fdf7 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sat, 17 Aug 2024 12:04:46 -0700 Subject: [PATCH] no docker (#1081) * cleanup dependencies * all * install * less * try this * slimmm * skip docker * silence that one * disable for now * e * fix build * bring that back * not ready yet --- .github/workflows/tests.yml | 22 ++++++++--------- .gitignore | 2 ++ Dockerfile | 47 ------------------------------------- SConstruct | 8 +++---- opendbc/can/SConscript | 16 ++++--------- pyproject.toml | 25 ++++++++++++++++++++ requirements.txt | 16 ------------- 7 files changed, 47 insertions(+), 89 deletions(-) delete mode 100644 Dockerfile delete mode 100644 requirements.txt diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 93fbbb4c68..c1f2b1e6a6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -6,10 +6,9 @@ on: - master pull_request: -env: - RUN: docker run -e PYTHONWARNINGS="error,default::DeprecationWarning" --shm-size 1G --rm opendbc /bin/bash -c - BUILD: docker buildx build --pull --load --cache-to type=inline --cache-from type=registry,ref=ghcr.io/commaai/opendbc:latest -t opendbc -f Dockerfile . - PYTHONWARNINGS: error +# TODO: enable this +#env: +# PYTHONWARNINGS: error,default::DeprecationWarning jobs: unit-tests: @@ -22,22 +21,23 @@ jobs: # run: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] steps: - uses: actions/checkout@v4 - - name: Build Docker image - run: eval "$BUILD" - - name: Unit tests - run: ${{ env.RUN }} "pytest -n logical --durations=0" + - uses: actions/setup-python@v5 + with: + cache: 'pip' + python-version: '3.11' + - run: pip install -e .[testing,docs] + - run: scons -j$(nproc) + - run: pytest -n logical --durations=0 static-analysis: name: static analysis runs-on: ubuntu-latest timeout-minutes: 1 - env: - # package install has DeprecationWarnings - PYTHONWARNINGS: default steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: + cache: 'pip' python-version: '3.11' - run: sudo apt install --no-install-recommends -y cppcheck - run: pip install -e . diff --git a/.gitignore b/.gitignore index 2f57ce978b..bfe2238555 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/build/ .mypy_cache/ *.pyc *.os @@ -8,6 +9,7 @@ .DS_Store .sconsign.dblite .hypothesis +*.egg-info/ opendbc/can/*.so opendbc/can/*.a diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 7cbf7c522d..0000000000 --- a/Dockerfile +++ /dev/null @@ -1,47 +0,0 @@ -FROM ubuntu:24.04 - -ENV DEBIAN_FRONTEND=noninteractive -RUN apt-get update && apt-get install -y --no-install-recommends \ - autoconf \ - build-essential \ - ca-certificates \ - capnproto \ - clang \ - cppcheck \ - curl \ - git \ - libtool \ - make \ - libbz2-dev \ - libffi-dev \ - libcapnp-dev \ - liblzma-dev \ - libncurses5-dev \ - libncursesw5-dev \ - libreadline-dev \ - libssl-dev \ - libsqlite3-dev \ - libzmq3-dev \ - llvm \ - ocl-icd-opencl-dev \ - opencl-headers \ - tk-dev \ - python3-pip \ - python3-dev \ - python3-openssl \ - python-is-python3 \ - xz-utils \ - zlib1g-dev \ - cmake \ - && rm -rf /var/lib/apt/lists/* - -COPY requirements.txt /tmp/ -RUN pip3 install --break-system-packages --no-cache-dir -r /tmp/requirements.txt -RUN pip3 install --break-system-packages --no-cache-dir pre-commit==2.15.0 pylint==2.17.4 - -WORKDIR /project/opendbc -ENV PYTHONPATH=/project/opendbc - -COPY . . -RUN ls && rm -rf .git && \ - scons -c && scons -j$(nproc) \ diff --git a/SConstruct b/SConstruct index 2401720f17..932ff26e8b 100644 --- a/SConstruct +++ b/SConstruct @@ -3,7 +3,6 @@ import subprocess import sysconfig import numpy as np -zmq = 'zmq' arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip() python_path = sysconfig.get_paths()['include'] @@ -28,8 +27,8 @@ ldflags_asan = ["-fsanitize=address"] if GetOption('asan') else [] env = Environment( ENV=os.environ, - CC='clang', - CXX='clang++', + CC='gcc', + CXX='g++', CCFLAGS=[ "-g", "-fPIC", @@ -38,6 +37,7 @@ env = Environment( "-Werror", "-Wshadow", "-Wno-vla-cxx-extension", + "-Wno-unknown-warning-option", # for compatibility across compiler versions ] + ccflags_asan, LDFLAGS=ldflags_asan, LINKFLAGS=ldflags_asan, @@ -52,7 +52,7 @@ env = Environment( ) common = '' -Export('env', 'zmq', 'arch', 'common') +Export('env', 'arch', 'common') envCython = env.Clone() envCython["CPPPATH"] += [np.get_include()] diff --git a/opendbc/can/SConscript b/opendbc/can/SConscript index 1c1629d584..ab2fbd1d3a 100644 --- a/opendbc/can/SConscript +++ b/opendbc/can/SConscript @@ -1,30 +1,24 @@ Import('env', 'envCython', 'common', 'arch') -import os - envDBC = env.Clone() dbc_file_path = '-DDBC_FILE_PATH=\'"%s"\'' % (envDBC.Dir("../dbc").abspath) envDBC['CXXFLAGS'] += [dbc_file_path] src = ["dbc.cc", "parser.cc", "packer.cc", "common.cc"] -libs = [common, "zmq"] # shared library for openpilot LINKFLAGS = envDBC["LINKFLAGS"] if arch == "Darwin": LINKFLAGS += ["-Wl,-install_name,@loader_path/libdbc.dylib"] -libdbc = envDBC.SharedLibrary('libdbc', src, LIBS=libs, LINKFLAGS=LINKFLAGS) +libdbc = envDBC.SharedLibrary('libdbc', src, LIBS=[common, ], LINKFLAGS=LINKFLAGS) # static library for tools like cabana -envDBC.Library('libdbc_static', src, LIBS=libs) +envDBC.Library('libdbc_static', src, LIBS=[common, ]) # Build packer and parser lenv = envCython.Clone() -lenv["LINKFLAGS"] += [libdbc[0].get_labspath()] -parser = lenv.Program('parser_pyx.so', 'parser_pyx.pyx') -packer = lenv.Program('packer_pyx.so', 'packer_pyx.pyx') - -lenv.Depends(parser, libdbc) -lenv.Depends(packer, libdbc) +lenv["RPATH"] = [libdbc[0].dir.abspath, ] +parser = lenv.Program('parser_pyx.so', 'parser_pyx.pyx', LIBS=[common, libdbc]) +packer = lenv.Program('packer_pyx.so', 'packer_pyx.pyx', LIBS=[common, libdbc]) opendbc_python = Alias("opendbc_python", [parser, packer]) diff --git a/pyproject.toml b/pyproject.toml index f7925c8162..aa552a8b57 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,6 +9,31 @@ requires-python = ">=3.9" urls = { "homepage" = "https://github.com/commaai/opendbc" } +dependencies = [ + "scons", + "pyyaml", + "numpy", + "Cython", + "crcmod", + "pandacan@git+https://github.com/commaai/panda.git@master", +] + +[project.optional-dependencies] +testing = [ + "ruff", + "pytest", + "pytest-mock", + "pytest-xdist", + "pytest-subtests", + "hypothesis==6.47.*", + "parameterized>=0.8,<0.9", + "pre-commit", +] +docs = [ + "Jinja2", + "natsort", +] + [tool.pytest.ini_options] addopts = "--ignore=panda/ -Werror --strict-config --strict-markers --durations=10 -n auto" python_files = "test_*.py" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index b3c3d9f9ab..0000000000 --- a/requirements.txt +++ /dev/null @@ -1,16 +0,0 @@ -ruff -Cython -Jinja2 -numpy -pycapnp -pyyaml -scons -pytest -pytest-xdist -pytest-subtests -pytest-mock -hypothesis==6.47.* -crcmod -natsort -parameterized>=0.8,<0.9 -git+https://github.com/commaai/panda.git