Feature #495
PYTHON
Status: | In Progress | Start date: | 02/03/2013 | |
---|---|---|---|---|
Priority: | Normal | Due date: | ||
Assignee: | - | % Done: | 0% |
|
Category: | - | |||
Target version: | - | |||
Chirp Version: | 0.4.0 | Model affected: | (All models) |
Description
Any plans to upgrade to Python 3.3?
Software is great, local ham club has nothing but good things to say about Chirp.
thanks,
David
Related issues
Associated revisions
[py3] Changes to bitwise and friends for py3 compatibility
Much of this came from 2to3, but all the unicode/str/bytes changes were
hand-done. Unit tests pass for bitwise.
[py3] Make setup.py compatible and start a new py3 tox environment
Right now, this runs just the bitwise tests which are the only ones that
work on py3.
[py3] Changes to make test_chirp_common (and deps) work on py3
This is enough to be able to use pytest too, so convert to that.
[py3] Fix up py2 related issues introduced into bitwise and memmap
The previous patch broke bitwise and memmap for py2, undetected because of a test
environment snafu.
[py3] Make platform module and tests py3 compatible
[py3] Add two more test modules that are already py3 compatible
[py3] Make settings module compatible and add its tests
[py3] Changes to many ui modules to make test_memedit_edits work
[py3] Changes to make test_directory compatible
[py3] Add pytest cache directory to hgignore
[py3] Changes to make test_shiftdialog compatible
This marks the point at which all the tests/unit tests pass in py3
[py3] Some minimal driver 2to3 conversions for things imported directly in the ui
[py3] chirp/detect and chirp/logger 2to3 conversion
[py3] ui/editorset and ui/importdialog 2to3 and removal of generic_xml
Not going to port generic_xml to py3, so just remove it where used
[py3] Fix another unicode issue in directory and prevent drivers from crashing us
If a driver raises during detection, we should not kill the whole process.
[py3] Fixes to generic_csv and icf relating to the detection process
[py3] Changes to ui so that we can actually start under py3/gi
This adds a chirp.ui.compat module where we can pile things needed to
handle python3 differently. Right now there are a bunch of things that just fail
for reasons I don't fully grasp yet. Those go under a py3safe() decorator,
which logs and then ignores them.
Also, there is an issue with the sensitive=True bit on the columns for empty
memories. Need to figure that out.
[py3] Remove a big debug print from a previous patch
[py3] 2to3 run_tests.py and re-enable importing it in the unittest adapter
Also add pyserial to requirements because this is the first time we have
hit that import.
[py3] More bitwise changes to be compatible with py2 and py3
With this, the py2 driver tests run successfully, and the bitwise unit tests
run on py3.
[py3] Re-re-do of the charDataElement in bitwise
So, I've been a little bit on unicode autopilot, just trying to get the
data types to match up. However, once getting into the work of making
the drivers work, we have a ton that do things like this:
memobj.name = 'foobar\xFF'
because the radio needs the \xFF terminating byte to know where the end
of the string is. We need to not encode/decode that even on py3 because
we won't end up with the right value in memory if we do (and we'll fail
to encode/decode some values).
So, this cheats our unicodeness to end up with single-byte characters and
the right things get into/out of memory for now. Ideally all drivers would
be converted to bytestrings for things like that, but, babysteps.
Yes, I know how unicode works in Python, and yes I know this is not how
it's supposed to work.
[py3] More bitwise fixes for array operations and set_raw()
Found while converting real drivers.
[py3] Another obligatory float->int conversion for an index
[py3] A workaround for match_model legacy, and test harness updates
This is enough to run the driver tests in py3 to actually start hitting issues.
The filestring hack in directory just lets us get to some of them without
having to convert match_model on all of them. Same deal with skipping drivers
that don't load if CHIRP_DEBUG is set.
[py3] Fix generic_csv writing to file
We need to open the file non-binary so we can write strings to it.
[py3] Another icf detection fix - unicode errors mean no
[py3] Fix writing config
[py3] Fix bankedit store - the new gtk does not like type mismatches
[py3] Graceful fail on set_url_hook for about dialog
[py3] Fix up a bunch of gtk3 issues
- Removed the authors on the about box as neither the gtk2 compat or gtk3
APIs seem to work. No offense to the other contributors, we can add it
back when we figure it out.
- Fix the get_cell_renderers() missing stuff in memedit and miscwidgets
- Quiet some of the py3safe() warnings which are known and not critical
[py3] Fix memedit cut/copy/paste for GTK3
[py3] Fix up miscwidget.make_choice() and clone dialog
[py3]: Fix run_tests.py:
- Import hack to work from a variety of places. This is really ugly,
but these are going away once the driver files can at least be imported.
- Something in the 2to3ing earlier broke the settings tests. Had to add
len and getitem to RadioSettingValueString, which caused an infinite
loop in the test's compare_settings. I dunno what I was thinking with
the latter, but it seems like a infinite loop waiting to happen and
it's hard to see through the blur how that ever worked.
[py3] Make hexprint work in py3 and add a test
[py3] Add a CompatSerial which will converse in strings
Gate this on the driver having a flag that indicates it needs this help.
[py3] Make the straight string encoders both work on sequences
[py3] 2to3 for chirpc and quick import * hack
Also fixed float division in the chirp_common.Status so that chirpc will work
[py3] Add a str-compatible MemoryMap implementation
I really hate to do this, but the more I dig into making a driver actually
work, I think this needs to be the default. I retained the bytes-clean
version as a base, and we can/should make new drivers use it, as well as
convert drivers to use it in this process. Bitwise still uses it under the
covers, so this is really just a usability shim to buy us some more time.
[py3] Add a string-compatible version of the struct module
With this, even struct.pack,unpack work on our strings.
[py3] Make icf work with python3
Just importing our modified struct module lets me run chirpw in python3,
upload and download from an id800.
[py3] Fix some issues introduced by recent bitwise/memmap comap changes
- Make bitwise arrayDataElement getitem support integer-ifying slices too
- Support setting a single value in memmap to an integer as apparently a lot
of places depend on that working.
- Don't initialize a MemoryMap (which is string-based) with bytes
Update from default branch
[py3] bitwise.py: Python 3-ize
[py3] chirp_common.py: Fix file saving
[py3] uvb5.py: 2to3 with manual fixes
[py3] uvb5.py: Adapt for new Serial
[py3] memmap.py: Fix slicing
[py3] memedit.py: Convert power to str
Fix some style and unittest regressions in recent patches
[py3] Fix bitwise structDataElement indexing with float
[py3] Add some tests for the bitwise integer division operators
[py3] Make bitwise get_raw() methods take asbytes=bool
This will enable modern drivers to get bytes instead of string
[py3] Split py3 tox environment into py3unit and py3driver
[py3] A bunch of fixes to drivers that already import/run under py3
With this, all driver tests pass on py3 and py2, but note that most
of the drivers are still not even importing.
[py3] th350.py: 2to3, with many manual fixes
[py3] bitwise.py: Always return a bytes-compatible object when asbytes=True
This commit ensures that drivers that ask for bytes representations will always
get bytes or a bytes-compatible object, whether on Python 2 or 3.
python-future provides a mostly-complete implementation of bytes for Python 2.
[py3] Generalize the safe import routine
[py3] Include requirements.txt and tests in sdist build
This will help make it easier to build and run tests on py2
[py3] Fix broken win32 platform 2to3 conversion
The 2to3 of platform.py converted a unicode() to a str(), which made us
no longer compatible on win32 with py2.
[py3] Fix safe_import_drivers() for win32
The glob'ing doesn't work on win32, especially in the frozen build, so
just do the old thing if we are on win32.
[py3] Include future in the py2 test environment
[py3] Make memmap use future bytes
[py3] Clean up hexprint to not choke on bytes, newbytes, or string
[py3] Add an icom clone simulator (for non-raw mode) and test
This tests regular icom radios for byte-clean cloning and includes the
necessry changes to icf.py to make it work.
Tested on an ID800 and ID880
This doesn't address the live-mode radios, which still function under py2
properly. I don't have an IC-2730 to test with, but wrote unit tests for
the frame encoding routines, so hopefully that works as well.
[py3] Fix memedit regression in aa4dd87eb5d0 for non-power radios
If a radio doesn't set mem.power, we would str(None) into the liststore, which
caused us to fail to detect it being unset when trying to edit a memory.
[py3] Fix memedit context menu to be gtk2/3 compatible
[py3] Fix up the properties dialog in memedit for gtk3
[py3] Fix initializing memory range SpinButton on gtk3
[py3] Put a py3clean environment in the list before the py3 jobs
This helps prevent python3 from stumbling over py2 cache files
[py3] Fix making empty memories not sensitive on gtk3
We can do this in the render function (probably always should have), which
works on both.
[py3] Fix settings editor for gtk3
[py3] Minor 2to3 and struct wrapper conversion for uv5r driver
This makes the uv5r driver clone operations work under py3, but with the
compatibility layers in place.
[py3] Convert uv5r driver to byte clean on py3
[py3] Fix editing empty memories on gtk3
In order to go from empty/sensitive=False to editing in gtk3 we have to do a little
more work.
[py3] Make _init_macos() work for pygobject and gtk-mac-integration 2.1.3
[py3] Fix icom cloning when a MemoryMap (not bytes) was handed to us
[py3] 2to3 for id31 driver, related fixes for id51 and id51plus
The id31 driver required minor tweaks to be py3 compatible, which brought
the id51 and id51plus modules online. Tested with a real id31, which is
probably good enough for the id51s as well.
[py3] Make kenwood_live radios use native serial
All the kenwood_live drivers speak ASCII to the radio using the exact same
low-level routine. They don't do any binary mapping or manipulation. Thus,
we really only need to do the usual unicode handling, and in one place. With
this change, all kenwood live radios should be good and not need independent
testing. Verified with a real TM-D700.
[py3] Make the StringStruct wrapper encode/decode string arguments
This is needed for further compatibility
[py3] Straight 2to3, plus StringStruct conversion of h777 and friends
Tested with a real Arcshell AR-6 (BF-888S)
[py3] Fix integer divison in from_NHz() helpers
NOTE: These appear to be unused, except for one use of from_GHz() in the
icq7 driver. AFAICT, these have always been wrong in the tree, so this
just converts the division and adds (wrong) tests to validate the division
change, but they should be fixed (along with the icq7 driver).
[py3] Make the clone test on py3 check that serial.write() passes proper data type
If a radio claims NEEDS_COMPAT_SERIAL=False, make sure it is writing with bytes and
not a string (and vice versa). This is not perfect because these are just clone
error tests, and all of the clone routine for a driver isn't going to get hit here.
But, it's something.
[py3] 2to3 of ft817 and ft857
Tested with a real FT-817. Expect 857 and 897 to be fine as they share so
much in common.
[py3] Fix test_icom_clone finding the icom images
When I moved this into tests/unit I didn't realize it was not able to find the
images directory, and thus not doing anything. Make it smarter to be based
on the location of the test file itself.
[py3] Finally, unified test running across all environments and pythons
pytest doesn't support the loadTests() discovery protocol, which means it would
not ever find the driver test adapter in tests/__init__.py. So, this adds another
adapter just for pytest (et al) which will trigger the test loader and make it
find them.
Now, with all environments and python versions, you get nicer pytest output,
and can use expressions to run subsets of tests, like:
tox -epy3driver 880.*clone
[py3] Fix up style issues introduced by 2to3 in ft8x7
[py3] Initialize the test radio once per unittest.TestCase instance
Also, don't parse a mmap file just to get_sub_devices(). Makes the tests run
like 50% faster on my system.
Change the browser widget to use an HPaned instead of HBox
This means the tree panel can be resized, and is necessary for GTK3 to look and
behave sanely.
Related to work for #495
[py3] Fix a couple style issues introduced in recent ic208 patch
[py3] Make the exception dialog parented to the main window
This is probably applicable to the main branch, but for some reason it's really
broken in gtk3 without it.
[py3] Make YaesuChecksum operate on bytes
[py3] Use bytes() instead of byte literal when constructing test mmap
[py3] Make ft817 byte-clean
Tested with a real FT-817, expect ft857 and ft897 to be okay since they share so much.
[py3] Fix up python3 related failures found by the new delete memory test
[py3] 2to3 conversion of vx2
Not tested with a real radio, but it passes tests and uses the yaesu_clone module
for cloning, so it is likely okay.
[py3] Fix generic_tpe import of UserDict for python3
Untested as we have no sample files, but since this depends almost entirely
on the generic_csv driver (which works), it should be okay.
[py3] Remove generic_xml driver
This never really caught on, nor got the attention or maintenance it really needed.
I dunno if it even works in py2 for much anymore, but I don't think converting it
to py3 makes any sense.
Fix Edges::do_oddsteps() test
This test was completely wrong, and not really running for any driver. Realized it was
doing something stupid while trying to run it against the CSV driver (which supports
DC->daylight).
Some radios were claiming to support steps they don't support because they were taking
the full list in chirp_common as a default, which is clearly wrong. This patch changes
the default to a very conservative set, which may cause some drivers to no longer accept
some frequencies that may be valid because they were not declaring their real supported
list.
This also uncovered at least one buggy driver that can't support anything other than
5kHz step frequencies (ic2730).
Found in the pursuit of #495
[py3] Make RadioSettingGroup sortable in python3
This is a fix for some error handling in the tests that assumes it can
sort these objects.
[py3] Fix ict7h driver regression from 2to3 conversion
This fixes the ict7h driver for 12.5kHz step frequencies, uncovered by the
recent fix to the oddsteps test.
[py3] Enable testing the CSV and HMK drivers
This fixes some test infrastructure so we can run the tests on these, as well as
makes the two drivers work properly in py3. I guess we were never running the
tests against things like this, even though we should be.
Fix up the miscwidgets.make_choice() for non-editable combo boxes on gtk3
This was never finished before, and required a little more monkeywork to get
things working. This also fixes up the RepeaterBook prompting to work with
the new mechanism.
[py3] Fix headless logger init on python3 because of file() usage
[py3] Make directory safe import defensive on win32 too
Fix load_mmap() to provide the right memmap class based on the compat flag
[py3] Fix icom simulator and 2730 driver after default and py3 merge
The 2730 had a py3 syntax error and the icom clone simulator was not
handling the W32E's off-by-one hack.
Related to #495
Merge with default
Set row label to mem.number to account for zero-origin radios
Related to #495
[py3] Auto resize grid columns larger when required after editing
[py3] Fix memory properties editor
[py3] Implement editing multiple memories via properties at once
[py3] Implement developer-mode radio browser
Add a decorator/contextmanager that wraps a dangerous operation with an error message
Add cross tone modes and rx_dtcs to the memory editor.
Center the MemoryDialog and do not reload the browser once loaded.
Add missing power level to memedit
Also fix off-by-one errors when loading raw memories from 1-origin radios
Allow limiting driver loading for speed during development
This lets you only load the driver you are working on when running from
the command line, which speeds up startup quite a bit (especially if
working on a network share).
Add Radio->Developer functions
This adds two things for developers to the Radio menu:
1. A "reload driver" option, which reloads the current driver module in-place,
and attempt to hot-swap the current UI's editorset with a new copy of the driver
with the old driver's memory loaded.
2. An "interact" option which drops the terminal to an interactive console where
you can poke at the driver and UI application manually.
[py3] More wrestling with the memory properties dialog and non-string choices
[py3] Make the driver reload avoid closing the editorset early
This helps avoid losing the current state if the driver fails to load.
[py3] Fix use of deprecated Menu::AppendItem to avoid warnings
[py3] Add --inspect argument to chirpwx for wxPython debugging
[py3] Fix second+ editors from being shown when selected on macos
For some reason intercepting the EDITOR_CHANGED event was causing the default
behavior of showing the editor pane to not happen on macos (only). Using the
EDITOR_CHANGING for our selected() purposes instead works around it.
Make memedit filter memory names according to the radio rules
[py3] Make the memory editor use fixed-width fonts, like it should
[py3] Add another option to reload the driver and the currently-open file
Makes developing against another piece of software much easier.
[py3] Make the radio browser pop open the first level by default
[py3] Display type and offset information as a tooltip in browser
[py3] Center the clone upload/download boxes by default
These don't center by default on macos for some reason, but do elsewhere.
[py3] Make the browser support edits, validation and fixed-width fonts
[py3] Re-select the last editor when reloading the radio.
History
Updated by Dan Smith about 8 years ago
- Status changed from New to Rejected
PyGTK is not supported on Python 3.x, and is a core requirement for CHIRP. There are a lot of applications that fit into this category with similar requirements, and as a result, python 2.x isn't going anywhere any time soon.
Closing as rejected since this is not a bug.
Thanks!
Updated by Richard Shaw over 2 years ago
5 years later this is no longer the case. Fedora is actively working on transitioning to Python 3 to stay ahead of the 2020 EOL for Python 2.
Updated by Dan Smith about 2 years ago
- Status changed from Rejected to In Progress
- Chirp Version changed from 0.2.3 to 0.4.0
Work in progress in the "py3" branch
Updated by Richard Shaw over 1 year ago
Just an FYI but chirp will likely be removed from Fedora as of F32 (currently working towards beta freeze) due to python 2 removal.