Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

numpy.distutils is no longer available in Python 3.12 #78

Closed
jan-janssen opened this issue Sep 25, 2023 · 22 comments
Closed

numpy.distutils is no longer available in Python 3.12 #78

jan-janssen opened this issue Sep 25, 2023 · 22 comments

Comments

@jan-janssen
Copy link

numpy.distutils has been deprecated in NumPy 1.23.0. It will be removed for Python 3.12; for Python <= 3.11 it will not be removed until 2 years after the Python 3.12 release (Oct 2025).

https://numpy.org/devdocs/reference/distutils_status_migration.html

The use of numpy.distutils caused the Python 3.12 migration on conda-forge to crash conda-forge/scikit-fmm-feedstock#30 . Is it possible to replace numpy.distutils in the setup.py file?

@jkfurtney
Copy link
Member

We are due for an upgrade to the build of this package. Do you have any recommendations? I would appreciate anything you can contribute on this.

@bdale
Copy link

bdale commented Feb 17, 2024

I believe this may be the root cause behind building of the Debian scikit-fmm package to fail now that Python 3.12 is in wide use? I maintain the package as a build dependency for openmotor, not because I'm particularly good with Python, so I don't have any useful suggestions. Just wanted to add weight to this issue.

@jkfurtney
Copy link
Member

Thanks Bdale, and thanks for all your open source work over the years. I will have a look at getting this package to work with Python 3.12 soon.

@ma-sadeghi
Copy link

Just following up to see if there's been any updates. Thanks for all your efforts :)

@jkfurtney
Copy link
Member

OK I am working on this. Reading up a little bit, it looks like NumPy and SciPy moved to building with Meson, so that seems like the way to go. scipy/scipy#13615 https://meson-python.readthedocs.io/en/latest/

@jkfurtney
Copy link
Member

I have something working in this branch: https://github.com/scikit-fmm/scikit-fmm/tree/meson

For now, build with python -m build in the source dir. Can someone test this?

