Commit Graph
118 Commits
Author SHA1 Message Date
Håkon Hægland b5e7ccc0b1 Clarify why test case ordering is necessary
and delete comment in code about static variables that can no longer be
reproduced.
2025-09-17 10:06:49 +02:00
Svenn Tveit 67a701ef4f Tests for PyGasWaterSimulator 2025-09-17 10:06:49 +02:00
Svenn Tveit 32dd09c78f Add Python gas-water simulator and refactor to template base class
Extend the Python blackoil simulator to support two-phase gas-water
simulations by extracting common functionality into a template base
class and implementing proper module separation.

- Extract PyBaseSimulator<TypeTag> template base class containing all
  common simulator functionality (20+ methods including advance, run,
  step, property access, and MPI handling)
- Add PyGasWaterSimulator for two-phase gas-water simulations using
  FlowGasWaterProblem TypeTag with oil phase disabled
- Split Python modules to avoid ODR violations:
  - BlackOil.so for PyBlackOilSimulator (FlowProblemTPFA)
  - GasWater.so for PyGasWaterSimulator (FlowGasWaterProblem)
- Implement proper template instantiation control with explicit
  instantiations per module

- Eliminate ~400 lines of code duplication between simulators
- Clean inheritance hierarchy: derived classes contain only constructors
- Type-safe specialization through OPM's TypeTag property system
- Separate docstring generation for each simulator type
- Independent build targets with shared infrastructure

- Update CMakeLists.txt to support multiple pybind11 modules
- Add docstrings_gw_simulators.json for gas-water simulator documentation
- Remove centralized Pybind11Exporter.cpp in favor of distributed exports
- Implement proper build dependencies and custom targets

This establishes a scalable foundation for extending OPM's Python
bindings to support additional simulator types (thermal, polymer,
solvent) while maintaining type safety and avoiding symbol conflicts.

Files changed: 21 files, 915 insertions, 428 deletions
2025-09-17 10:06:44 +02:00
Arne Morten Kvarving b44692349e python packaging: enable LTO 2025-09-15 09:53:25 +02:00
Håkon Hægland 53270c95b6 docker: clean pip usage and drop pytest-runner
- Export PIP_ROOT_USER_ACTION=ignore to silence root-user warning in manylinux.
- Remove pytest-runner from build-time pip installs; no longer needed after
  removing setup_requires.
2025-09-12 17:57:33 +02:00
Håkon Hægland ac490531f1 python/docker: finalize pyproject build-system and SPDX license
- Bump setuptools floor to >=61 in pyproject.toml with rationale comments.
- Declare build-backend explicitly; keep classic scikit-build.
- Switch setup.py license to SPDX expression (GPL-3.0-or-later) and remove
  deprecated license classifier, keeping only non-license classifiers.
2025-09-12 16:06:51 +02:00
Håkon Hægland 31716f2cef docker/python: switch to PEP 517 builds via python -m build
- Replace direct setup.py invocations with: python -m build --sdist --wheel
- Add comments explaining motivation (setuptools deprecations, build isolation)
  and why we drop explicit --plat-name/--python-tag (auditwheel/env handles).
- Ensure the build frontend is present per-interpreter by installing 'build'.

Also add build-backend to pyproject.toml with notes and TODO for full modernization.
2025-09-12 16:00:57 +02:00
Håkon Hægland ce3ee6fc98 python: remove deprecated setup.py args (setuptools warnings)
- Drop legacy setup_requires and test_suite to stop
  setuptools _DeprecatedInstaller / fetch_build_eggs and
  unknown distribution option warnings.
