diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index d77633af..d5992976 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -45,7 +45,7 @@ jobs: - name: Build Docker image run: eval "$BUILD" - name: Test python package installer - run: ${{ env.RUN }} "python3 setup.py install" + run: ${{ env.RUN }} "pip install --break-system-packages .[dev]" - name: Build panda images and bootstub run: ${{ env.RUN }} "scons -j4" - name: Build panda with SPI support diff --git a/Dockerfile b/Dockerfile index 96a2a86e..c2f04bf7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,7 +30,7 @@ COPY tests/misra/install.sh /tmp/ RUN /tmp/install.sh && rm -rf $CPPCHECK_DIR/.git/ ENV SKIP_CPPCHECK_INSTALL=1 -COPY setup.py __init__.py $PYTHONPATH/panda/ +COPY pyproject.toml __init__.py $PYTHONPATH/panda/ COPY python/__init__.py $PYTHONPATH/panda/python/ RUN pip3 install --break-system-packages --no-cache-dir $PYTHONPATH/panda/[dev] diff --git a/Jenkinsfile b/Jenkinsfile index 64429b77..a771ff53 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -106,7 +106,7 @@ pipeline { steps { phone_steps("panda-tres", [ ["build", "scons -j4"], - ["flash", "cd tests/ && ./reflash_internal_panda.py"], + ["flash", "cd scripts/ && ./reflash_internal_panda.py"], ["flash jungle", "cd board/jungle && ./flash.py --all"], ["test", "cd tests/hitl && HW_TYPES=9 pytest -n0 --durations=0 2*.py [5-9]*.py"], ]) @@ -118,7 +118,7 @@ pipeline { steps { phone_steps("panda-dos", [ ["build", "scons -j4"], - ["flash", "cd tests/ && ./reflash_internal_panda.py"], + ["flash", "cd scripts/ && ./reflash_internal_panda.py"], ["flash jungle", "cd board/jungle && ./flash.py --all"], ["test", "cd tests/hitl && HW_TYPES=6 pytest -n0 --durations=0 [2-9]*.py -k 'not test_send_recv'"], ]) diff --git a/board/README.md b/board/README.md index ab3d59d3..558beae7 100644 --- a/board/README.md +++ b/board/README.md @@ -17,4 +17,4 @@ If panda is blinking fast with green LED, use `flash.py`. Otherwise if LED is off and panda can't be seen with `lsusb` command, use [panda paw](https://comma.ai/shop/products/panda-paw) to go into DFU mode. -If your device has an internal panda and none of the above works, try running `../tests/reflash_internal_panda.py`. +If your device has an internal panda and none of the above works, try running `../scripts/reflash_internal_panda.py`. diff --git a/pyproject.toml b/pyproject.toml index 0f616b3b..32b65ace 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,60 @@ +[project] +name = "pandacan" +version = "0.0.10" +description = "Code powering the comma.ai panda" +readme = "README.md" +requires-python = ">=3.11,<3.13" +license = {text = "MIT"} +authors = [{name = "comma.ai"}] +classifiers = [ + "Natural Language :: English", + "Programming Language :: Python :: 3", + "Topic :: System :: Hardware", +] +dependencies = [ + "libusb1", + "opendbc @ git+https://github.com/commaai/opendbc.git@45bf6c8f548473dece52f780f60bd8e20c32bd65#egg=opendbc", +] + +[project.optional-dependencies] +dev = [ + "scons", + "pycryptodome >= 3.9.8", + "cffi", + "flaky", + "pytest", + "pytest-mock", + "pytest-xdist", + "pytest-timeout", + "pytest-randomly", + "pre-commit", + "ruff", + "spidev", + "setuptools", +] + +[build-system] +requires = ["setuptools>=61", "wheel"] +build-backend = "setuptools.build_meta" + +[tool.setuptools] +packages = ["panda"] + +[tool.setuptools.package-dir] +panda = "python" + +[tool.mypy] +# third-party packages +ignore_missing_imports = true + +# helpful warnings +warn_redundant_casts = true +warn_unreachable = true +warn_unused_ignores = true + +# restrict dynamic typing +warn_return_any = true + # https://beta.ruff.rs/docs/configuration/#using-pyprojecttoml [tool.ruff] line-length = 160 @@ -12,17 +69,4 @@ flake8-implicit-str-concat.allow-multiline=false "pytest.main".msg = "pytest.main requires special handling that is easy to mess up!" [tool.pytest.ini_options] -addopts = "-n auto --ignore-glob='*.sh'" - - -[tool.mypy] -# third-party packages -ignore_missing_imports = true - -# helpful warnings -warn_redundant_casts = true -warn_unreachable = true -warn_unused_ignores = true - -# restrict dynamic typing -warn_return_any = true +addopts = "-n auto --ignore-glob='*.sh'" \ No newline at end of file diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 3480374b..00000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[bdist_wheel] -universal=1 \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index 7786b9e4..00000000 --- a/setup.py +++ /dev/null @@ -1,80 +0,0 @@ -""" - Panda CAN Controller Dongle - ~~~~~ - - Setup - ````` - - $ pip install . # or python setup.py install -""" - -import codecs -import os -import re -from setuptools import setup - -here = os.path.abspath(os.path.dirname(__file__)) - -def read(*parts): - """Taken from pypa pip setup.py: - intentionally *not* adding an encoding option to open, See: - https://github.com/pypa/virtualenv/issues/201#issuecomment-3145690 - """ - return codecs.open(os.path.join(here, *parts), 'r').read() - - -def find_version(*file_paths): - version_file = read(*file_paths) - version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", - version_file, re.M) - if version_match: - return version_match.group(1) - raise RuntimeError("Unable to find version string.") - -setup( - name='pandacan', - version=find_version("python", "__init__.py"), - url='https://github.com/commaai/panda', - author='comma.ai', - author_email='', - packages=[ - 'panda', - ], - package_dir={'panda': 'python'}, - platforms='any', - license='MIT', - python_requires='>=3.11,<3.13', - install_requires=[ - 'libusb1', - 'opendbc @ git+https://github.com/commaai/opendbc.git@45bf6c8f548473dece52f780f60bd8e20c32bd65#egg=opendbc', - ], - extras_require = { - 'dev': [ - "scons", - "pycryptodome >= 3.9.8", - "cffi", - "flaky", - "pytest", - "pytest-mock", - "pytest-xdist", - "pytest-timeout", - "pytest-randomly", - "parameterized", - "pre-commit", - "numpy", - "ruff", - "spidev", - "setuptools", # for setup.py - ], - }, - ext_modules=[], - description="Code powering the comma.ai panda", - long_description='See https://github.com/commaai/panda', - classifiers=[ - 'Development Status :: 2 - Pre-Alpha', - "Natural Language :: English", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 3", - "Topic :: System :: Hardware", - ], -) diff --git a/scripts/setup_device_ci.sh b/tests/setup_device_ci.sh similarity index 100% rename from scripts/setup_device_ci.sh rename to tests/setup_device_ci.sh