From f032922b3b1d9bfa5b8530ab8efdd047937b9b38 Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Sat, 7 Jun 2025 21:40:37 +0200 Subject: [PATCH 01/15] MAINT: Bump to 3.9 3.8 is EOL for the past 8 months now.. and not built on CI anyway xref: https://github.com/bodono/scs-python/pull/117 --- pyproject.toml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 8f2947cd..08362325 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,7 @@ [build-system] build-backend = 'mesonpy' requires = [ - "numpy >= 2.0.0; python_version > '3.8'", - "oldest-supported-numpy; python_version <= '3.8'", + "numpy >= 2.0.0", "meson-python" ] @@ -11,7 +10,7 @@ name = 'scs' version = "3.2.7" description = 'Splitting conic solver' readme = 'README.md' -requires-python = '>=3.7' +requires-python = '>=3.9' license = {file = 'LICENSE'} authors = [ {name = "Brendan O'Donoghue", email = "bodonoghue85@gmail.com"}] From 6945364ffce089fff0d3e3af739a2e606e55398c Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Sat, 7 Jun 2025 22:00:50 +0200 Subject: [PATCH 02/15] ENH: Rework meson build Be more DRY --- meson.build | 230 ++++++++++++++++++++++------------------------------ 1 file changed, 98 insertions(+), 132 deletions(-) diff --git a/meson.build b/meson.build index d428a164..24e727a0 100644 --- a/meson.build +++ b/meson.build @@ -3,8 +3,25 @@ project('scs', 'c') py = import('python').find_installation(pure: false) cc = meson.get_compiler('c') -blas_deps = [] +fs = import('fs') +# Check for submodule before doing anything else +if not fs.exists('scs_source/README.md') + error('Missing the `scs_source` submodule! Run `git submodule update --init` to fix this.') +endif +# Simpler check for numpy +incdir_numpy = run_command(py,['-c', +'''import os +import numpy as np +try: + incdir = os.path.relpath(np.get_include()) +except Exception: + incdir = np.get_include() +print(incdir) +'''], check: true).stdout().strip() + +# Get BLAS +blas_deps = [] if get_option('link_mkl') blas_deps = [cc.find_library('mkl_rt', required : false)] if not blas_deps[0].found() @@ -49,147 +66,96 @@ if not blas_deps[0].found() and not get_option('sdist_mode') error('OpenBLAS or Netlib BLAS/CBLAS is required on all platforms, and was not found.') endif -fs = import('fs') -if not fs.exists('scs_source/README.md') - error('Missing the `scs_source` submodule! Run `git submodule update --init` to fix this.') -endif - -incdir_numpy = run_command(py,['-c', -'''import os -import numpy as np -try: - incdir = os.path.relpath(np.get_include()) -except Exception: - incdir = np.get_include() -print(incdir) -'''], check: true).stdout().strip() +# Common +common_c_args = cc.get_supported_arguments('-Wno-unused-result') + [ + '-DPYTHON', '-DCTRLC=1', '-DUSE_LAPACK=1', '-DDLONG=1' +] +common_includes = [ + 'scs', + 'scs_source/include', + 'scs_source/linsys', + incdir_numpy +] +_deps = [blas_deps] + +# Sources +scs_core_sources = files( + 'scs_source/src/aa.c', + 'scs_source/src/cones.c', + 'scs_source/src/ctrlc.c', + 'scs_source/src/exp_cone.c', + 'scs_source/src/linalg.c', + 'scs_source/src/normalize.c', + 'scs_source/src/rw.c', + 'scs_source/src/scs_version.c', + 'scs_source/src/scs.c', + 'scs_source/src/util.c' +) -# rw.c emits a lot of -Wunused-result warnings, silence them for now: -c_args = cc.get_supported_arguments('-Wno-unused-result') +common_linsys_sources = files( + 'scs_source/linsys/scs_matrix.c', + 'scs_source/linsys/csparse.c' +) +amd_sources = files( + 'scs_source/linsys/external/amd/amd_1.c', + 'scs_source/linsys/external/amd/amd_2.c', + 'scs_source/linsys/external/amd/amd_aat.c', + 'scs_source/linsys/external/amd/amd_control.c', + 'scs_source/linsys/external/amd/amd_defaults.c', + 'scs_source/linsys/external/amd/amd_dump.c', + 'scs_source/linsys/external/amd/amd_global.c', + 'scs_source/linsys/external/amd/amd_info.c', + 'scs_source/linsys/external/amd/amd_order.c', + 'scs_source/linsys/external/amd/amd_post_tree.c', + 'scs_source/linsys/external/amd/amd_postorder.c', + 'scs_source/linsys/external/amd/amd_preprocess.c', + 'scs_source/linsys/external/amd/amd_valid.c', + 'scs_source/linsys/external/amd/SuiteSparse_config.c' +) py.extension_module( - '_scs_direct', - - 'scs/scspy.c', - 'scs_source/linsys/cpu/direct/private.c', - - # scs_source/src: - 'scs_source/src/aa.c', - 'scs_source/src/cones.c', - 'scs_source/src/ctrlc.c', - 'scs_source/src/exp_cone.c', - 'scs_source/src/linalg.c', - 'scs_source/src/normalize.c', - 'scs_source/src/rw.c', - 'scs_source/src/scs_version.c', - 'scs_source/src/scs.c', - 'scs_source/src/util.c', - - # scs_source/linsys: - 'scs_source/linsys/scs_matrix.c', - 'scs_source/linsys/csparse.c', - - # scs_source/linsys/external/qdldl: - 'scs_source/linsys/external/qdldl/qdldl.c', - - # scs_source/linsys/external/amd: - 'scs_source/linsys/external/amd/amd_1.c', - 'scs_source/linsys/external/amd/amd_2.c', - 'scs_source/linsys/external/amd/amd_aat.c', - 'scs_source/linsys/external/amd/amd_control.c', - 'scs_source/linsys/external/amd/amd_defaults.c', - 'scs_source/linsys/external/amd/amd_dump.c', - 'scs_source/linsys/external/amd/amd_global.c', - 'scs_source/linsys/external/amd/amd_info.c', - 'scs_source/linsys/external/amd/amd_order.c', - 'scs_source/linsys/external/amd/amd_post_tree.c', - 'scs_source/linsys/external/amd/amd_postorder.c', - 'scs_source/linsys/external/amd/amd_preprocess.c', - 'scs_source/linsys/external/amd/amd_valid.c', - 'scs_source/linsys/external/amd/SuiteSparse_config.c', - - include_directories : [ - 'scs', - 'scs_source/include', - 'scs_source/linsys', - 'scs_source/linsys/cpu/direct', - 'scs_source/linsys/external/qdldl', - 'scs_source/linsys/external/amd', - incdir_numpy], - install: true, - c_args: c_args + ['-DPYTHON', '-DCTRLC=1', '-DUSE_LAPACK=1', '-DDLONG=1'], - dependencies: blas_deps, + '_scs_direct', + 'scs/scspy.c', + 'scs_source/linsys/cpu/direct/private.c', + 'scs_source/linsys/external/qdldl/qdldl.c', + common_linsys_sources, + scs_core_sources, + amd_sources, + c_args: common_c_args, + include_directories: common_includes + [ + 'scs_source/linsys/cpu/direct', + 'scs_source/linsys/external/qdldl', + 'scs_source/linsys/external/amd' + ], + dependencies: _deps, + install: true, ) py.extension_module( - '_scs_indirect', - - 'scs/scspy.c', - 'scs_source/linsys/cpu/indirect/private.c', - - # scs_source/src: - 'scs_source/src/aa.c', - 'scs_source/src/cones.c', - 'scs_source/src/ctrlc.c', - 'scs_source/src/exp_cone.c', - 'scs_source/src/linalg.c', - 'scs_source/src/normalize.c', - 'scs_source/src/rw.c', - 'scs_source/src/scs_version.c', - 'scs_source/src/scs.c', - 'scs_source/src/util.c', - - # scs_source/linsys: - 'scs_source/linsys/scs_matrix.c', - 'scs_source/linsys/csparse.c', - - include_directories : [ - 'scs', - 'scs_source/include', - 'scs_source/linsys', - 'scs_source/linsys/cpu/indirect', - incdir_numpy], - install: true, - c_args: c_args + ['-DPYTHON', '-DCTRLC=1', '-DPY_INDIRECT', '-DINDIRECT=1', - '-DUSE_LAPACK=1', '-DDLONG=1'], - dependencies: blas_deps, + '_scs_indirect', + 'scs/scspy.c', + 'scs_source/linsys/cpu/indirect/private.c', + common_linsys_sources, + scs_core_sources, + c_args: common_c_args + ['-DPY_INDIRECT', '-DINDIRECT=1'], + include_directories: common_includes + ['scs_source/linsys/cpu/indirect'], + dependencies: _deps, + install: true, ) if get_option('link_mkl') - py.extension_module( - '_scs_mkl', - - 'scs/scspy.c', - 'scs_source/linsys/mkl/direct/private.c', - - # scs_source/src: - 'scs_source/src/aa.c', - 'scs_source/src/cones.c', - 'scs_source/src/ctrlc.c', - 'scs_source/src/exp_cone.c', - 'scs_source/src/linalg.c', - 'scs_source/src/normalize.c', - 'scs_source/src/rw.c', - 'scs_source/src/scs_version.c', - 'scs_source/src/scs.c', - 'scs_source/src/util.c', - - # scs_source/linsys: - 'scs_source/linsys/scs_matrix.c', - 'scs_source/linsys/csparse.c', - - include_directories : [ - 'scs', - 'scs_source/include', - 'scs_source/linsys', - 'scs_source/linsys/mkl/direct', - incdir_numpy], - install: true, - c_args: c_args + ['-DPYTHON', '-DCTRLC=1', '-DPY_MKL', - '-DUSE_LAPACK=1', '-DDLONG=1'], - dependencies: blas_deps, - ) + py.extension_module( + '_scs_mkl', + 'scs/scspy.c', + 'scs_source/linsys/mkl/direct/private.c', + common_linsys_sources, + scs_core_sources, + c_args: common_c_args + ['-DPY_MKL'], + include_directories: common_includes + ['scs_source/linsys/mkl/direct'], + dependencies: _deps, + install: true, + ) endif py.install_sources('scs/__init__.py', subdir: 'scs') From f7d2cbcf54167ee765dc0c968a7b218762ad3cd6 Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Sat, 7 Jun 2025 22:07:23 +0200 Subject: [PATCH 03/15] ENH: Add use_openmp for meson --- meson.build | 3 +++ meson.options | 2 ++ 2 files changed, 5 insertions(+) diff --git a/meson.build b/meson.build index 24e727a0..12dd00f4 100644 --- a/meson.build +++ b/meson.build @@ -77,6 +77,9 @@ common_includes = [ incdir_numpy ] _deps = [blas_deps] +if get_option('use_openmp') + _deps += dependency('openmp') +endif # Sources scs_core_sources = files( diff --git a/meson.options b/meson.options index 79b56784..91b984f4 100644 --- a/meson.options +++ b/meson.options @@ -5,5 +5,7 @@ option('link_blas_statically', type: 'boolean', value: false, description: 'copy BLAS compiled object into SCS module(s)') option('link_mkl', type: 'boolean', value: false, description: 'link to mkl-rt library') +option('use_openmp', type: 'boolean', + value: false, description: 'Compile SCS with OpenMP parallelization enabled. This can make SCS faster, but requires a compiler with openMP support, the user must control how many threads OpenMP uses') option('sdist_mode', type: 'boolean', value: false, description: 'Set to true if building an sdist') From c2698ab4676cb3c2140a8b5618d7f8dd057c607d Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Sat, 7 Jun 2025 22:14:55 +0200 Subject: [PATCH 04/15] ENH: Setup installation directory Stop polluting site-packages with _scs*.so --- meson.build | 5 +++++ scs/__init__.py | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/meson.build b/meson.build index 12dd00f4..589ae15d 100644 --- a/meson.build +++ b/meson.build @@ -117,6 +117,8 @@ amd_sources = files( 'scs_source/linsys/external/amd/SuiteSparse_config.c' ) +# Build modules +scs_dir = py.get_install_dir() / 'scs' py.extension_module( '_scs_direct', 'scs/scspy.c', @@ -132,6 +134,7 @@ py.extension_module( 'scs_source/linsys/external/amd' ], dependencies: _deps, + install_dir: scs_dir, install: true, ) @@ -144,6 +147,7 @@ py.extension_module( c_args: common_c_args + ['-DPY_INDIRECT', '-DINDIRECT=1'], include_directories: common_includes + ['scs_source/linsys/cpu/indirect'], dependencies: _deps, + install_dir: scs_dir, install: true, ) @@ -157,6 +161,7 @@ if get_option('link_mkl') c_args: common_c_args + ['-DPY_MKL'], include_directories: common_includes + ['scs_source/linsys/mkl/direct'], dependencies: _deps, + install_dir: scs_dir, install: true, ) endif diff --git a/scs/__init__.py b/scs/__init__.py index 893879ff..f0941cdf 100644 --- a/scs/__init__.py +++ b/scs/__init__.py @@ -1,7 +1,7 @@ #!/usr/bin/env python from warnings import warn from scipy import sparse -import _scs_direct +from scs import _scs_direct __version__ = _scs_direct.version() __sizeof_int__ = _scs_direct.sizeof_int() @@ -31,7 +31,7 @@ def _select_scs_module(stgs): raise NotImplementedError( "GPU direct solver not yet available, pass `use_indirect=True`." ) - import _scs_gpu + from scs import _scs_gpu return _scs_gpu @@ -40,12 +40,12 @@ def _select_scs_module(stgs): raise NotImplementedError( "MKL indirect solver not yet available, pass `use_indirect=False`." ) - import _scs_mkl + from scs import _scs_mkl return _scs_mkl if stgs.pop("use_indirect", _USE_INDIRECT_DEFAULT): - import _scs_indirect + from scs import _scs_indirect return _scs_indirect From 02778685039e44ddc4c964fb756290ebdf2a99db Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Sat, 7 Jun 2025 22:17:06 +0200 Subject: [PATCH 05/15] MAINT: Move to enable python -mpytest test in the same directory, otherwise scs/__init__.py shadows the one installed with python -mpip install . --- meson.build | 2 +- scs/{ => py}/__init__.py | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename scs/{ => py}/__init__.py (100%) diff --git a/meson.build b/meson.build index 589ae15d..4cde8d2f 100644 --- a/meson.build +++ b/meson.build @@ -166,4 +166,4 @@ if get_option('link_mkl') ) endif -py.install_sources('scs/__init__.py', subdir: 'scs') +py.install_sources('scs/py/__init__.py', subdir: 'scs') diff --git a/scs/__init__.py b/scs/py/__init__.py similarity index 100% rename from scs/__init__.py rename to scs/py/__init__.py From 007d9bdbf71f0724762d23dcbf287a3ec30e88c8 Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Sat, 7 Jun 2025 22:19:40 +0200 Subject: [PATCH 06/15] CI: Use meson for openmp --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 92014b84..476d717f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,11 +36,11 @@ jobs: channels: conda-forge,anaconda - name: Install dependencies run: | - conda install scipy numpy pytest 'setuptools<=60' + conda install scipy numpy pytest - name: Test run: | - python legacy_setup.py install --scs --openmp - pytest + python -m pip install -v . --no-build-isolation -Csetup-args=-Duse_openmp=true + pytest test rm -rf build/ build_mkl: From e50b2208b663ee68df9eb6e66fd187a14ab54e5e Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Sat, 7 Jun 2025 22:35:20 +0200 Subject: [PATCH 07/15] MAINT: Add in rt similar to legacy_setup --- meson.build | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/meson.build b/meson.build index 4cde8d2f..b90f5596 100644 --- a/meson.build +++ b/meson.build @@ -81,6 +81,11 @@ if get_option('use_openmp') _deps += dependency('openmp') endif +is_linux = host_machine.system() == 'linux' +if is_linux + _deps += cc.find_library('rt', required : true) +endif + # Sources scs_core_sources = files( 'scs_source/src/aa.c', From 986840a82203b91434f3100b43e415dbb1ba7ec8 Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Sat, 7 Jun 2025 22:41:15 +0200 Subject: [PATCH 08/15] ENH: Add in more options from legacy_setup --- meson.build | 21 ++++++++++++++++++++- meson.options | 8 ++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index b90f5596..5a05d3fe 100644 --- a/meson.build +++ b/meson.build @@ -68,7 +68,7 @@ endif # Common common_c_args = cc.get_supported_arguments('-Wno-unused-result') + [ - '-DPYTHON', '-DCTRLC=1', '-DUSE_LAPACK=1', '-DDLONG=1' + '-DPYTHON', '-DCTRLC=1' ] common_includes = [ 'scs', @@ -86,6 +86,25 @@ if is_linux _deps += cc.find_library('rt', required : true) endif +if get_option('use_lapack') + common_c_args += '-DUSE_LAPACK=1' +endif + +if get_option('use_long') + common_c_args += '-DDLONG=1' +endif + +if get_option('use_singleprec') + common_c_args += '-DSFLOAT=1' +endif + +if get_option('use_blas64') + common_c_args += '-DBLAS64=1' +endif + +if get_option('use_extraverbose') + common_c_args += '-DVERBOSITY=999' +endif # Sources scs_core_sources = files( 'scs_source/src/aa.c', diff --git a/meson.options b/meson.options index 91b984f4..e9f0dc86 100644 --- a/meson.options +++ b/meson.options @@ -9,3 +9,11 @@ option('use_openmp', type: 'boolean', value: false, description: 'Compile SCS with OpenMP parallelization enabled. This can make SCS faster, but requires a compiler with openMP support, the user must control how many threads OpenMP uses') option('sdist_mode', type: 'boolean', value: false, description: 'Set to true if building an sdist') +option('use_lapack', type: 'boolean', + value: true, description: 'use LAPACK') +option('use_singleprec', type: 'boolean', + value: false, description: 'use single precision floating point') +option('use_long', type: 'boolean', + value: true, description: 'use long over int') +option('use_extraverbose', type: 'boolean', + value: false, description: 'Enable extra verbose SCS (for debugging).') From 6396e231a5f1083b4c1e7dd72fcb0d84b420a2b7 Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Sat, 7 Jun 2025 22:58:20 +0200 Subject: [PATCH 09/15] ENH: Try to setup the GPU variant --- meson.build | 44 ++++++++++++++++++++++++++++++++++++++++---- meson.options | 10 ++++++++-- 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/meson.build b/meson.build index 5a05d3fe..ec76fe1b 100644 --- a/meson.build +++ b/meson.build @@ -90,10 +90,6 @@ if get_option('use_lapack') common_c_args += '-DUSE_LAPACK=1' endif -if get_option('use_long') - common_c_args += '-DDLONG=1' -endif - if get_option('use_singleprec') common_c_args += '-DSFLOAT=1' endif @@ -105,6 +101,46 @@ endif if get_option('use_extraverbose') common_c_args += '-DVERBOSITY=999' endif + +is_gpu_build = get_option('use_gpu') +use_32bit_ints = get_option('int32') + +if is_gpu_build and not use_32bit_ints + error('GPU builds require 32-bit integers. Please re-run Meson with -Dint32=true') +endif + +if not use_32bit_ints + common_c_args += '-DDLONG=1' +endif + +cuda_dep = dependency('cuda', required: is_gpu_build) +if is_gpu_build and not cuda_dep.found() + error('GPU build requested but CUDA toolkit was not found.') +endif + +if is_gpu_build + gpu_c_args = c_args + ['-DPY_GPU=1', '-DINDIRECT=1'] + deps += + if get_option('gpu_atrans') + gpu_c_args += '-DGPU_TRANSPOSE_MAT=1' + endif + ext_modules += py.extension_module( + '_scs_gpu', + common_sources, + # In Meson, sources with a `.cu` extension are compiled with nvcc by default. + # To compile `.c` files with nvcc, they must be explicitly targeted. + # It is strongly recommended to rename CUDA-C files to `.cu`. + fs.glob('scs_source/linsys/gpu/*.c'), + fs.glob('scs_source/linsys/gpu/indirect/*.c'), + c_args: gpu_c_args, + dependencies: [blas_dep, cuda_dep], + include_directories: [ + common_includes, 'scs_source/linsys/gpu/', 'scs_source/linsys/gpu/indirect' + ], + install: true, + ) +endif + # Sources scs_core_sources = files( 'scs_source/src/aa.c', diff --git a/meson.options b/meson.options index e9f0dc86..996ccca4 100644 --- a/meson.options +++ b/meson.options @@ -13,7 +13,13 @@ option('use_lapack', type: 'boolean', value: true, description: 'use LAPACK') option('use_singleprec', type: 'boolean', value: false, description: 'use single precision floating point') -option('use_long', type: 'boolean', - value: true, description: 'use long over int') option('use_extraverbose', type: 'boolean', value: false, description: 'Enable extra verbose SCS (for debugging).') +option('use_gpu', type: 'boolean', + value: false, description: 'setup the GPU variant') +option('int32', type: 'boolean', + value: false, description: 'Use 32-bit integers (required for GPU).') +option('gpu_atrans', type: 'boolean', + value: false, description: 'transpose matrices for the GPU') +option('use_blas64', type: 'boolean', + value: false, description: 'Use 64-bit convention for BLAS') From fc901ed8627a62c1dc58b621db6e4296a837344d Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Sat, 7 Jun 2025 23:02:18 +0200 Subject: [PATCH 10/15] CI: Fix typo --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 476d717f..bafe1e1a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,7 +36,7 @@ jobs: channels: conda-forge,anaconda - name: Install dependencies run: | - conda install scipy numpy pytest + conda install scipy numpy pytest meson meson-python openblas - name: Test run: | python -m pip install -v . --no-build-isolation -Csetup-args=-Duse_openmp=true From b96d2a8054ccacec1fa42aeb0125cafc1d983ac3 Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Sat, 7 Jun 2025 23:16:22 +0200 Subject: [PATCH 11/15] MAINT: Try to explicitly take mkl --- .github/workflows/build.yml | 8 ++++---- meson.build | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bafe1e1a..93a89214 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -84,13 +84,13 @@ jobs: BLAS_PKGS="blas-devel=*=*openblas" fi if [[ "$PYTHON_VERSION" == "3.9" ]]; then - conda install scipy=1.5 numpy=1.19 pytest $BLAS_PKGS pkg-config + conda install scipy=1.5 numpy=1.19 pytest mkl mkl-devel $BLAS_PKGS pkg-config elif [[ "$PYTHON_VERSION" == "3.10" ]]; then - conda install scipy=1.7 numpy=1.21 pytest $BLAS_PKGS pkg-config + conda install scipy=1.7 numpy=1.21 pytest mkl mkl-devel $BLAS_PKGS pkg-config elif [[ "$PYTHON_VERSION" == "3.11" ]]; then - conda install scipy=1.9.3 numpy=1.23.4 pytest $BLAS_PKGS pkg-config + conda install scipy=1.9.3 numpy=1.23.4 pytest mkl mkl-devel $BLAS_PKGS pkg-config elif [[ "$PYTHON_VERSION" == "3.12" || "$PYTHON_VERSION" == "3.13" ]]; then - conda install scipy numpy pytest $BLAS_PKGS pkg-config + conda install scipy numpy pytest mkl mkl-devel $BLAS_PKGS pkg-config fi - name: Build run: | diff --git a/meson.build b/meson.build index ec76fe1b..20950998 100644 --- a/meson.build +++ b/meson.build @@ -220,7 +220,7 @@ if get_option('link_mkl') scs_core_sources, c_args: common_c_args + ['-DPY_MKL'], include_directories: common_includes + ['scs_source/linsys/mkl/direct'], - dependencies: _deps, + dependencies: _deps, install_dir: scs_dir, install: true, ) From b1573aae2f02f4f0d5028fcc4f184f43ac17818b Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Sat, 7 Jun 2025 23:19:19 +0200 Subject: [PATCH 12/15] MAINT: More typos --- meson.build | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index 20950998..72d559fa 100644 --- a/meson.build +++ b/meson.build @@ -119,8 +119,8 @@ if is_gpu_build and not cuda_dep.found() endif if is_gpu_build - gpu_c_args = c_args + ['-DPY_GPU=1', '-DINDIRECT=1'] - deps += + gpu_c_args = common_c_args + ['-DPY_GPU=1', '-DINDIRECT=1'] + deps += cuda_dep if get_option('gpu_atrans') gpu_c_args += '-DGPU_TRANSPOSE_MAT=1' endif @@ -133,11 +133,12 @@ if is_gpu_build fs.glob('scs_source/linsys/gpu/*.c'), fs.glob('scs_source/linsys/gpu/indirect/*.c'), c_args: gpu_c_args, - dependencies: [blas_dep, cuda_dep], + dependencies: deps, include_directories: [ common_includes, 'scs_source/linsys/gpu/', 'scs_source/linsys/gpu/indirect' ], install: true, + install_dir: scs_dir, ) endif From 575137f058d8080ed55f6de16cecbad8e69d1204 Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Sat, 7 Jun 2025 23:53:40 +0200 Subject: [PATCH 13/15] MAINT: Try mkl again --- meson.build | 2 ++ 1 file changed, 2 insertions(+) diff --git a/meson.build b/meson.build index 72d559fa..9612937f 100644 --- a/meson.build +++ b/meson.build @@ -26,6 +26,8 @@ if get_option('link_mkl') blas_deps = [cc.find_library('mkl_rt', required : false)] if not blas_deps[0].found() blas_deps = [dependency('mkl-sdl', required : false)] + else + blas_deps = [ dependency('mkl-dynamic-ilp64-iomp', required: false) ] endif else if host_machine.system() == 'darwin' From 9e0da5b805031cb58bc71a5a342b7f1e88d54a9e Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Sun, 8 Jun 2025 00:05:34 +0200 Subject: [PATCH 14/15] CI: Rework --- .github/workflows/build.yml | 50 ++++++++++++++++--------------------- .gitignore | 4 +++ meson.build | 3 ++- pixi.toml | 12 +++++++++ 4 files changed, 40 insertions(+), 29 deletions(-) create mode 100644 pixi.toml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 93a89214..e93a5e7d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,19 +28,19 @@ jobs: - uses: actions/checkout@v4 with: submodules: recursive - - uses: conda-incubator/setup-miniconda@v3 + - uses: prefix-dev/setup-pixi@v0.8.8 with: - auto-update-conda: true - python-version: ${{ matrix.python-version }} - miniforge-version: latest - channels: conda-forge,anaconda + cache: false + pixi-version: v0.46.0 + - name: Add .pixi/envs/default to the $PATH + run: echo "$(pwd)/.pixi/envs/default/bin" >> $GITHUB_PATH + shell: bash - name: Install dependencies - run: | - conda install scipy numpy pytest meson meson-python openblas + run: pixi add scipy numpy pip pytest meson meson-python openblas python==${{ matrix.python-version }} - name: Test run: | - python -m pip install -v . --no-build-isolation -Csetup-args=-Duse_openmp=true - pytest test + pixi r python -m pip install -v . --no-build-isolation -Csetup-args=-Duse_openmp=true + pixi r pytest test rm -rf build/ build_mkl: @@ -53,7 +53,7 @@ jobs: matrix: # macos-13 runners have intel chips. macos-14 and above # runners have Apple silicon chips. - os: [ ubuntu-latest, macos-13, windows-latest ] + os: [ ubuntu-latest ] python-version: [ 3.9, "3.10", "3.11", "3.12", "3.13"] link_mkl: [true] @@ -70,12 +70,13 @@ jobs: shell: bash run: | echo "PYTHON_SUBVERSION=$(echo $PYTHON_VERSION | cut -c 3-)" >> $GITHUB_ENV - - uses: conda-incubator/setup-miniconda@v3 + - uses: prefix-dev/setup-pixi@v0.8.8 with: - auto-update-conda: true - python-version: ${{ matrix.python-version }} - miniforge-version: latest - channels: conda-forge,anaconda + cache: false + pixi-version: v0.46.0 + - name: Add .pixi/envs/default to the $PATH + run: echo "$(pwd)/.pixi/envs/default/bin" >> $GITHUB_PATH + shell: bash - name: Install dependencies run: | if [[ "$LINK_MKL" == "true" ]]; then @@ -83,26 +84,19 @@ jobs: else BLAS_PKGS="blas-devel=*=*openblas" fi - if [[ "$PYTHON_VERSION" == "3.9" ]]; then - conda install scipy=1.5 numpy=1.19 pytest mkl mkl-devel $BLAS_PKGS pkg-config - elif [[ "$PYTHON_VERSION" == "3.10" ]]; then - conda install scipy=1.7 numpy=1.21 pytest mkl mkl-devel $BLAS_PKGS pkg-config - elif [[ "$PYTHON_VERSION" == "3.11" ]]; then - conda install scipy=1.9.3 numpy=1.23.4 pytest mkl mkl-devel $BLAS_PKGS pkg-config - elif [[ "$PYTHON_VERSION" == "3.12" || "$PYTHON_VERSION" == "3.13" ]]; then - conda install scipy numpy pytest mkl mkl-devel $BLAS_PKGS pkg-config - fi + pixi add $BLAS_PKGS pip scipy numpy pytest mkl mkl-devel pkg-config meson meson-python - name: Build run: | - python -c "import numpy as np; print('NUMPY BLAS INFOS'); print(np.show_config())" + pixi r python -c "import numpy as np;print(np.show_config())" if [[ "$LINK_MKL" == "true" ]]; then - python -m pip install --verbose -Csetup-args=-Dlink_mkl=true . + + pixi r python -m pip install --verbose --no-build-isolation -Csetup-args=-Dlink_mkl=true . else - python -m pip install --verbose . + pixi r python -m pip install --verbose --no-build-isolation . fi - name: Test run: | - pytest + pixi r pytest test rm -rf build/ # from here to end it's a copy-paste, with few changes, of diff --git a/.gitignore b/.gitignore index 77784e71..7b0df7db 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,7 @@ out *.jar *.egg-info *.ipynb_checkpoints/ + +# pixi environments +.pixi +*.egg-info diff --git a/meson.build b/meson.build index 9612937f..fe0e37c3 100644 --- a/meson.build +++ b/meson.build @@ -26,7 +26,8 @@ if get_option('link_mkl') blas_deps = [cc.find_library('mkl_rt', required : false)] if not blas_deps[0].found() blas_deps = [dependency('mkl-sdl', required : false)] - else + endif + if not blas_deps[0].found() blas_deps = [ dependency('mkl-dynamic-ilp64-iomp', required: false) ] endif else diff --git a/pixi.toml b/pixi.toml new file mode 100644 index 00000000..999d0f5c --- /dev/null +++ b/pixi.toml @@ -0,0 +1,12 @@ +[workspace] +channels = ["conda-forge"] +name = "scs-python" +platforms = ["linux-64"] +version = "0.1.0" + +[tasks] + +[dependencies] +pkg-config = ">=0.29.2,<0.30" +meson = ">=1.8.1,<2" +meson-python = ">=0.18.0,<0.19" From bd042c7bb484119a83574537f9205ddc3556f031 Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Sun, 8 Jun 2025 00:55:17 +0200 Subject: [PATCH 15/15] MAINT: Use configuration over CI --- .github/workflows/build.yml | 4 ++-- pyproject.toml | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e93a5e7d..34e5617f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,7 +40,7 @@ jobs: - name: Test run: | pixi r python -m pip install -v . --no-build-isolation -Csetup-args=-Duse_openmp=true - pixi r pytest test + pixi r pytest rm -rf build/ build_mkl: @@ -96,7 +96,7 @@ jobs: fi - name: Test run: | - pixi r pytest test + pixi r pytest rm -rf build/ # from here to end it's a copy-paste, with few changes, of diff --git a/pyproject.toml b/pyproject.toml index 08362325..8e340d29 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -79,3 +79,8 @@ inherit.before-all = "append" before-all = [ # "apk update", "apk search -v '*blas*'", "apk add openblas-dev"] + +[tool.pytest.ini_options] +testpaths = [ + "test", +]