- Add inline comment explaining rationale and PEP 517 context.
2025-09-12 15:42:24 +02:00
Håkon Hægland d5664a5f1c python/docker(test_wheels): prefer hyphenated OS names; accept colon input
- Default --docker-os to ubuntu-22.04
- Normalize input (: -> -) for paths/tags
- Fallback to legacy directories pre-rename
- Update docs with Windows compatibility note
2025-09-12 13:08:40 +02:00
Håkon Hægland bd69d21af8 docker(test_wheels): rename dockerfiles dirs to hyphen (Windows checkout fix)
- debian:11    -> debian-11
- ubuntu:22.04 -> ubuntu-22.04
- ubuntu:24.04 -> ubuntu-24.04

CLI accepts colon or hyphen; code now canonicalizes to hyphen.
2025-09-12 13:06:41 +02:00
Håkon Hægland 922e0c0522 Copy host dir files to container to avoid conflict.
Copy host directory files from opm-simulators/python and
opm-common/python to container to avoid conflict with
opm-simulators/python/opm/ and opm-common/python/opm/ folders when
running "python -m unittest discover" from the python directories.
An alternative would be to rename the opm directories in the host.
2025-09-04 17:15:11 +02:00
Håkon Hægland 9167a35ae4 Add option to use opm python tests folders from host
This will help avoid rebuilding the test containers each time
the host data changes.
2025-09-04 13:25:57 +02:00
Håkon Hægland ec56668d8b Fix path lookup for python_versions.json file 2025-09-04 11:58:17 +02:00
Håkon Hægland 4bc25047c2 Trim white space at EOL 2025-09-04 11:24:05 +02:00
Håkon Hægland be8039a0a8 Add support for version_tag
Add support for adding a version tag to the generated wheels
2025-08-28 11:37:56 +02:00
Håkon Hægland 158ddddca0 Replace head with merge
Don't encourage building PR branches directly
2025-08-28 11:25:25 +02:00
Håkon Hægland 6e2503cac8 Major Python Docker Build System Restructure and Enhancement
Reorganize Python folder: separate Docker/PyPI from CMake/PyBind11 workflows
and implement comprehensive build automation

This commit represents a comprehensive restructuring and enhancement of the
OPM Python build system, addressing maintainability, consistency, and
usability issues through architectural improvements and automation.

FILES CHANGED
=============

Refactored:
- python/Dockerfile -> python/docker/Dockerfile
- python/generate-pypi-package.sh -> python/docker/scripts/generate-pypi-package.sh
- python/setup-docker-image.sh -> python/docker/scripts/setup-docker-image.sh
- python/build-deps.sh -> python/docker/scripts/build-boost.sh
- python/build-deps.sh -> python/docker/scripts/build-dune.sh

