Skip to content

setuptools>=82.0 dropped pkg_resources #285

@jkbjh

Description

@jkbjh

setuptools (>=82) dropped pkg_resources, so importing fails.

Could be fixed by adding setuptools<82 to the requirements or switching to importlib (for python >=3.10) and doing something like:

diff --git a/vpython/__init__.py b/vpython/__init__.py
index 1c17f05..0a10f75 100644
--- a/vpython/__init__.py
+++ b/vpython/__init__.py
@@ -1,17 +1,18 @@
-from pkg_resources import get_distribution, DistributionNotFound
+from importlib.metadata import distribution, PackageNotFoundError
+
 
 from .gs_version import glowscript_version
 
 try:
-    __version__ = get_distribution(__name__).version
-except DistributionNotFound:
+    __version__ = distribution(__name__).version
+except PackageNotFoundError:
     # package is not installed
     pass
 __gs_version__ = glowscript_version()
 
 del glowscript_version
-del get_distribution
-del DistributionNotFound
+del distribution
+del PackageNotFoundError

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions