forked from mirrors/kingfisher
initial support for distribution via pypi wheels
This commit is contained in:
parent
3294b2baf7
commit
1c3ea6cb22
4 changed files with 51 additions and 7 deletions
|
|
@ -51,17 +51,53 @@ while [[ $# -gt 0 ]]; do
|
|||
esac
|
||||
done
|
||||
|
||||
if [[ -z "$binary_path" || -z "$version" || -z "$plat_name" ]]; then
|
||||
usage
|
||||
PYTHON="${PYTHON:-}"
|
||||
|
||||
if [[ -z "${PYTHON}" ]]; then
|
||||
if command -v python >/dev/null 2>&1; then
|
||||
PYTHON="python"
|
||||
elif command -v python3 >/dev/null 2>&1; then
|
||||
PYTHON="python3"
|
||||
else
|
||||
echo "Python not found. Install Python 3 (or set PYTHON=/path/to/python3)." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Ensure build module exists
|
||||
"$PYTHON" -m build --version >/dev/null 2>&1 || {
|
||||
echo "Installing Python build backend (build)..." >&2
|
||||
"$PYTHON" -m pip install -U build >/dev/null
|
||||
}
|
||||
|
||||
|
||||
# Resolve binary_path to an absolute, normalized path (works without realpath)
|
||||
if [[ -z "$binary_path" ]]; then
|
||||
echo "Missing --binary" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$binary_path" != /* ]]; then
|
||||
# interpret relative to the directory where the user invoked the script
|
||||
binary_path="$PWD/$binary_path"
|
||||
fi
|
||||
|
||||
# Normalize path and verify it exists
|
||||
if ! binary_path="$(cd "$(dirname "$binary_path")" && pwd)/$(basename "$binary_path")"; then
|
||||
echo "Failed to resolve binary path: $binary_path" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "$binary_path" ]]; then
|
||||
echo "Binary not found: $binary_path" >&2
|
||||
echo "Tip: check for typos (e.g. 'kiingfisher' vs 'kingfisher')." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
root_dir="$(git rev-parse --show-toplevel)"
|
||||
cd "$root_dir"
|
||||
|
||||
pkg_dir="$root_dir/pypi"
|
||||
bin_dir="$pkg_dir/kingfisher/bin"
|
||||
|
||||
|
|
@ -74,15 +110,20 @@ fi
|
|||
|
||||
cp "$binary_path" "$bin_dir/$binary_name"
|
||||
chmod +x "$bin_dir/$binary_name" || true
|
||||
test -x "$bin_dir/$binary_name" || {
|
||||
echo "Binary copy failed: $bin_dir/$binary_name" >&2
|
||||
exit 1
|
||||
}
|
||||
ls -la "$bin_dir/$binary_name"
|
||||
|
||||
|
||||
cat > "$pkg_dir/kingfisher/_version.py" <<EOF
|
||||
__version__ = "$version"
|
||||
EOF
|
||||
|
||||
python -m build \
|
||||
"$PYTHON" -m build \
|
||||
--wheel \
|
||||
--outdir "$out_dir" \
|
||||
--config-setting "--plat-name=$plat_name" \
|
||||
"$pkg_dir"
|
||||
|
||||
echo "Built wheel(s) in $out_dir"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue