-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Meson Build + Proper Windows Support (#300)
Co-authored-by: Jack Myers <[email protected]> Co-authored-by: Neil Wu <[email protected]> Co-authored-by: Neil Wu <[email protected]> Co-authored-by: Sabet Seraj <[email protected]>
- Loading branch information
1 parent
4ae37e6
commit 7b98186
Showing
45 changed files
with
854 additions
and
2,366 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
dependencies: | ||
# build | ||
- python >=3.8 | ||
- numpy >=1.16 | ||
- ipopt | ||
- swig | ||
- meson >=0.60 | ||
- compilers | ||
- pkg-config | ||
- pip | ||
- setuptools | ||
- build | ||
# testing | ||
- parameterized | ||
- testflo | ||
- scipy >1.2 | ||
- mdolab-baseclasses >=1.3.1 | ||
- sqlitedict >=1.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
trigger: | ||
- main | ||
|
||
pr: | ||
- main | ||
|
||
pool: | ||
vmImage: windows-latest | ||
|
||
jobs: | ||
- job: Windows | ||
steps: | ||
- powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts" | ||
displayName: Add conda to PATH | ||
|
||
- script: conda config --add channels conda-forge && conda config --set channel_priority strict | ||
displayName: Set channel priority | ||
|
||
- script: conda create --yes --name pyos-build | ||
displayName: Create environment | ||
|
||
- script: | | ||
call activate pyos-build | ||
call conda install -y mamba | ||
call mamba env update --file .github/environment.yml | ||
call mamba install -y libpgmath | ||
displayName: Install mamba and update environment | ||
- script: | | ||
set IPOPT_DIR=%CONDA_PREFIX%\Library | ||
set CC=cl | ||
set FC=flang | ||
set CC_LD=link | ||
python -m build -n -x . | ||
pip install --no-deps --no-index --find-links dist pyoptsparse | ||
displayName: Build and install pyoptsparse | ||
- script: | | ||
cd tests | ||
testflo -n 1 . | ||
displayName: Run tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: PyOptSparse Windows Actions | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build-windows: | ||
runs-on: windows-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: conda-incubator/setup-miniconda@v2 | ||
with: | ||
python-version: 3.8 | ||
mamba-version: "*" | ||
channels: conda-forge,defaults | ||
channel-priority: strict | ||
activate-environment: pyos-build | ||
environment-file: .github/environment.yml | ||
- name: Install libpgmath | ||
shell: bash -l {0} | ||
run: | | ||
conda activate pyos-build | ||
mamba install libpgmath | ||
- name: Build and install pyoptsparse | ||
shell: cmd /C CALL {0} | ||
run: | | ||
call conda activate pyos-build | ||
set IPOPT_DIR=%CONDA_PREFIX%\Library | ||
set CC=cl | ||
set FC=flang | ||
set CC_LD=link | ||
python -m build -n -x . | ||
pip install --no-deps --no-index --find-links dist pyoptsparse | ||
- name: Run tests | ||
shell: bash -l {0} | ||
run: | | ||
conda activate pyos-build | ||
cd tests | ||
testflo --pre_announce -v -n 1 . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Much of this is from SciPy | ||
|
||
project( | ||
'pyoptsparse', | ||
'c', 'cpp', | ||
# unnecessary metadata commented out until Meson supports PEP517 and installation with pip | ||
# version: 'x.x.x', | ||
# license: 'GPL-3', | ||
meson_version: '>= 0.60', | ||
default_options: [ | ||
'buildtype=debugoptimized', | ||
'c_std=c99', | ||
'cpp_std=c++14', | ||
], | ||
) | ||
|
||
fortranobject_c = '../fortranobject.c' | ||
|
||
cc = meson.get_compiler('c') | ||
cpp = meson.get_compiler('cpp') | ||
|
||
# We need -lm for all C code (assuming it uses math functions, which is safe to | ||
# assume for SciPy). For C++ it isn't needed, because libstdc++/libc++ is | ||
# guaranteed to depend on it. For Fortran code, Meson already adds `-lm`. | ||
m_dep = cc.find_library('m', required : false) | ||
if m_dep.found() | ||
add_project_link_arguments('-lm', language : 'c') | ||
endif | ||
|
||
# Adding at project level causes many spurious -lgfortran flags. | ||
add_languages('fortran', native: false) | ||
|
||
# https://mesonbuild.com/Python-module.html | ||
# Here we differentiate from the python used by meson, py3_command, and that python target, py3_target. This is useful | ||
# when cross compiling like on conda-forge | ||
py_mod = import('python') | ||
py3_command = py_mod.find_installation() | ||
if get_option('python_target') != '' | ||
py3_target = py_mod.find_installation(get_option('python_target')) | ||
else | ||
py3_target = py3_command | ||
endif | ||
py3_dep = py3_target.dependency() | ||
|
||
subdir('pyoptsparse') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
option('ipopt_dir', type: 'string', value: '', | ||
description: 'Top-level dir for ipopt') | ||
|
||
option('incdir_numpy', type: 'string', value: '', | ||
description: 'Include directory for numpy. If left empty Meson will try to find it on its own.') | ||
|
||
option('python_target', type: 'string', value: '', | ||
description: '''Target python path. This is used in the case that the Python installation that PyOptSparse is intended | ||
to be built for is different than the Python installation that is used to run Meson. For example, Meson may be installed | ||
on the user's system which is run using the system Python installation, but the user may want build PyOptSparse for | ||
a Python installation in a virtual environment. Leave as an empty string to build for Python installation running | ||
Meson.''') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.