Skip to content

Remove deprecated pkg_resources fallback from resource loading - #166

Open
bjornrun wants to merge 1 commit into
iamaisim:mainfrom
bjornrun:fix/python314-pkg-resources
Open

Remove deprecated pkg_resources fallback from resource loading#166
bjornrun wants to merge 1 commit into
iamaisim:mainfrom
bjornrun:fix/python314-pkg-resources

Conversation

@bjornrun

@bjornrun bjornrun commented Jun 30, 2026

Copy link
Copy Markdown

Summary

  • remove the deprecated pkg_resources fallback in projectairsim.utils.load_text_resource
  • always use importlib.resources.files(), with the maintained importlib-resources backport on Python <3.9
  • join nested resource paths with joinpath(*resource_path.split("/"))

Motivation

This is a maintenance and compatibility change. Current main already prefers importlib.resources.files() on Python >=3.9, so the pkg_resources branch is not normally reached on Python 3.14. Removing it still drops a deprecated runtime dependency on setuptools/pkg_resources and keeps schema loading working on environments that no longer ship pkg_resources by default.

Verification

  • python3 -m compileall -q client/python/projectairsim/src/projectairsim/utils.py
  • isolated Python 3.14 resource-load check for schema/robot_config_schema.jsonc, confirming pkg_resources is not imported
  • git diff --check -- client/python/projectairsim/src/projectairsim/utils.py client/python/projectairsim/pyproject.toml

Full package import was not run because this local Python 3.14 environment does not have the package runtime dependencies installed (msgpack fails first).

@aurebidart

Copy link
Copy Markdown
Contributor

Thanks for contributing this improvement! Could you please share a little more information about the error you encountered, such as the full traceback, Python and Setuptools versions, and how ProjectAirSim was installed?
We ask because, on Python 3.9 and newer, the current implementation should already use importlib.resources.files(), so the pkg_resources fallback would not normally be reached on Python 3.14. We were also unable to reproduce the reported failure in that version.
That said, the proposed change is still valuable because it removes the deprecated pkg_resources dependency and improves compatibility across supported environments. If the original Python 3.14 issue cannot be reproduced, perhaps we could present the PR as a maintenance and compatibility improvement, updating the title and description to reflect that motivation.
Thanks again for taking the time to identify and address this area!

@bjornrun bjornrun changed the title Fix Python 3.14 package resource loading Remove deprecated pkg_resources fallback from resource loading Aug 13, 2026
@bjornrun

Copy link
Copy Markdown
Author

Thanks for taking a look — your reading is correct.

I cannot reproduce a Python 3.14 failure of the current load_text_resource() path, and I do not have a ProjectAirSim traceback that shows that function reaching the pkg_resources fallback on 3.14. On the same interpreter I used when I opened this PR:

  • CPython 3.14.6 (/opt/homebrew/opt/python@3.14/bin/python3.14, Clang 21.0.0)
  • hasattr(importlib.resources, "files") is True, so current main already takes the files() branch
  • ProjectAirSim was a local git checkout, not an installed wheel
  • setuptools is not installed, so import pkg_resources fails immediately with ModuleNotFoundError: No module named 'pkg_resources'

That missing-module error is what prompted the change. I agree it is not evidence that the 3.9+ files() path is broken on 3.14.

The remaining reason for the patch is the one you described: drop the deprecated pkg_resources fallback entirely, keep schema loading on importlib.resources.files(), and use importlib-resources only for the declared Python <3.9 range. I have updated the title and description to present this as a maintenance/compatibility cleanup rather than a 3.14 bugfix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants