├── __init__.py ├── __main__.py ├── .github ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── test_workflow.yml ├── NOTICE ├── pyproject.toml ├── README.md └── LICENSE /__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = '2.0.12' 2 | -------------------------------------------------------------------------------- /__main__.py: -------------------------------------------------------------------------------- 1 | from . import perform_install 2 | 3 | if __name__ == '__main__': 4 | perform_install() 5 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Summary 2 | 3 | Summary of PR. 4 | 5 | ### Related Issues 6 | 7 | - Resolves # 8 | 9 | ### Backwards incompatibilities 10 | 11 | None 12 | 13 | ### New Dependencies 14 | 15 | None 16 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Copyright 2023 OpenMDAO 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this software except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["hatchling"] 3 | build-backend = "hatchling.build" 4 | 5 | [project] 6 | name = "build-pyoptsparse" 7 | dynamic = ["version"] 8 | description = "Automated installer for pyOptSparse" 9 | readme = "README.md" 10 | license = "Apache-2.0" 11 | requires-python = ">=3.7" 12 | authors = [ 13 | { name = "OpenMDAO Team", email = "openmdao@openmdao.org" }, 14 | ] 15 | dependencies = [ 16 | "ansicolors", 17 | "numpy", 18 | "cython", 19 | "packaging", 20 | "sqlitedict", 21 | ] 22 | 23 | [project.optional-dependencies] 24 | paropt = [ 25 | "mpi4py", 26 | ] 27 | 28 | [project.scripts] 29 | build-pyoptsparse = "build_pyoptsparse:perform_install" 30 | build_pyoptsparse = "build_pyoptsparse:perform_install" 31 | 32 | [project.urls] 33 | Homepage = "http://openmdao.org" 34 | 35 | [tool.hatch.version] 36 | path = "__init__.py" 37 | 38 | [tool.hatch.build.targets.sdist] 39 | include = [ 40 | "/", 41 | ] 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # build_pyoptsparse 2 | This script was written to overcome the complexities of building pyOptSparse and IPOPT. It can download and install IPOPT and other dependencies and pyOptSparse itself. This behavior can be adjusted with various command-line switches. 3 | 4 | Support for **conda** and will be used if either has been activated, unless disabled by command line arguments. In both cases, software will be installed under the virtual environment folder. If a conda environment is active and **mamba** is available, it will be used to install/uninstall to improve performance. 5 | 6 | Alternatively, if a **venv** environement is active, the script will install to that virtual environment's folder. 7 | 8 | For dependencies that require building, temporary directories are used then removed by default after the item has been installed. 9 | 10 | By default, MUMPS is used as the linear solver, but if HSL or PARDISO are available, one of those can be selected instead. 11 | 12 | The script performs checks the environment by testing for commands that are required to build or install pyOptSparse and it dependencies. 13 | 14 | If you have a previous installation of pyOptSparse and its dependencies and are encountering errors when running this script, try using the --uninstall switch first to remove old include/library files. 15 | 16 | To install: 17 | 1. Activate your virtual environment 18 | 2. Git clone the repository 19 | 3. Run `python -m pip install ./build_pyoptsparse`. 20 | If ParOpt support is desired, run `python -m pip install './build_pyoptsparse[paropt]'` 21 | 22 | ## Usage 23 | ``` 24 | usage: build_pyoptsparse [-h] [-a] [-b BRANCH] [-c CONDA_CMD] [-d] [-e] [-f] [-k] [-i] 25 | [-l {mumps,hsl,pardiso}] [-m] [-n] [-o] [-p PREFIX] [-s SNOPT_DIR] 26 | [-t HSL_TAR_FILE] [-u] [-v] 27 | 28 | Download, configure, build, and/or install pyOptSparse with dependencies. 29 | Temporary working directories are created, which are removed after 30 | installation unless -d is used. 31 | 32 | When running with a conda environment active, all packages that can be installed 33 | with conda will be, except when command line arguments modify this behavior. If 34 | found, mamba will be used to install/uninstall unless -m is invoked. 35 | 36 | 37 | options: 38 | -h, --help show this help message and exit 39 | -a, --paropt Add ParOpt support. Default: no ParOpt 40 | -b BRANCH, --branch BRANCH 41 | pyOptSparse git branch. Default: v2.9.2 42 | -c CONDA_CMD, --conda-cmd CONDA_CMD 43 | Command to install packages with if conda is used. Default: conda 44 | -d, --no-delete Do not erase the build directories after completion. 45 | -e, --ignore-conda Do not install conda packages, install under conda environment, or 46 | uninstall from the conda environment. 47 | -f, --force-build Build/rebuild packages even if found to be installed or can be installed 48 | with conda. 49 | -k, --no-sanity-check 50 | Skip the sanity checks. 51 | -i, --intel Build with the Intel compiler suite instead of GNU. 52 | -l {mumps,hsl,pardiso}, --linear-solver {mumps,hsl,pardiso} 53 | Which linear solver to use with IPOPT. Default: mumps 54 | -m, --ignore-mamba Do not use mamba to install conda packages. Default: Use mamba if found 55 | -n, --no-install Prepare, but do not build/install pyOptSparse itself. Default: 56 | install 57 | -o, --no-ipopt Do not install IPOPT. Default: install IPOPT 58 | -p PREFIX, --prefix PREFIX 59 | Where to install if not a conda/venv environment. Default: 60 | $HOME/pyoptsparse 61 | -s SNOPT_DIR, --snopt-dir SNOPT_DIR 62 | Include SNOPT from SNOPT-DIR. Default: no SNOPT 63 | -t HSL_TAR_FILE, --hsl-tar-file HSL_TAR_FILE 64 | If HSL is the linear solver, use this as the path to the tar file of the 65 | HSL source. E.g. -t ../../coinhsl-archive-2014.01.17.tar.gz 66 | -u, --uninstall Attempt to remove an installation previously built from source (using the 67 | same --prefix) and/or installed with conda in the same environment, then 68 | exit. Default: Do not uninstall 69 | -v, --verbose Show output from git, configure, make, conda, etc. and expand all 70 | environment variables. 71 | 72 | NOTES: 73 | When using HSL as the linear solver, the source code tar file can be obtained 74 | from http://www.hsl.rl.ac.uk/ipopt/ 75 | If PARDISO is selected as the linear solver, the Intel compiler suite with MKL 76 | must be available. 77 | 78 | Examples: 79 | build_pyoptsparse 80 | build_pyoptsparse --intel --linear-solver=pardiso 81 | build_pyoptsparse -l hsl -n -t ../../coinhsl-archive-2014.01.17.tar.gz 82 | ``` 83 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | -------------------------------------------------------------------------------- /.github/workflows/test_workflow.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | 3 | on: 4 | # Trigger on push or pull request events for the master branch 5 | push: 6 | branches: [ master ] 7 | pull_request: 8 | branches: [ master ] 9 | 10 | # Run the workflow Sundays at 0400 UTC 11 | schedule: 12 | - cron: '0 4 * * 0' 13 | 14 | # Allow running the workflow manually from the Actions tab 15 | workflow_dispatch: 16 | inputs: 17 | run_name: 18 | description: 'Name of workflow run as it will appear under Actions tab (optional):' 19 | type: string 20 | required: false 21 | default: '' 22 | job_name: 23 | description: 'Select a job from the matrix to run (default: all jobs)' 24 | type: choice 25 | options: 26 | - '' 27 | - 'Ubuntu Default' 28 | - 'Ubuntu Default, no MPI' 29 | - 'Ubuntu Default, Numpy 2.x' 30 | - 'MacOS Default, NumPy 2.x' 31 | - 'Ubuntu Latest' 32 | - 'Ubuntu Default, no SciPy' 33 | - 'MacOS Default, SciPy from PyPI' 34 | - 'Ubuntu Oldest' 35 | - 'Ubuntu Default, no MPI, forced build' 36 | - 'Ubuntu Latest, no MPI, forced build' 37 | required: false 38 | default: '' 39 | debug_enabled: 40 | description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' 41 | type: boolean 42 | required: false 43 | default: false 44 | 45 | run-name: ${{ inputs.run_name }} 46 | 47 | jobs: 48 | 49 | tests: 50 | 51 | timeout-minutes: 30 52 | 53 | strategy: 54 | fail-fast: false 55 | matrix: 56 | include: 57 | 58 | # test default pyoptsparse on Ubuntu, Numpy 1.x 59 | - NAME: Ubuntu Default 60 | OS: ubuntu-latest 61 | PY: '3.12' 62 | NUMPY: '1.26' 63 | SCIPY: '1.13' 64 | MPI: true 65 | PYOPTSPARSE: 'default' 66 | # PAROPT: true 67 | SNOPT: 7.7 68 | 69 | # test default pyoptsparse on Ubuntu, NumPy 1.x, no MPI 70 | - NAME: Ubuntu Default, no MPI 71 | OS: ubuntu-latest 72 | PY: '3.12' 73 | NUMPY: '1.26' 74 | SCIPY: '1.13' 75 | PYOPTSPARSE: 'default' 76 | SNOPT: 7.7 77 | 78 | # test default pyoptsparse on Ubuntu, Numpy 2.x 79 | - NAME: Ubuntu Default, Numpy 2.x 80 | OS: ubuntu-latest 81 | PY: '3.13' 82 | NUMPY: '2.2' 83 | SCIPY: '1.15' 84 | MPI: true 85 | PYOPTSPARSE: 'default' 86 | # PAROPT: true 87 | SNOPT: 7.7 88 | 89 | # test default pyoptsparse on MacOS latest (ARM), NumPy 2.x 90 | - NAME: MacOS Default, NumPy 2.x 91 | OS: macos-latest 92 | PY: '3.12' 93 | NUMPY: '1.26' 94 | SCIPY: '1.13' 95 | MPI: true 96 | PYOPTSPARSE: 'default' 97 | SNOPT: 7.7 98 | 99 | # test latest release of pyoptsparse, NumPy 2.x 100 | - NAME: Ubuntu Latest 101 | OS: ubuntu-latest 102 | PY: 3.13 103 | NUMPY: 2.2 104 | SCIPY: 1.16 105 | MPI: true 106 | PYOPTSPARSE: 'latest' 107 | # PAROPT: true 108 | SNOPT: 7.7 109 | 110 | # test default release of pyoptsparse, NumPy 2.x, no scipy 111 | - NAME: Ubuntu Default, no SciPy 112 | OS: ubuntu-latest 113 | PY: 3.13 114 | NUMPY: 2.2 115 | MPI: true 116 | PYOPTSPARSE: 'default' 117 | # PAROPT: true 118 | SNOPT: 7.7 119 | 120 | # test default release of pyoptsparse, NumPy 2.x, scipy from pypi 121 | - NAME: MacOS Default, SciPy from PyPI 122 | OS: macos-latest 123 | PY: '3.12' 124 | NUMPY: '1.26' 125 | SCIPY: '1.13' 126 | SCIPY_FROM_PYPI: true 127 | MPI: true 128 | PYOPTSPARSE: 'default' 129 | # PAROPT: true 130 | SNOPT: 7.7 131 | 132 | # test oldest supported version of pyoptsparse 133 | - NAME: Ubuntu Oldest 134 | OS: ubuntu-latest 135 | PY: 3.8 136 | NUMPY: 1.22 137 | SCIPY: 1.7 138 | PYOPTSPARSE: 'v2.9.0' 139 | NO_IPOPT: true 140 | SNOPT: 7.2 141 | 142 | # test default pyoptsparse on Ubuntu without MPI with forced build, NumPy 1.x 143 | - NAME: Ubuntu Default, no MPI, forced build 144 | OS: ubuntu-latest 145 | PY: '3.12' 146 | NUMPY: '1.26' 147 | SCIPY: '1.13' 148 | PYOPTSPARSE: 'default' 149 | SNOPT: 7.7 150 | FORCE_BUILD: true 151 | GCC: 'gcc=13.3' 152 | 153 | # test latest pyoptsparse without MPI with forced build 154 | - NAME: Ubuntu Latest, no MPI, forced build 155 | OS: ubuntu-latest 156 | PY: 3.13 157 | NUMPY: 2.2 158 | SCIPY: 1.15 159 | PYOPTSPARSE: 'latest' 160 | SNOPT: 7.7 161 | FORCE_BUILD: true 162 | GCC: 'gcc=13.3' 163 | 164 | runs-on: ${{ matrix.OS }} 165 | 166 | name: ${{ matrix.NAME }} 167 | 168 | defaults: 169 | run: 170 | shell: bash -l {0} 171 | 172 | steps: 173 | - name: Display run details 174 | run: | 175 | echo "=============================================================" 176 | echo "Run #${GITHUB_RUN_NUMBER}" 177 | echo "Run ID: ${GITHUB_RUN_ID}" 178 | echo "Testing: ${GITHUB_REPOSITORY}" 179 | echo "Triggered by: ${GITHUB_EVENT_NAME}" 180 | echo "Initiated by: ${GITHUB_ACTOR}" 181 | echo "=============================================================" 182 | 183 | - name: Exit if this job was not selected 184 | if: github.event_name == 'workflow_dispatch' && inputs.job_name != '' && inputs.job_name != matrix.NAME 185 | uses: actions/github-script@v7 186 | with: 187 | script: core.setFailed('The ${{ matrix.NAME }} job was not included in the run, exiting...'); 188 | 189 | - name: Create SSH key 190 | if: matrix.SNOPT 191 | env: 192 | SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} 193 | SSH_KNOWN_HOSTS: ${{ secrets.SSH_KNOWN_HOSTS }} 194 | run: | 195 | mkdir -p ~/.ssh/ 196 | echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa 197 | sudo chmod 600 ~/.ssh/id_rsa 198 | echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts 199 | 200 | - name: Checkout code 201 | uses: actions/checkout@v4 202 | 203 | - name: Setup conda 204 | uses: conda-incubator/setup-miniconda@v3 205 | with: 206 | miniconda-version: latest 207 | python-version: ${{ matrix.PY }} 208 | channels: conda-forge 209 | 210 | - name: Install 211 | run: | 212 | if [[ "${{ matrix.NUMPY}}" ]]; then 213 | if [[ "${{ matrix.SCIPY_FROM_PYPI }}" ]]; then 214 | echo "=============================================================" 215 | echo "Install NumPy from PyPI" 216 | echo "=============================================================" 217 | python -m pip install numpy==${{ matrix.NUMPY }} 218 | else 219 | echo "=============================================================" 220 | echo "Install NumPy from conda-forge" 221 | echo "=============================================================" 222 | conda install numpy=${{ matrix.NUMPY }} -c conda-forge -q -y 223 | fi 224 | fi 225 | 226 | if [[ "${{ matrix.SCIPY}}" ]]; then 227 | if [[ "${{ matrix.SCIPY_FROM_PYPI }}" ]]; then 228 | echo "=============================================================" 229 | echo "Install SciPy from PyPI" 230 | echo "=============================================================" 231 | python -m pip install scipy==${{ matrix.SCIPY }} 232 | else 233 | echo "=============================================================" 234 | echo "Install SciPy from conda-forge" 235 | echo "=============================================================" 236 | conda install scipy=${{ matrix.SCIPY }} -c conda-forge -q -y 237 | fi 238 | fi 239 | 240 | conda install cython swig compilers=1.10 ${{ matrix.GCC }} cmake meson liblapack openblas -q -y 241 | 242 | if [[ "${{ matrix.XCODE }}" ]]; then 243 | sudo xcode-select -s "/Applications/Xcode_${{ matrix.XCODE }}.app" 244 | fi 245 | 246 | echo "=============================================================" 247 | echo "Install build_pyoptsparse" 248 | echo "=============================================================" 249 | python -m pip install . 250 | 251 | - name: Install MPI 252 | if: matrix.MPI 253 | run: | 254 | echo "=============================================================" 255 | echo "Install MPI" 256 | echo "=============================================================" 257 | conda install openmpi-mpicc mpi4py -q -y 258 | 259 | echo "PRTE_MCA_rmaps_default_mapping_policy=:oversubscribe" >> $GITHUB_ENV 260 | echo "OMPI_MCA_rmaps_base_oversubscribe=1" >> $GITHUB_ENV 261 | echo "OMPI_MCA_btl=^openib" >> $GITHUB_ENV 262 | 263 | - name: Display environment before 264 | run: | 265 | conda info 266 | conda list 267 | 268 | echo "=============================================================" 269 | echo "Check installed versions of Python, Numpy and Scipy" 270 | echo "=============================================================" 271 | python -c "import sys; assert str(sys.version).startswith(str(${{ matrix.PY }})), \ 272 | f'Python version {sys.version} is not the requested version (${{ matrix.PY }})'" 273 | 274 | python -c "import numpy; assert str(numpy.__version__).startswith(str(${{ matrix.NUMPY }})), \ 275 | f'Numpy version {numpy.__version__} is not the requested version (${{ matrix.NUMPY }})'" 276 | 277 | if [[ "${{ matrix.SCIPY}}" ]]; then 278 | python -c "import scipy; assert str(scipy.__version__).startswith(str(${{ matrix.SCIPY }})), \ 279 | f'Scipy version {scipy.__version__} is not the requested version (${{ matrix.SCIPY }})'" 280 | fi 281 | 282 | - name: Build pyOptSparse 283 | run: | 284 | echo "=============================================================" 285 | echo "Build pyoptsparse" 286 | echo "=============================================================" 287 | 288 | if [[ "${{ matrix.PYOPTSPARSE }}" == "default" ]]; then 289 | BRANCH="" 290 | elif [[ "${{ matrix.PYOPTSPARSE }}" == "latest" ]]; then 291 | LATEST_URL=`curl -fsSLI -o /dev/null -w %{url_effective} https://github.com/mdolab/pyoptsparse/releases/latest` 292 | LATEST_VER=`echo $LATEST_URL | awk '{split($0,a,"/tag/"); print a[2]}'` 293 | BRANCH="-b $LATEST_VER" 294 | else 295 | BRANCH="-b ${{ matrix.PYOPTSPARSE }}" 296 | fi 297 | 298 | if [[ "${{ matrix.PAROPT }}" ]]; then 299 | PAROPT="-a" 300 | fi 301 | 302 | if [[ "${{ matrix.SNOPT }}" == "7.7" && "${{ secrets.SNOPT_LOCATION_77 }}" ]]; then 303 | echo " > Secure copying SNOPT 7.7 over SSH" 304 | mkdir SNOPT 305 | scp -qr ${{ secrets.SNOPT_LOCATION_77 }} SNOPT 306 | SNOPT="-s SNOPT/src" 307 | elif [[ "${{ matrix.SNOPT }}" == "7.2" && "${{ secrets.SNOPT_LOCATION_72 }}" ]]; then 308 | echo " > Secure copying SNOPT 7.2 over SSH" 309 | mkdir SNOPT 310 | scp -qr ${{ secrets.SNOPT_LOCATION_72 }} SNOPT 311 | SNOPT="-s SNOPT/source" 312 | elif [[ "${{ matrix.SNOPT }}" ]]; then 313 | echo "SNOPT version ${{ matrix.SNOPT }} was requested but source is not available" 314 | fi 315 | 316 | if [[ "${{ matrix.LINEAR_SOLVER }}" == "hsl" ]]; then 317 | if "${{ secrets.HSL_LOCATION }}" ]]; then 318 | scp -q ${{ secrets.HSL_LOCATION }} hsl.tar.gz 319 | LINEAR_SOLVER="-l hsl -t hsl.tar.gz" 320 | else 321 | echo "---------------------------------------------------------------------------" 322 | echo "HSL was requested but source is not available, using default linear solver." 323 | echo "---------------------------------------------------------------------------" 324 | fi 325 | elif [[ "${{ matrix.LINEAR_SOLVER }}" == "pardiso" ]]; then 326 | echo "-------------------------------------------------------------------------------" 327 | echo "Pardiso requires Intel compilers, which are not installed. The build will fail." 328 | echo "-------------------------------------------------------------------------------" 329 | LINEAR_SOLVER="-l pardiso" 330 | fi 331 | 332 | if [[ "${{ matrix.NO_IPOPT }}" ]]; then 333 | NO_IPOPT="--no-ipopt" 334 | fi 335 | 336 | if [[ "${{ matrix.FORCE_BUILD }}" ]]; then 337 | FORCE_BUILD="--force-build" 338 | fi 339 | 340 | echo "build_pyoptsparse -v $BRANCH $FORCE_BUILD $PAROPT $SNOPT $NO_IPOPT $LINEAR_SOLVER" 341 | build_pyoptsparse -v $BRANCH $FORCE_BUILD $PAROPT $SNOPT $NO_IPOPT $LINEAR_SOLVER -d 342 | 343 | echo "BRANCH=${BRANCH}" >> $GITHUB_ENV 344 | 345 | - name: Display build log 346 | if: failure() 347 | run: | 348 | for f in $(find /tmp/ -name 'meson-log.txt'); do 349 | echo "=============================================================" 350 | echo $f 351 | echo "=============================================================" 352 | cat $f 353 | done 354 | if test -d /private/var/folders; then 355 | for f in $(find /private/var/folders/ -name 'meson-log.txt'); do 356 | echo "=============================================================" 357 | echo $f 358 | echo "=============================================================" 359 | cat $f 360 | done 361 | for f in $(find /private/var/folders/ -name 'compile.log'); do 362 | echo "=============================================================" 363 | echo $f 364 | echo "=============================================================" 365 | cat $f 366 | done 367 | fi 368 | 369 | # Enable tmate debugging of manually-triggered workflows if the input option was provided 370 | # 371 | # To access the terminal through the web-interface: 372 | # 1. Click on the web-browser link printed out in this action from the github 373 | # workflow terminal 374 | # 2. Press cntrl + c in the new tab that opens up to reveal the terminal 375 | # 3. To activate the conda environment run: 376 | # $ source $CONDA/etc/profile.d/conda.sh 377 | # $ conda activate test 378 | - name: Setup tmate session 379 | if: github.event_name == 'workflow_dispatch' && inputs.debug_enabled && inputs.job_name == matrix.NAME 380 | uses: mxschmitt/action-tmate@v3 381 | with: 382 | limit-access-to-actor: true 383 | 384 | - name: Setup tmate session after failure 385 | if: github.event_name == 'workflow_dispatch' && inputs.debug_enabled && inputs.job_name == matrix.NAME && failure() 386 | uses: mxschmitt/action-tmate@v3 387 | with: 388 | limit-access-to-actor: true 389 | 390 | - name: Display environment after 391 | run: | 392 | conda info 393 | conda list 394 | 395 | echo "=============================================================" 396 | echo "Check installed versions of Python, Numpy and Scipy" 397 | echo "=============================================================" 398 | python -c "import sys; assert str(sys.version).startswith(str(${{ matrix.PY }})), \ 399 | f'Python version {sys.version} is not the requested version (${{ matrix.PY }})'" 400 | 401 | python -c "import numpy; assert str(numpy.__version__).startswith(str(${{ matrix.NUMPY }})), \ 402 | f'Numpy version {numpy.__version__} is not the requested version (${{ matrix.NUMPY }})'" 403 | 404 | python -c "import scipy; assert str(scipy.__version__).startswith(str(${{ matrix.SCIPY }})), \ 405 | f'Scipy version {scipy.__version__} is not the requested version (${{ matrix.SCIPY }})'" 406 | 407 | - name: Run tests 408 | run: | 409 | python -m pip install testflo parameterized six 410 | 411 | echo "=============================================================" 412 | echo "Run tests from pyoptsparse repository" 413 | echo "=============================================================" 414 | unset DYLD_LIBRARY_PATH 415 | 416 | if [[ "$BRANCH" == "" ]]; then 417 | BRANCH=`python -c "from build_pyoptsparse import build_info; print(build_info['pyoptsparse']['branch'])"` 418 | BRANCH="-b $BRANCH" 419 | fi 420 | 421 | echo "git clone $BRANCH https://github.com/mdolab/pyoptsparse" 422 | git clone $BRANCH https://github.com/mdolab/pyoptsparse 423 | 424 | cd pyoptsparse/test*/ 425 | testflo --pre_announce --timeout=120 --show_skipped . 426 | 427 | - name: Audit dependencies 428 | id: audit 429 | continue-on-error: true 430 | run: | 431 | python -m pip install pip-audit 432 | 433 | echo "=============================================================" 434 | echo "Scan environment for packages with known vulnerabilities" 435 | echo "=============================================================" 436 | python -m pip_audit 437 | 438 | - name: Slack audit warnings 439 | if: steps.audit.outcome == 'failure' && matrix.NAME != 'Ubuntu Oldest' 440 | uses: act10ns/slack@v2.0.0 441 | with: 442 | webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }} 443 | status: 'warning' 444 | message: | 445 | pip-audit detected vulnerabilities. 446 | ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} 447 | 448 | - name: Notify slack 449 | uses: act10ns/slack@v2.0.0 450 | with: 451 | webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }} 452 | status: ${{ job.status }} 453 | if: failure() 454 | --------------------------------------------------------------------------------