Skip to content

Question: Supported python versions #26

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

Closed
NicolaDonelli opened this issue Jan 2, 2023 · 3 comments · Fixed by #27
Closed

Question: Supported python versions #26

NicolaDonelli opened this issue Jan 2, 2023 · 3 comments · Fixed by #27
Assignees
Labels
question Further information is requested

Comments

@NicolaDonelli
Copy link
Contributor

NicolaDonelli commented Jan 2, 2023

What are the supported python versions for this package?

In the pyproject.toml file I found a reference to python 3.8 in the [tool.poetry.dependencies] section but I tried to use licensecheck in a pacakge of mine supporting python>=3.8 and it seems that there are issues at least with python 3.8 (while with python 3.9 and 3.10 everything seems to work fine)

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.8.15/x64/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/hostedtoolcache/Python/3.8.15/x64/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/opt/hostedtoolcache/Python/3.8.15/x64/lib/python3.8/site-packages/licensecheck/__main__.py", line 6, in <module>
    cli()
  File "/opt/hostedtoolcache/Python/3.8.15/x64/lib/python3.8/site-packages/licensecheck/__init__.py", line [90](https://github.com/NicolaDonelli/py4ai-core/actions/runs/3824810054/jobs/6507268900#step:4:91), in cli
    depsWithLicenses = get_deps.getDepsWithLicenses(
  File "/opt/hostedtoolcache/Python/3.8.15/x64/lib/python3.8/site-packages/licensecheck/get_deps.py", line 116, in getDepsWithLicenses
    packages = packageinfo.getPackages(reqs)
  File "/opt/hostedtoolcache/Python/3.8.15/x64/lib/python3.8/site-packages/licensecheck/packageinfo.py", line 109, in getPackages
    packageinfo.add(getPackageInfoLocal(requirement))
  File "/opt/hostedtoolcache/Python/3.8.15/x64/lib/python3.8/site-packages/licensecheck/packageinfo.py", line 36, in getPackageInfoLocal
    packagePath = resources.files(requirement)
AttributeError: module 'importlib.resources' has no attribute 'files'
@NicolaDonelli NicolaDonelli added the question Further information is requested label Jan 2, 2023
@FredHappyface
Copy link
Member

Hey thanks for opening the issue.

To answer your question in short python3.8 is supported (currently) so that is a bug

The longer answer is that code I write is typically for the newest released version of python or sometimes a version prior depending on when tests are run. Currently I haven't found a good solution to testing on multiple versions of python. Currently I use poetry run pytest which will take whatever version of python poetry is installed under which is 3.10 (I think, I'll likely do the update to 3.11 dance when I have the bandwidth). Tox looks promising though requires each version on my host so I may look to use docker or something similar. Though again this is when I get the time

Thanks

@NicolaDonelli
Copy link
Contributor Author

Oh, well... to test with multiple python versions I usually use Docker (locally) and Github Actions (remotely).
If you could be interested in that solutions please let me know, so that I could open a PR implementing my usual solution.

@FredHappyface
Copy link
Member

Had a think on this and after spending far too long trying to get docker working with Windows, I've decided to use tox natively...

Testing

For testing with the version of python used by poetry use

poetry run pytest

Alternatively use tox to run tests over python 3.8 - 3.11

tox

pyproject.toml

...
[tool.tox]
legacy_tox_ini = """
[tox]
env_list =
	py311
	py310
	py39
	py38

[testenv]
deps = pytest
commands = pytest tests
"""

Frustratingly my testing suite would have missed this particular instance as the error is thrown on invocation and I didn't have a clear idea on how to test the getPackageInfoLocal function. This will be updated next commit :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants