Skip to content

Commit a949ce3

Browse files
authored
Merge pull request #187 from rhempel/feature-python3-migrate
Feature python3 migrate
2 parents 537c47f + fb3cdbc commit a949ce3

File tree

12 files changed

+398
-85
lines changed

12 files changed

+398
-85
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: python
22
python:
3-
- 2.7
3+
- 3.4
44
sudo: false
55
install:
66
- pip install Pillow

README.rst

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ Python language bindings for ev3dev
77
:target: http://python-ev3dev.readthedocs.org/en/latest/?badge=latest
88
:alt: Documentation Status
99

10-
A Python library implementing unified interface for ev3dev_ devices.
10+
A Python3 library implementing unified interface for ev3dev_ devices.
1111

1212
Example Code
1313
------------
1414

15-
To run these minimal examples, run the Python interpreter from
15+
To run these minimal examples, run the Python3 interpreter from
1616
the terminal like this:
1717

1818
.. code-block:: bash
1919
20-
robot@ev3dev:~$ python
21-
Python 2.7.9 (default, Mar 1 2015, 13:52:09)
22-
[GCC 4.9.2] on linux2
20+
robot@ev3dev:~/ev3dev-lang-python$ python3
21+
Python 3.4.2 (default, Oct 8 2014, 14:47:30)
22+
[GCC 4.9.1] on linux
2323
Type "help", "copyright", "credits" or "license" for more information.
2424
>>>
2525
@@ -46,18 +46,18 @@ loop and start the program. Hit ``Ctrl-C`` to exit the loop.
4646
ev3.Leds.set_color(ev3.Leds.LEFT, (ev3.Leds.GREEN, ev3.Leds.RED)[ts.value()])
4747
4848
Now plug a motor into the ``A`` port and paste this code into the terminal. This
49-
little program will run the motor at 75% power for 3 seconds.
49+
little program will run the motor at 500 RPM for 3 seconds.
5050

5151
.. code-block:: python
5252
5353
m = ev3.LargeMotor('outA')
54-
m.run_timed(time_sp=3000, duty_cycle_sp=75)
54+
m.run_timed(time_sp=3000, speed_sp=500)
5555
5656
If you want to make your robot speak, then paste this code into the terminal:
5757

5858
.. code-block:: python
5959
60-
ev3.Sound.speak('Welcome to the EV3DEV project!').wait()
60+
ev3.Sound.speak('Welcome to the E V 3 dev project!').wait()
6161
6262
To quit Python, just type ``exit()`` or ``Ctrl-D``.
6363

@@ -109,20 +109,14 @@ The ev3dev-lang Project on GitHub
109109
Python2.x and Python3.x Compatibility
110110
-------------------------------------
111111

112-
The ev3dev_ distribution comes with both python2_ and python3_ installed and
113-
this library is compatible with both versions.
112+
The ev3dev_ distribution comes with both python2_ and python3_ installed
113+
but this library is compatible only with Python3.
114114

115-
Note that currently, the source is only installed in the default
116-
`Python 2.x`_ location - this will be addressed in the next package we
115+
Note that currently, the Python3 binding for ev3dev_ is not installed
116+
by default - this will be addressed in the next package we
117117
release.
118118

119-
For `Python 2.x`_ programs, you import the binding like this:
120-
121-
.. code-block:: python
122-
123-
from ev3dev.auto import *
124-
125-
For `Python 3.x`_ the easiest way to work around the problem is
119+
The easiest way to work around the problem is
126120
to get your EV3 connected to the Internet and then:
127121

128122
#. Update the package lists

debian/changelog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
python-ev3dev (0.7.0~rc1) stable; urgency=medium
2+
3+
* Drop python 2.x support.
4+
* Performance improvements for reading/writing sysfs attributes.
5+
* Updates for breaking ev3dev kernel changes.
6+
7+
-- David Lechner <[email protected]> Mon, 25 Jul 2016 21:13:43 -0500
8+
19
python-ev3dev (0.6.0) stable; urgency=medium
210

311
[Ralph Hempel]

