Skip to content

Commit fdfdf96

Browse files
authored
Add SCS object (backwards compatible with simple function call) (#59)
* Working two stage solve. * Cleanup API. * Comment fix. * Update scs. * Install fix. * updates to latest api * updates to latest api * fix action typo * black . --line-length=80 * tweak build rule * move solve function * tests passing * fixing test * attempting 3.10 fix * add testing * black * docs * Tweak api. * rename to finish * Pull in latest changes to update_b_c branch on scs. * bump to 3.2.0 * Update scs
1 parent c88cc12 commit fdfdf96

18 files changed

+1428
-979
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 3.1.0
2+
current_version = 3.2.0
33

44
[bumpversion:file:setup.py]
55

.github/workflows/black.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: black-action
2+
on: [push, pull_request]
3+
jobs:
4+
linter_name:
5+
name: runner / black formatter
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v2
9+
- uses: rickstaa/action-black@v1
10+
with:
11+
black_args: ". --line-length=80 --check"
12+

.github/workflows/build.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
name: build
22

3-
on:
4-
pull_request:
5-
push:
6-
branches:
7-
- master
8-
tags:
9-
- '*'
3+
on: [push, pull_request]
104

115
jobs:
126
cleanup-runs:
@@ -102,7 +96,7 @@ jobs:
10296
echo "DEPLOY=$( [[ $GITHUB_EVENT_NAME == 'push' && $GITHUB_REF == 'refs/tags'* ]] && echo 'True' || echo 'False' )" >> $GITHUB_ENV
10397
10498
- name: Build wheels
105-
if: ${{env.DEPLOY == 'True' || env.DEPLOY == 'True'}}
99+
if: ${{env.DEPLOY == 'True'}}
106100
env:
107101
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
108102
CIBW_BUILD: "cp3${{env.PYTHON_SUBVERSION}}-*"
@@ -160,4 +154,4 @@ jobs:
160154
run: |
161155
python -m pip install --upgrade twine
162156
twine check wheelhouse/*
163-
twine upload --repository-url $PYPI_SERVER wheelhouse/* -u $PYPI_USER -p $PYPI_PASSWORD
157+
twine upload --repository-url $PYPI_SERVER wheelhouse/* -u $PYPI_USER -p $PYPI_PASSWORD

scs

Submodule scs updated 69 files

setup.py

Lines changed: 109 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ def finalize_options(self):
138138
self.copy["library_dirs"] = blas_info.pop(
139139
"library_dirs", []
140140
) + lapack_info.pop("library_dirs", [])
141-
self.copy["libraries"] = blas_info.pop("libraries", []) + lapack_info.pop(
141+
self.copy["libraries"] = blas_info.pop(
142142
"libraries", []
143-
)
143+
) + lapack_info.pop("libraries", [])
144144
self.copy["extra_link_args"] = blas_info.pop(
145145
"extra_link_args", []
146146
) + lapack_info.pop("extra_link_args", [])
@@ -158,92 +158,112 @@ def build_extension(self, ext):
158158

159159

160160
def install_scs(**kwargs):
161-
extra_compile_args = ['-O3']
162-
libraries = []
163-
sources = [
164-
'src/scsmodule.c',
165-
] + glob('scs/src/*.c') + glob('scs/linsys/*.c')
166-
include_dirs = ['scs/include', 'scs/linsys']
167-
define_macros = [('PYTHON', None), ('CTRLC', 1)]
168-
169-
if system() == 'Linux':
170-
libraries += ['rt']
171-
if args.float32:
172-
define_macros += [('SFLOAT', 1)] # single precision floating point
173-
if args.extraverbose:
174-
define_macros += [('VERBOSITY', 999)] # for debugging
175-
if args.blas64:
176-
define_macros += [('BLAS64', 1)] # 64 bit blas
177-
if not args.int32 and not args.gpu:
178-
define_macros += [('DLONG', 1)] # longs for integer type
179-
180-
define_macros += [('COPYAMATRIX', None)]
181-
182-
_scs_direct = Extension(
183-
name='_scs_direct',
184-
sources=sources + glob('scs/linsys/cpu/direct/*.c') +
185-
glob('scs/linsys/external/amd/*.c') +
186-
glob('scs/linsys/external/qdldl/*.c'),
187-
define_macros=list(define_macros),
188-
include_dirs=include_dirs + ['scs/linsys/cpu/direct/',
189-
'scs/linsys/external/amd', 'scs/linsys/external/dqlql'],
190-
libraries=list(libraries),
191-
extra_compile_args=list(extra_compile_args))
192-
193-
_scs_indirect = Extension(
194-
name='_scs_indirect',
195-
sources=sources + glob('scs/linsys/cpu/indirect/*.c'),
196-
define_macros=list(define_macros) + [('PY_INDIRECT', None),
197-
('INDIRECT', 1)],
198-
include_dirs=include_dirs + ['scs/linsys/cpu/indirect/'],
199-
libraries=list(libraries),
200-
extra_compile_args=list(extra_compile_args))
201-
202-
ext_modules = [_scs_direct, _scs_indirect]
203-
204-
if args.gpu:
205-
library_dirs = []
206-
if system() == 'Windows':
207-
include_dirs += [os.environ['CUDA_PATH'] + '/include']
208-
library_dirs = [os.environ['CUDA_PATH'] + '/lib/x64']
209-
else:
210-
include_dirs += ['/usr/local/cuda/include']
211-
library_dirs = ['/usr/local/cuda/lib', '/usr/local/cuda/lib64']
212-
if args.gpu_atrans: # Should be True by default
213-
define_macros += [('GPU_TRANSPOSE_MAT', 1)]
214-
_scs_gpu = Extension(
215-
name='_scs_gpu',
216-
sources=sources + glob('scs/linsys/gpu/*.c') + glob('scs/linsys/gpu/indirect/*.c'),
217-
define_macros=list(define_macros) + [('PY_GPU', None), ('INDIRECT', 1)],
218-
include_dirs=include_dirs + ['scs/linsys/gpu/', 'scs/linsys/gpu/indirect'],
219-
library_dirs=library_dirs,
220-
libraries=libraries + ['cudart', 'cublas', 'cusparse'],
221-
extra_compile_args=list(extra_compile_args))
222-
ext_modules += [_scs_gpu]
223-
224-
setup(
225-
name='scs',
226-
version='3.1.0',
227-
author='Brendan O\'Donoghue',
228-
author_email='[email protected]',
229-
url='http://github.com/cvxgrp/scs',
230-
description='scs: splitting conic solver',
231-
package_dir={'scs': 'src'},
232-
packages=['scs'],
233-
ext_modules=ext_modules,
234-
cmdclass={'build_ext': build_ext_scs},
235-
setup_requires=['numpy >= 1.7'],
236-
install_requires=['numpy >= 1.7', 'scipy >= 0.13.2'],
237-
license='MIT',
238-
zip_safe=False,
239-
# TODO: update this:
240-
long_description=('Solves convex cone programs via operator splitting. '
241-
'Can solve: linear programs (LPs), second-order cone '
242-
'programs (SOCPs), semidefinite programs (SDPs), '
243-
'exponential cone programs (ECPs), and power cone '
244-
'programs (PCPs), or problems with any combination of '
245-
'those cones. See http://github.com/cvxgrp/scs for '
246-
'more details.'))
161+
extra_compile_args = ["-O3"]
162+
libraries = []
163+
sources = (
164+
[
165+
"src/scspy.c",
166+
]
167+
+ glob("scs/src/*.c")
168+
+ glob("scs/linsys/*.c")
169+
)
170+
include_dirs = ["scs/include", "scs/linsys"]
171+
define_macros = [("PYTHON", None), ("CTRLC", 1)]
172+
173+
if system() == "Linux":
174+
libraries += ["rt"]
175+
if args.float32:
176+
define_macros += [("SFLOAT", 1)] # single precision floating point
177+
if args.extraverbose:
178+
define_macros += [("VERBOSITY", 999)] # for debugging
179+
if args.blas64:
180+
define_macros += [("BLAS64", 1)] # 64 bit blas
181+
if not args.int32 and not args.gpu:
182+
define_macros += [("DLONG", 1)] # longs for integer type
183+
184+
_scs_direct = Extension(
185+
name="_scs_direct",
186+
sources=sources
187+
+ glob("scs/linsys/cpu/direct/*.c")
188+
+ glob("scs/linsys/external/amd/*.c")
189+
+ glob("scs/linsys/external/qdldl/*.c"),
190+
depends=glob("src/*.h"),
191+
define_macros=list(define_macros),
192+
include_dirs=include_dirs
193+
+ [
194+
"scs/linsys/cpu/direct/",
195+
"scs/linsys/external/amd",
196+
"scs/linsys/external/dqlql",
197+
],
198+
libraries=list(libraries),
199+
extra_compile_args=list(extra_compile_args),
200+
)
201+
202+
_scs_indirect = Extension(
203+
name="_scs_indirect",
204+
sources=sources + glob("scs/linsys/cpu/indirect/*.c"),
205+
depends=glob("src/*.h"),
206+
define_macros=list(define_macros)
207+
+ [("PY_INDIRECT", None), ("INDIRECT", 1)],
208+
include_dirs=include_dirs + ["scs/linsys/cpu/indirect/"],
209+
libraries=list(libraries),
210+
extra_compile_args=list(extra_compile_args),
211+
)
212+
213+
ext_modules = [_scs_direct, _scs_indirect]
214+
215+
if args.gpu:
216+
library_dirs = []
217+
if system() == "Windows":
218+
include_dirs += [os.environ["CUDA_PATH"] + "/include"]
219+
library_dirs = [os.environ["CUDA_PATH"] + "/lib/x64"]
220+
else:
221+
include_dirs += ["/usr/local/cuda/include"]
222+
library_dirs = ["/usr/local/cuda/lib", "/usr/local/cuda/lib64"]
223+
if args.gpu_atrans: # Should be True by default
224+
define_macros += [("GPU_TRANSPOSE_MAT", 1)]
225+
_scs_gpu = Extension(
226+
name="_scs_gpu",
227+
sources=sources
228+
+ glob("scs/linsys/gpu/*.c")
229+
+ glob("scs/linsys/gpu/indirect/*.c"),
230+
depends=glob("src/*.h"),
231+
define_macros=list(define_macros)
232+
+ [("PY_GPU", None), ("INDIRECT", 1)],
233+
include_dirs=include_dirs
234+
+ ["scs/linsys/gpu/", "scs/linsys/gpu/indirect"],
235+
library_dirs=library_dirs,
236+
libraries=libraries + ["cudart", "cublas", "cusparse"],
237+
extra_compile_args=list(extra_compile_args),
238+
)
239+
ext_modules += [_scs_gpu]
240+
241+
setup(
242+
name="scs",
243+
version="3.2.0",
244+
author="Brendan O'Donoghue",
245+
author_email="[email protected]",
246+
url="http://github.com/cvxgrp/scs",
247+
description="scs: splitting conic solver",
248+
package_dir={"scs": "src"},
249+
packages=["scs"],
250+
ext_modules=ext_modules,
251+
cmdclass={"build_ext": build_ext_scs},
252+
setup_requires=["numpy >= 1.7"],
253+
install_requires=["numpy >= 1.7", "scipy >= 0.13.2"],
254+
license="MIT",
255+
zip_safe=False,
256+
# TODO: update this:
257+
long_description=(
258+
"Solves convex cone programs via operator splitting. "
259+
"Can solve: linear programs (LPs), second-order cone "
260+
"programs (SOCPs), semidefinite programs (SDPs), "
261+
"exponential cone programs (ECPs), and power cone "
262+
"programs (PCPs), or problems with any combination of "
263+
"those cones. See http://github.com/cvxgrp/scs for "
264+
"more details."
265+
),
266+
)
247267

248-
install_scs()
249268

269+
install_scs()

0 commit comments

Comments
 (0)