Skip to content

Commit

Permalink
Use the right flatpak sdk
Browse files Browse the repository at this point in the history
* Use the right flatpak sdk
* add some dirs to the GI search path

Signed-off-by: Alvaro Saurin <alvaro.saurin@gmail.com>
  • Loading branch information
inercia committed May 29, 2020
1 parent 1af52e7 commit 9155142
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 78 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ __pycache__

/*.xz
/*.flatpak
/builddir

build-aux/flatpak-pip-generator
24 changes: 15 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ BUILD_ROOT = $(PROJECT_ROOT)/.flatpak-builder

FLATPAK_BUNDLE ?= $(PROJECT_ROOT)/$(APP_ID).flatpak

FLATPAK_RUN_COMMAND ?= k3x

STATE_DIR = $(BUILD_ROOT)
CCACHE_DIR = $(BUILD_ROOT)/ccache
BUILD_DIR ?= $(BUILD_ROOT)/build/staging
Expand Down Expand Up @@ -116,13 +118,6 @@ help: ## Show this help screen
##############################
##@ Development

pypi-dependencies.json: build-aux/flatpak-pip-generator requirements.txt
build-aux/flatpak-pip-generator --requirements-file=requirements.txt --output pypi-dependencies

build-aux/flatpak-pip-generator:
curl -o build-aux/flatpak-pip-generator https://raw.githubusercontent.com/flatpak/flatpak-builder-tools/master/pip/flatpak-pip-generator
chmod 755 build-aux/flatpak-pip-generator

deps: ## Install all the required dependencies for building/running
@printf "$(CYN)>>> $(GRN)Adding flatpak dependencies (apps, frameworks...)...$(END)\n"
flatpak --user remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
Expand Down Expand Up @@ -162,9 +157,13 @@ run: $(BUILD_DIR)/build.ninja ## Run the application locally
printf "$(CYN)>>> $(GRN)Running ninja install (in build_dir=$(BUILD_DIR))...$(END)\n" && \
flatpak build --build-dir=$(BUILD_DIR) $(FLATPAK_BUILD_ARGS) ninja install

@printf "$(CYN)>>> $(GRN)Running k3x in a sandbox...$(END)\n"
@printf "$(CYN)>>> $(GRN)Running $(FLATPAK_RUN_COMMAND) in the sandbox...$(END)\n"
$(Q)flatpak-builder $(FLATPAK_RUN_ARGS) $(FLATPAK_RUN_SHARES) --run $(BUILD_DIR) $(FLATPAK_MANIFEST) \
k3x
$(FLATPAK_RUN_COMMAND)

.PHONY: shell
shell: FLATPAK_RUN_COMMAND=bash
shell: run ## Run a shell in the sandbox

##############################
# Clean
Expand Down Expand Up @@ -216,6 +215,13 @@ $(FLATPAK_BUNDLE): $(FLATPAK_MANIFEST) $(APP_SRC_MESONS) $(APP_SRC_PY) $(APP_SRC
$(Q)flatpak build-bundle --arch=x86_64 $(FLATPAK_REPO_DIR) $(FLATPAK_BUNDLE) $(APP_ID) master
@printf "$(CYN)>>> $(GRN)Bundle available at $(FLATPAK_BUNDLE)$(END)\n"

generate: build-aux/flatpak-pip-generator requirements.txt ## Regenerate some files (ie, pypi-dependencies.json)
build-aux/flatpak-pip-generator --requirements-file=requirements.txt --output pypi-dependencies

build-aux/flatpak-pip-generator:
curl -o build-aux/flatpak-pip-generator https://raw.githubusercontent.com/flatpak/flatpak-builder-tools/master/pip/flatpak-pip-generator
chmod 755 build-aux/flatpak-pip-generator

##############################
# releases
##############################
Expand Down
6 changes: 3 additions & 3 deletions com.github.inercia.k3x.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"app-id": "com.github.inercia.k3x",
"runtime": "org.gnome.Platform",
"runtime-version": "3.36",
"sdk": "org.gnome.Sdk",
"base": "io.elementary.BaseApp",
"base-version": "juno-19.08",
"runtime": "org.freedesktop.Platform",
"sdk": "org.freedesktop.Sdk",
"runtime-version": "19.08",
"command": "k3x",
"finish-args": [
"--device=dri",
Expand Down
124 changes: 62 additions & 62 deletions data/com.github.inercia.k3x.appdata.xml.in
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>com.github.inercia.k3x.desktop</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>MIT</project_license>
<name>k3x</name>
<developer_name>Alvaro Saurin</developer_name>
<categories>
<category>Game</category>
<category>GTK</category>
</categories>
<provides>
<binary>com.github.inercia.k3x</binary>
</provides>
<screenshots>
<screenshot type="default">
<image>https://raw.githubusercontent.com/inercia/k3x/master/docs/screenshots/create-new-dialog-general.png</image>
</screenshot>
<screenshot>
<image>https://raw.githubusercontent.com/inercia/k3x/master/docs/screenshots/create-new-dialog-advanced.png</image>
</screenshot>
</screenshots>
<description>
<p>k3x is a graphical user interface for k3d (https://github.com/rancher/k3d), making it trivial to have your own local Kubernetes cluster(s).</p>
<p>k3x is perfect for:</p>
<id>com.github.inercia.k3x.desktop</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>MIT</project_license>
<name>k3x</name>
<summary>Manager for local Kubernetes clusters with k3d</summary>
<developer_name>Alvaro Saurin</developer_name>
<categories>
<category>Game</category>
<category>GTK</category>
</categories>
<provides>
<binary>com.github.inercia.k3x</binary>
</provides>
<screenshots>
<screenshot type="default">
<image>https://raw.githubusercontent.com/inercia/k3x/master/docs/screenshots/create-new-dialog-general.png</image>
</screenshot>
<screenshot>
<image>https://raw.githubusercontent.com/inercia/k3x/master/docs/screenshots/create-new-dialog-advanced.png</image>
</screenshot>
</screenshots>
<description>
<p>k3x is a graphical user interface for k3d (https://github.com/rancher/k3d), making it trivial to have your own local Kubernetes cluster(s).</p>
<p>k3x is perfect solution for:</p>
<ul>
<li>having a fresh Kubernetes cluster in a couple of seconds.</li>
<li>trying new deployments before going in production.</li>
<li>learning about Kubernetes.</li>
</ul>
<p>the k3x project goals are:</p>
<ul>
<li>to create/switch-to/destroy Kubernetes clusters easily.</li>
<li>to drive the most important operations with global keyboard shortcuts.</li>
<li>to reduce the learning curve of using Kubernetes.</li>
</ul>
</description>
<releases>
<release version="0.1" date="2020-04-17">
<description>
<p>Fist release!</p>
<ul>
<li>having a fresh Kubernetes cluster in a couple of seconds.</li>
<li>trying new deployments before going in production.</li>
<li>learning about Kubernetes.</li>
<li>Initial release.</li>
</ul>
<p>k3x goals are:</p>
<ul>
<li>to create/switch-to/destroy Kubernetes clusters easily.</li>
<li>to drive the most important operations with global keyboard shortcuts.</li>
<li>to reduce the learning curve of using Kubernetes.</li>
</ul>
</description>
<releases>
<release version="0.1" date="2020-04-17">
<description>
<p>Fist release!</p>
<ul>
<li>Initial release.</li>
</ul>
</description>
</release>
</releases>
<content_rating type="oars-1.1">
<content_attribute id="social-chat">none</content_attribute>
<content_attribute id="social-info">none</content_attribute>
<content_attribute id="social-audio">none</content_attribute>
<content_attribute id="social-location">none</content_attribute>
<content_attribute id="social-contacts">none</content_attribute>
<content_attribute id="money-purchasing">none</content_attribute>
<content_attribute id="money-gambling">none</content_attribute>
</content_rating>
<url type="homepage">https://github.com/inercia/k3x</url>
<url type="bugtracker">https://github.com/inercia/k3x/issues</url>
<url type="help">https://github.com/inercia/k3x/issues</url>
<update_contact>alvaro.saurin@gmail.com</update_contact>
<custom>
<value key="x-appcenter-color-primary">#82ffc4</value>
<value key="x-appcenter-color-primary-text">#000000</value>
<value key="x-appcenter-suggested-price">0</value>
</custom>
</description>
</release>
</releases>
<content_rating type="oars-1.1">
<content_attribute id="social-chat">none</content_attribute>
<content_attribute id="social-info">none</content_attribute>
<content_attribute id="social-audio">none</content_attribute>
<content_attribute id="social-location">none</content_attribute>
<content_attribute id="social-contacts">none</content_attribute>
<content_attribute id="money-purchasing">none</content_attribute>
<content_attribute id="money-gambling">none</content_attribute>
</content_rating>
<url type="homepage">https://github.com/inercia/k3x</url>
<url type="bugtracker">https://github.com/inercia/k3x/issues</url>
<url type="help">https://github.com/inercia/k3x/issues</url>
<update_contact>alvaro.saurin@gmail.com</update_contact>
<custom>
<value key="x-appcenter-color-primary">#82ffc4</value>
<value key="x-appcenter-color-primary-text">#000000</value>
<value key="x-appcenter-suggested-price">0</value>
</custom>
</component>

15 changes: 12 additions & 3 deletions src/k3x.in
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,31 @@ sys.path.insert(1, pkgdatadir)
signal.signal(signal.SIGINT, signal.SIG_DFL)
gettext.install('k3x', localedir)

# extra search path (in reverse order of precedence)
GI_EXTRA_SEARCH_PATH = [
'/usr/lib/x86_64-linux-gnu/girepository-1.0',
'@PREFIX@/lib/girepository-1.0/'
]

if __name__ == '__main__':
import gi

from gi.repository import Gio
resource = Gio.Resource.load(os.path.join(pkgdatadir, 'k3x.gresource'))
resource._register()

print(f"[PRE-MAIN] Adding to GI path @PREFIX@/lib/girepository-1.0/")
import gi.repository
# Set the search path to use the newly generated introspection files
gi.require_version('GIRepository', '2.0')

# FIXME: for some unknown reason, we must add the standard GI paths
from gi.repository import GIRepository
GIRepository.Repository.prepend_search_path('@PREFIX@/lib/girepository-1.0/')
for d in GI_EXTRA_SEARCH_PATH:
GIRepository.Repository.prepend_search_path(d)

print("GI search path:")
for p in GIRepository.Repository.get_search_path():
print("[PRE-MAIN] - " + p)
print("[PRE-MAIN] [search-path] - " + p)

print(f"[PRE-MAIN] Current LD_LIBRARY_PATH: " + os.getenv("LD_LIBRARY_PATH", default=""))

Expand Down
2 changes: 1 addition & 1 deletion src/kubectl.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def run_kubectl_command(*args, **kwargs) -> Iterator[str]:
env["KUBECONFIG"] = kubeconfig
kwargs["env"] = env

logging.debug(f"[KUBECTL] Running kubectl command {args} {kwargs}")
logging.debug(f"[KUBECTL] Running kubectl command {args}")

# IMPORTANT: remember to "consume" this iterator, or this will not be run at all
yield from run_command_stdout(kubectl_exe, *args, **kwargs)
Expand Down

0 comments on commit 9155142

Please sign in to comment.