Skip to content

Commit e03e409

Browse files
authored
Merge pull request #1519 from compas-dev/fix-deprecated-feature
Fix __main__
2 parents 277cbba + de78370 commit e03e409

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818
* Changed `Tolerance` class to no longer use singleton pattern. `Tolerance()` now creates independent instances instead of returning the global `TOL`.
1919
* Renamed `Tolerance.units` to `Tolerance.unit` to better reflect the documented properties. Left `units` with deprecation warning.
2020
* Fixed `NotImplementedErorr` when calling `BrepLoop.vertices`.
21+
* Fixed `python -m compas` to detect extensions based on `importlib` rather than `pkg_resources`.
2122

2223
### Removed
2324

‎src/compas/__main__.py‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import platform
33

44
try:
5-
import pkg_resources
5+
from importlib.metadata import distributions
66
except ImportError:
7-
pkg_resources = None
7+
distributions = None
88

99
import compas
1010

@@ -22,10 +22,9 @@
2222
print("COMPAS: {}".format(compas.__version__))
2323
print("Python: {} ({})".format(platform.python_version(), platform.python_implementation()))
2424

25-
if pkg_resources:
26-
working_set = pkg_resources.working_set
27-
packages = set([p.project_name for p in working_set]) - set(["COMPAS"])
28-
compas_pkgs = [p for p in packages if p.lower().startswith("compas")]
25+
if distributions:
26+
names = {dist.metadata.get("Name") for dist in distributions()}
27+
compas_pkgs = [p for p in names if p and p.lower().startswith("compas") and p != "COMPAS"]
2928

3029
if compas_pkgs:
31-
print("Extensions: {}".format([p for p in compas_pkgs]))
30+
print("Extensions: {}".format(compas_pkgs))

0 commit comments

Comments
 (0)