Added (24 files):
- python/docker/python_versions.json (single source of truth)
- python/docker/scripts/sync_versions.sh
- python/docker/scripts/read_python_config.py
- python/docker/run-docker-build.sh
- python/docker/README.md
- python/docker/test_wheels/* (complete testing framework)

Modified:
- python/setup.py.in
- .gitignore

MAJOR CHANGES
=============

Architecture Restructure
------------------------
- Separated build workflows: Clearly distinguished Docker/PyPI wheel
  generation from CMake/PyBind11 compilation
- Moved Docker-specific files: Relocated docker build system to
  appropriate locations
- Streamlined organization: Created logical separation between different
  build contexts

Single Source of Truth Configuration
-------------------------------------
- Centralized Python version management: Created python_versions.json as
  authoritative configuration
- Automated synchronization: Built sync_versions.sh script to maintain
  consistency across all components
- Dynamic configuration: Components now read from JSON rather than
  hardcoded values

Enhanced Docker Build System
----------------------------
- Multi-OS support: Added Ubuntu 22.04, Ubuntu 24.04, and Debian 11
  Dockerfiles
- Improved caching: Split dependencies into separate Docker layers for
  better build performance
- Fixed PyPI wheel generation: Added LD_LIBRARY_PATH setup for proper
  library bundling, corrected auditwheel wheel copying from wheelhouse/
  instead of dist/
- Optimized Docker layer structure: Delayed source code copying until
  final stage, preventing dependency rebuilds on source changes and
  reducing iteration time from 30+ to <5 minutes during development

Build Automation & Tooling
--------------------------
- Comprehensive wheel testing: Created opm-wheels CLI tool for building
  and testing Docker images
- Automated validation: Integrated Python version validation and error
  handling
- Enhanced scripts: Improved generate-pypi-package.sh with better error
  handling and version management

Testing Framework
-----------------
- Docker-based testing: Complete framework for testing wheels across
  multiple Python versions and OS configurations
- Automated validation: Wheel installation and import testing with
  comprehensive error reporting
- Multi-version support: Parallel testing across Python 3.8-3.13
- Platform verification: Validates manylinux wheels install and function
  correctly across Ubuntu 22.04/24.04 and Debian 11

Documentation & Usability
-------------------------
- Comprehensive maintenance guides: Detailed instructions for
  adding/removing Python versions
- Clear workflows: Step-by-step procedures for build system maintenance
- Improved CLI experience: Better error messages, path handling, and
  user guidance
- Updated documentation: Enhanced README files with practical examples
  and troubleshooting

IMPACT
======

This restructure transforms the Python build system from a collection of
loosely coupled scripts into a cohesive, maintainable, and reliable build
automation system. The single source of truth configuration eliminates the
primary source of maintenance overhead, while the enhanced testing
framework provides confidence in the quality of generated wheels.

The changes enable the OPM project to more easily support new Python
versions, maintain consistency across platforms, and provide a better
developer experience for both maintainers and users.
2025-08-28 07:24:46 +02:00
Arne Morten Kvarving 4f33fbd598 Merge pull request #6142 from hakonhagland/gen_shared
Allow Dockerfile to generate PyPI package from shared libs
2025-08-22 10:27:15 +02:00
Arne Morten Kvarving 20212094f4 remove python 3.6 and 3.7 packages
these were eol'd in 2021/2023 and have now been removed from the
docker image.

add python 3.13 package
2025-05-09 09:28:36 +02:00
Håkon Hægland ea63ae9cc8 Also build from shared libs
Allow PyPI packages to be built from shared libraries by adding a
build argument to the Dockerfile.
2025-04-03 15:00:02 +02:00
Bård Skaflestad 54663f96a4 Add Missing Headers to Python Simulator
These were originally obtained through transitive includes,
especially from Main.hpp, but that's not a stable condition if the
set of transitive includes changes.
2025-01-30 12:17:39 +01:00
Lisa Julia Nebel 6fecef3fb1 Add missing return type to check_simulation_finished function of BlackOilSimulator 2025-01-14 14:11:09 +01:00
Lisa Julia Nebel 6958abdbc2 Change return type of other _init_ of the BlackOilSimulator class 2025-01-14 10:58:12 +01:00
Lisa Julia Nebel 053fe26eff Change return type of _init_ of the BlackOilSimulator class 2025-01-14 10:32:55 +01:00
Lisa Julia Nebel 016a806a0c Change return type of _init_ of the BlackOilSimulator class 2025-01-14 09:40:54 +01:00
Lisa Julia Nebel 82ba8b4ea5 Fix errors in documentation. 2025-01-08 14:08:41 +01:00
Arne Morten Kvarving 4d5a67fa82 added: ability to pass command line parameters from python 2024-11-28 09:14:53 +01:00
Arne Morten Kvarving 1dd66769cd Merge pull request #5722 from blattms/bugfix/pyhon-licensing
Added the missing plus in gplv3+ for the Python packages.
2024-11-08 12:30:56 +01:00
Markus Blatt 0629a83266 Added the missing plus in gplv3+ for the Python packages. 2024-11-08 12:25:17 +01:00
Arne Morten Kvarving 5085877d4e fixed: building pypi release packages 2024-11-07 12:01:03 +01:00
Arne Morten Kvarving bfc5d6f742 small adjustments to python packaging 2024-10-03 13:13:52 +02:00
Arne Morten Kvarving 2353ba56a6 changed: don't store schedule keywords unless required in simulators
in the python simulator we cannot make this decision up front
since the schedule can be modified from python code so we have
to do the safe thing
2024-09-27 11:24:20 +02:00
Bård Skaflestad 03795d5b23 Merge pull request #5588 from akva2/move_python_initialization_function
Move python initialization function
2024-09-09 14:54:14 +02:00
Arne Morten Kvarving 2a9d81227b changed: subclass Main for python
move the initFlowBlackoil method into it

in particular we then avoid the FlowMainType type alias
in Main.hpp
2024-09-09 14:28:20 +02:00
Arne Morten Kvarving 8ed1149252 fix python package versioning
remove opm-models cloning
build both bindings in one build directory
2024-09-09 12:45:00 +02:00
Arne Morten Kvarving a78337fc33 fixed: make python simulator object depend on copy_python
if not building just the python binding won't end up in
a complete build
2024-09-02 08:21:36 +02:00
Arne Morten Kvarving ed11ba604d Merge pull request #5567 from akva2/add_python_packaging
add python packaging fluff
2024-08-30 17:04:11 +02:00
Arne Morten Kvarving 0203f74b3f add python packaging fluff 2024-08-30 14:28:25 +02:00
hnil 6609d9fbcb changed references 2024-08-29 11:19:29 +02:00
hnil 5c0176371c -- fixed reference 2024-08-28 13:27:46 +02:00
Tor Harald Sandve 8e490e9b3f relax python tests slightly 2024-08-16 10:18:50 +02:00
Lisa Julia Nebel 13e3cd590c Fix typos and test the automatic deployment to opm-python-documentation 2024-07-25 19:34:17 +02:00
Markus Blatt c243620057 Merge pull request #5474 from lisajulia/feature/add-failureFlag-to-tasklets
Remove UNIFOUT keyword from python test data file SPE1CASE1.DATA
2024-07-12 13:13:47 +02:00
Lisa Julia Nebel 42d79ebb97 Delete almost everything of the documentation here, this will be done in a separate repository opm-python-documentation
Keep only the file docstrings.json (renamed to docstrings_simulators.json)
2024-07-10 18:02:41 +02:00
Lisa Julia Nebel b4ee039f07 Remove UNIFOUT keyword from python test data file SPE1CASE1b/SPE1CASE1.DATA file as well
... just in case
2024-07-09 17:27:50 +02:00
Lisa Julia Nebel e9d3d81ae2 Remove UNIFOUT keyword from python test data file SPE1CASE1a/SPE1CASE1.DATA
With this keyword, the SPE1CASE1.UNRST file could not be read in correctly at some point, until I've added a check in opm-models that checks this, this went unnoticed probably.
2024-07-09 17:27:43 +02:00
Lisa Julia Nebel fa3392fb7d Use generate_docstring_hpp.py of opm-common and delete the one here 2024-07-09 13:52:01 +02:00
Arne Morten Kvarving b55cc972c2 Merge pull request #5459 from OPM/dependabot/pip/python/sphinx_docs/requests-2.32.2
Bump requests from 2.31.0 to 2.32.2 in /python/sphinx_docs
2024-07-01 13:40:48 +02:00
Arne Morten Kvarving ae6e58a468 Merge pull request #5458 from OPM/dependabot/pip/python/sphinx_docs/idna-3.7
Bump idna from 3.6 to 3.7 in /python/sphinx_docs
2024-07-01 13:40:24 +02:00
Arne Morten Kvarving 1f92effa27 Merge pull request #5456 from OPM/dependabot/pip/python/sphinx_docs/jinja2-3.1.4
Bump jinja2 from 3.1.3 to 3.1.4 in /python/sphinx_docs
2024-07-01 13:39:57 +02:00