diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 003e99ab..99d9437c 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -29,7 +29,11 @@ jobs: - name: Test wheel contents before upload run: | - pip install 'mhkit[all]' --no-index --find-links dist/ + # Install the built wheel from dist/ to verify it was packaged correctly before upload + # --find-links dist/ tells pip to look in dist/ directory first and prefer the wheel + # Dependencies (numpy, pandas, etc.) are fetched from PyPI as normal + # This verifies the wheel contains all necessary files and can be installed successfully + pip install 'mhkit[all]' --find-links dist/ python -c "from mhkit import wave, river, tidal, dolfyn, power, loads, mooring, acoustics, qc, utils; print('All modules imported successfully')" - name: Upload to Test PyPI diff --git a/.github/workflows/test-wheel-build.yml b/.github/workflows/test-wheel-build.yml new file mode 100644 index 00000000..59e316bc --- /dev/null +++ b/.github/workflows/test-wheel-build.yml @@ -0,0 +1,43 @@ +# Tests that the package can be built and installed from a wheel +# Runs on PRs to catch build issues before merging to main +# Does NOT publish to PyPI + +name: Test PIP Package Build + +on: + pull_request: + branches: + - main + - develop + +jobs: + test-build: + name: Test wheel build + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.10', '3.11', '3.12'] + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install build tools + run: python -m pip install build --user + + - name: Build wheel and source distribution + run: python -m build --sdist --wheel --outdir dist/ . + + - name: Test wheel installation + run: | + # Install the built wheel from dist/ to verify it was packaged correctly + # --find-links dist/ tells pip to look in dist/ directory first and prefer the wheel + # Dependencies (numpy, pandas, etc.) are fetched from PyPI as normal + # This verifies the wheel contains all necessary files and can be installed successfully + pip install 'mhkit[all]' --find-links dist/ + python -c "from mhkit import wave, river, tidal, dolfyn, power, loads, mooring, acoustics, qc, utils; print('All modules imported successfully')"