Skip to content

[All] Several fixes on main branch to pass CI#1554

Open
loumalouomega wants to merge 13 commits into
nschloe:mainfrom
loumalouomega:minor-fixes-main
Open

[All] Several fixes on main branch to pass CI#1554
loumalouomega wants to merge 13 commits into
nschloe:mainfrom
loumalouomega:minor-fixes-main

Conversation

@loumalouomega

@loumalouomega loumalouomega commented Apr 8, 2026

Copy link
Copy Markdown

Description

This PR addresses several critical issues identified in the CI and provides better compatibility with modern environments (NumPy 2.0+) and older Python versions (3.8).

Summary of Changes

1. Fix Windows CI Failure (Python 3.8)

  • Problem: The Windows build for Python 3.8 was failing because pip attempted to build netCDF4 from source, which required HDF5 headers that were missing from the runner.
  • Solution: Modified tox.ini to explicitly list dependencies and use environment markers (netCDF4; sys_platform != "win32" or python_version != "3.8") to skip netCDF4 only in this specific failing environment.

2. NumPy 2.0+ Compatibility

  • Problem: NumPy 2.0 changed the repr() of scalars to include the type (e.g., np.float64(1.23) instead of 1.23). This broke several ASCII file writers that used {!r}, %r, or repr() for formatting, as the resulting files could not be parsed by standard readers.
  • Solution:
    • Updated writers for GMSH, MDPA, DOLFIN, and UGRID to use str() ({!s}, %s) instead of repr().
    • Improved ASCII reading robustness in GMSH and UGRID by replacing np.fromfile(..., sep=" ") with a more reliable readline().split() approach to handle potential whitespace/newline issues.

3. Python 3.8 Compatibility & Modernization

  • Type Hints: Replaced modern | union type hints with typing.Union in several files to maintain compatibility with Python 3.8.
  • Version Discovery: Improved src/meshio/__about__.py to use importlib.metadata (with a fallback to importlib_metadata) more robustly.
  • CLI: Adjusted argparse subparser requirement syntax for better compatibility across Python versions.

4. Linter and CI Updates

  • flake8: Added venv and .tox to the exclusion list in .flake8 to avoid false positives from third-party packages in local development environments.
  • GitHub Actions: Updated the tox command in CI to explicitly select the appropriate environment (py38 or py312).

Verification Results

  • Python 3.8 (Linux): 740 passed, 10 skipped.
  • Python 3.12 (Linux): 740 passed, 10 skipped.
  • Linter: isort, black, and flake8 pass cleanly.
  • NumPy: Verified fix for np.float64 string representation issues in NumPy 2.4.4.

- Replace | with Union in type hints for compatibility with Python < 3.10
- Add missing topological_dimension import in meshio/__init__.py
- Update tox.ini and CI to explicitly use py38 and py312 environments
- Ensure tox uses the correct environment version in GitHub Actions
- Use math.prod in VTK writers (as suggested in code)
- Fix argparse subparser compatibility
- Refine __about__.py version discovery
- General cleanup of type hints and imports
@loumalouomega

Copy link
Copy Markdown
Author

Fantastic, now CI passes, i will try to minimize changes and pass the CI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant