Skip to content

Commit

Permalink
Now picks up Windows Ipopt binary files that are adjacent to setup.py…
Browse files Browse the repository at this point in the history
… (restores regression) (#220)

* Adds a Github action to build against the Ipopt Windows binaries.

* Update windows.yml

* Update windows.yml

* Add back option for loading Ipopt dlls adjacent to the setup.py on Windows.

* Use Cython <3 in CI.

* Try to fix parsing error.

* Try without quotes.

* Try quoting all deps.

* Fix typo.

* Try tilde instead of <.

* Try cython 0.29.

* Run h2071 after install with windows binaries.

* Try ipopt <3.14.12.

* Set the IPOPTWINDIR, not sure why it wasn't set before.

* Corrected env var.

* Print some info about where ipopt is found.

* Back to ipopt 3.14.

* Run env var before install command.

* Improved print statements in setup.py.
  • Loading branch information
moorepants authored Sep 16, 2023
1 parent 5b089a0 commit 999f0c3
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
channels: conda-forge
miniforge-variant: Mambaforge
- name: Install basic dependencies
run: mamba install -y -v lapack "libblas=*=*netlib" cython>=0.26 "ipopt=${{ matrix.ipopt-version }}" numpy>=1.15 pkg-config>=0.29.2 setuptools>=39.0 --file docs/requirements.txt
run: mamba install -y -v lapack "libblas=*=*netlib" "cython>=0.26,<3" "ipopt=${{ matrix.ipopt-version }}" numpy>=1.15 pkg-config>=0.29.2 setuptools>=39.0 --file docs/requirements.txt
- name: Install CyIpopt
run: |
rm pyproject.toml
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ jobs:
miniforge-variant: Mambaforge
- name: Install basic dependencies
run: |
mamba install -q -y lapack "libblas=*=*netlib" cython>=0.26 "ipopt=${{ matrix.ipopt-version }}" numpy>=1.15 pkg-config>=0.29.2 setuptools>=39.0
mamba install -q -y lapack "libblas=*=*netlib" "ipopt=${{ matrix.ipopt-version }}" "numpy>=1.15" "pkg-config>=0.29.2" "setuptools>=39.0" "cython=0.29.*"
- run: echo "IPOPTWINDIR=USECONDAFORGEIPOPT" >> $GITHUB_ENV
- name: Install CyIpopt
run: |
rm pyproject.toml
Expand All @@ -45,7 +46,7 @@ jobs:
run: |
python -c "import cyipopt"
mamba remove lapack
mamba install -q -y cython>=0.26 "ipopt=${{ matrix.ipopt-version }}" numpy>=1.15 pkg-config>=0.29.2 setuptools>=39.0 pytest>=3.3.2
mamba install -q -y "ipopt=${{ matrix.ipopt-version }}" "numpy>=1.15" "pkg-config>=0.29.2" "setuptools>=39.0" "pytest>=3.3.2" "cython=0.29.*"
mamba list
pytest
- name: Test with pytest and scipy, new ipopt
Expand All @@ -54,6 +55,6 @@ jobs:
# Ipopt needed different libfortrans.
if: (matrix.ipopt-version != '3.12' && matrix.python-version != '3.11') || (matrix.ipopt-version != '3.12' && matrix.python-version != '3.10' && matrix.os != 'macos-latest')
run: |
mamba install -q -y -c conda-forge "cython>=0.26" "ipopt=${{ matrix.ipopt-version }}" "numpy>=1.15" "pkg-config>=0.29.2" "setuptools>=39.0" "scipy=1.9.*" "pytest>=3.3.2"
mamba install -q -y -c conda-forge "ipopt=${{ matrix.ipopt-version }}" "numpy>=1.15" "pkg-config>=0.29.2" "setuptools>=39.0" "scipy=1.9.*" "pytest>=3.3.2" "cython=0.29.*"
mamba list
pytest
26 changes: 26 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: windows

on: [push, pull_request]

# cancels prior builds for this workflow when new commit is pushed
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Manually install on Windows with Ipopt binaries
runs-on: windows-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- run: python -m pip install numpy "cython<3" setuptools
- run: Invoke-WebRequest -Uri "https://github.com/coin-or/Ipopt/releases/download/releases%2F3.13.3/Ipopt-3.13.3-win64-msvs2019-md.zip" -OutFile "Ipopt-3.13.3-win64-msvs2019-md.zip"
- run: 7z x Ipopt-3.13.3-win64-msvs2019-md.zip
- run: mv Ipopt-3.13.3-win64-msvs2019-md/* .
- run: python setup.py install
- run: python examples/hs071.py
8 changes: 8 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,18 @@ def handle_ext_modules_general_os():
# environment variable is set to USECONDAFORGEIPOPT then this setup will be
# run.
if sys.platform == "win32" and ipoptdir == "USECONDAFORGEIPOPT":
print('Using Conda Forge Ipopt on Windows.')
ext_module_data = handle_ext_modules_win_32_conda_forge_ipopt()
elif sys.platform == "win32" and ipoptdir:
print('Using Ipopt in {} directory on Windows.'.format(ipoptdir))
ext_module_data = handle_ext_modules_win_32_other_ipopt()
elif sys.platform == "win32" and not ipoptdir:
ipoptdir = os.path.abspath(os.path.dirname(__file__))
msg = 'Using Ipopt adjacent to setup.py in {} on Windows.'
print(msg.format(ipoptdir))
ext_module_data = handle_ext_modules_win_32_other_ipopt()
else:
print('Using Ipopt found with pkg-config.')
ext_module_data = handle_ext_modules_general_os()
EXT_MODULES, DATA_FILES, include_package_data = ext_module_data
# NOTE : The `name` kwarg here is the distribution name, i.e. the name that
Expand Down

0 comments on commit 999f0c3

Please sign in to comment.