Development¶
Setup and tests¶
The tests are in two groups. The unit tests in tests/unit solve small problems and cover
all the code, and uv run pytest -m unit runs only them. The integration tests in
tests/integration compare with SciPy, solve published problems and start new processes,
and the code blocks of the README and of these pages count as integration tests as well.
Run them with uv run pytest -m integration.
uv sync builds the extension module in editable mode. Meson downloads the meson-jll
tool and the JLL libraries during the first configuration. The unit tests need 100%
coverage, including the Cython module, whose lines the development build traces. The code
blocks of the README and of these pages carry a <!-- name: test_... --> comment.
The traced build makes the callbacks several times slower. For timing, reinstall without
tracing. The --no-config flag stops uv from adding the coverage setting of
pyproject.toml, and uv run --no-sync stops it from rebuilding with that setting:
uv pip install --no-config --no-deps --no-build-isolation --reinstall -e . \
-C setup-args=-Dcoverage=false
Layout¶
src/xipopt/_solver.pyis the Cython module in pure Python mode._solver.pxdholds the state that the callbacks share,_ipopt.pxddeclares the C interface of Ipopt and_solver.pyitypes the part that Python sees._platform.hholds the operating system calls, so the module stays portable._compile.pybuilds a problem,_programs.pyholds the functions and derivatives it compiles,_patterns.pyconverts sparsity patterns and_cache.pykeys the disk cache._solve.pyruns a solve and_layout.pyflattens pytrees.build_backend/xipopt_build.pywraps meson-python. Meson reads the wraps ofsubprojectsbeforemeson-jll synchas written them, so the backend configures the project once in a scratch directory to write them first.licenses/holds the licenses of the libraries that the wheels bundle.
Conventions¶
- Code is formatted and linted with Ruff and type-checked with
ty. Avoid inheritance, prefer protocols and plain functions, and usematchstatements where they replace chains of conditions. - The Cython code uses the pure Python syntax. The callbacks of Ipopt must not raise or allocate Python objects.
- Bump the pin on cyxla in
pyproject.tomlwhenever itsABI_VERSIONchanges.
Continuous integration¶
One workflow tests on Linux, macOS and Windows with the oldest and the newest supported
Python, lints, type checks, builds wheels with cibuildwheel for every platform and
builds the source distribution. A tag vX.Y.Z that matches the version in
pyproject.toml publishes to PyPI through trusted publishing, and so does a manual run
with the release input. A second workflow builds this site and deploys it to GitHub
Pages.