diff --git a/.gitignore b/.gitignore index ec3fdbb..f975797 100644 --- a/.gitignore +++ b/.gitignore @@ -212,4 +212,7 @@ fabric.properties rust-project.json .dockerignore -# End of https://www.toptal.com/developers/gitignore/api/intellij,rust-analyzer \ No newline at end of file +# End of https://www.toptal.com/developers/gitignore/api/intellij,rust-analyzer +# build artifacts +/dist-pypi/ +*.whl diff --git a/pypi/kingfisher/_version.py b/pypi/kingfisher/_version.py index 6c8e6b9..10aa336 100644 --- a/pypi/kingfisher/_version.py +++ b/pypi/kingfisher/_version.py @@ -1 +1 @@ -__version__ = "0.0.0" +__version__ = "1.2.3" diff --git a/pypi/pyproject.toml b/pypi/pyproject.toml index 4f8bee4..f485a2e 100644 --- a/pypi/pyproject.toml +++ b/pypi/pyproject.toml @@ -29,6 +29,7 @@ kingfisher = "kingfisher:main" path = "kingfisher/_version.py" [tool.hatch.build] +ignore-vcs = true include = [ "kingfisher/**/*.py", "kingfisher/bin/*", @@ -38,6 +39,5 @@ include = [ [tool.hatch.build.targets.wheel] only-include = [ "kingfisher", - "kingfisher/bin", "README.md", ] diff --git a/scripts/build-pypi-wheel.sh b/scripts/build-pypi-wheel.sh index 2705886..ea797bb 100755 --- a/scripts/build-pypi-wheel.sh +++ b/scripts/build-pypi-wheel.sh @@ -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" <