Python 3.12.2 (tags/v3.12.2:6abddd9, Feb  6 2024, 21:26:36) [MSC v.1937 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import skfmm
>>> skfmm.distance([-1,1])
array([-0.5,  0.5])
>>> skfmm.test()
Summary: 374 tests run 0 failures

@jkfurtney
Copy link
Member

I only tested in on Windows 11 with Python 3.12.2 and numpy 1.26.4

@jkfurtney
Copy link
Member

I have the GitHub build action working in Linux but cannot get the Windows test step to work. The README is updated. Once I get get the Windows tests fixed I should be able to merge and do a release. This seems to involve dropping support for Python 3.7 as meson does not support 3.7.

@w8sl
Copy link

w8sl commented Apr 27, 2024

Compiles, installs and works correctly on macOS and Ubuntu. No problems on Sonoma. On Ubuntu 24 LTS it was necessary to extract contents from .whl file and move manually as pip3 install refuses to work with Python 12 (build and meson are available as system packages on Ubuntu)

@jkfurtney
Copy link
Member

I think everything is working for the Python 3.12 build and I am almost ready to do a release. I am stuck on the Windows Github Action for build and test. The build works fine but the tests all fail. The issues seems to be the tests script is run from the source directory and the dll for the c module cannot be found. This works fine in the Linux version. Somehow, I should be able to copy the binaries into the source folder like the python setup.py develop command used to do previously. Or force the tests to run in a different directory. The meson build set up is confusing, does anyone know how to resolve this?

@jkfurtney
Copy link
Member

This is what I keep getting from the Windows build/test action output. The artifacts are fine, all the binary stuff is there.

Run python -c 'import os; os.chdir(".."); import skfmm; print(skfmm.__version__)'
  python -c 'import os; os.chdir(".."); import skfmm; print(skfmm.__version__)'
  python -c 'import os; os.chdir(".."); import skfmm, sys; sys.exit(skfmm.test())'
  shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
  env:
    pythonLocation: C:\hostedtoolcache\windows\Python\3.8.10\x64
    PKG_CONFIG_PATH: C:\hostedtoolcache\windows\Python\3.8.10\x64/lib/pkgconfig
    Python_ROOT_DIR: C:\hostedtoolcache\windows\Python\3.8.10\x64
    Python[2](https://github.com/scikit-fmm/scikit-fmm/actions/runs/8912859692/job/24477172160#step:7:2)_ROOT_DIR: C:\hostedtoolcache\windows\Python\3.8.10\x64
    Python3_ROOT_DIR: C:\hostedtoolcache\windows\Python\[3](https://github.com/scikit-fmm/scikit-fmm/actions/runs/8912859692/job/24477172160#step:7:3).8.10\x64
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\hostedtoolcache\windows\Python\3.8.10\x6[4](https://github.com/scikit-fmm/scikit-fmm/actions/runs/8912859692/job/24477172160#step:7:4)\lib\site-packages\skfmm\__init__.py", line 51, in <module>
    from .pfmm import distance, travel_time, extension_velocities
  File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\site-packages\skfmm\pfmm.py", line 4, in <module>
    from .cfmm import cFastMarcher
ImportError: DLL load failed while importing cfmm: The specified module could not be found.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\site-packages\skfmm\__init__.py", line [5](https://github.com/scikit-fmm/scikit-fmm/actions/runs/8912859692/job/24477172160#step:7:5)1, in <module>
    from .pfmm import distance, travel_time, extension_velocities
  File "C:\hostedtoolcache\windows\Python\3.8.10\x[6](https://github.com/scikit-fmm/scikit-fmm/actions/runs/8912859692/job/24477172160#step:7:6)4\lib\site-packages\skfmm\pfmm.py", line 4, in <module>
    from .cfmm import cFastMarcher
ImportError: DLL load failed while importing cfmm: The specified module could not be found.
Error: Process completed with exit code 1.

@w8sl
Copy link

w8sl commented May 1, 2024

Both Ubuntu and Arch prefer meson and python3-build resp. python-build as system packages if system-wide Python is used. Build works from a clone of meson branch.
pip3 resp pip install from .whl file works, when forced with "--break-system-packages" option.
skfmm works correctly - creating distance masks in Ortho4XP.

Using Python 3.12.2 via pyenv or venv on Linux makes installation easier. Instructions from readme and binary work perfectly!

Install on Python 3.12.3 works on macOS Sonoma and Widows (gcc) directly - without problems.

@bdale
Copy link

bdale commented May 27, 2024

Any update? Still hoping for a new release supporting Python 3.12 I can package for Debian.

@jkfurtney
Copy link
Member

Everything is ready to go for the Linux version, I am stuck on the Windows build. I merged the meson branch into main. Let me tinker with the Windows build a little more, I will get a release out as soon as I can.

@jkfurtney
Copy link
Member

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[1], line 1
----> 1 import skfmm

File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\skfmm\__init__.py:51
     48 __version__ = "2024.05.28"
     49 __docformat__ = 'restructuredtext'
---> 51 from .pfmm import distance, travel_time, extension_velocities
     52 from .heap import heap
     54 def testing():

File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\skfmm\pfmm.py:4
      1 from sys import float_info
      2 import numpy as np
----> 4 from cfmm import cFastMarcher
      6 FAR, NARROW, FROZEN, MASK = 0, 1, 2, 3
      7 DISTANCE, TRAVEL_TIME, EXTENSION_VELOCITY = 0, 1, 2

ModuleNotFoundError: No module named 'cfmm'

@jkfurtney
Copy link
Member

This is the error I get when I install the wheels from the Github action. The dll (.pyd) is there in the correct place so I am not sure what the problem is. This is the same failure the github action build has on Windows. When I install from source on Windows it works for me. One option is to do a release with no Windows binary wheels.

@w8sl
Copy link

w8sl commented May 29, 2024

I have no access to Windows in coming weeks. I have seen some warnings during compilation of C code on all systems but it has been working anyway.

Flow modified by https://github.com/JT8D-17 has been tested in Python 3.12 venv on macOS, Arch Linux and Ubuntu 24 :

pip install build
git clone https://github.com/scikit-fmm/scikit-fmm.git $path_to_venv/scikit-fmm
python -m build $path_to_venv/scikit-fmm
pip install $path_to_venv/scikit-fmm

Recommended flow is also working:
cd $path_to_git_clone_of/scikit-fmm
python -m build
pip install .

Build from downloaded scikit-fmm-master.zip works this way:
python or python3 -m build --wheel
pip or pip3 install $path_to/scikit-fmm-master/dist/scikit_fmm-2024.5.28-cp312-cp312.........whl

@w8sl
Copy link

w8sl commented May 29, 2024

Congratulations for solving the problem!
Running test from a source directory was it!

@jkfurtney
Copy link
Member

OK, I pushed out a release with source code only. I will work on the Windows wheels as time allows. The Linux wheels are fine but need to be converted to a different format.

Let me know if there are any problems.

@w8sl
Copy link

w8sl commented May 29, 2024

Installed from PyPi in Python 3.12 venv on macOS, Ubuntu 24 and Arch.
12 tests passed with 0 errors.
Thank You!

@jan-janssen
Copy link
Author

Thank you so much - this fixed the conda package conda-forge/scikit-fmm-feedstock#32

@w8sl
Copy link

w8sl commented May 30, 2024

A suggestion: Windows binary wheels are available from PyPI.

Christoph Gohlke has moved to GitHub, but I don't see scikit-fmm on the list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants