From 0abdea5c86fbe7b54cfa7f34cdf7b261171752d4 Mon Sep 17 00:00:00 2001 From: Neil Hanlon Date: Fri, 17 Jun 2022 15:54:11 -0400 Subject: [PATCH] Some changes to make scripts work in the new setup" --- iso/empanadas/empanadas/common.py | 7 ++++-- .../scripts/{build-iso.py => build_iso.py} | 0 ...c-from-peridot.py => sync_from_peridot.py} | 0 ...idot-test.py => sync_from_peridot_test.py} | 0 .../scripts/{sync-sig.py => sync_sig.py} | 0 iso/empanadas/empanadas/util/dnf_utils.py | 4 +-- iso/empanadas/empanadas/util/iso_utils.py | 4 +-- iso/empanadas/poetry.lock | 25 ++++++++++++++++--- iso/empanadas/pyproject.toml | 11 ++++---- 9 files changed, 37 insertions(+), 14 deletions(-) rename iso/empanadas/empanadas/scripts/{build-iso.py => build_iso.py} (100%) rename iso/empanadas/empanadas/scripts/{sync-from-peridot.py => sync_from_peridot.py} (100%) rename iso/empanadas/empanadas/scripts/{sync-from-peridot-test.py => sync_from_peridot_test.py} (100%) rename iso/empanadas/empanadas/scripts/{sync-sig.py => sync_sig.py} (100%) diff --git a/iso/empanadas/empanadas/common.py b/iso/empanadas/empanadas/common.py index 509a622..29ee4c5 100644 --- a/iso/empanadas/empanadas/common.py +++ b/iso/empanadas/empanadas/common.py @@ -41,12 +41,15 @@ config = { } # Importing the config from yaml -for conf in glob.iglob('configs/*.yaml'): +import importlib_resources +_rootdir = importlib_resources.files("empanadas") + +for conf in glob.iglob(f"{_rootdir}/configs/*.yaml"): with open(conf, 'r', encoding="utf-8") as file: rldict.update(yaml.safe_load(file)) # Import all SIG configs from yaml -for conf in glob.iglob('sig/*.yaml'): +for conf in glob.iglob(f"{_rootdir}/sig/*.yaml"): with open(conf, 'r', encoding="utf-8") as file: sigdict.update(yaml.safe_load(file)) diff --git a/iso/empanadas/empanadas/scripts/build-iso.py b/iso/empanadas/empanadas/scripts/build_iso.py similarity index 100% rename from iso/empanadas/empanadas/scripts/build-iso.py rename to iso/empanadas/empanadas/scripts/build_iso.py diff --git a/iso/empanadas/empanadas/scripts/sync-from-peridot.py b/iso/empanadas/empanadas/scripts/sync_from_peridot.py similarity index 100% rename from iso/empanadas/empanadas/scripts/sync-from-peridot.py rename to iso/empanadas/empanadas/scripts/sync_from_peridot.py diff --git a/iso/empanadas/empanadas/scripts/sync-from-peridot-test.py b/iso/empanadas/empanadas/scripts/sync_from_peridot_test.py similarity index 100% rename from iso/empanadas/empanadas/scripts/sync-from-peridot-test.py rename to iso/empanadas/empanadas/scripts/sync_from_peridot_test.py diff --git a/iso/empanadas/empanadas/scripts/sync-sig.py b/iso/empanadas/empanadas/scripts/sync_sig.py similarity index 100% rename from iso/empanadas/empanadas/scripts/sync-sig.py rename to iso/empanadas/empanadas/scripts/sync_sig.py diff --git a/iso/empanadas/empanadas/util/dnf_utils.py b/iso/empanadas/empanadas/util/dnf_utils.py index 6fe3da4..6cb8ba4 100644 --- a/iso/empanadas/empanadas/util/dnf_utils.py +++ b/iso/empanadas/empanadas/util/dnf_utils.py @@ -17,7 +17,7 @@ import json from jinja2 import Environment, FileSystemLoader -from empanadas.common import Color +from empanadas.common import Color, _rootdir #HAS_LIBREPO = True #try: @@ -83,7 +83,7 @@ class RepoSync: self.gpgkey = gpgkey # Templates - file_loader = FileSystemLoader('templates') + file_loader = FileSystemLoader(f"{_rootdir}/templates") self.tmplenv = Environment(loader=file_loader) # each el can have its own designated container to run stuff in, diff --git a/iso/empanadas/empanadas/util/iso_utils.py b/iso/empanadas/empanadas/util/iso_utils.py index 500a980..6243dd1 100644 --- a/iso/empanadas/empanadas/util/iso_utils.py +++ b/iso/empanadas/empanadas/util/iso_utils.py @@ -23,7 +23,7 @@ import productmd.treeinfo from jinja2 import Environment, FileSystemLoader -from empanadas.common import Color +from empanadas.common import Color, _rootdir class IsoBuild: """ @@ -86,7 +86,7 @@ class IsoBuild: ) # Templates - file_loader = FileSystemLoader('templates') + file_loader = FileSystemLoader(f"{_rootdir}/templates") self.tmplenv = Environment(loader=file_loader) self.compose_latest_dir = os.path.join( diff --git a/iso/empanadas/poetry.lock b/iso/empanadas/poetry.lock index 3e597d0..5b679ac 100644 --- a/iso/empanadas/poetry.lock +++ b/iso/empanadas/poetry.lock @@ -45,6 +45,21 @@ docs = ["sphinx", "jaraco.packaging (>=8.2)", "rst.linker (>=1.9)"] perf = ["ipython"] testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "packaging", "pep517", "pyfakefs", "flufl.flake8", "pytest-perf (>=0.9.2)", "pytest-black (>=0.3.7)", "pytest-mypy", "importlib-resources (>=1.3)"] +[[package]] +name = "importlib-resources" +version = "5.8.0" +description = "Read resources from Python packages" +category = "main" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +zipp = {version = ">=3.1.0", markers = "python_version < \"3.10\""} + +[package.extras] +docs = ["sphinx", "jaraco.packaging (>=9)", "rst.linker (>=1.9)"] +testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "pytest-black (>=0.3.7)", "pytest-mypy (>=0.9.1)"] + [[package]] name = "jinja2" version = "2.11.3" @@ -197,7 +212,7 @@ python-versions = "*" name = "zipp" version = "3.6.0" description = "Backport of pathlib-compatible object wrapper for zip files" -category = "dev" +category = "main" optional = false python-versions = ">=3.6" @@ -207,8 +222,8 @@ testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytes [metadata] lock-version = "1.1" -python-versions = ">=3.6" -content-hash = "24b4f1aa7304910b04db920cbf95e7c5f483008effe499a9303d02d561a421d4" +python-versions = ">=3.7" +content-hash = "17bc9d78b4ea2e474754a1d321fec745361870a5315784e2a2f5b54a564bc5d8" [metadata.files] atomicwrites = [ @@ -227,6 +242,10 @@ importlib-metadata = [ {file = "importlib_metadata-4.8.3-py3-none-any.whl", hash = "sha256:65a9576a5b2d58ca44d133c42a241905cc45e34d2c06fd5ba2bafa221e5d7b5e"}, {file = "importlib_metadata-4.8.3.tar.gz", hash = "sha256:766abffff765960fcc18003801f7044eb6755ffae4521c8e8ce8e83b9c9b0668"}, ] +importlib-resources = [ + {file = "importlib_resources-5.8.0-py3-none-any.whl", hash = "sha256:7952325ffd516c05a8ad0858c74dff2c3343f136fe66a6002b2623dd1d43f223"}, + {file = "importlib_resources-5.8.0.tar.gz", hash = "sha256:568c9f16cb204f9decc8d6d24a572eeea27dacbb4cee9e6b03a8025736769751"}, +] jinja2 = [ {file = "Jinja2-2.11.3-py2.py3-none-any.whl", hash = "sha256:03e47ad063331dd6a3f04a43eddca8a966a26ba0c5b7207a9a9e4e08f1b29419"}, {file = "Jinja2-2.11.3.tar.gz", hash = "sha256:a6d58433de0ae800347cab1fa3043cebbabe8baa9d29e668f1c768cb87a333c6"}, diff --git a/iso/empanadas/pyproject.toml b/iso/empanadas/pyproject.toml index db5bb83..22dfe42 100644 --- a/iso/empanadas/pyproject.toml +++ b/iso/empanadas/pyproject.toml @@ -5,20 +5,21 @@ description = "hand crafted ISOs with love and spice" authors = ["Louis Abel ", "Neil Hanlon "] [tool.poetry.dependencies] -python = ">=3.6" +python = ">=3.7" rpm-py-installer = "~1.1.0" PyYAML = "~6.0" Jinja2 = "~2" productmd = "~1.33" +importlib-resources = "^5.8.0" [tool.poetry.dev-dependencies] pytest = "~5" [tool.poetry.scripts] -sync-from-peridot = "empanadas.scripts.sync-from-peridot:run" -sync-from-peridot-test = "empanadas.scripts.sync-from-peridot-test:run" -sync-sig = "empanadas.scripts.sync-sig:run" -build-iso = "empanadas.scripts.build-iso:run" +sync_from_peridot = "empanadas.scripts.sync_from_peridot:run" +sync_from_peridot_test = "empanadas.scripts.sync_from_peridot_test:run" +sync_sig = "empanadas.scripts.sync_sig:run" +build-iso = "empanadas.scripts.build_iso:run" [build-system] requires = ["poetry-core>=1.0.0"]