diff --git a/.github/workflows/dependency_check.yml b/.github/workflows/dependency_check.yml deleted file mode 100644 index f2d09c69d..000000000 --- a/.github/workflows/dependency_check.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Dependency check - -on: - workflow_dispatch: - schedule: - - cron: '0 2 * * *' - -jobs: - python-latest: - runs-on: ubuntu-latest - container: - image: python:latest - - steps: - - uses: actions/checkout@v4 - - - name: python version - run: python --version - - - name: install lib - run: pip install -e . - - python-python311: - runs-on: ubuntu-latest - container: - image: python:3.11 - - steps: - - uses: actions/checkout@v4 - - - name: python version - run: python --version - - - name: install lib - run: pip install -e . - - minimum-python310: - runs-on: ubuntu-latest - container: - image: python:3.10 - - steps: - - uses: actions/checkout@v4 - - - name: python version - run: python --version - - - name: install lib - run: pip install -e . diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 000000000..cf3ba9f9c --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,87 @@ +# Run check and build of the lib using the Bitcraze builder docker image +name: Nightly Build + +on: + workflow_dispatch: + schedule: + - cron: '0 2 * * *' + +jobs: + build-and-test: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, lab-mac, windows-latest] + python-version: ["3.10", "3.11", "3.12", "3.13"] + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + if: runner.os == 'Linux' || runner.os == 'Windows' + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Set up Python ${{ matrix.python-version }} and venv on macOS + if: runner.os == 'macOS' + run: | + brew install python@${{ matrix.python-version }} + $(brew --prefix)/bin/python${{ matrix.python-version }} -m venv venv + echo "PATH=$(pwd)/venv/bin:$PATH" >> $GITHUB_ENV + + - name: Set up MSVC environment (Windows) + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: x64 + if: runner.os == 'Windows' + + - name: Install dependencies + run: | + python3 -m pip install --upgrade pip build setuptools + python3 -m pip install pre-commit + + - name: Code quality checks + run: pre-commit run --all-files + + - name: Build wheel + run: python3 -m build --wheel + + - name: Install the built wheel + run: | + # Find the built wheel + WHEEL_FILE=$(ls dist/*.whl | head -n 1) + echo "Installing wheel: $WHEEL_FILE" + pip install "$WHEEL_FILE" + shell: bash + if: runner.os != 'Windows' + + - name: Install the built wheel (Windows) + run: | + for /f %%i in ('dir /b dist\*.whl') do set WHEEL_FILE=dist\%%i + echo Installing wheel: %WHEEL_FILE% + pip install %WHEEL_FILE% + shell: cmd + if: runner.os == 'Windows' + + - name: Test + run: python3 -m unittest discover test/ + + build-docs: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v4 + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python3 -m pip install --upgrade pip setuptools + python3 -m pip install pdoc3 pyyaml + - name: Build docs + run: ./tools/build-docs/build-docs diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 0dc3d068c..0e197504e 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -18,9 +18,16 @@ jobs: deploy: runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/cflib + permissions: + id-token: write steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v4 with: @@ -34,5 +41,4 @@ jobs: - name: Publish package uses: pypa/gh-action-pypi-publish@release/v1 with: - username: __token__ - password: ${{ secrets.PYPI_TOKEN }} + verbose: true diff --git a/.github/workflows/test-python-publish.yml b/.github/workflows/test-python-publish.yml index 444e635f2..2b4851bd3 100644 --- a/.github/workflows/test-python-publish.yml +++ b/.github/workflows/test-python-publish.yml @@ -18,9 +18,16 @@ jobs: deploy: runs-on: ubuntu-latest + environment: + name: pypi-test + url: https://pypi.org/p/cflib + permissions: + id-token: write steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v4 with: @@ -34,6 +41,5 @@ jobs: - name: Publish package to TestPyPI uses: pypa/gh-action-pypi-publish@release/v1 with: - username: __token__ - password: ${{ secrets.PYPI_TEST_TOKEN }} - repository_url: https://test.pypi.org/legacy/ + repository-url: https://test.pypi.org/legacy/ + verbose: true diff --git a/cflib/crazyflie/__init__.py b/cflib/crazyflie/__init__.py index cb9a0eed4..06f5e2e6d 100644 --- a/cflib/crazyflie/__init__.py +++ b/cflib/crazyflie/__init__.py @@ -109,7 +109,7 @@ def __init__(self, link=None, ro_cache=None, rw_cache=None): rw_cache=rw_cache) self.incoming = _IncomingPacketHandler(self) - self.incoming.setDaemon(True) + self.incoming.daemon = True if self.link: self.incoming.start() diff --git a/cflib/crazyflie/param.py b/cflib/crazyflie/param.py index 1dc199e8f..25ea37a0b 100644 --- a/cflib/crazyflie/param.py +++ b/cflib/crazyflie/param.py @@ -520,7 +520,7 @@ class _ExtendedTypeFetcher(Thread): def __init__(self, cf, toc): Thread.__init__(self) - self.setDaemon(True) + self.daemon = True self._lock = Lock() self._cf = cf @@ -599,7 +599,7 @@ class _ParamUpdater(Thread): def __init__(self, cf, useV2, updated_callback): """Initialize the thread""" Thread.__init__(self) - self.setDaemon(True) + self.daemon = True self.wait_lock = Lock() self.cf = cf self._useV2 = useV2 diff --git a/cflib/crtp/radiodriver.py b/cflib/crtp/radiodriver.py index 7d22b6c52..2d805f7c1 100644 --- a/cflib/crtp/radiodriver.py +++ b/cflib/crtp/radiodriver.py @@ -156,7 +156,7 @@ def __init__(self, devid: int): self._lock = Semaphore(1) - self.setDaemon(True) + self.daemon = True self.start() diff --git a/docs/installation/install.md b/docs/installation/install.md index f8c696dda..a505d74e3 100644 --- a/docs/installation/install.md +++ b/docs/installation/install.md @@ -7,6 +7,7 @@ page_id: install This project requires Python 3.10+. +To install on Python 3.13, build tools and Python development headers are required. See below sections for more platform-specific requirements. ## Install from Source @@ -78,6 +79,8 @@ With linux, the crazyradio is easily recognized, but you have to setup UDEVpermi Look at the [Zadig crazyradio instructions](https://www.bitcraze.io/documentation/repository/crazyradio-firmware/master/building/usbwindows/) to install crazyradio on Windows +If you're using Python 3.13, you need to install [Visual Studio](https://visualstudio.microsoft.com/downloads/). During the installation process, you only need to select the Desktop Development with C++ workload in the Visual Studio Installer. + ### macOS If you are using python 3.12 on mac you need to install libusb using homebrew. ``` diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..6677f6f41 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,64 @@ +[build-system] +requires = ["setuptools>=61.0", "wheel", "setuptools_scm"] +build-backend = "setuptools.build_meta" + +[project] +name = "cflib" +dynamic = ["version"] +description = "Crazyflie Python driver" +authors = [ + { name = "Bitcraze and contributors", email = "contact@bitcraze.io" }, +] + +readme = {file = "README.md", content-type = "text/markdown"} +license = { text = "GPLv3" } +keywords = ["driver", "crazyflie", "quadcopter"] + +classifiers = [ + "Development Status :: 5 - Production/Stable", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Topic :: System :: Hardware :: Hardware Drivers", + "Topic :: Scientific/Engineering :: Robotics", + "Intended Audience :: Science/Research", + "Intended Audience :: Education", + "Intended Audience :: Developers", + "Operating System :: Linux", + "Operating System :: MacOS", + "Operating System :: Microsoft :: Windows", + + # Supported Python versions + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +requires-python = ">= 3.10" + +dependencies = [ + "pyusb~=1.2", + "libusb-package~=1.0", + "scipy~=1.14", + "numpy~=1.26", + "packaging~=24.2", +] + +[project.urls] +Homepage = "https://www.bitcraze.io" +Documentation = "https://www.bitcraze.io/documentation/repository/crazyflie-lib-python/master/" +Repository = "https://github.com/bitcraze/crazyflie-lib-python" +Issues = "https://github.com/bitcraze/crazyflie-lib-python/issues" + +[project.optional-dependencies] +dev = ["pre-commit"] + +[tool.setuptools] +include-package-data = true + +[tool.setuptools.packages] +find = { exclude = ["examples", "test"] } + +[tool.setuptools.package-data] +"cflib.resources.binaries" = ["cflib/resources/binaries/*.bin"] + +[tool.setuptools_scm] +version_scheme = "no-guess-dev" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 3c6e79cf3..000000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[bdist_wheel] -universal=1 diff --git a/setup.py b/setup.py deleted file mode 100644 index fdcd5e5a5..000000000 --- a/setup.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env python3 -from pathlib import Path - -from setuptools import find_packages -from setuptools import setup -# read the contents of README.md file fo use in pypi description -directory = Path(__file__).parent -long_description = (directory / 'README.md').read_text() - -package_data = { - 'cflib.resources.binaries': ['cflib/resources/binaries/*.bin'], -} - -setup( - name='cflib', - version='0.1.27', - packages=find_packages(exclude=['examples', 'test']), - - description='Crazyflie python driver', - url='https://github.com/bitcraze/crazyflie-lib-python', - - long_description=long_description, - long_description_content_type='text/markdown', - - author='Bitcraze and contributors', - author_email='contact@bitcraze.io', - license='GPLv3', - - classifiers=[ - 'Development Status :: 4 - Beta', - 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', - 'Topic :: System :: Hardware :: Hardware Drivers', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 3' - ], - - keywords='driver crazyflie quadcopter', - - install_requires=[ - 'pyusb>=1.0.0b2', - 'libusb-package~=1.0', - 'scipy~=1.7', - 'numpy~=1.20', - 'packaging~=24.0', - ], - - # $ pip install -e .[dev] - extras_require={ - 'dev': [ - 'pre-commit' - ], - }, - - include_package_data=True, - package_data=package_data -) diff --git a/tools/build/bdist b/tools/build/bdist index c0bc8dc31..40a9acd04 100755 --- a/tools/build/bdist +++ b/tools/build/bdist @@ -9,7 +9,7 @@ try: script_dir = os.path.dirname(os.path.realpath(__file__)) root = _path.normpath(_path.join(script_dir, '../..')) - subprocess.check_call(['python3', 'setup.py', 'bdist_wheel'], cwd=root) + subprocess.check_call(['python3', '-m', 'build', '--wheel'], cwd=root) print('Wheel built') except subprocess.CalledProcessError as e: