From 33a62b6b8975f10951226612768a1dea3b83b26d Mon Sep 17 00:00:00 2001 From: Ruslan Sivak Date: Mon, 7 Jul 2025 18:53:32 -0400 Subject: [PATCH 1/2] Fixing build --- .github/workflows/publish-to-pypi.yml | 10 +++++++--- .github/workflows/test-build.yml | 8 +++++++- MANIFEST.in | 6 ++++++ 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 MANIFEST.in diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index e25c4dc..284fc56 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -38,8 +38,12 @@ jobs: run: python -m pip install build - name: Build a binary wheel and a source tarball run: python -m build --sdist --wheel --outdir dist/ + - name: Check distribution with twine + run: | + pip install twine + twine check dist/* + ls -la dist/ - name: Publish distribution 📦 to PyPI - uses: pypa/gh-action-pypi-publish@release/v1.8 + uses: pypa/gh-action-pypi-publish@release/v1.12.4 with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} # Use OIDC token as the default password \ No newline at end of file + password: ${{ secrets.PYPI_API_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml index 4eb4d5f..d77cec4 100644 --- a/.github/workflows/test-build.yml +++ b/.github/workflows/test-build.yml @@ -31,7 +31,13 @@ jobs: - name: Build a binary wheel and a source tarball run: python -m build --sdist --wheel --outdir dist/ - name: Check distribution - run: twine check dist/* + run: | + pip install twine + twine check dist/* + echo "Contents of dist directory:" + ls -la dist/ + echo "\nChecking wheel metadata:" + python -c "import zipfile; z = zipfile.ZipFile('dist/'+(import glob, glob.glob('dist/*.whl')[0])[1]); print(z.read(next(f for f in z.namelist() if f.endswith('METADATA'))).decode()[:500])" - name: Upload artifacts uses: actions/upload-artifact@v4 with: diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..6847aef --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,6 @@ +include LICENSE +include README.md +include pyproject.toml +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] +recursive-exclude tests * \ No newline at end of file From 071c0f7f5242df55359ce1709524bba248e683c5 Mon Sep 17 00:00:00 2001 From: Ruslan Sivak Date: Mon, 7 Jul 2025 19:41:38 -0400 Subject: [PATCH 2/2] Fix build --- .github/workflows/test-build.yml | 4 +- test_build_local.sh | 87 ++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 2 deletions(-) create mode 100755 test_build_local.sh diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml index d77cec4..85235ea 100644 --- a/.github/workflows/test-build.yml +++ b/.github/workflows/test-build.yml @@ -36,8 +36,8 @@ jobs: twine check dist/* echo "Contents of dist directory:" ls -la dist/ - echo "\nChecking wheel metadata:" - python -c "import zipfile; z = zipfile.ZipFile('dist/'+(import glob, glob.glob('dist/*.whl')[0])[1]); print(z.read(next(f for f in z.namelist() if f.endswith('METADATA'))).decode()[:500])" + echo -e "\nChecking wheel metadata:" + python -c "import zipfile, glob; whl = glob.glob('dist/*.whl')[0]; z = zipfile.ZipFile(whl); print(z.read([f for f in z.namelist() if f.endswith('METADATA')][0]).decode()[:500])" - name: Upload artifacts uses: actions/upload-artifact@v4 with: diff --git a/test_build_local.sh b/test_build_local.sh new file mode 100755 index 0000000..0a717b8 --- /dev/null +++ b/test_build_local.sh @@ -0,0 +1,87 @@ +#!/bin/bash +# Script to test the build process locally, simulating GitHub Actions + +echo "=== Simulating GitHub Actions Build Process ===" +echo + +# Clean up any existing build artifacts +echo "1. Cleaning build artifacts..." +rm -rf dist/ build/ *.egg-info + +# Install dependencies +echo -e "\n2. Installing dependencies..." +pip install --upgrade pip +pip install -r requirements.txt +pip install -r test-requirements.txt + +# Simulate bump2version (without actually bumping) +echo -e "\n3. Current version in pyproject.toml:" +grep "version = " pyproject.toml + +# Run tests +echo -e "\n4. Running tests..." +python -m unittest discover -s tests || { echo "Tests failed!"; exit 1; } + +# Install build tools +echo -e "\n5. Installing build tools..." +pip install --upgrade build twine + +# Build the package +echo -e "\n6. Building package..." +python -m build --sdist --wheel --outdir dist/ + +# Check with twine +echo -e "\n7. Checking distribution with twine..." +twine check dist/* + +# List dist contents +echo -e "\n8. Contents of dist directory:" +ls -la dist/ + +# Check wheel metadata +echo -e "\n9. Checking wheel metadata:" +python -c "import zipfile, glob; whl = glob.glob('dist/*.whl')[0]; z = zipfile.ZipFile(whl); print(z.read([f for f in z.namelist() if f.endswith('METADATA')][0]).decode()[:500])" + +# Simulate the pypa/gh-action-pypi-publish check +echo -e "\n10. Simulating PyPI publish action check..." +python -c " +import zipfile +import glob +import sys + +wheel_file = glob.glob('dist/*.whl')[0] +print(f'Checking wheel: {wheel_file}') + +with zipfile.ZipFile(wheel_file, 'r') as z: + metadata_files = [f for f in z.namelist() if f.endswith('METADATA')] + if not metadata_files: + print('ERROR: No METADATA file found in wheel!') + sys.exit(1) + + metadata_content = z.read(metadata_files[0]).decode('utf-8') + + # Check for required fields + required_fields = ['Name:', 'Version:'] + missing_fields = [] + + for field in required_fields: + if field not in metadata_content: + missing_fields.append(field) + + if missing_fields: + print(f'ERROR: Missing required fields: {missing_fields}') + print('First 1000 chars of METADATA:') + print(metadata_content[:1000]) + sys.exit(1) + + # Extract name and version + for line in metadata_content.split('\\n'): + if line.startswith('Name:'): + print(f' {line}') + elif line.startswith('Version:'): + print(f' {line}') + + print('✓ Metadata check passed') +" + +echo -e "\n=== Build test complete ===" \ No newline at end of file