Skip to content

Commit

Permalink
Merge pull request #33 from mxstack/entry-point-handling-delegated
Browse files Browse the repository at this point in the history
Depend on mxdev>=4.0.2, which fixes the deprecation of pkg_resources …
  • Loading branch information
jensens authored Mar 15, 2024
2 parents a26d1cb + b5f10c7 commit 3393cf9
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 32 deletions.
17 changes: 11 additions & 6 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

## 1.0a5 (unreleased)

- Add `Makefile` as dependency target for `SENTINEL` target to make sure
target execution if Makefile changes.

- 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)

- 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.

Expand All @@ -31,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.

Expand All @@ -41,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.

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ classifiers = [
]
dependencies = [
"Jinja2",
"mxdev",
"mxdev>=4.0.2",
"inquirer",
]
dynamic = ["readme"]
Expand Down
5 changes: 3 additions & 2 deletions src/mxmake/tests/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,10 +654,11 @@ def test_Makefile(self, tempdir):
# Sentinel files
SENTINEL_FOLDER?=$(MXMAKE_FOLDER)/sentinels
SENTINEL?=$(SENTINEL_FOLDER)/about.txt
$(SENTINEL):
$(SENTINEL): $(firstword $(MAKEFILE_LIST))
@mkdir -p $(SENTINEL_FOLDER)
@echo "Sentinels for the Makefile process." > $(SENTINEL)
##############################################################################
##############################################################################
# mxenv
##############################################################################
Expand Down
23 changes: 2 additions & 21 deletions src/mxmake/topics.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/mxmake/topics/core/base.mk
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ MXMAKE_FOLDER?=.mxmake
# Sentinel files
SENTINEL_FOLDER?=$(MXMAKE_FOLDER)/sentinels
SENTINEL?=$(SENTINEL_FOLDER)/about.txt
$(SENTINEL):
$(SENTINEL): $(firstword $(MAKEFILE_LIST))
@mkdir -p $(SENTINEL_FOLDER)
@echo "Sentinels for the Makefile process." > $(SENTINEL)

0 comments on commit 3393cf9

Please sign in to comment.