From 962b238f6afde16ce552b9c631ca81e2c9ded7f6 Mon Sep 17 00:00:00 2001 From: Jip-Hop <2871973+Jip-Hop@users.noreply.github.com> Date: Tue, 16 Jul 2024 17:28:16 +0200 Subject: [PATCH] Remove Hatch --- .github/workflows/build.yml | 59 ---------------------------------- src/builder/app/__init__.py | 3 -- src/builder/app/build_app.py | 56 -------------------------------- src/builder/app/hooks_app.py | 11 ------- src/builder/app/pyproject.toml | 22 ------------- src/builder/zip/__init__.py | 3 -- src/builder/zip/build_zip.py | 59 ---------------------------------- src/builder/zip/hooks_zip.py | 11 ------- src/builder/zip/pyproject.toml | 22 ------------- 9 files changed, 246 deletions(-) delete mode 100644 .github/workflows/build.yml delete mode 100644 src/builder/app/__init__.py delete mode 100644 src/builder/app/build_app.py delete mode 100644 src/builder/app/hooks_app.py delete mode 100644 src/builder/app/pyproject.toml delete mode 100644 src/builder/zip/__init__.py delete mode 100644 src/builder/zip/build_zip.py delete mode 100644 src/builder/zip/hooks_zip.py delete mode 100644 src/builder/zip/pyproject.toml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 118e1cf..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,59 +0,0 @@ -# Inspiration from - -name: Build - -on: - push: - branches: ["**"] - pull_request: - branches: ["**"] - - workflow_dispatch: - -jobs: - - build: - name: Build jlmkr tool - runs-on: ubuntu-24.04 - strategy: - matrix: - python-version: - - "3.11" # TrueNAS SCALE 24.04 Dragonfish - steps: - - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - - name: Set up pip cache - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }} - restore-keys: ${{ runner.os }}-pip- - - - name: Install Hatch - uses: pypa/hatch@install - - - name: Run style check - run: hatch fmt --check - -# - name: Run unit tests -# run: hatch run +py=${{ matrix.python-version }} test:test - - - name: Build distribution - run: hatch build -t zipapp -t appzip - -# - name: Upload artifacts -# uses: actions/upload-artifact@v4 -# with: -# path: -# - dist/jlmkr -# - dist/jlmkr-*.zip -# if-no-files-found: error diff --git a/src/builder/app/__init__.py b/src/builder/app/__init__.py deleted file mode 100644 index 4662c4f..0000000 --- a/src/builder/app/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -# SPDX-FileCopyrightText: © 2024 Jip-Hop and the Jailmakers -# -# SPDX-License-Identifier: LGPL-3.0-only diff --git a/src/builder/app/build_app.py b/src/builder/app/build_app.py deleted file mode 100644 index 22675ed..0000000 --- a/src/builder/app/build_app.py +++ /dev/null @@ -1,56 +0,0 @@ -# SPDX-FileCopyrightText: © 2024 Jip-Hop and the Jailmakers -# -# SPDX-License-Identifier: LGPL-3.0-only - -import os -from io import BytesIO -from pathlib import Path -from typing import Any, Callable, Iterable -from zipapp import create_archive - -from hatchling.builders.plugin.interface import BuilderInterface - - -class ZipAppBuilder(BuilderInterface): - PLUGIN_NAME = "zipapp" - - def get_version_api(self) -> dict[str, Callable[..., str]]: - return {"standard": self.build_standard} - - def clean(self, directory: str, versions: Iterable[str]) -> None: - try: - os.remove(Path(directory, 'jlmkr')) - except: - pass - - def build_standard(self, directory: str, **build_data: Any) -> str: - - # generate zipapp source archive - pyzbuffer = BytesIO() - create_archive('src/jlmkr', target=pyzbuffer, - interpreter='=PLACEHOLDER=', -# main='donor.jlmkr:main', - compressed=True) - zipdata = pyzbuffer.getvalue() #.removeprefix(b"#!=PLACEHOLDER=\n") - - # output with preamble - outpath = Path(directory, 'jlmkr') - with open(outpath, 'wb') as f: - f.write(preamble(self.metadata.version).encode()) - f.write(zipdata) - os.chmod(outpath, 0o755) - return os.fspath(outpath) - - -# 10 lines will conveniently match the default of head(1) -def preamble(version): return f'''#!/usr/bin/env python3 - -jlmkr {version} - -Persistent Linux 'jails' on TrueNAS SCALE to install software (k3s, docker, portainer, podman, etc.) with full access to all files via bind mounts. - -SPDX-FileCopyrightText: © 2024 Jip-Hop and the Jailmakers -SPDX-License-Identifier: LGPL-3.0-only - --=-=-=- this is a zip file -=-=-=- what follows is binary -=-=-=- -''' diff --git a/src/builder/app/hooks_app.py b/src/builder/app/hooks_app.py deleted file mode 100644 index beb4253..0000000 --- a/src/builder/app/hooks_app.py +++ /dev/null @@ -1,11 +0,0 @@ -# SPDX-FileCopyrightText: © 2024 Jip-Hop and the Jailmakers -# -# SPDX-License-Identifier: LGPL-3.0-only - -from hatchling.plugin import hookimpl - -from build_app import ZipAppBuilder - -@hookimpl -def hatch_register_builder(): - return ZipAppBuilder diff --git a/src/builder/app/pyproject.toml b/src/builder/app/pyproject.toml deleted file mode 100644 index 8af91bc..0000000 --- a/src/builder/app/pyproject.toml +++ /dev/null @@ -1,22 +0,0 @@ -# SPDX-FileCopyrightText: © 2024 Jip-Hop and the Jailmakers -# -# SPDX-License-Identifier: LGPL-3.0-only - -[build-system] -build-backend = "hatchling.build" -requires = ["hatchling"] - -[project] -name = "hatch-zipapp" -version = "0.0.dev0" -classifiers = [ - "License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)", - "Private :: Do Not Upload", -] -dependencies = ["hatchling"] - -[project.entry-points.hatch] -zipapp = "hooks_app" - -[tool.hatch.build.targets.wheel] -packages = ["."] diff --git a/src/builder/zip/__init__.py b/src/builder/zip/__init__.py deleted file mode 100644 index 4662c4f..0000000 --- a/src/builder/zip/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -# SPDX-FileCopyrightText: © 2024 Jip-Hop and the Jailmakers -# -# SPDX-License-Identifier: LGPL-3.0-only diff --git a/src/builder/zip/build_zip.py b/src/builder/zip/build_zip.py deleted file mode 100644 index 53caf1f..0000000 --- a/src/builder/zip/build_zip.py +++ /dev/null @@ -1,59 +0,0 @@ -# SPDX-FileCopyrightText: © 2024 Jip-Hop and the Jailmakers -# -# SPDX-License-Identifier: LGPL-3.0-only - -# hat tip: - -import os -from hatchling.builders.config import BuilderConfig -from hatchling.builders.plugin.interface import BuilderInterface -from hatchling.builders.utils import normalize_relative_path -from pathlib import Path -from typing import Any, Callable, Iterable -from zipfile import ZipFile, ZIP_DEFLATED - - -class AppZipBuilderConfig(BuilderConfig): pass - -class AppZipBuilder(BuilderInterface): - PLUGIN_NAME = "appzip" - - @classmethod - def get_config_class(cls): - return AppZipBuilderConfig - - def get_version_api(self) -> dict[str, Callable[..., str]]: - return {'standard': self.build_standard} - - def clean(self, directory: str, versions: Iterable[str]) -> None: - for filename in os.listdir(directory): - if filename.startswith('jlmkr-') and filename.endswith('.zip'): - os.remove(Path(directory, filename)) - - def build_standard(self, directory: str, **build_data: Any) -> str: - outpath = Path(directory, f'jlmkr-{self.metadata.version}.zip') - with ZipFile(outpath, 'w') as zip: - zip.write(Path(directory, 'jlmkr'), 'jlmkr') - force_map = build_data['force_include'] - for included_file in self.recurse_forced_files(force_map): - zip.write( - included_file.relative_path, - included_file.distribution_path, - ZIP_DEFLATED) - return os.fspath(outpath) - - def get_default_build_data(self) -> dict[str, Any]: - build_data: dict[str, Any] = super().get_default_build_data() - - extra_files = [] - if self.metadata.core.readme_path: - extra_files.append(self.metadata.core.readme_path) - if self.metadata.core.license_files: - extra_files.extend(self.metadata.core.license_files) - - force_include = build_data.setdefault("force_include", {}) - for fn in map(normalize_relative_path, extra_files): - force_include[os.path.join(self.root, fn)] = Path(fn).name - build_data['force_include'] = force_include - - return build_data diff --git a/src/builder/zip/hooks_zip.py b/src/builder/zip/hooks_zip.py deleted file mode 100644 index 5bd8a60..0000000 --- a/src/builder/zip/hooks_zip.py +++ /dev/null @@ -1,11 +0,0 @@ -# SPDX-FileCopyrightText: © 2024 Jip-Hop and the Jailmakers -# -# SPDX-License-Identifier: LGPL-3.0-only - -from hatchling.plugin import hookimpl - -from build_zip import AppZipBuilder - -@hookimpl -def hatch_register_builder(): - return AppZipBuilder diff --git a/src/builder/zip/pyproject.toml b/src/builder/zip/pyproject.toml deleted file mode 100644 index 1aa6674..0000000 --- a/src/builder/zip/pyproject.toml +++ /dev/null @@ -1,22 +0,0 @@ -# SPDX-FileCopyrightText: © 2024 Jip-Hop and the Jailmakers -# -# SPDX-License-Identifier: LGPL-3.0-only - -[build-system] -build-backend = "hatchling.build" -requires = ["hatchling"] - -[project] -name = "hatch-appzip" -version = "0.0.dev0" -classifiers = [ - "License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)", - "Private :: Do Not Upload", -] -dependencies = ["hatchling"] - -[project.entry-points.hatch] -appzip = "hooks_zip" - -[tool.hatch.build.targets.wheel] -packages = ["."]