From 7d008ef0578c314fb9a3bb4f4ef01a961031a7a7 Mon Sep 17 00:00:00 2001 From: jaseg Date: Tue, 10 Mar 2026 19:02:21 +0100 Subject: [PATCH] Update svg-flatten-wasi package to pyproject.toml/uv-build --- svg-flatten/.gitignore | 3 + svg-flatten/Makefile | 1 + svg-flatten/pyproject.toml | 42 +++++++++++ svg-flatten/setup.py | 55 --------------- svg-flatten/svg-flatten-wasi-ci.yml | 4 +- svg-flatten/svg_flatten_wasi/__init__.py | 10 ++- svg-flatten/uv.lock | 89 ++++++++++++++++++++++++ 7 files changed, 140 insertions(+), 64 deletions(-) create mode 100644 svg-flatten/.gitignore create mode 100644 svg-flatten/pyproject.toml delete mode 100644 svg-flatten/setup.py create mode 100644 svg-flatten/uv.lock diff --git a/svg-flatten/.gitignore b/svg-flatten/.gitignore new file mode 100644 index 0000000..31244bb --- /dev/null +++ b/svg-flatten/.gitignore @@ -0,0 +1,3 @@ +*.wasm +__pycache__ +cache diff --git a/svg-flatten/Makefile b/svg-flatten/Makefile index ac2b710..0471f74 100644 --- a/svg-flatten/Makefile +++ b/svg-flatten/Makefile @@ -78,6 +78,7 @@ all: $(BUILDDIR)/$(BINARY) $(BUILDDIR)/nopencv-test .PHONY: wasm wasm: $(BUILDDIR)/$(BINARY).wasm + cp $(BUILDDIR)/$(BINARY).wasm svg_flatten_wasi/ $(CACHEDIR)/$(WASI_SDK): mkdir -p $(dir $@) diff --git a/svg-flatten/pyproject.toml b/svg-flatten/pyproject.toml new file mode 100644 index 0000000..7af7485 --- /dev/null +++ b/svg-flatten/pyproject.toml @@ -0,0 +1,42 @@ +[project] +name = "svg-flatten-wasi" +version = "3.1.9" +description = "svg-flatten SVG downconverter" +readme = { file = "README.rst", content-type = "text/x-rst" } +license = { text = "AGPLv3+" } +authors = [{ name = "jaseg", email = "pypi@jaseg.de" }] +requires-python = ">=3.12" +dependencies = [ + "appdirs~=1.4.4", + "wasmtime>=42.0.0", + "click>=8.3.0", +] + +[project.optional-dependencies] +resvg-wasi = ["resvg-wasi >= 0.47.0"] + +[project.scripts] +wasi-svg-flatten = "svg_flatten_wasi:run_svg_flatten" + +[project.urls] +"Source Code" = "https://git.jaseg.de/gerbolyze" +"Bug Tracker" = "https://github.com/jaseg/gerbolyze/issues" + +[build-system] +requires = ["uv-build >= 0.10.9, <= 0.11.0"] +build-backend = "uv_build" + +[tool.uv-build.include] +"svg_flatten_wasi/*.wasm" = "svg_flatten_wasi/" + +[tool.uv.build-backend] +module-name = "svg_flatten_wasi" +module-root = "" + +[tool.hatch.metadata] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)", + "Topic :: Utilities", +] diff --git a/svg-flatten/setup.py b/svg-flatten/setup.py deleted file mode 100644 index 06e813d..0000000 --- a/svg-flatten/setup.py +++ /dev/null @@ -1,55 +0,0 @@ -import subprocess -from setuptools import setup, find_packages -from pathlib import Path -import re -import shutil - -def version(): - res = subprocess.run(['git', 'describe', '--tags', '--match', 'v*'], capture_output=True, check=True, text=True) - version, _, _rest = res.stdout.strip()[1:].partition('-') - return version - -def long_description(): - with open("README.rst") as f: - return f.read() - -setup( - name="svg-flatten-wasi", - version=version(), - author="jaseg", - author_email="pypi@jaseg.de", - description="svg-flatten SVG downconverter", - long_description=long_description(), - long_description_content_type="text/x-rst", - license="AGPLv3+", - python_requires="~=3.7", - setup_requires=["wheel"], - install_requires=[ - "importlib_resources; python_version<'3.9'", - "appdirs~=1.4", - "wasmtime>=0.28", - "click >= 4.0" - ], - extras_require={ - 'resvg-wasi': ['resvg-wasi'], - }, - packages=["svg_flatten_wasi"], - package_data={"svg_flatten_wasi": [ - "*.wasm", - ]}, - entry_points={ - "console_scripts": [ - "wasi-svg-flatten = svg_flatten_wasi:run_svg_flatten", - ], - }, - project_urls={ - "Source Code": "https://git.jaseg.de/gerbolyze", - "Bug Tracker": "https://github.com/jaseg/gerbolyze/issues", - }, - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Environment :: Console', - "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)", - 'Topic :: Utilities' - ], -) diff --git a/svg-flatten/svg-flatten-wasi-ci.yml b/svg-flatten/svg-flatten-wasi-ci.yml index dfca567..e3e14a6 100644 --- a/svg-flatten/svg-flatten-wasi-ci.yml +++ b/svg-flatten/svg-flatten-wasi-ci.yml @@ -6,8 +6,7 @@ build:svg-flatten-wasi: - git config --global --add safe.directory "$CI_PROJECT_DIR" - cd svg-flatten # we start out in the repo's root - make -j 2 build/svg-flatten.wasm - - cp build/svg-flatten.wasm svg_flatten_wasi/ - - python3 setup.py bdist_wheel + - uv build - cd .. artifacts: name: "gerbolyze-$CI_COMMIT_REF_NAME-svg-flatten-wasi" @@ -21,7 +20,6 @@ publish:svg-flatten-wasi: image: "registry.gitlab.com/gerbolyze/build-containers/archlinux:latest" cache: {} script: - - pip install -U --user --break-system-packages twine - export TWINE_USERNAME TWINE_PASSWORD - twine upload svg-flatten/dist/* dependencies: diff --git a/svg-flatten/svg_flatten_wasi/__init__.py b/svg-flatten/svg_flatten_wasi/__init__.py index 85d5657..b9c543d 100644 --- a/svg-flatten/svg_flatten_wasi/__init__.py +++ b/svg-flatten/svg_flatten_wasi/__init__.py @@ -9,11 +9,7 @@ from pathlib import Path import hashlib import lzma import appdirs -from importlib import resources as importlib_resources -try: - importlib_resources.files # py3.9+ stdlib -except AttributeError: - import importlib_resources # py3.8- shim +from importlib.resources import files as package_files # ============================== @@ -33,7 +29,9 @@ except AttributeError: def _run_wasm_app(wasm_filename, argv, cachedir="svg-flatten-wasi"): - module_binary = importlib_resources.read_binary(__package__, wasm_filename) + print('foo') + module_binary = package_files(__package__).joinpath(wasm_filename).read_binary() + print('bar') module_path_digest = hashlib.sha256(__file__.encode()).hexdigest() module_digest = hashlib.sha256(module_binary).hexdigest() diff --git a/svg-flatten/uv.lock b/svg-flatten/uv.lock new file mode 100644 index 0000000..e93acce --- /dev/null +++ b/svg-flatten/uv.lock @@ -0,0 +1,89 @@ +version = 1 +revision = 3 +requires-python = ">=3.12" + +[[package]] +name = "appdirs" +version = "1.4.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d7/d8/05696357e0311f5b5c316d7b95f46c669dd9c15aaeecbb48c7d0aeb88c40/appdirs-1.4.4.tar.gz", hash = "sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41", size = 13470, upload-time = "2020-05-11T07:59:51.037Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/3b/00/2344469e2084fb287c2e0b57b72910309874c3245463acd6cf5e3db69324/appdirs-1.4.4-py2.py3-none-any.whl", hash = "sha256:a841dacd6b99318a741b166adb07e19ee71a274450e68237b4650ca1055ab128", size = 9566, upload-time = "2020-05-11T07:59:49.499Z" }, +] + +[[package]] +name = "click" +version = "8.3.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "colorama", marker = "sys_platform == 'win32'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/3d/fa/656b739db8587d7b5dfa22e22ed02566950fbfbcdc20311993483657a5c0/click-8.3.1.tar.gz", hash = "sha256:12ff4785d337a1bb490bb7e9c2b1ee5da3112e94a8622f26a6c77f5d2fc6842a", size = 295065, upload-time = "2025-11-15T20:45:42.706Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/98/78/01c019cdb5d6498122777c1a43056ebb3ebfeef2076d9d026bfe15583b2b/click-8.3.1-py3-none-any.whl", hash = "sha256:981153a64e25f12d547d3426c367a4857371575ee7ad18df2a6183ab0545b2a6", size = 108274, upload-time = "2025-11-15T20:45:41.139Z" }, +] + +[[package]] +name = "colorama" +version = "0.4.6" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697, upload-time = "2022-10-25T02:36:22.414Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" }, +] + +[[package]] +name = "resvg-wasi" +version = "0.47.0.post1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "appdirs" }, + { name = "click" }, + { name = "wasmtime" }, +] +wheels = [ + { url = "https://files.pythonhosted.org/packages/f9/04/1e3b94bb5623319728f7ec1ef89f8b7fe2edc568b7dd55f0b15c1da8e018/resvg_wasi-0.47.0.post1-py3-none-any.whl", hash = "sha256:8c5e657b4f177b92764c0c0e8368df05010d1aca4badd65eecf6ff008fc48a1b", size = 1657274, upload-time = "2026-03-10T17:28:27.384Z" }, +] + +[[package]] +name = "svg-flatten-wasi" +version = "3.1.9" +source = { editable = "." } +dependencies = [ + { name = "appdirs" }, + { name = "click" }, + { name = "wasmtime" }, +] + +[package.optional-dependencies] +resvg-wasi = [ + { name = "resvg-wasi" }, +] + +[package.metadata] +requires-dist = [ + { name = "appdirs", specifier = "~=1.4.4" }, + { name = "click", specifier = ">=8.3.0" }, + { name = "resvg-wasi", marker = "extra == 'resvg-wasi'", specifier = ">=0.47.0" }, + { name = "wasmtime", specifier = ">=42.0.0" }, +] +provides-extras = ["resvg-wasi"] + +[[package]] +name = "wasmtime" +version = "42.0.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/54/cd/1f110419ed006f91624010f4df4da82490220bd5527650284c97fc758a6c/wasmtime-42.0.0.tar.gz", hash = "sha256:90485655d6e541b817a7baa1b3071b4525d03f76bcb6ad04661774f06a3b02d4", size = 117133, upload-time = "2026-02-24T19:12:53.321Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/20/cb/f206f7a839d6843b01c041000056bf7aad23cf72fe2333a0c5dad144e0f2/wasmtime-42.0.0-py3-none-android_26_arm64_v8a.whl", hash = "sha256:214e7d294ce1b5adb94f09a870a2ab6759173dc0194bdde74ee4492b477d8392", size = 6829706, upload-time = "2026-02-24T19:12:36.637Z" }, + { url = "https://files.pythonhosted.org/packages/2d/97/d4f5f46eef74e013c3a0caa9b8625bb1c4162e2b9817258596ee6932c019/wasmtime-42.0.0-py3-none-android_26_x86_64.whl", hash = "sha256:cdd9710fad242dde7cb0eacbe48bf902bb1bac6ecbecd3e743c31af463a795c6", size = 7699640, upload-time = "2026-02-24T19:12:38.471Z" }, + { url = "https://files.pythonhosted.org/packages/c6/d2/5b2bf901b0a9b8050d966dff61e353de7cd86dd58679a79e48372ff8b3a6/wasmtime-42.0.0-py3-none-any.whl", hash = "sha256:7a166bd262608806f3295343fcd07ee3e037f931f6d3b0a24ab1cfc7ccc3e8eb", size = 6403639, upload-time = "2026-02-24T19:12:39.777Z" }, + { url = "https://files.pythonhosted.org/packages/3c/6f/a40322bdd55809441bab7e1ac707aa38ced3572904a700f1dfb4b2520dcd/wasmtime-42.0.0-py3-none-macosx_10_13_x86_64.whl", hash = "sha256:21e3dafd74704de0e7ed7668ab76cc5a9df130b4306befbfcb08ddb29673c784", size = 7483525, upload-time = "2026-02-24T19:12:41.422Z" }, + { url = "https://files.pythonhosted.org/packages/47/04/ef61af9fe9e5c0a8d782c8662302535ee6e6dba1a6929191fa3ea371a491/wasmtime-42.0.0-py3-none-macosx_11_0_arm64.whl", hash = "sha256:411bf05df47c8a36c6b31b6012720ac1251b95fdd155e389b25eb6fbbd7e181c", size = 6493225, upload-time = "2026-02-24T19:12:42.9Z" }, + { url = "https://files.pythonhosted.org/packages/44/54/a774313c19c1c0ae2c1897af697c12178904d67911f42c4a9bdddba68640/wasmtime-42.0.0-py3-none-manylinux1_x86_64.whl", hash = "sha256:ca12269ee88aac6b1f64b5f324abf3c6370ff853338d991292f10cb17b906667", size = 7740997, upload-time = "2026-02-24T19:12:44.453Z" }, + { url = "https://files.pythonhosted.org/packages/ed/5d/fae28526b1d42f0365e4fd6c2a212c7c000e47d7320632018fa45735a06e/wasmtime-42.0.0-py3-none-manylinux2014_aarch64.whl", hash = "sha256:78f9353b9fdc2f6e7ed13e28ce0394533f5a62710b75c00434ac82681f738924", size = 6785820, upload-time = "2026-02-24T19:12:45.777Z" }, + { url = "https://files.pythonhosted.org/packages/a3/ae/5c5e96273a36c70753e8ba4db323dd9b1ccf6fcea4ccad99d458ad2ecf13/wasmtime-42.0.0-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:ba317e879aab71c407e7012f4dc10b221c6daf737496c501005612e11d26e8ee", size = 6810021, upload-time = "2026-02-24T19:12:47.453Z" }, + { url = "https://files.pythonhosted.org/packages/46/68/5c129389f67219a90c3ba0dcf85555249bde9797760f2d715bec03bc198a/wasmtime-42.0.0-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:e9ef6dbd1a2cff21694ba64f27b90a7ab0af61a54d911a59682005830683dc8a", size = 7779984, upload-time = "2026-02-24T19:12:48.642Z" }, + { url = "https://files.pythonhosted.org/packages/9a/e5/6650c9e7ad904c9a6730c4b762b1dfed4f7d7b0e981e3624a6ecd7abb7ed/wasmtime-42.0.0-py3-none-win_amd64.whl", hash = "sha256:3a360a1285457021efe24369490cd719996596f2cbe1aa62dae6ad68179cf0f9", size = 6403647, upload-time = "2026-02-24T19:12:50.373Z" }, + { url = "https://files.pythonhosted.org/packages/44/b2/e93046661deef4d8fee2f40080a28e5ff201cc98d4fb1929a46367c34778/wasmtime-42.0.0-py3-none-win_arm64.whl", hash = "sha256:8caa13a6ee264969449c008da1dcb8f9f6c954800853527714e7fcddbdda9166", size = 5397896, upload-time = "2026-02-24T19:12:51.639Z" }, +]