rebased python3 rfc

This commit is contained in:
Simon John 2019-08-25 15:23:42 +01:00
parent e870443f48
commit be3f7de842
8 changed files with 29 additions and 45 deletions

View file

@ -861,7 +861,7 @@ ifndef RESET_CMD
endif
ifneq (,$(findstring CYGWIN,$(shell uname -s)))
# confirm user is using default cygwin unix Python (which uses ttySx) and not Windows Python (which uses COMx)
ifeq ($(shell which python),/usr/bin/python)
ifeq ($(shell which python3),/usr/bin/python3)
RESET_CMD = $(ARD_RESET_ARDUINO) $(ARD_RESET_OPTS) $(DEVICE_PATH)
else
RESET_CMD = $(ARD_RESET_ARDUINO) $(ARD_RESET_OPTS) $(call get_monitor_port)

View file

@ -83,14 +83,14 @@ installer or download the distribution zip file and extract it.
The Makefile also delegates resetting the board to a short Python program.
You'll need to install [`pySerial`](https://pypi.python.org/pypi/pyserial) to use it though.
On most systems you should be able to install it using either `pip` or `easy_install`.
On most systems you should be able to install it using either `pip3` or `easy_install3`.
```sh
pip install pyserial
pip3 install pyserial
# or if you prefer easy_install
easy_install -U pyserial
easy_install3 -U pyserial
```
If you prefer to install it as a package, then you can do that as well.
@ -98,23 +98,19 @@ If you prefer to install it as a package, then you can do that as well.
On Debian or Ubuntu:
```sh
apt-get install python-serial
apt-get install python3-serial
```
On Fedora:
```sh
yum install pyserial
# or on Fedora 22+
dnf install pyserial
dnf install python3-pyserial
```
On openSUSE:
```sh
zypper install python-serial
zypper install python3-serial
```
On Arch:
@ -126,12 +122,12 @@ sudo pacman -S python-pyserial
On Mac using MacPorts:
```sh
sudo port install py27-serial
sudo port install py35-serial
```
On Windows:
You need to install Cygwin and its packages for Make, Perl, Python2 and the following Serial library.
You need to install Cygwin and its packages for Make, Perl, Python3 and the following Serial library.
Assuming you included Python in your Cygwin installation:
@ -141,15 +137,15 @@ Assuming you included Python in your Cygwin installation:
4. build and install Python module:
```
python setup.py build
python setup.py install
python3 setup.py build
python3 setup.py install
```
Alternatively, if you have setup Cygwin to use a Windows Python installation,
simply install using pip:
```
pip install pyserial
pip3 install pyserial
```
Arduino-Makefile should automatically detect the Python installation type and

View file

@ -1,18 +1,11 @@
#!/usr/bin/env python
#!/usr/bin/python3
from __future__ import print_function
import serial
import serial.tools.list_ports
import os.path
import argparse
from time import sleep
pyserial_version = None
try:
pyserial_version = int(serial.VERSION[0])
except:
pyserial_version = 2 # less than 2.3
parser = argparse.ArgumentParser(description='Reset an Arduino')
parser.add_argument('--zero', action='store_true', help='Reset Arduino Zero or similar Native USB to enter bootloader')
parser.add_argument('--caterina', action='store_true', help='Reset a Leonardo, Micro, Robot or LilyPadUSB.')
@ -65,11 +58,7 @@ if args.zero:
ser = serial.Serial(args.port[0], 57600)
ser.close()
if pyserial_version < 3:
ser.setBaudrate(1200)
else:
ser.baudrate = 1200
ser.baudrate = 1200
# do the open/close at 1200 BAUD
ser.open()

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/python3
"""
Arduino-mk Makefile and project initialiser
@ -17,7 +17,6 @@ Example:
See `armk-init --help` for CLI arguments
"""
from __future__ import print_function
import os
import argparse
@ -54,7 +53,7 @@ PARSER.add_argument('--cli', action='store_true', help='run with user prompts (r
PARSER.add_argument('-P', '--project', action='store_true',
help='create boilerplate project with src, lib and bin folder structure')
PARSER.add_argument('-t', '--template', action='store_true',
help='create bare minimum Arduino source file')
help='create bare minimum Arduino source file')
PARSER.add_argument('-V', '--version', action='version', version='%(prog)s '+ VERSION)
ARGS = PARSER.parse_args()

View file

@ -1,8 +1,8 @@
#!/usr/bin/python
#!/usr/bin/python3
# This script sends a program on a robotis board (OpenCM9.04 or CM900)
# using the robotis bootloader (used in OpenCM IDE)
#
#
# Usage:
# python robotis-loader.py <serial port> <binary>
#

View file

@ -9,7 +9,7 @@ Group: Development/Tools
License: LGPLv2+
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
Requires: arduino-core pyserial
Requires: arduino-core python3-pyserial
BuildRequires: arduino-core
%description

View file

@ -160,22 +160,22 @@ if [ -z $COMMON_SOURCED ]; then
fi
fi
if ! command -v python >/dev/null 2>&1; then
if ! command -v python3 >/dev/null 2>&1; then
echo "Installing Python..."
_install "python"
_install "python3"
fi
if ! command -v pip >/dev/null 2>&1; then
if ! command -v pip3 >/dev/null 2>&1; then
echo "Installing Pip..."
if ! command -v easy_install >/dev/null 2>&1; then
_install "python-setuptools"
if ! command -v easy_install3 >/dev/null 2>&1; then
_install "python3-setuptools"
fi
if ! command -v easy_install >/dev/null 2>&1; then
die "easy_install not available, can't install pip"
if ! command -v easy_install3 >/dev/null 2>&1; then
die "easy_install3 not available, can't install pip3"
fi
$SUDO_CMD easy_install pip
$SUDO_CMD easy_install3 pip3
fi
PIP_SUDO_CMD=
@ -184,7 +184,7 @@ if [ -z $COMMON_SOURCED ]; then
PIP_SUDO_CMD=$SUDO_CMD
fi
$PIP_SUDO_CMD pip install --src dependencies --pre -Ur $BOOTSTRAP_DIR/pip-requirements.txt
$PIP_SUDO_CMD pip3 install --src dependencies --pre -Ur $BOOTSTRAP_DIR/pip-requirements.txt
COMMON_SOURCED=1
fi

View file

@ -1 +1 @@
pyserial==2.7
pyserial==3.4