-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
circuitpython_setboard command python version support #9363
Comments
Do you understand which part of the code is dependent on 3.10? importlib.resources.files is listed as being in 3.9 however I found at least one other project having trouble with importlib.resources.files in 3.9, without much explanation: jupyter/notebook#7016 |
I don't necessarily understand the reason behind the issue, everything underneath our code in the stack trace is a bit cryptic to me. Something is resolving to None, but it's unclear to me what specific thing is actually None. I searched around for a bit with different parts of the stack trace and was able to find references to the same or similar issues, but nothing really stood out as a cause or way to change the code to make it work. The crux of it is that
On 3.9 this statement raises the exception with stacktrace above. On 3.10 it returns an object containing the path to the On py3.10 it returns:
That path is used afterward in order to copy the board file specified by the user into If we can find a different way to programmatically get the path of site-packages it could be used instead of resources.files() in order to work around this problem. |
OK, here's the reason. Because it does not contain a init.py, pip-installable "importlib-resources" supports namespace packages https://github.com/python/importlib_resources so it could be used as a substitute across any supported python version. I don't know if simply adding With Python 3.9.16 (main, Jun 23 2024, 09:40:19)
[GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from importlib.resources import files
>>> files("t1")
PosixPath('/tmp/t1')
>>> files("t2")
...
TypeError: expected str, bytes or os.PathLike object, not NoneType |
Ahhh I see, thank you for tracking that down and sharing the cause. I refactored it to use Knowing the real cause now though, I do think adding I will test that locally in a little bit and close that PR and make a new one. |
I think it depends on what versions of python you want to support. |
@justmobilize I don't think we intent to support anything lower than 3.9. Although it seems the issue isn't whether resources.files exists at all, but rather whether it supports those "namespace packages" which changed between 3.9 and 3.10 it seems. |
I tested that by manually adding a However it may be a little tricky to create that file inside of board-stubs "for real", I just manually created with |
@FoamyGuy it might be worth adding a version check at the very top of the file (before specific imports), giving a clean error if they are on anything less than 3.9 Or specifying the minimum version so it can't be installed on 3.8 or below I'm always seeing users with random versions |
Makes sense to me, I added an explicit check version in the new PR. This one also uses |
Awesome! |
the
circuitpython_setboard
command currently supports python 3.10+ only due to a change between py3.9 and py3.10.Here is an example of the traceback that results from trying a version below 3.10:
We could improve the situation with one these:
The text was updated successfully, but these errors were encountered: