Skip to content

Commit

Permalink
refactor: get runtime metadata from package init file (#289)
Browse files Browse the repository at this point in the history
* __init__: add runtime metadata

* umu_run: pass runtime metadata to setup function

* umu_runtime: remove function that parsed runtime metadata from JSON

* umu_runtime: use runtime metadata variables instead of values from JSON

* umu: delete JSON template file

* Makefile: remove version target

* umu_test: update tests

* umu_test_plugins: update tests
  • Loading branch information
R1kaB3rN authored Nov 24, 2024
1 parent 55fd787 commit 5f7599f
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 297 deletions.
28 changes: 6 additions & 22 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,6 @@ all: umu-dist umu-docs umu-launcher
install: umu-install umu-launcher-install
endif

# Special case, do this inside the source directory for release distribution
umu/umu_version.json: umu/umu_version.json.in
$(info :: Updating $(@) )
cp $(<) $(<).tmp
sed 's|##UMU_VERSION##|$(shell git describe --always --long --tags)|g' -i $(<).tmp
mv $(<).tmp $(@)

.PHONY: version
version: umu/umu_version.json

version-install: version
$(info :: Installing umu_version.json )
install -d $(DESTDIR)$(PYTHONDIR)/$(INSTALLDIR)
install -Dm 644 umu/umu_version.json -t $(DESTDIR)$(PYTHONDIR)/$(INSTALLDIR)


$(OBJDIR)/.build-umu-docs: | $(OBJDIR)
$(info :: Building umu man pages )
Expand All @@ -67,7 +52,7 @@ umu-docs-install: umu-docs
install -m644 $(OBJDIR)/umu.5 $(DESTDIR)$(MANDIR)/man5/umu.5


$(OBJDIR)/.build-umu-dist: | $(OBJDIR) version
$(OBJDIR)/.build-umu-dist: | $(OBJDIR)
$(info :: Building umu )
$(PYTHON_INTERPRETER) -m build --wheel --skip-dependency-check --no-isolation --outdir=$(OBJDIR)
touch $(@)
Expand All @@ -81,9 +66,9 @@ umu-dist-install: umu-dist
$(PYTHON_INTERPRETER) -m installer --destdir=$(DESTDIR) $(OBJDIR)/*.whl

ifeq ($(FLATPAK), xtrue)
umu-install: version-install umu-dist-install
umu-install: umu-dist-install
else
umu-install: version-install umu-dist-install umu-docs-install
umu-install: umu-dist-install umu-docs-install
endif

ifeq ($(FLATPAK), xtrue)
Expand Down Expand Up @@ -136,15 +121,15 @@ $(OBJDIR):
.PHONY: clean
clean:
$(info :: Cleaning source directory )
@rm -rf -v $(OBJDIR) umu/umu_version.json ./$(RELEASEDIR) $(RELEASEDIR).tar.gz
@rm -rf -v ./$(RELEASEDIR) $(RELEASEDIR).tar.gz


RELEASEDIR := $(PROJECT)-$(shell git describe --abbrev=0)
$(RELEASEDIR):
mkdir -p $(@)

.PHONY: release
release: $(RELEASEDIR) | version zipapp
release: $(RELEASEDIR) | zipapp
$(info :: Creating source distribution for release )
mkdir -p $(<)
rm -rf umu/__pycache__
Expand All @@ -165,11 +150,10 @@ ZIPAPP := $(OBJDIR)/umu-run
ZIPAPP_STAGING := $(OBJDIR)/zipapp_staging
ZIPAPP_VENV := $(OBJDIR)/zipapp_venv

$(OBJDIR)/.build-zipapp: | $(OBJDIR) version
$(OBJDIR)/.build-zipapp: | $(OBJDIR)
$(info :: Building umu-launcher as zipapp )
$(PYTHON_INTERPRETER) -m venv $(ZIPAPP_VENV)
. $(ZIPAPP_VENV)/bin/activate && python3 -m pip install -t "$(ZIPAPP_STAGING)" -U --no-compile .
install -Dm644 umu/umu_version.json "$(ZIPAPP_STAGING)"/umu/umu_version.json
cp umu/__main__.py "$(ZIPAPP_STAGING)"
find "$(ZIPAPP_STAGING)" -exec touch -h -d "$(SOURCE_DATE_EPOCH)" {} +
. $(ZIPAPP_VENV)/bin/activate && python3 -m zipapp $(ZIPAPP_STAGING) -o $(ZIPAPP) -p "$(PYTHON_INTERPRETER)" -c
Expand Down
2 changes: 2 additions & 0 deletions umu/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
__version__ = "1.1.4" # noqa: D104
__runtime_versions__ = (("sniper", "steamrt3"), ("soldier", "steamrt2"))
__runtime_version__ = __runtime_versions__[0]
4 changes: 2 additions & 2 deletions umu/umu_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from Xlib.protocol.rq import Event
from Xlib.xobject.drawable import Window

from umu import __version__
from umu import __runtime_version__, __version__
from umu.umu_consts import (
PR_SET_CHILD_SUBREAPER,
PROTON_VERBS,
Expand Down Expand Up @@ -803,7 +803,7 @@ def umu_run(args: Namespace | tuple[str, list[str]]) -> int:

# Setup the launcher and runtime files
future: Future = thread_pool.submit(
setup_umu, root, UMU_LOCAL, thread_pool
setup_umu, root, UMU_LOCAL, __runtime_version__, thread_pool
)

if isinstance(args, Namespace):
Expand Down
Loading

0 comments on commit 5f7599f

Please sign in to comment.