Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,62 @@ jobs:
parallel: true
path-to-lcov: ./coverage.lcov

test-wheel-packaging:
name: Test Built Wheel
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install build dependencies
run: python -m pip install build --user

- name: Build wheel
run: python -m build --wheel --outdir dist/ .

- name: Install MHKiT from built wheel
run: |
# Install from build wheel in dist/ directory, not from PyPI
# -f, --find-links <url> If a URL or path to an html file, then parse for links to archives such as sdist (.tar.gz) or wheel (.whl) files.
# If a local path or file:// URL that's a directory, then look for archives in the directory listing.
pip install 'mhkit[all]' --find-links dist/

- name: Test mhkit submodule imports
run: |
python -c "
import mhkit
print(f'Version: {mhkit.__version__}')

# Test all submodules can be imported
modules = ['wave', 'river', 'tidal', 'dolfyn', 'power', 'loads', 'mooring', 'acoustics', 'qc', 'utils']
for mod in modules:
exec(f'from mhkit import {mod}')
print(f'Successfully imported mhkit.{mod}')

print('All submodules imported successfully!')
"

- name: Verify mhkit package structure
run: |
python -c "
import mhkit
import os

mhkit_path = os.path.dirname(mhkit.__file__)
expected_dirs = ['wave', 'river', 'tidal', 'dolfyn', 'power', 'loads', 'mooring', 'acoustics', 'qc', 'utils']

for d in expected_dirs:
dir_path = os.path.join(mhkit_path, d)
assert os.path.isdir(dir_path), f'Missing submodule directory: {d}'
init_file = os.path.join(dir_path, '__init__.py')
assert os.path.isfile(init_file), f'Missing __init__.py in {d}'

print('Package structure verified!')
"

test-optional-pip-dependencies:
needs: [set-os, prepare-nonhindcast-cache]
runs-on: ubuntu-latest
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ jobs:
- run: python -m pip install build --user
- run: python -m build --sdist --wheel --outdir dist/ .

- name: Test wheel contents before upload
run: |
pip install 'mhkit[all]' --no-index --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
if: github.event_name != 'release' && github.repository_owner == 'MHKiT-Software'
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
2 changes: 1 addition & 1 deletion mhkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

configure_warnings()

__version__ = "v1.0.0"
__version__ = "v1.0.1"

__copyright__ = """
Copyright 2019, Alliance for Sustainable Energy, LLC under the terms of
Expand Down
16 changes: 15 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,22 @@ examples = [
Homepage = "https://github.com/MHKiT-Software/mhkit-python"
Documentation = "https://mhkit-software.github.io/MHKiT"

[tool.setuptools.packages.find]
# This section controls how this python package is built for pip installations
# Getting this section wrong results in an incomplete package that is missing submodules
# This can be tested by simply running python -m build in the root directory
# and then inspecting the generated .tar.gz and .whl files in the dist/ directory
#
# https://setuptools.pypa.io/en/latest/userguide/package_discovery.html#finding-simple-packages
# What this does: (per the above docs):
# - `where = ["."]`: Search for packages starting from the root directory
# - `include = ["mhkit*"]`: Only include packages that match the pattern `mhkit*`
# - this includes `mhkit`, `mhkit.wave`, `mhkit.river`, etc.
# - Setuptools will automatically discover all directories containing `__init__.py` files
where = ["."]
include = ["mhkit*"]

[tool.setuptools]
packages = ["mhkit"]
zip-safe = false
include-package-data = true

Expand Down
Loading