feat: Add Ruff linting, pre-commit hooks, and build scripts
- Configure Ruff for linting and formatting with pre-commit hooks - Add Makefile with convenient commands for development workflow - Create build and upload scripts for Gitea package registry - Update README with documentation for new features - Fix code quality issues identified by Ruff - Add development dependencies (ruff, pre-commit) to pyproject.toml - Update Python version requirement to >=3.9 - Add template for Gitea PyPI configuration - Bump version to 0.3.0 - All tests passing and code properly formatted
This commit is contained in:
Executable
+68
@@ -0,0 +1,68 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script to build and upload Python package to Gitea PyPI registry
|
||||
# Usage: ./scripts/build_and_upload.sh
|
||||
|
||||
set -e # Exit on any error
|
||||
|
||||
echo "=== Building and Uploading Package to Gitea ==="
|
||||
|
||||
# Create scripts directory if it doesn't exist
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
||||
cd "$PROJECT_ROOT"
|
||||
|
||||
# Check if we're in the right directory
|
||||
if [[ ! -f "pyproject.toml" ]]; then
|
||||
echo "Error: pyproject.toml not found. Please run this script from the project root."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Install twine if not already installed
|
||||
if ! command -v twine &> /dev/null; then
|
||||
echo "Installing twine..."
|
||||
uv pip install twine
|
||||
fi
|
||||
|
||||
# Clean previous builds
|
||||
echo "Cleaning previous builds..."
|
||||
rm -rf dist/
|
||||
|
||||
# Build the package
|
||||
echo "Building package..."
|
||||
uv build
|
||||
|
||||
# Check if build was successful
|
||||
if [[ ! -d "dist" ]] || [[ -z "$(ls -A dist)" ]]; then
|
||||
echo "Error: Build failed or no files created in dist/"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Build successful. Files created:"
|
||||
ls -la dist/
|
||||
|
||||
# Upload to Gitea PyPI registry
|
||||
echo "Uploading to Gitea PyPI registry..."
|
||||
echo "Note: You need to have ~/.pypirc configured with Gitea credentials"
|
||||
echo "See: https://docs.gitea.com/usage/packages/pypi"
|
||||
|
||||
# Check if .pypirc exists
|
||||
if [[ ! -f "$HOME/.pypirc" ]]; then
|
||||
echo "Warning: ~/.pypirc not found. Please create it with your Gitea credentials:"
|
||||
echo ""
|
||||
echo "[distutils]"
|
||||
echo "index-servers = gitea"
|
||||
echo ""
|
||||
echo "[gitea]"
|
||||
echo "repository = https://gitea.parano.ch/api/packages/herel/pypi"
|
||||
echo "username = herel"
|
||||
echo "password = YOUR_GITEA_TOKEN"
|
||||
echo ""
|
||||
echo "Replace YOUR_GITEA_TOKEN with a personal access token from Gitea."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Upload using twine
|
||||
twine upload --repository gitea dist/*
|
||||
|
||||
echo "Package uploaded successfully to Gitea!"
|
||||
Reference in New Issue
Block a user