mechmotum / cyipopt

Cython interface for the interior point optimzer IPOPT
Eclipse Public License 2.0
235 stars 54 forks source link

Added Github action to build wheels. #163

Open moorepants opened 1 year ago

moorepants commented 1 year ago

Here is an example result of what is in a wheel:

Archive:  wheelhouse/cyipopt-1.3.0.dev0-cp39-cp39-linux_x86_64.whl
  Length      Date    Time    Name
---------  ---------- -----   ----
   298424  2022-12-10 08:39   ipopt_wrapper.cpython-39-x86_64-linux-gnu.so
      373  2022-12-10 08:37   cyipopt/__init__.py
     2548  2022-12-10 08:37   cyipopt/ipopt_wrapper.py
    11639  2022-12-10 08:37   cyipopt/scipy_interface.py
     2854  2022-12-10 08:37   cyipopt/utils.py
      279  2022-12-10 08:37   cyipopt/version.py
     5165  2022-12-10 08:37   cyipopt/cython/ipopt.pxd
    34976  2022-12-10 08:37   cyipopt/cython/ipopt_wrapper.pyx
        0  2022-12-10 08:37   cyipopt/tests/__init__.py
     6363  2022-12-10 08:37   cyipopt/tests/conftest.py
        0  2022-12-10 08:37   cyipopt/tests/integration/__init__.py
      498  2022-12-10 08:37   cyipopt/tests/integration/test_hs071.py
        0  2022-12-10 08:37   cyipopt/tests/integration/test_lasso.py
        0  2022-12-10 08:37   cyipopt/tests/integration/test_rosen.py
        0  2022-12-10 08:37   cyipopt/tests/unit/__init__.py
        0  2022-12-10 08:37   cyipopt/tests/unit/test_defaults.py
     4602  2022-12-10 08:37   cyipopt/tests/unit/test_deprecations.py
        0  2022-12-10 08:37   cyipopt/tests/unit/test_errors.py
        0  2022-12-10 08:37   cyipopt/tests/unit/test_exceptions.py
        0  2022-12-10 08:37   cyipopt/tests/unit/test_ipopt_funcs.py
        0  2022-12-10 08:37   cyipopt/tests/unit/test_options.py
     6199  2022-12-10 08:37   cyipopt/tests/unit/test_scipy_optional.py
      486  2022-12-10 08:37   ipopt/__init__.py
      640  2022-12-10 08:39   cyipopt-1.3.0.dev0.dist-info/AUTHORS
    11585  2022-12-10 08:39   cyipopt-1.3.0.dev0.dist-info/LICENSE
     3588  2022-12-10 08:39   cyipopt-1.3.0.dev0.dist-info/METADATA
      103  2022-12-10 08:39   cyipopt-1.3.0.dev0.dist-info/WHEEL
       28  2022-12-10 08:39   cyipopt-1.3.0.dev0.dist-info/top_level.txt
     2497  2022-12-10 08:39   cyipopt-1.3.0.dev0.dist-info/RECORD
---------                     -------
   392847                     29 files
moorepants commented 1 year ago

Windows is giving these errors but the wheel seems to still be built:

--- Logging error ---
Traceback (most recent call last):
  File "C:\Miniconda\envs\test-environment\lib\logging\__init__.py", line 1086, in emit
    stream.write(msg + self.terminator)
ValueError: underlying buffer has been detached
Call stack:
  File "D:\a\cyipopt\cyipopt\setup.py", line 200, in <module>
    setup(name=PACKAGE_NAME,
  File "C:\Miniconda\envs\test-environment\lib\site-packages\setuptools\__init__.py", line 87, in setup
    return distutils.core.setup(**attrs)
  File "C:\Miniconda\envs\test-environment\lib\site-packages\setuptools\_distutils\core.py", line 185, in setup
    return run_commands(dist)
  File "C:\Miniconda\envs\test-environment\lib\site-packages\setuptools\_distutils\core.py", line 201, in run_commands
    dist.run_commands()
  File "C:\Miniconda\envs\test-environment\lib\site-packages\setuptools\_distutils\dist.py", line 968, in run_commands
    self.run_command(cmd)
  File "C:\Miniconda\envs\test-environment\lib\site-packages\setuptools\dist.py", line 1217, in run_command
    super().run_command(command)
  File "C:\Miniconda\envs\test-environment\lib\site-packages\setuptools\_distutils\dist.py", line 987, in run_command
    cmd_obj.run()
  File "C:\Miniconda\envs\test-environment\lib\site-packages\wheel\bdist_wheel.py", line 399, in run
    log.info(f"removing {self.bdist_dir}")
Message: 'removing build\\bdist.win-amd64\\wheel'
Arguments: ()
moorepants commented 1 year ago

The wheel builds, I then remove the conda installed ipopt and numpy and install the wheel with pip. Once installed I try to run and example and get this:

Successfully installed cyipopt-1.3.0.dev0 numpy-1.23.5
Traceback (most recent call last):
  File "/home/runner/work/cyipopt/cyipopt/examples/hs071.py", line 20, in <module>
    import cyipopt
  File "/usr/share/miniconda/envs/test-environment/lib/python3.10/site-packages/cyipopt/__init__.py", line 12, in <module>
    from ipopt_wrapper import *
ImportError: libipopt.so.3: cannot open shared object file: No such file or directory
Error: Process completed with exit code 1.

Looks like ipopt is not included in the wheel.

moorepants commented 1 year ago

Tried auditwheel as suggested at https://github.com/mechmotum/cyipopt/issues/41#issuecomment-1435996883 but get this error:

auditwheel: error: cannot repair "wheelhouse/cyipopt-1.3.0.dev0-cp39-cp39-linux_x86_64.whl" to "manylinux_2_5_x86_64" ABI because of the presence of too-recent versioned symbols. You'll need to compile the wheel on an older toolchain.
moorepants commented 1 year ago

Should try this: https://github.com/messense/auditwheel-symbols

moorepants commented 1 year ago

This explains that building wheels from conda binaries may be possible but not trivial. https://github.com/pypa/cibuildwheel/discussions/773?sort=top