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

[Enhancement] Support Python 3.9.x #3

Open
amal-khailtash opened this issue Mar 17, 2021 · 0 comments
Open

[Enhancement] Support Python 3.9.x #3

amal-khailtash opened this issue Mar 17, 2021 · 0 comments

Comments

@amal-khailtash
Copy link

There are two issues to support latest version of Python. Python header include is hard-coded:

     PyScModule.cpp:9:30: fatal error: python3.6/Python.h: No such file or directory
9:   #include <python3.6/Python.h>

Changing it to the following makes this independent of Python version:

9:     #include <Python.h>

In PyScModule constructor, I get the following warnings:

    PyScModule.cpp: In constructor ‘scc::PyScModule::PyScModule(PyObject*, const sc_core::sc_module_name&)’:
    PyScModule.cpp:22:11: warning: ‘int PyEval_ThreadsInitialized()’ is deprecated (declared at /opt/tools/wh/dtd/RHE64-7/python/3.9.2/include/python3.9/ceval.h:129) [-Wdeprecated-declarations]
         if (! PyEval_ThreadsInitialized())
               ^
    PyScModule.cpp:22:37: warning: ‘int PyEval_ThreadsInitialized()’ is deprecated (declared at /opt/tools/wh/dtd/RHE64-7/python/3.9.2/include/python3.9/ceval.h:129) [-Wdeprecated-declarations]
         if (! PyEval_ThreadsInitialized())
                                         ^
    PyScModule.cpp:23:9: warning: ‘void PyEval_InitThreads()’ is deprecated (declared at /opt/tools/wh/dtd/RHE64-7/python/3.9.2/include/python3.9/ceval.h:130) [-Wdeprecated-declarations]
             PyEval_InitThreads();
             ^
    PyScModule.cpp:23:28: warning: ‘void PyEval_InitThreads()’ is deprecated (declared at /opt/tools/wh/dtd/RHE64-7/python/3.9.2/include/python3.9/ceval.h:130) [-Wdeprecated-declarations]
             PyEval_InitThreads();

PyEval_InitThreads is deprecated since 3.9 and "Changed in version 3.9: The function now does nothing."
https://docs.python.org/3/c-api/init.html#c.PyEval_InitThreads

Changing the constructor to the following would get rid of the problem.

scc::PyScModule::PyScModule(PyObject*  self, const sc_core::sc_module_name& nm)
: sc_core::sc_module(nm)
, self(self)
{
#if PY_MAJOR_VERSION < 3 || PY_MINOR_VERSION < 7
    if (! PyEval_ThreadsInitialized())
        PyEval_InitThreads();
#endif
    Py_INCREF(self);
}
@amal-khailtash amal-khailtash changed the title Support Python 3.9.x [Enhancement] Support Python 3.9.x Mar 17, 2021
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

1 participant