[Python-Dev] Re: Using the Python C API in C++

2022-05-02 Thread Victor Stinner
Hi,

I merged the best basic tests to make sure that using the Python C API in
C++ does not emit compiler warnings:

* Code: https://github.com/python/cpython/blob/main/Lib/test/_testcppext.cpp
* Test: https://github.com/python/cpython/blob/main/Lib/test/test_cppext.py

The code is only built to check for compiler warnings. Later, I plan to
build this C++ extension to be able to *execute* it at runtime. For now, a
C++ compiler is required to run the Python 3.11 test suite. Maybe it should
be made optional, but so far I failed to test if distutils has an available
C++ compiler.

Slowly, more and more tests can be added. For example, this change fixing
compiler warnings when passing "const PyObject*" to Python C API functions
adds tests to _testcppext.cpp:
https://github.com/python/cpython/pull/92138

Victor
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/5I6EJNRWDEHYL773TQHZWHNHG2ZAY3SI/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: Using the Python C API in C++

2022-05-02 Thread Steve Dower

On 5/2/2022 2:21 PM, Victor Stinner wrote:
Maybe it 
should be made optional, but so far I failed to test if distutils has an 
available C++ compiler.


Considering the current status of distutils, you should probably put 
that check in configure or the Makefile and build the extension from 
there. Then the test suite can check whether it was built or not.


Cheers,
Steve

___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/46C4ZJZZ5KSPHS4WRICHEOEQZWHXHWWT/
Code of Conduct: http://python.org/psf/codeofconduct/