Skip to content

Commit

Permalink
Added setup.py for installing Python bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
simondlevy committed Aug 3, 2023
1 parent e56b7fd commit 4af0e62
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ MOD_SRC = src/modules/src
bindings_python build/cffirmware.py: bindings/setup.py $(MOD_SRC)/*.c
swig -python -I$(MOD_INC) -Isrc/hal/interface -Isrc/utils/interface -Isrc/modules/interface/controller -o build/cffirmware_wrap.c bindings/cffirmware.i
$(PYTHON) bindings/setup.py build_ext --inplace
cp cffirmware_setup.py build/setup.py

test_python: build/cffirmware.py
PYTHONPATH=build $(PYTHON) -m pytest test_python
Expand Down
36 changes: 36 additions & 0 deletions cffirmware_setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Distutils setup file for Crazyflie Python firmware bindings
#
# Automatically copied to build/ directory when you run
#
# make bindings_python
#
# Then you can cd to build/ and do
#
# sudo python3 setup.py install
#
# Copyright (C) 2023 Bitcraze AB and Simon D. Levy
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

from distutils.core import setup

setup(
name='cffirmware',
version='0.1',
packages=[''],
package_dir={'': '.'},
package_data={'': ['_cffirmware.cpython-38-x86_64-linux-gnu.so']},
)
3 changes: 2 additions & 1 deletion docs/building-and-flashing/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,10 @@ First make sure that you have [SWIG](https://swig.org/) installed on your system
```bash
make cf2_defconfig
make bindings_python
cd build
sudo python3 setup.py install
```


## Make targets

### General targets
Expand Down

0 comments on commit 4af0e62

Please sign in to comment.