From 7b5c23e901a3e9a771a27e2ed2d01997c634a2d9 Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Wed, 13 Mar 2024 01:00:06 +0100 Subject: [PATCH 1/5] Depend on mxdev>=4.0.2, which fixes the deprecation of pkg_resources and use the provided infrastructure of mxdev to handle entry_points in mxmake. --- CHANGES.md | 4 +--- pyproject.toml | 2 +- src/mxmake/topics.py | 23 ++--------------------- 3 files changed, 4 insertions(+), 25 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index c164814..7534da2 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,9 +2,7 @@ ## 1.0a5 (unreleased) - -- Nothing changed yet. - +- Depend on `mxdev>=4.0.2`, which fixes the deprecation of `pkg_resources` and use the provided infrastructure of mxdev to handle entry_points in mxmake. ## 1.0a4 (2024-03-12) diff --git a/pyproject.toml b/pyproject.toml index 8cc137a..fb6e720 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ classifiers = [ ] dependencies = [ "Jinja2", - "mxdev", + "mxdev>=4.0.2", "inquirer", ] dynamic = ["readme"] diff --git a/src/mxmake/topics.py b/src/mxmake/topics.py index c4c0445..41fa003 100644 --- a/src/mxmake/topics.py +++ b/src/mxmake/topics.py @@ -1,6 +1,6 @@ from collections import Counter from dataclasses import dataclass -from importlib.metadata import entry_points +from mxdev.entry_points import load_eps_by_group from pathlib import Path import configparser @@ -10,15 +10,6 @@ import typing -try: - # do we have Python 3.12+ - from importlib.metadata import EntryPoints # type: ignore # noqa: F401 - - HAS_IMPORTLIB_ENTRYPOINTS = True -except ImportError: - HAS_IMPORTLIB_ENTRYPOINTS = False - - @dataclass class Setting: name: str @@ -174,17 +165,7 @@ def domain(self, name: str) -> typing.Optional[Domain]: @functools.lru_cache(maxsize=4096) def load_topics() -> typing.List[Topic]: - if HAS_IMPORTLIB_ENTRYPOINTS: - topics_eps = entry_points(group="mxmake.topics") # type: ignore - else: - eps = entry_points() - if "mxmake.topics" not in eps: - return [] - topics_eps = eps["mxmake.topics"] # type: ignore - # XXX: for some reasons entry points are loaded twice. not sure if this - # is a glitch when installing with uv or something related to - # importlib.metadata.entry_points - return list(set([ep.load() for ep in topics_eps])) # type: ignore + return [ep.load() for ep in load_eps_by_group("mxmake.topics")] # type: ignore def get_topic(name: str) -> Topic: From f56c4993fbd55664f5a9393f5c1176586f85b9ba Mon Sep 17 00:00:00 2001 From: Robert Niederreiter Date: Thu, 14 Mar 2024 07:32:51 +0100 Subject: [PATCH 2/5] Add `Makefile` as dependency target for `SENTINEL` target to make sure target execution if Makefile changes. --- CHANGES.md | 17 ++++++++++++----- Makefile | 2 +- src/mxmake/topics/core/base.mk | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 7534da2..44d90ef 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,13 +2,18 @@ ## 1.0a5 (unreleased) -- Depend on `mxdev>=4.0.2`, which fixes the deprecation of `pkg_resources` and use the provided infrastructure of mxdev to handle entry_points in mxmake. +- Add `Makefile` as dependency target for `SENTINEL` target to make sure + target execution if Makefile changes. + +- Depend on `mxdev>=4.0.2`, which fixes the deprecation of `pkg_resources` and + use the provided infrastructure of mxdev to handle entry_points in mxmake. ## 1.0a4 (2024-03-12) - Add experimental windows support. -- Support `mxmake update` command, updating the Makefile without prompting for settings. +- Support `mxmake update` command, updating the Makefile without prompting for + settings. - Use importlib.metadata to load entrypoints. @@ -29,7 +34,8 @@ - Rename `PYTHON_BIN` to `PRIMARY_PYTHON` in `mxenv` domain. -- Introduce `MXENV_PYTHON`. It defines the Python executable used for mxmake operations. +- Introduce `MXENV_PYTHON`. It defines the Python executable used for mxmake + operations. - Remove ruff cache when running `make ruff-clean` target. @@ -39,8 +45,9 @@ - Add pyupgrade based code formatter, see https://pypi.org/project/pyupgrade/. -- Add `ZOPE_TEMPLATE_CHECKOUT` option to zope domain to allow pinning to a tag, branch or revision (uses cookiecutter `--checkout`). - If empty, do not apply `--checkout` option. +- Add `ZOPE_TEMPLATE_CHECKOUT` option to zope domain to allow pinning to a tag, + branch or revision (uses cookiecutter `--checkout`). If empty, do not apply + `--checkout` option. - Add phony target `cookiecutter` to be able to just install it. diff --git a/Makefile b/Makefile index 5705d99..0d36970 100644 --- a/Makefile +++ b/Makefile @@ -214,7 +214,7 @@ MXMAKE_FOLDER?=.mxmake # Sentinel files SENTINEL_FOLDER?=$(MXMAKE_FOLDER)/sentinels SENTINEL?=$(SENTINEL_FOLDER)/about.txt -$(SENTINEL): +$(SENTINEL): Makefile @mkdir -p $(SENTINEL_FOLDER) @echo "Sentinels for the Makefile process." > $(SENTINEL) diff --git a/src/mxmake/topics/core/base.mk b/src/mxmake/topics/core/base.mk index b82d557..a5a5ff5 100644 --- a/src/mxmake/topics/core/base.mk +++ b/src/mxmake/topics/core/base.mk @@ -72,6 +72,6 @@ MXMAKE_FOLDER?=.mxmake # Sentinel files SENTINEL_FOLDER?=$(MXMAKE_FOLDER)/sentinels SENTINEL?=$(SENTINEL_FOLDER)/about.txt -$(SENTINEL): +$(SENTINEL): Makefile @mkdir -p $(SENTINEL_FOLDER) @echo "Sentinels for the Makefile process." > $(SENTINEL) From da2f52f2ba7cef05aa00f7a58d4b2e8d36a77178 Mon Sep 17 00:00:00 2001 From: Robert Niederreiter Date: Thu, 14 Mar 2024 07:33:54 +0100 Subject: [PATCH 3/5] Fix tests --- src/mxmake/tests/test_templates.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mxmake/tests/test_templates.py b/src/mxmake/tests/test_templates.py index 5789308..7501011 100644 --- a/src/mxmake/tests/test_templates.py +++ b/src/mxmake/tests/test_templates.py @@ -654,10 +654,11 @@ def test_Makefile(self, tempdir): # Sentinel files SENTINEL_FOLDER?=$(MXMAKE_FOLDER)/sentinels SENTINEL?=$(SENTINEL_FOLDER)/about.txt - $(SENTINEL): + $(SENTINEL): Makefile @mkdir -p $(SENTINEL_FOLDER) @echo "Sentinels for the Makefile process." > $(SENTINEL) - ############################################################################## + + ############################################################################## # mxenv ############################################################################## From 5fc3b450c5b017f4a6266ad50e416cde74298836 Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Fri, 15 Mar 2024 12:17:06 +0100 Subject: [PATCH 4/5] Update src/mxmake/tests/test_templates.py --- src/mxmake/tests/test_templates.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mxmake/tests/test_templates.py b/src/mxmake/tests/test_templates.py index 7501011..90138cc 100644 --- a/src/mxmake/tests/test_templates.py +++ b/src/mxmake/tests/test_templates.py @@ -654,7 +654,7 @@ def test_Makefile(self, tempdir): # Sentinel files SENTINEL_FOLDER?=$(MXMAKE_FOLDER)/sentinels SENTINEL?=$(SENTINEL_FOLDER)/about.txt - $(SENTINEL): Makefile + $(SENTINEL): $(firstword $(MAKEFILE_LIST)) @mkdir -p $(SENTINEL_FOLDER) @echo "Sentinels for the Makefile process." > $(SENTINEL) From b5f10c7fcc0cad16af15f89109d0e1abb13db9d0 Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Fri, 15 Mar 2024 12:17:11 +0100 Subject: [PATCH 5/5] Update src/mxmake/topics/core/base.mk --- src/mxmake/topics/core/base.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mxmake/topics/core/base.mk b/src/mxmake/topics/core/base.mk index a5a5ff5..2a78170 100644 --- a/src/mxmake/topics/core/base.mk +++ b/src/mxmake/topics/core/base.mk @@ -72,6 +72,6 @@ MXMAKE_FOLDER?=.mxmake # Sentinel files SENTINEL_FOLDER?=$(MXMAKE_FOLDER)/sentinels SENTINEL?=$(SENTINEL_FOLDER)/about.txt -$(SENTINEL): Makefile +$(SENTINEL): $(firstword $(MAKEFILE_LIST)) @mkdir -p $(SENTINEL_FOLDER) @echo "Sentinels for the Makefile process." > $(SENTINEL)