Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 2, 2025

pkg_resources is deprecated and slated for removal by 2025-11-30. This causes warnings throughout the codebase.

Changes

Removed unused import:

  • activitysim/cli/create.py - file already used importlib.resources

Replaced resource path resolution in 13 test files:

# Before
import pkg_resources
path = pkg_resources.resource_filename("activitysim", resource)

# After
import importlib.resources
path = str(importlib.resources.files("activitysim").joinpath(resource))

Files Modified

  • activitysim/cli/create.py
  • activitysim/abm/test/test_pipeline/test_pipeline.py
  • activitysim/abm/test/test_misc/{setup_utils.py,test_load_cached_accessibility.py}
  • activitysim/examples/*/test/*.py (9 test files)
  • activitysim/examples/prototype_mtc_extended/sampling_scenarios.py
  • test/random_seed/test_random_seed.py

Uses standard library importlib.resources (Python 3.9+), compatible with project minimum requirement of Python 3.10+.

Original prompt

This section details on the original issue you should resolve

<issue_title>Remove deprecated pkg_resources</issue_title>
<issue_description>Running ActivitySim currently warns:

UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.

This package is imported in activitysim/cli/create.py, and in several tests. ActivitySim needs to be refactored to not use this deprecated package, in favor of importlib.resources, importlib.metadata and their backports (importlib_resources, importlib_metadata). </issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Remove deprecated pkg_resources from ActivitySim Replace deprecated pkg_resources with importlib.resources Nov 2, 2025
Copilot AI requested a review from jpn-- November 2, 2025 22:16
@jpn-- jpn-- marked this pull request as ready for review November 3, 2025 03:15
@jpn-- jpn-- merged commit 009d64a into main Nov 3, 2025
39 checks passed
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.

Remove deprecated pkg_resources

2 participants