add nanosvg package (#50)
This commit is contained in:
3
build.sh
3
build.sh
@@ -34,6 +34,9 @@ fi
|
|||||||
if [[ -n "${BUILD_SH_IN_MANYLINUX:-}" ]]; then
|
if [[ -n "${BUILD_SH_IN_MANYLINUX:-}" ]]; then
|
||||||
export PATH="/opt/python/cp312-cp312/bin:$PATH"
|
export PATH="/opt/python/cp312-cp312/bin:$PATH"
|
||||||
|
|
||||||
|
# cached *-src repos may be owned by the host runner user; tell git to trust them
|
||||||
|
git config --global --add safe.directory '*'
|
||||||
|
|
||||||
./setup.sh
|
./setup.sh
|
||||||
|
|
||||||
if [[ -z "${BUILD_SH_REUSE_MANYLINUX_ARTIFACTS:-}" ]]; then
|
if [[ -z "${BUILD_SH_REUSE_MANYLINUX_ARTIFACTS:-}" ]]; then
|
||||||
|
|||||||
25
nanosvg/build.sh
Executable file
25
nanosvg/build.sh
Executable file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
COMMIT="5cefd9847949af6df13f65027fd43af5a7513633"
|
||||||
|
INSTALL_DIR="$DIR/nanosvg/install"
|
||||||
|
|
||||||
|
# Clone/update source
|
||||||
|
if [ ! -d "nanosvg-src/.git" ]; then
|
||||||
|
rm -rf nanosvg-src
|
||||||
|
git clone --depth 1 https://github.com/memononen/nanosvg.git nanosvg-src
|
||||||
|
fi
|
||||||
|
git -C nanosvg-src fetch --depth 1 origin "$COMMIT"
|
||||||
|
git -C nanosvg-src checkout --force FETCH_HEAD
|
||||||
|
|
||||||
|
# Copy headers
|
||||||
|
rm -rf "$INSTALL_DIR"
|
||||||
|
mkdir -p "$INSTALL_DIR/include"
|
||||||
|
cp nanosvg-src/src/nanosvg.h "$INSTALL_DIR/include/"
|
||||||
|
cp nanosvg-src/src/nanosvgrast.h "$INSTALL_DIR/include/"
|
||||||
|
|
||||||
|
echo "Installed nanosvg to $INSTALL_DIR"
|
||||||
|
du -sh "$INSTALL_DIR"
|
||||||
10
nanosvg/nanosvg/__init__.py
Normal file
10
nanosvg/nanosvg/__init__.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
DIR = os.path.join(os.path.dirname(__file__), "install")
|
||||||
|
INCLUDE_DIR = os.path.join(DIR, "include")
|
||||||
|
LIB_DIR = DIR # header-only; no libraries
|
||||||
|
|
||||||
|
|
||||||
|
def smoketest():
|
||||||
|
assert os.path.isfile(os.path.join(INCLUDE_DIR, "nanosvg.h")), "nanosvg.h not found"
|
||||||
|
assert os.path.isfile(os.path.join(INCLUDE_DIR, "nanosvgrast.h")), "nanosvgrast.h not found"
|
||||||
15
nanosvg/pyproject.toml
Normal file
15
nanosvg/pyproject.toml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
[build-system]
|
||||||
|
requires = ["setuptools>=64", "wheel"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "nanosvg"
|
||||||
|
version = "0.0.1"
|
||||||
|
description = "NanoSVG: simple SVG parser and rasterizer"
|
||||||
|
requires-python = ">=3.8"
|
||||||
|
|
||||||
|
[tool.setuptools.packages.find]
|
||||||
|
include = ["nanosvg*"]
|
||||||
|
|
||||||
|
[tool.setuptools.package-data]
|
||||||
|
nanosvg = ["install/**/*"]
|
||||||
58
nanosvg/setup.py
Normal file
58
nanosvg/setup.py
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
import os
|
||||||
|
import platform
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
from setuptools.command.build_py import build_py
|
||||||
|
|
||||||
|
try:
|
||||||
|
from wheel.bdist_wheel import bdist_wheel
|
||||||
|
except ImportError:
|
||||||
|
bdist_wheel = None
|
||||||
|
|
||||||
|
|
||||||
|
class BuildNanosvg(build_py):
|
||||||
|
"""Run build.sh to download nanosvg headers before collecting package data."""
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
pkg_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
build_script = os.path.join(pkg_dir, "build.sh")
|
||||||
|
subprocess.check_call(["bash", build_script], cwd=pkg_dir)
|
||||||
|
|
||||||
|
super().run()
|
||||||
|
|
||||||
|
|
||||||
|
cmdclass = {"build_py": BuildNanosvg}
|
||||||
|
|
||||||
|
if bdist_wheel is not None:
|
||||||
|
|
||||||
|
class PlatformWheel(bdist_wheel):
|
||||||
|
"""Produce a platform-specific, Python-version-agnostic wheel."""
|
||||||
|
|
||||||
|
def finalize_options(self):
|
||||||
|
super().finalize_options()
|
||||||
|
self.root_is_pure = False
|
||||||
|
|
||||||
|
def get_tag(self):
|
||||||
|
system = platform.system()
|
||||||
|
machine = platform.machine()
|
||||||
|
|
||||||
|
if system == "Linux":
|
||||||
|
plat = f"linux_{machine}"
|
||||||
|
elif system == "Darwin":
|
||||||
|
plat = "macosx_11_0_arm64"
|
||||||
|
else:
|
||||||
|
plat = f"{system.lower()}_{machine}"
|
||||||
|
|
||||||
|
return "py3", "none", plat
|
||||||
|
|
||||||
|
cmdclass["bdist_wheel"] = PlatformWheel
|
||||||
|
|
||||||
|
|
||||||
|
def setup():
|
||||||
|
from setuptools import setup as _setup
|
||||||
|
|
||||||
|
_setup(cmdclass=cmdclass)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
setup()
|
||||||
@@ -11,6 +11,7 @@ members = [
|
|||||||
"json11",
|
"json11",
|
||||||
"libjpeg",
|
"libjpeg",
|
||||||
"libyuv",
|
"libyuv",
|
||||||
|
"nanosvg",
|
||||||
"ncurses",
|
"ncurses",
|
||||||
"python3-dev",
|
"python3-dev",
|
||||||
"raylib",
|
"raylib",
|
||||||
|
|||||||
Reference in New Issue
Block a user