-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python 3.9 fixups #332
base: master
Are you sure you want to change the base?
Python 3.9 fixups #332
Conversation
I get the following exception on start: $ python3 chirpwx.py Traceback (most recent call last): File "/home/asheplyakov/work/radio/chirp/chirpwx.py", line 8, in <module> sys.exit(chirpmain()) File "/home/asheplyakov/work/radio/chirp/chirp/wxui/__init__.py", line 41, in chirpmain from chirp.wxui import main File "/home/asheplyakov/work/radio/chirp/chirp/wxui/main.py", line 28, in <module> import importlib_resources ModuleNotFoundError: No module named 'importlib_resources' $ python3 --version Python 3.9.6 However importlib is available in Python 3.9 (as a part of the standard library). To avoid the problem this patch removes the version check, and checks for importlib_resources/importlib.resources modules instead.
I get the following error on startup: $ python3 chirpwx.py Traceback (most recent call last): File "/home/asheplyakov/work/radio/chirp/chirpwx.py", line 8, in <module> sys.exit(chirpmain()) File "/home/asheplyakov/work/radio/chirp/chirp/wxui/__init__.py", line 94, in chirpmain mainwindow = main.ChirpMain(None, title='CHIRP') File "/home/asheplyakov/work/radio/chirp/chirp/wxui/main.py", line 307, in __init__ self.set_icon() File "/home/asheplyakov/work/radio/chirp/chirp/wxui/main.py", line 342, in set_icon importlib_resources.files('chirp.share') File "/usr/lib64/python3.9/importlib/resources.py", line 147, in files return _common.from_package(_get_package(package)) File "/usr/lib64/python3.9/importlib/_common.py", line 14, in from_package return fallback_resources(package.__spec__) File "/usr/lib64/python3.9/importlib/_common.py", line 18, in fallback_resources package_directory = pathlib.Path(spec.origin).parent File "/usr/lib64/python3.9/pathlib.py", line 1072, in __new__ self = cls._from_parts(args, init=False) File "/usr/lib64/python3.9/pathlib.py", line 697, in _from_parts drv, root, parts = self._parse_args(args) File "/usr/lib64/python3.9/pathlib.py", line 681, in _parse_args a = os.fspath(a) TypeError: expected str, bytes or os.PathLike object, not NoneType The problem is that 'chirp.share' is not a proper python package, therefore importlib fails to locate its resources. To avoid the problem this patch adds empty __init__.py files to chirp/share and chirp/stock_configs directories. As a side effect setup.py installs (the content of) these directories (which makes packagers more happy).
b2638aa
to
21a74cd
Compare
> You need to install the packages in requirements.txt to get the importlib-resources compatibility package.
I've tried that (via pip install -r requirements.txt), the application failed to start anyway.
I haven't bothered to find out the exact cause, instead I tweaked imports to use the importlib.resources from the stdlib, and it worked for me.
Also setup.py skips chirp/share and chirp/stock_configs directories (they are not python packages), as a result the application can't find icon and fails to start.
…> The macos build is already using python 3.8 and it works fine that way.
|
They're good enough for the bundler to pick up - I didn't really think they had to be proper python packages to be considered resources, but I dunno. Maybe @vishwin has some context here, but I can poke with python3.9 a little later. I thought that the thing we specifically needed was only in 3.10... |
The new-style API was introduced in Python 3.10, and to simplify maintenance (especially when Python 3.11 formally marked the old-style but imo more concise API deprecated), the package is used for Python < 3.10. |
As for package detection itself, setuptools does (or at least did) consider |
@asheplyakov Is it possible that just the |
On a clean python 3.9 docker image, So, I'm not sure what the problem is, but I don't think it's specific to 3.9. |
Installing via You should see an error message like the following when you invoke setup.py directly:
Sorry for interjecting... |
That's not an error, but a warning. And yes PEP-517 compliance is next on the list. Until then, setuptools can theoretically be pinned to 58, which is the last version with full setup.py support. |
On second look, both of these commits are wrong. The |
Yep, this is exactly what I meant when I said "I thought that the thing we specifically needed was only in 3.10...". Further confirmed, I think, by the fact that it works fine for me in 3.9. |
Yes. But it skips share and stock_configs (unless there is the
This one successfully builds a wheel and dist-info. |
If that was the case, I would not have had implemented this the way it is.
Any chance you have some outdated components in your chain by virtue of using RPMs provided by your operating system's repositories? |
Apparently it didn't work as intended.
Which components should I check, and what are the correct versions? (the only versioned dependency in requirements.txt is |
As noted, it does for me, on python 3.8, 3.9, and 3.10. |
I am trying to run chirp on Python3 to help test the drivers, but seems the installer doesnt work and is looking for python package Any pointers on getting this running on Python 3.8 ? |
It would help to know what system you're running, but it works fine on python 3.8 without anything specific. See this page: https://chirp.danplanet.com/projects/chirp/wiki/DevelopersPython3Environment Probably best to discuss further on the devel mailing list, separate from this PR. |
Ah - good point. sorry. I am running Ubuntu 20.04 |
Seems there is no branch
|
Because |
After a very lengthy build process, I was able to get CHIRP and all of it's dependencies installed on a fresh Ubuntu 20.04 VM using the commands below. (It is probably not necessary to run pip as root and you'll see a message discouraging it.)
|
Guys, on linux, don't install wxpython from pip - it builds the entire thing for no reason. Follow the instructions on the build page, install the distro package and then do the pip stuff. Should be two seconds. |
Ah, I knew there should be a faster way. Thanks for the tip Dan. And now I understand why From https://chirp.danplanet.com/projects/chirp/wiki/DevelopersPython3Environment:
then
Another confirm that the current tip of master installs (and runs) on Ubuntu 20.04 with python 3.8. |
As of now CHIRP fails to start with Python 3.9:
importlib_resources
module (althoughimportlib
is available as a part of the standard library)chirp.share
is not a proper python package)With this patchset I can use CHIRP with Python 3.9.