debian/control

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ Maintainer: Ralph Hempel <[email protected]>
33
Section: python
44
Priority: optional
55
Standards-Version: 3.9.5
6-
Build-Depends: python-setuptools (>= 0.6b3), python-all (>= 2.6.6-3), debhelper (>= 9), dh-python
6+
Build-Depends: python3-setuptools (>= 0.6b3), python3-all (>= 3.4), debhelper (>= 9), dh-python
77
VCS-Git: git://github.com/rhempel/ev3dev-lang-python.git
88
VCS-Browser: https://github.com/rhempel/ev3dev-lang-python
99

10-
Package: python-ev3dev
10+
Package: python3-ev3dev
1111
Architecture: all
12-
Depends: ${misc:Depends}, ${python:Depends}
12+
Depends: ${misc:Depends}, ${python3:Depends}
1313
Description: Python language bindings for ev3dev
1414
This package is a pure Python binding to the peripheral
1515
devices on hardware that is supported by ev3dev.org - a

debian/copyright

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Files: debian/*
22
License: MIT
3-
Copyright: 2015 Ralph Hempel <[email protected]>
3+
Copyright: 2016 Ralph Hempel <[email protected]>
44

55
Files: *
66
License: MIT
7-
Copyright: 2015 Ralph Hempel <[email protected]>
7+
Copyright: 2016 Ralph Hempel <[email protected]>
88
Copyright: 2015 Denis Demidov <[email protected]>
99
Copyright: 2015 Eric Pascual <[email protected]>
1010
Copyright: 2015 Anton Vanhoucke <[email protected]>

debian/rules

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
#!/usr/bin/make -f
22

3-
export PYBUILD_NAME=python-ev3dev
3+
export PYBUILD_NAME=python3-ev3dev
44

5-
VERSION=$(shell dpkg-parsechangelog | sed -rne 's,^Version: (.*),\1,p')
5+
VERSION=$(shell dpkg-parsechangelog | sed -rne 's,^Version: (.*),\1,p' | sed 's,~,,')
66

77
%:
8-
dh $@ --with python2 --buildsystem=pybuild
8+
dh $@ --with python3 --buildsystem=pybuild
99

1010
override_dh_auto_configure:
11-
echo VERSION > RELEASE-VERSION
11+
echo $(VERSION) > RELEASE-VERSION
1212
dh_auto_configure
1313

1414
override_dh_auto_clean:
15-
echo VERSION > RELEASE-VERSION
15+
echo $(VERSION) > RELEASE-VERSION
1616
dh_auto_clean
1717
rm -f RELEASE-VERSION

ev3dev-lang

ev3dev/GyroBalancer.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# The MIT License (MIT)
33
#
44
# Copyright (c) 2016 Laurens Valk ([email protected])
@@ -294,8 +294,8 @@ def shutdown():
294294
## Calibrate Gyro
295295
##
296296
########################################################################
297-
print "-----------------------------------"
298-
print "Calibrating..."
297+
print("-----------------------------------")
298+
print("Calibrating...")
299299

300300
#As you hold the robot still, determine the average sensor value of 100 samples
301301
gyroRateCalibrateCount = 100
@@ -305,10 +305,10 @@ def shutdown():
305305
gyroOffset = gyroOffset/gyroRateCalibrateCount
306306

307307
# Print the result
308-
print "GyroOffset: %s" % gyroOffset
309-
print "-----------------------------------"
310-
print "GO!"
311-
print "-----------------------------------"
308+
print("GyroOffset: %s" % gyroOffset)
309+
print("-----------------------------------")
310+
print("GO!")
311+
print("-----------------------------------")
312312

313313
########################################################################
314314
##

ev3dev/auto.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
# -----------------------------------------------------------------------------
44
# Guess platform we are running on
5+
56
def current_platform():
67
machine = platform.machine()
78
if machine == 'armv5tejl':
@@ -11,6 +12,8 @@ def current_platform():
1112
else:
1213
return 'unsupported'
1314

15+
# -----------------------------------------------------------------------------
16+
1417
if current_platform() == 'brickpi':
1518
from .brickpi import *
1619
else:

0 commit comments

Comments
 (0)