Skip to content

collect_info.py does not start: pkg_resources is gone from setuptools 82 #2354

Open

Description

🐛 Bug Description

scripts/collect_info.py aborts on its first import. This is the script the
bug report template points users to for their environment details.

Two causes, one behind the other, both in the same file:

cause effect
1 import pkg_resources at module level ModuleNotFoundError, the script never starts
2 REQUIRED lists wheel and cython DistributionNotFound, the script dies part way through its output

The second one only becomes visible once the first is fixed. wheel and
cython sit in build-system.requires, not in dependencies, so a plain
pip install pyqlib does not have them.

To Reproduce

  1. Install qlib in an environment with setuptools 82 or newer. Since Python
    3.12 python -m venv no longer seeds setuptools at all, so pkg_resources
    can be missing regardless of any version boundary.
  2. cd scripts && python collect_info.py all
  3. Output:
Traceback (most recent call last):
  File "scripts/collect_info.py", line 5, in <module>
    import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'

Measured boundary, one throwaway venv per version, nothing else changed:

setuptools ships pkg_resources
80.9.0 yes
81.0.0 yes, with a deprecation warning
82.0.0 no

Expected Behavior

collect_info.py all prints the system, Python and package details and exits
with 0, including when a package from its list is not installed.

Environment

Collected by hand, since the script itself does not run:

  • Qlib version: 0.9.8.dev34 (editable install)
  • Python version: 3.12.13
  • OS: MacOS 26.6.2, arm64
  • Commit number: be72549
  • setuptools 84.0.0

Additional Notes

#1947 covers the same line, but from June 2025, when it was still a
UserWarning with a different traceback behind it. Today the script does not
start at all.

Activity

  1. rytjy commented on Oct 10, 2026

    @rytjy

    Can confirm, same file (scripts/collect_info.py):

    • L5: import pkg_resources at module level → on setuptools 82 this raises ModuleNotFoundError before anything runs;
    • L60: version = pkg_resources.get_distribution(package).version → the only other use.

    Since pkg_resources is going away, the drop-in for both is importlib.metadata, which removes the setuptools dependency entirely:

    from importlib.metadata import version as _dist_version, PackageNotFoundError
    # L5  -> the import above
    # L60 ->
    try:
        version = _dist_version(package)
    except PackageNotFoundError:
        version = "not installed"

    That fixes cause 1. Cause 2 (wheel/cython listed in REQUIRED but living in build-system.requires) is independent and still worth fixing separately — the importlib.metadata change doesn't move them out of REQUIRED.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions