Skip to content

Commit a2fe740

Browse files
Transurgeonclaude
andcommitted
Add diff_engine build infrastructure and CI submodule checkout
- Add _diffengine Extension to setup/extensions.py (optional, only built if diff_engine_core submodule is initialized) - Update setup.py to include diffengine in extensions list - Update imports from dnlp_diff_engine to _diffengine - Add submodules: recursive to all CI workflows that build CVXPY: - test_nlp_solvers.yml - test_optional_solvers.yml - test_backends.yml - cvxpygen.yml - docs.yml - gcsopt.yml - build.yml Cherry-picked from submodule-setup branch. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 1d81fb4 commit a2fe740

11 files changed

Lines changed: 56 additions & 8 deletions

File tree

.github/workflows/build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ jobs:
5454

5555
steps:
5656
- uses: actions/checkout@v5
57+
with:
58+
submodules: recursive
5759
- name: Set Additional Envs
5860
run: |
5961
echo "PYTHON_SUBVERSION=$(echo $PYTHON_VERSION | cut -c 3-)" >> $GITHUB_ENV
@@ -114,6 +116,8 @@ jobs:
114116

115117
steps:
116118
- uses: actions/checkout@v5
119+
with:
120+
submodules: recursive
117121
- uses: actions/setup-python@v6
118122
with:
119123
python-version: ${{ matrix.python-version }}

.github/workflows/cvxpygen.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ jobs:
1515
with:
1616
python-version: "3.12"
1717
- uses: actions/checkout@v5
18+
with:
19+
submodules: recursive
1820
- name: Install pytest and cvxpygen
1921
run: |
2022
pip install . pytest hypothesis

.github/workflows/docs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ jobs:
2121
2222
# Checkout master
2323
- uses: actions/checkout@v5
24+
with:
25+
submodules: recursive
2426
- name: Install
2527
run: |
2628
python -m pip install -e .

.github/workflows/gcsopt.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ jobs:
1515
with:
1616
python-version: "3.12"
1717
- uses: actions/checkout@v5
18+
with:
19+
submodules: recursive
1820
- name: Install pytest and gcsopt
1921
run: |
2022
pip install . pytest hypothesis

.github/workflows/test_backends.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ jobs:
1616
with:
1717
python-version: "3.12"
1818
- uses: actions/checkout@v5
19+
with:
20+
submodules: recursive
1921
- name: Install cvxpy dependencies
2022
run: |
2123
pip install -e .

.github/workflows/test_nlp_solvers.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ jobs:
2222
with:
2323
python-version: "3.12"
2424
- uses: actions/checkout@v5
25+
with:
26+
submodules: recursive
2527
- name: Set up Conda
2628
uses: conda-incubator/setup-miniconda@v3
2729
with:

.github/workflows/test_optional_solvers.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ jobs:
2020
os: [ ubuntu-22.04, macos-14 ] # Windows excluded - cylp/CBC cannot be built
2121
steps:
2222
- uses: actions/checkout@v5
23+
with:
24+
submodules: recursive
2325
- name: Set Additional Envs
2426
run: |
2527
echo "PYTHON_SUBVERSION=$(echo $PYTHON_VERSION | cut -c 3-)" >> $GITHUB_ENV
@@ -31,7 +33,6 @@ jobs:
3133
with:
3234
python-version: 3.12
3335
enable-cache: true
34-
- uses: actions/checkout@v5
3536
- name: Setup Julia
3637
uses: julia-actions/setup-julia@v2
3738
with:

cvxpy/reductions/solvers/nlp_solvers/diff_engine/c_problem.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@
2222

2323
# Import the low-level C bindings
2424
try:
25-
import dnlp_diff_engine as _diffengine
25+
import _diffengine
2626
except ImportError as e:
2727
raise ImportError(
28-
"dnlp-diff-engine is required for NLP solving. "
29-
"Install with: pip install dnlp-diff-engine"
28+
"NLP support requires diff-engine. Rebuild with: pip install -e ."
3029
) from e
3130

3231
from cvxpy.reductions.solvers.nlp_solvers.diff_engine.converters import (

cvxpy/reductions/solvers/nlp_solvers/diff_engine/converters.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@
2727

2828
# Import the low-level C bindings
2929
try:
30-
import dnlp_diff_engine as _diffengine
30+
import _diffengine
3131
except ImportError as e:
3232
raise ImportError(
33-
"dnlp-diff-engine is required for NLP solving. "
34-
"Install with: pip install dnlp-diff-engine"
33+
"NLP support requires diff-engine. Rebuild with: pip install -e ."
3534
) from e
3635

3736

setup.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ def finalize_options(self) -> None:
5252

5353
setup_versioning.write_version_py()
5454
VERSION = setup_versioning.VERSION
55-
extensions = [setup_extensions.cvxcore, setup_extensions.sparsecholesky]
55+
extensions = [
56+
setup_extensions.cvxcore,
57+
setup_extensions.sparsecholesky,
58+
setup_extensions.diffengine, # None if submodule not initialized
59+
]
60+
extensions = [ext for ext in extensions if ext is not None]
5661

5762
setup(
5863
name="cvxpy",

0 commit comments

Comments
 (0)