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

Python 3.13 support #2640

Open
sanjayankur31 opened this issue Dec 12, 2023 · 4 comments
Open

Python 3.13 support #2640

sanjayankur31 opened this issue Dec 12, 2023 · 4 comments

Comments

@sanjayankur31
Copy link
Contributor

Filing this early because the Fedora Python maintainers have started to test all our packages with Python 3.13, and NEURON does not currently build with it.

https://bugzilla.redhat.com/show_bug.cgi?id=2254189

neuron fails to build with Python 3.13.0a2.

/builddir/build/BUILD/nrn-8.2.2/src/nrnpython/nrnpython.cpp:157:13: error: ‘Py_SetPythonHome’ was not declared in this scope; did you mean ‘Py_GetPythonHome’?
  157 |             Py_SetPythonHome(mywstrdup(_p_pyhome));
      |             ^~~~~~~~~~~~~~~~
      |             Py_GetPythonHome
/builddir/build/BUILD/nrn-8.2.2/src/nrnpython/nrnpython.cpp:165:9: error: ‘PySys_SetArgv’ was not declared in this scope
  165 |         PySys_SetArgv(nrn_global_argc, wcargv);
      |         ^~~~~~~~~~~~~

According to https://docs.python.org/3.13/whatsnew/3.13.html:
Remove the following old functions to configure the Python initialization, deprecated in Python 3.11:

  • PySys_AddWarnOptionUnicode(): use PyConfig.warnoptions instead.
  • PySys_AddWarnOption(): use PyConfig.warnoptions instead.
  • PySys_AddXOption(): use PyConfig.xoptions instead.
  • PySys_HasWarnOptions(): use PyConfig.xoptions instead.
  • PySys_SetArgvEx(): set PyConfig.argv instead.
  • PySys_SetArgv(): set PyConfig.argv instead.
  • PySys_SetPath(): set PyConfig.module_search_paths instead.
  • Py_SetPath(): set PyConfig.module_search_paths instead.
  • Py_SetProgramName(): set PyConfig.program_name instead.
  • Py_SetPythonHome(): set PyConfig.home instead.
  • Py_SetStandardStreamEncoding(): set PyConfig.stdio_encoding instead, and set also maybe PyConfig.legacy_windows_stdio (on Windows).
  • _Py_SetProgramFullPath(): set PyConfig.executable instead.

https://docs.python.org/3.13/whatsnew/3.13.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.13/fedora-rawhide-x86_64/06712032-neuron/

For all our attempts to build neuron with Python 3.13, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.13/package/neuron/

@alkino
Copy link
Member

alkino commented Dec 12, 2023

This is an already known problem. It should not be really long to fix this. Thanks for the report.

@alkino
Copy link
Member

alkino commented Jan 8, 2024

I was giving a try, and I was not able to install the dependencies of nrn with python 3.13. We depend on matplotlib that depends of contourpy that depends of meson.

meson is not yet ready for python 3.13: mesonbuild/meson#12714

Here we are.

@JCGoran
Copy link
Contributor

JCGoran commented Jan 16, 2024

@sanjayankur31 The removal of the initialization functions was fixed in #2317, can you try to re-build with the latest master?

@JCGoran
Copy link
Contributor

JCGoran commented Oct 3, 2024

As Python 3.13 is just around the corner, I've done some preliminary testing in this PR of compatibility of NEURON with 3.13. The notable findings are:

  • MUSIC is not compatible with mpi4py version 4 or above; on the other hand, mpi4py version 3.x (which we are currently using) is not compatible with Python 3.13 OOTB, but there is a workaround for this (see this comment) which is currently being used in the above-mentioned PR
  • the following tests do not run successfully on 3.13:
The following tests FAILED:
	 18 - pytest_coreneuron::basic_tests_py3.13 (Failed)
Errors while running CTest
	 51 - example_nmodl::cagkftab_py (Failed)
	 52 - example_nmodl::expsynspine_py (Failed)
	 53 - example_nmodl::nonlin_py (Failed)
	 56 - example_nmodl::vlag_py (Failed)
	 72 - hoctests::test_hocGUI2_py (Failed)
	 74 - hoctests::test_hocmech_py (Failed)
	 75 - hoctests::test_kschan_py (Failed)
	 78 - hoctests::test_mechstd_py (Failed)
	 80 - hoctests::test_mview_py (Failed)
	 87 - hoctests::test_shape_py (Failed)
	 92 - coreneuron_standalone::test_nrn_corenrn_standalone (Failed)
	 93 - nmodl_tests::test_table (Failed)
	 94 - nmodl_tests::test_disc (Failed)
	 95 - nmodl_tests::test_function_table (Failed)
	 96 - nmodl_tests::test_kinetic (Failed)
	101 - coreneuron_modtests::direct_py_cpu (Failed)
	103 - coreneuron_modtests::spikes_py_cpu (Failed)
	104 - coreneuron_modtests::spikes_file_mode_py_cpu (Failed)
	105 - coreneuron_modtests::fast_imem_py_cpu (Failed)
	106 - coreneuron_modtests::datareturn_py_cpu (Failed)
	111 - coreneuron_modtests::test_psolve_py_cpu (Failed)
	116 - coreneuron_modtests::array_variable_transfer_run_mode_0_py_cpu (Failed)
	117 - coreneuron_modtests::array_variable_transfer_run_mode_1_py_cpu (Failed)
	118 - coreneuron_modtests::array_variable_transfer_run_mode_2_py_cpu (Failed)
	119 - coreneuron_modtests::array_variable_transfer_file_mode_py_cpu (Failed)
	120 - nmodl_tests_coreneuron::test_table_coreneuron_cpu (Failed)
	121 - nmodl_tests_coreneuron::test_disc_coreneuron_cpu (Failed)
	122 - nmodl_tests_coreneuron::test_function_table_coreneuron_cpu (Failed)
	123 - nmodl_tests_coreneuron::test_kinetic_coreneuron_cpu (Failed)

It seems most (or even all) of them fail due to issues with the thread sanitizer (tsan), which is also reproducible locally (on MacOS 13 w/ 3.13 rc3):

Warning: WARNING: ThreadSanitizer: thread leak (pid=14664)
  Thread T4 (tid=14678, finished) created by main thread at:
    #0 pthread_create ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:1022 (libtsan.so+0x5a267) (BuildId: 64c1e8de04b11a7d960abd7e45f94f3b277b7779)
    #1 do_start_joinable_thread Python/thread_pthread.h:290 (libpython3.13.so.1.0+0x2c3595) (BuildId: 4f20c916039e5f46e2e9fcab34c92c2704fa298e)

Warning: SUMMARY: ThreadSanitizer: thread leak Python/thread_pthread.h:290 in do_start_joinable_thread

My guess is that the changes to the threading C API have something to do with this...

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

No branches or pull requests

3 participants