diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ca0c63f48c..48f84651072 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Changed `Tolerance` class to no longer use singleton pattern. `Tolerance()` now creates independent instances instead of returning the global `TOL`. * Renamed `Tolerance.units` to `Tolerance.unit` to better reflect the documented properties. Left `units` with deprecation warning. * Fixed `NotImplementedErorr` when calling `BrepLoop.vertices`. +* Fixed `python -m compas` to detect extensions based on `importlib` rather than `pkg_resources`. ### Removed diff --git a/src/compas/__main__.py b/src/compas/__main__.py index e38c73f7080..4a2aca4ae69 100644 --- a/src/compas/__main__.py +++ b/src/compas/__main__.py @@ -2,9 +2,9 @@ import platform try: - import pkg_resources + from importlib.metadata import distributions except ImportError: - pkg_resources = None + distributions = None import compas @@ -22,10 +22,9 @@ print("COMPAS: {}".format(compas.__version__)) print("Python: {} ({})".format(platform.python_version(), platform.python_implementation())) - if pkg_resources: - working_set = pkg_resources.working_set - packages = set([p.project_name for p in working_set]) - set(["COMPAS"]) - compas_pkgs = [p for p in packages if p.lower().startswith("compas")] + if distributions: + names = {dist.metadata.get("Name") for dist in distributions()} + compas_pkgs = [p for p in names if p and p.lower().startswith("compas") and p != "COMPAS"] if compas_pkgs: - print("Extensions: {}".format([p for p in compas_pkgs])) + print("Extensions: {}".format(compas_pkgs))