Compare commits
1 Commits
zeromq/v4.
...
git-lfs/v3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c57efe15bc |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -19,3 +19,6 @@ capnproto/capnproto/install/
|
||||
|
||||
# built ffmpeg
|
||||
ffmpeg/ffmpeg/install/
|
||||
|
||||
# downloaded git-lfs
|
||||
git-lfs/git_lfs/bin/
|
||||
|
||||
57
git-lfs/build.sh
Executable file
57
git-lfs/build.sh
Executable file
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
|
||||
cd "$DIR"
|
||||
|
||||
VERSION="3.6.1"
|
||||
INSTALL_DIR="$DIR/git_lfs/bin"
|
||||
|
||||
# Idempotent: skip if already present
|
||||
if [ -x "$INSTALL_DIR/git-lfs" ]; then
|
||||
echo "git-lfs already present, skipping download."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
OS="$(uname -s)"
|
||||
ARCH="$(uname -m)"
|
||||
|
||||
case "${OS}-${ARCH}" in
|
||||
Linux-x86_64) PLATFORM="linux-amd64" ; EXT="tar.gz" ;;
|
||||
Linux-aarch64) PLATFORM="linux-arm64" ; EXT="tar.gz" ;;
|
||||
Darwin-arm64) PLATFORM="darwin-arm64" ; EXT="zip" ;;
|
||||
*)
|
||||
echo "Unsupported platform: ${OS}-${ARCH}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
FILENAME="git-lfs-${PLATFORM}-v${VERSION}.${EXT}"
|
||||
URL="https://github.com/git-lfs/git-lfs/releases/download/v${VERSION}/${FILENAME}"
|
||||
|
||||
echo "Downloading $FILENAME ..."
|
||||
curl -fSL -o "$FILENAME" "$URL"
|
||||
|
||||
echo "Extracting ..."
|
||||
mkdir -p "$INSTALL_DIR"
|
||||
if [ "$EXT" = "zip" ]; then
|
||||
python3 -c "
|
||||
import zipfile, sys
|
||||
with zipfile.ZipFile('$FILENAME') as zf:
|
||||
for info in zf.infolist():
|
||||
if info.filename.endswith('/git-lfs'):
|
||||
with open('$INSTALL_DIR/git-lfs', 'wb') as f:
|
||||
f.write(zf.read(info))
|
||||
break
|
||||
"
|
||||
else
|
||||
tar --strip-components=1 -xzf "$FILENAME" -C "$INSTALL_DIR" --wildcards '*/git-lfs'
|
||||
fi
|
||||
|
||||
chmod +x "$INSTALL_DIR/git-lfs"
|
||||
strip "$INSTALL_DIR/git-lfs" 2>/dev/null || true
|
||||
|
||||
rm -f "$FILENAME"
|
||||
|
||||
echo "Installed git-lfs to $INSTALL_DIR"
|
||||
du -sh "$INSTALL_DIR"
|
||||
15
git-lfs/git_lfs/__init__.py
Normal file
15
git-lfs/git_lfs/__init__.py
Normal file
@@ -0,0 +1,15 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
BIN_DIR = os.path.join(os.path.dirname(__file__), "bin")
|
||||
|
||||
|
||||
def _run():
|
||||
binary = os.path.join(BIN_DIR, "git-lfs")
|
||||
os.execvp(binary, [binary] + sys.argv[1:])
|
||||
|
||||
|
||||
def smoketest():
|
||||
import subprocess
|
||||
binary = os.path.join(BIN_DIR, "git-lfs")
|
||||
subprocess.run([binary, "--version"], check=True)
|
||||
18
git-lfs/pyproject.toml
Normal file
18
git-lfs/pyproject.toml
Normal file
@@ -0,0 +1,18 @@
|
||||
[build-system]
|
||||
requires = ["setuptools>=64", "wheel"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "git-lfs"
|
||||
version = "3.6.1"
|
||||
description = "Git Large File Storage extension"
|
||||
requires-python = ">=3.8"
|
||||
|
||||
[project.scripts]
|
||||
git-lfs = "git_lfs:_run"
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
include = ["git_lfs*"]
|
||||
|
||||
[tool.setuptools.package-data]
|
||||
git_lfs = ["bin/**/*"]
|
||||
61
git-lfs/setup.py
Normal file
61
git-lfs/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 BuildGitLfs(build_py):
|
||||
"""Run build.sh to download git-lfs before collecting package data."""
|
||||
|
||||
def run(self):
|
||||
pkg_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
marker = os.path.join(pkg_dir, "git_lfs", "bin", "git-lfs")
|
||||
|
||||
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": BuildGitLfs}
|
||||
|
||||
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()
|
||||
Reference in New Issue
Block a user