Skip to content

Conversation

mattip
Copy link
Contributor

@mattip mattip commented May 25, 2024

Reference issue

Closes #20783

What does this implement/fix?

The use of Py_Initialize in SpecFun_Initialize is redundant. This function is called in two places, both are the initialization functions called at module import time (thus the use of PyMODINIT_FUNC). Python must have been initialized for the import function to be called. What is more: PyPy does not implement Py_Initialize, so including it here needlessly breaks building SciPy on PyPy.

Additional information

Here are the calls to SpecFun_Initialize:

PyMODINIT_FUNC PyInit__gufuncs() {
if (!SpecFun_Initialize()) {
return nullptr;

PyMODINIT_FUNC PyInit__special_ufuncs() {
if (!SpecFun_Initialize()) {
return nullptr;

@mattip mattip requested review from person142 and steppi as code owners May 25, 2024 18:08
@github-actions github-actions bot added scipy.special C/C++ Items related to the internal C/C++ code base defect A clear bug or issue that prevents SciPy from being installed or used as expected labels May 25, 2024
@rgommers rgommers added this to the 1.14.0 milestone May 25, 2024
@lucascolley lucascolley changed the title BUG: remove redundant Py_Initialize BUG: special: remove redundant Py_Initialize May 25, 2024
Copy link
Member

@lucascolley lucascolley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @mattip !

@lucascolley lucascolley merged commit 5200e01 into scipy:main May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C/C++ Items related to the internal C/C++ code base defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.special
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Build failure on PyPy3.10 7.3.16: error: ‘Py_Initialize’ was not declared in this scope
3 participants