stevengj / nlopt

library for nonlinear optimization, wrapping many algorithms for global and local, constrained or unconstrained, optimization
Other
1.86k stars 574 forks source link

python 3.12 Support #548

Closed Hecatron closed 6 months ago

Hecatron commented 8 months ago

Hi, This is in relation to the python bindings for NLopt

On pypi currently the latest version of python listed as supported is 3.10 https://pypi.org/project/nlopt/2.7.1/ what this means is if you install under python 3.11 / 3.12 it drops down to nlopt version 2.6.2 for some reason because of the way the dependencies are setup

because version 2.6.2 is an old version it causes issues under windows - https://github.com/stevengj/nlopt/issues/507

I've found that manually building the sources and copying the files over for 2.7.1 works under python 3.12 I would raise a pull request to add in the additional supported python platforms, but I've not been able to find that inside this repository (if there's a different one dedicated to the python releases then please let me know)

In my case I'm trying to use this as it's a dependency of https://github.com/bernhard-42/vscode-ocp-cad-viewer

Hecatron commented 8 months ago

Ok so after a bit more digging, it looks like there is a wheel built for 3.11 So this is just a 3.12 issue

I did try force installing it

pip install --target C:\Python312\Lib\site-packages --no-deps --python-version 3.11 https://download.lfd.uci.edu/pythonlibs/archived/nlopt-2.7.1-cp311-cp311-win_amd64.whl

But this lead to another issue of

ModuleNotFoundError: No module named 'imp'

It turns out 3.12 dropped the imp module

so for now I've just dropped back to python 3.11

GroovyMuffins commented 7 months ago

This sounds more like an issue with the packaging. Would assume this is more relevant for the repo linked to the nlopt pypi package: https://github.com/DanielBok/nlopt-python