add zstd and ncurses packages (#14)
This commit is contained in:
73
ncurses/build.sh
Executable file
73
ncurses/build.sh
Executable file
@@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
|
||||
cd "$DIR"
|
||||
|
||||
VERSION="6.5"
|
||||
INSTALL_DIR="$DIR/ncurses/install"
|
||||
|
||||
# Idempotent: skip if already built
|
||||
if [ -f "$INSTALL_DIR/lib/libncurses.a" ]; then
|
||||
echo "ncurses already present, skipping build."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
NJOBS="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2)"
|
||||
|
||||
# Download
|
||||
TARBALL="ncurses-${VERSION}.tar.gz"
|
||||
if [ ! -f "$TARBALL" ]; then
|
||||
curl -fsSL "https://ftp.gnu.org/gnu/ncurses/${TARBALL}" -o "$TARBALL"
|
||||
fi
|
||||
|
||||
# Extract
|
||||
if [ ! -d "ncurses-${VERSION}" ]; then
|
||||
tar xf "$TARBALL"
|
||||
fi
|
||||
|
||||
# Build
|
||||
PREFIX="$DIR/build/prefix"
|
||||
mkdir -p "$DIR/build"
|
||||
|
||||
cd "ncurses-${VERSION}"
|
||||
./configure \
|
||||
--prefix="$PREFIX" \
|
||||
--without-shared \
|
||||
--with-normal \
|
||||
--without-debug \
|
||||
--without-cxx \
|
||||
--without-cxx-binding \
|
||||
--without-ada \
|
||||
--without-manpages \
|
||||
--without-progs \
|
||||
--without-tests \
|
||||
--without-dlsym \
|
||||
--enable-overwrite
|
||||
|
||||
make -j"$NJOBS"
|
||||
# Only install libs and headers; skip terminfo database (fails on macOS CI)
|
||||
make install.libs install.includes
|
||||
cd "$DIR"
|
||||
|
||||
# Copy to package install dir
|
||||
rm -rf "$INSTALL_DIR"
|
||||
mkdir -p "$INSTALL_DIR"/{lib,include}
|
||||
|
||||
# Libraries (ncurses 6.x builds wide-char by default; provide as libncurses.a)
|
||||
cp "$PREFIX/lib/libncursesw.a" "$INSTALL_DIR/lib/libncurses.a" 2>/dev/null \
|
||||
|| cp "$PREFIX/lib/libncurses.a" "$INSTALL_DIR/lib/"
|
||||
|
||||
# Headers (--enable-overwrite puts them directly in include/)
|
||||
cp "$PREFIX/include/ncurses.h" "$INSTALL_DIR/include/"
|
||||
cp "$PREFIX/include/curses.h" "$INSTALL_DIR/include/"
|
||||
cp "$PREFIX/include/ncurses_dll.h" "$INSTALL_DIR/include/"
|
||||
cp "$PREFIX/include/unctrl.h" "$INSTALL_DIR/include/"
|
||||
cp "$PREFIX/include/term.h" "$INSTALL_DIR/include/"
|
||||
cp "$PREFIX/include/termcap.h" "$INSTALL_DIR/include/"
|
||||
|
||||
# Clean up
|
||||
rm -rf "ncurses-${VERSION}" "$TARBALL" "$DIR/build"
|
||||
|
||||
echo "Installed ncurses to $INSTALL_DIR"
|
||||
du -sh "$INSTALL_DIR"
|
||||
10
ncurses/ncurses/__init__.py
Normal file
10
ncurses/ncurses/__init__.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import os
|
||||
|
||||
DIR = os.path.join(os.path.dirname(__file__), "install")
|
||||
LIB_DIR = os.path.join(DIR, "lib")
|
||||
INCLUDE_DIR = os.path.join(DIR, "include")
|
||||
|
||||
|
||||
def smoketest():
|
||||
assert os.path.isfile(os.path.join(LIB_DIR, "libncurses.a")), "libncurses.a not found"
|
||||
assert os.path.isfile(os.path.join(INCLUDE_DIR, "ncurses.h")), "ncurses.h not found"
|
||||
15
ncurses/pyproject.toml
Normal file
15
ncurses/pyproject.toml
Normal file
@@ -0,0 +1,15 @@
|
||||
[build-system]
|
||||
requires = ["setuptools>=64", "wheel"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "ncurses"
|
||||
version = "6.5"
|
||||
description = "ncurses terminal library (static build)"
|
||||
requires-python = ">=3.8"
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
include = ["ncurses*"]
|
||||
|
||||
[tool.setuptools.package-data]
|
||||
ncurses = ["install/**/*"]
|
||||
61
ncurses/setup.py
Normal file
61
ncurses/setup.py
Normal file
@@ -0,0 +1,61 @@
|
||||
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 BuildNcurses(build_py):
|
||||
"""Run build.sh to compile ncurses before collecting package data."""
|
||||
|
||||
def run(self):
|
||||
pkg_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
marker = os.path.join(pkg_dir, "ncurses", "install", "lib", "libncurses.a")
|
||||
|
||||
if not os.path.exists(marker):
|
||||
build_script = os.path.join(pkg_dir, "build.sh")
|
||||
subprocess.check_call(["bash", build_script], cwd=pkg_dir)
|
||||
|
||||
super().run()
|
||||
|
||||
|
||||
cmdclass = {"build_py": BuildNcurses}
|
||||
|
||||
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()
|
||||
58
zstd/build.sh
Executable file
58
zstd/build.sh
Executable file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
|
||||
cd "$DIR"
|
||||
|
||||
VERSION="1.5.6"
|
||||
INSTALL_DIR="$DIR/zstd/install"
|
||||
|
||||
# Idempotent: skip if already built
|
||||
if [ -f "$INSTALL_DIR/lib/libzstd.a" ]; then
|
||||
echo "zstd already present, skipping build."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
NJOBS="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2)"
|
||||
|
||||
# Clone
|
||||
if [ ! -d "zstd-src" ]; then
|
||||
git clone --depth 1 --branch "v${VERSION}" https://github.com/facebook/zstd.git zstd-src
|
||||
fi
|
||||
|
||||
# Build
|
||||
PREFIX="$DIR/build/prefix"
|
||||
mkdir -p "$DIR/build"
|
||||
|
||||
cmake -S zstd-src/build/cmake -B "$DIR/build" \
|
||||
-DCMAKE_BUILD_TYPE=MinSizeRel \
|
||||
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
|
||||
-DCMAKE_INSTALL_PREFIX="$PREFIX" \
|
||||
-DCMAKE_INSTALL_LIBDIR=lib \
|
||||
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
|
||||
-DZSTD_BUILD_PROGRAMS=OFF \
|
||||
-DZSTD_BUILD_TESTS=OFF \
|
||||
-DZSTD_BUILD_CONTRIB=OFF \
|
||||
-DZSTD_BUILD_SHARED=OFF \
|
||||
-DZSTD_BUILD_STATIC=ON
|
||||
|
||||
cmake --build "$DIR/build" -j"$NJOBS"
|
||||
cmake --install "$DIR/build"
|
||||
|
||||
# Copy to package install dir
|
||||
rm -rf "$INSTALL_DIR"
|
||||
mkdir -p "$INSTALL_DIR"/{lib,include}
|
||||
|
||||
# Library
|
||||
cp "$PREFIX/lib/libzstd.a" "$INSTALL_DIR/lib/"
|
||||
|
||||
# Headers
|
||||
cp "$PREFIX/include/zstd.h" "$INSTALL_DIR/include/"
|
||||
cp "$PREFIX/include/zstd_errors.h" "$INSTALL_DIR/include/"
|
||||
cp "$PREFIX/include/zdict.h" "$INSTALL_DIR/include/"
|
||||
|
||||
# Clean up
|
||||
rm -rf zstd-src "$DIR/build"
|
||||
|
||||
echo "Installed zstd to $INSTALL_DIR"
|
||||
du -sh "$INSTALL_DIR"
|
||||
15
zstd/pyproject.toml
Normal file
15
zstd/pyproject.toml
Normal file
@@ -0,0 +1,15 @@
|
||||
[build-system]
|
||||
requires = ["setuptools>=64", "wheel"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "zstd"
|
||||
version = "1.5.6"
|
||||
description = "Zstandard compression library (static build)"
|
||||
requires-python = ">=3.8"
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
include = ["zstd*"]
|
||||
|
||||
[tool.setuptools.package-data]
|
||||
zstd = ["install/**/*"]
|
||||
61
zstd/setup.py
Normal file
61
zstd/setup.py
Normal file
@@ -0,0 +1,61 @@
|
||||
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 BuildZstd(build_py):
|
||||
"""Run build.sh to compile zstd before collecting package data."""
|
||||
|
||||
def run(self):
|
||||
pkg_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
marker = os.path.join(pkg_dir, "zstd", "install", "lib", "libzstd.a")
|
||||
|
||||
if not os.path.exists(marker):
|
||||
build_script = os.path.join(pkg_dir, "build.sh")
|
||||
subprocess.check_call(["bash", build_script], cwd=pkg_dir)
|
||||
|
||||
super().run()
|
||||
|
||||
|
||||
cmdclass = {"build_py": BuildZstd}
|
||||
|
||||
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()
|
||||
10
zstd/zstd/__init__.py
Normal file
10
zstd/zstd/__init__.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import os
|
||||
|
||||
DIR = os.path.join(os.path.dirname(__file__), "install")
|
||||
LIB_DIR = os.path.join(DIR, "lib")
|
||||
INCLUDE_DIR = os.path.join(DIR, "include")
|
||||
|
||||
|
||||
def smoketest():
|
||||
assert os.path.isfile(os.path.join(LIB_DIR, "libzstd.a")), "libzstd.a not found"
|
||||
assert os.path.isfile(os.path.join(INCLUDE_DIR, "zstd.h")), "zstd.h not found"
|
||||
Reference in New Issue
Block a user