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
19 changes: 19 additions & 0 deletions recipes/recipes_emscripten/cvxpy/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

set -eux

# `DNDEBUG` flag is used to disable debug mode, this may lead to issues.
# See: https://github.com/cvxpy/cvxpy/issues/1690
# Emscripten flags for Python extension modules:
# - `-fPIC`: Required for building shared libraries (.so files) for WebAssembly/emscripten
# targets. Without it, wasm-ld will fail with relocation errors.
# - `SIDE_MODULE=1`: Build as side module for WebAssembly
# - `WASM_BIGINT`: Enable big integer support
# - `MODULARIZE=1, LINKABLE=1, EXPORT_ALL=1`: Export Python module initialization functions
# - `fexceptions`: Enable exception handling
export FLAGS="-DNDEBUG -fPIC -sWASM_BIGINT -s SIDE_MODULE=1 -fexceptions"
export CXXFLAGS="${CXXFLAGS:-} ${FLAGS}"
export CFLAGS="${CFLAGS:-} ${FLAGS}"
export LDFLAGS="${LDFLAGS:-} -s MODULARIZE=1 -s LINKABLE=1 -s EXPORT_ALL=1 -s WASM=1 -s SIDE_MODULE=1 -sWASM_BIGINT -fexceptions -L$PREFIX/lib"
${PYTHON} -m pip install . --no-deps -vvv

120 changes: 120 additions & 0 deletions recipes/recipes_emscripten/cvxpy/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
context:
version: "1.7.5"

recipe:
name: cvxpy-split
version: ${{ version }}

source:
- url: https://github.com/cvxpy/cvxpy/archive/refs/tags/v${{ version }}.tar.gz
sha256: 01b589b51a49ac8d1e4a41bf98ba4ed8048ce1ade2a8344f9b4fdb5574f0e9f4

build:
number: 0

outputs:
- package:
name: cvxpy-base
version: ${{ version }}
build:
script: build.sh
requirements:
build:
- python
- cross-python_${{ target_platform }}
- numpy
- ${{ compiler('c') }}
- ${{ compiler('cxx') }}
host:
- python
- pybind11
- numpy
- pip
- setuptools
run:
- python
- scipy >=1.1.0
tests:
- script: pytester
requirements:
build:
- pytester
run:
- pytester-run
files:
recipe:
- test_cvxpy_base.py

# TODO: Distribute scs on emscripten-forge first
# - package:
# name: cvxpy
# version: ${{ version }}
# requirements:
# host:
# - python
# run:
# - python
# - ${{ pin_subpackage('cvxpy-base', exact=True) }}
# - osqp >=0.6.2
# - clarabel >=0.5
# - scs >=3.2.4
# tests:
# - script: pytester
# requirements:
# build:
# - pytester
# run:
# - pytester-run
# files:
# recipe:
# - test_cvxpy.py
# - script:
# - if: unix
# then:
# - |
# tests_to_skip="_not_a_real_test"
# # accuracy failure on PPC, likely due to emulation
# if [ "${{ target_platform }}" == "linux-ppc64le" ]; then
# tests_to_skip="${tests_to_skip} or (TestDqcp and test_basic_multiply)"
# fi
# # test that fails on Python 3.13
# python_version=$(python -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
# if [ "$python_version" == "3.13" ]; then
# tests_to_skip="${tests_to_skip} or test_sparsity_condition"
# fi
# pytest cvxpy/tests -v -k "not (${tests_to_skip})"
# # test that pip recognizes installation correctly, see https://github.com/cvxpy/cvxpy/issues/2389;
# # 'grep -v' inverts the match but returns non-zero exit code if no lines are returned; so we use 'wc -l';
# - if [ 0 -eq $(pip list | grep "UNKNOWN" | wc -l) ]; then exit 0; else (pip list && exit 1); fi
# else:
# - pytest cvxpy/tests -v -k "not _not_a_real_test"
# requirements:
# run:
# - pip
# - pytest
# # issues with newer scipy and other libraries
# # - cvxopt
# - hypothesis
# - scipy
# files:
# source:
# - cvxpy/tests

about:
homepage: http://www.cvxpy.org/
license: Apache-2.0
license_family: Apache
license_file: LICENSE
summary: A Python-embedded modeling language for convex optimization problems
description: |
CVXPY is a Python-embedded modeling language for convex optimization
problems. It allows you to express your problem in a natural way that
follows the math, rather than in the restrictive standard form required
by solvers.
documentation: http://www.cvxpy.org/
repository: https://github.com/cvxpy/cvxpy

extra:
recipe-maintainers:
- jjerphan
feedstock-name: cvxpy
5 changes: 5 additions & 0 deletions recipes/recipes_emscripten/cvxpy/test_cvxpy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def test_cvxpy():
import cvxpy
import cvxpy.cvxcore
import cvxpy.cvxcore.python

5 changes: 5 additions & 0 deletions recipes/recipes_emscripten/cvxpy/test_cvxpy_base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def test_cvxpy_base():
# public interface is defined (see #75) to be the content of
# https://github.com/cvxpy/cvxpy/blob/master/cvxpy/__init__.py
import cvxpy